incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1200658 - in /incubator/ace/trunk: ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/ ace-tageditor/src/main/java/org/apache/ace/tageditor/
Date Fri, 11 Nov 2011 00:22:38 GMT
Author: marrs
Date: Fri Nov 11 00:22:36 2011
New Revision: 1200658

URL: http://svn.apache.org/viewvc?rev=1200658&view=rev
Log:
For now, added checks to make sure the gateway is registered before attempting to address
it as such.

Modified:
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
    incubator/ace/trunk/ace-tageditor/src/main/java/org/apache/ace/tageditor/ACETagEditorExtension.java

Modified: incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java?rev=1200658&r1=1200657&r2=1200658&view=diff
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java
(original)
+++ incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java
Fri Nov 11 00:22:36 2011
@@ -34,6 +34,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.object.DeploymentVersionObject;
 import org.apache.ace.client.repository.object.GatewayObject;
 import org.apache.ace.client.repository.repository.DeploymentVersionRepository;
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 import org.apache.ace.deployment.verifier.VerifierService;
 import org.apache.ace.deployment.verifier.VerifierService.VerifyEnvironment;
 import org.apache.ace.deployment.verifier.VerifierService.VerifyReporter;
@@ -51,26 +52,29 @@ import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Button.ClickListener;
 import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
 import com.vaadin.ui.PopupView;
 import com.vaadin.ui.TextArea;
 import com.vaadin.ui.VerticalLayout;
 
 public class ACEVerifierExtension implements UIExtensionFactory {
-	volatile VerifierService m_verifier;
-	volatile DeploymentVersionRepository m_repo;
+    volatile VerifierService m_verifier;
+    volatile DeploymentVersionRepository m_repo;
 
-	public Component create(Map<String, Object> context) {
-		RepositoryObject object = getRepositoryObjectFromContext(context);
-		
-		String id = object.getAttribute(GatewayObject.KEY_ID);
-		return new ManifestArea(id, (object.getAttribute("manifest") == null) ?  
-				Constants.BUNDLE_MANIFESTVERSION + ": " + "2" + "\n" +
-				Constants.BUNDLE_SYMBOLICNAME + ": " + "org.apache.felix.framework" + "\n" +
-				Constants.EXPORT_PACKAGE + ": " + VerifierService.SYSTEM_PACKAGES + "," + VerifierService.JRE_1_6_PACKAGES
+ "," +
-				"org.osgi.service.cm;version=1.2,org.osgi.service.metatype;version=1.1.1,org.osgi.service.cm;
version=1.3.0,org.osgi.service.deploymentadmin.spi; version=1.0.1,org.osgi.service.deploymentadmin;
version=1.1.0" + "\n":
-			    object.getAttribute("manifest"), object);
-		
-	}
+    public Component create(Map<String, Object> context) {
+        RepositoryObject object = getRepositoryObjectFromContext(context);
+        if (object instanceof StatefulGatewayObject) {
+            StatefulGatewayObject statefulTarget = (StatefulGatewayObject) object;
+            if (statefulTarget.isRegistered()) {
+                String id = object.getAttribute(GatewayObject.KEY_ID);
+                return new ManifestArea(id, (object.getAttribute("manifest") == null) ? Constants.BUNDLE_MANIFESTVERSION
+ ": " + "2" + "\n" + Constants.BUNDLE_SYMBOLICNAME + ": " + "org.apache.felix.framework"
+ "\n" + Constants.EXPORT_PACKAGE + ": " + VerifierService.SYSTEM_PACKAGES + "," + VerifierService.JRE_1_6_PACKAGES
+ "," + "org.osgi.service.cm;version=1.2,org.osgi.service.metatype;version=1.1.1,org.osgi.service.cm;
version=1.3.0,org.osgi.service.deploymentadmin.spi; version=1.0.1,org.osgi.service.deploymentadmin;
version=1.1.0" + "\n" : object.getAttribute("manifest"), object);
+            }
+        }
+        VerticalLayout result = new VerticalLayout();
+        result.setCaption("VerifyResolve");
+        result.addComponent(new Label("This target is not yet registered, so it can not verify
anything."));
+        return result;
+    }
 
     private RepositoryObject getRepositoryObjectFromContext(Map<String, Object> context)
{
         Object contextObject = context.get("object");
@@ -86,18 +90,17 @@ public class ACEVerifierExtension implem
                 .getObject() : contextObject));
     }
     
-    class ManifestArea extends VerticalLayout implements
-    Property.ValueChangeListener   {
-    	private volatile String text;
-    	private final com.vaadin.ui.TextArea editor;
-    	private final String m_id;
-    	private TextArea plainText;
-    	private final RepositoryObject m_object;
+    class ManifestArea extends VerticalLayout implements Property.ValueChangeListener {
+        private volatile String text;
+        private final com.vaadin.ui.TextArea editor;
+        private final String m_id;
+        private TextArea plainText;
+        private final RepositoryObject m_object;
 
         public ManifestArea(String id, String initialText, RepositoryObject object) {
-        	m_object = object;
-        	setCaption("VerifyResolve");
-        	m_id = id;
+            m_object = object;
+            setCaption("VerifyResolve");
+            m_id = id;
             setSpacing(true);
             setWidth("100%");
             text = initialText;
@@ -111,118 +114,107 @@ public class ACEVerifierExtension implem
 
             Button verify = new Button("Verify");
             verify.addListener(new ClickListener() {
-				private PopupView popup;
-				public void buttonClick(ClickEvent event) {
+                private PopupView popup;
 
-		            plainText.setReadOnly(false);
-					try {
-						DeploymentVersionObject version = m_repo.getMostRecentDeploymentVersion(m_id);
-						if (version != null)
-						{
-							DeploymentArtifact[] artifacts = version.getDeploymentArtifacts();
-							ByteArrayOutputStream output = new ByteArrayOutputStream();
-							final PrintStream out = new PrintStream(output);
-							Set<BundleRevision> bundles = new HashSet<BundleRevision>();
-							StringTokenizer tok = new StringTokenizer(editor.getValue().toString(), ":\n");
-							Map<String, String> manMap = new HashMap<String, String>();
-							while (tok.hasMoreTokens()) {
-								manMap.put(tok.nextToken(), tok.nextToken());
-							}
-							String ee = manMap.get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
-							if (ee == null) {
-								ee = VerifierService.EE_1_6;
-							}
-							final Map<String, String> envMap = new HashMap<String, String>();
-							envMap.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
-							VerifyEnvironment env = m_verifier.createEnvironment(envMap, new VerifyReporter()
{
-								
-								public void reportWire(BundleRevision importer,
-										BundleRequirement reqirement, BundleRevision exporter,
-										BundleCapability capability) {
-									out.println("WIRE: " + reqirement + " -> " + capability + "\n");
-								}
-								
-								public void reportLog(LogEntry logEntry) {
-									out.println("Log(" + logEntry.getTime() + "): " + logEntry.getLevel() + " " + logEntry.getMessage());
-									if (logEntry.getException() != null) {
-										logEntry.getException().printStackTrace();
-									}
-								}
-								
-								public void reportException(Exception ex) {
-									ex.printStackTrace(out);
-								}
-							});
-							
-							bundles.add(env.addBundle(0, manMap));
-							Set<String> customizers = new HashSet<String>();
-							Set<String> processors = new HashSet<String>();
-							for (DeploymentArtifact data : artifacts) {
-								if (data.getDirective(Constants.BUNDLE_SYMBOLICNAME) != null) {
-									JarInputStream input = null;
-									try
-									{ 
-										input = new JarInputStream(new URL(data.getUrl()).openStream(), false);
-										final Attributes attributes = input.getManifest().getMainAttributes();
-										Map<String, String> manifest = new HashMap<String, String>();
-										for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
-											manifest.put(entry.getKey().toString(), entry.getValue().toString());
-										}
-										bundles.add(env.addBundle(bundles.size(), manifest));
-										if (attributes.getValue("DeploymentPackage-Customizer") != null) {
-											String typeString = attributes.getValue("Deployment-ProvidesResourceProcessor");
-											if (typeString != null) {
-												String[] types = typeString.split(",");
-												for (String type : types) {
-													customizers.add(type.trim());
-												}
-											}
-										}
-									} catch (Exception ex) {
-										ex.printStackTrace();
-									}
-									finally {
-										if (input != null) {
-											try {
-												input.close();
-											} catch (Exception ex) {
-												ex.printStackTrace();
-											}
-										}
-									}
-								}
-								else {
-									String processor = data.getDirective("Resource-Processor");
-									if (processor != null) {
-										processors.add(processor.trim());
-									}
-								}
-							}
-							plainText.setValue((
-									"Customizers match: " + customizers.containsAll(processors) + "\n" 
-									+ " (provided=" + customizers + ",required=" + processors + ")\n\n"
-									+ "Resolve: " + env.verifyResolve(bundles, null, null) + "\n\n"
-									+ output.toString()));
-						}
-						
-					} catch (Exception e) {
-						ByteArrayOutputStream output = new ByteArrayOutputStream();
-						e.printStackTrace(new PrintStream(output));
-						plainText.setValue(output.toString());
-					}
-
-					if (popup != null) {
-						removeComponent(popup);
-					}
-
-		            plainText.setReadOnly(true);
-					popup = new PopupView("Result", plainText);
-					popup.setHideOnMouseOut(false);
-					addComponent(popup);
-					popup.setPopupVisible(true);
-				}
-				
-			});
+                public void buttonClick(ClickEvent event) {
+                    plainText.setReadOnly(false);
+                    try {
+                        DeploymentVersionObject version = m_repo.getMostRecentDeploymentVersion(m_id);
+                        if (version != null) {
+                            DeploymentArtifact[] artifacts = version.getDeploymentArtifacts();
+                            ByteArrayOutputStream output = new ByteArrayOutputStream();
+                            final PrintStream out = new PrintStream(output);
+                            Set<BundleRevision> bundles = new HashSet<BundleRevision>();
+                            StringTokenizer tok = new StringTokenizer(editor.getValue().toString(),
":\n");
+                            Map<String, String> manMap = new HashMap<String, String>();
+                            while (tok.hasMoreTokens()) {
+                                manMap.put(tok.nextToken(), tok.nextToken());
+                            }
+                            String ee = manMap.get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
+                            if (ee == null) {
+                                ee = VerifierService.EE_1_6;
+                            }
+                            final Map<String, String> envMap = new HashMap<String,
String>();
+                            envMap.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
+                            VerifyEnvironment env = m_verifier.createEnvironment(envMap,
new VerifyReporter() {
+                                public void reportWire(BundleRevision importer, BundleRequirement
reqirement, BundleRevision exporter, BundleCapability capability) {
+                                    out.println("WIRE: " + reqirement + " -> " + capability
+ "\n");
+                                }
+
+                                public void reportLog(LogEntry logEntry) {
+                                    out.println("Log(" + logEntry.getTime() + "): " + logEntry.getLevel()
+ " " + logEntry.getMessage());
+                                    if (logEntry.getException() != null) {
+                                        logEntry.getException().printStackTrace();
+                                    }
+                                }
+
+                                public void reportException(Exception ex) {
+                                    ex.printStackTrace(out);
+                                }
+                            });
+                            bundles.add(env.addBundle(0, manMap));
+                            Set<String> customizers = new HashSet<String>();
+                            Set<String> processors = new HashSet<String>();
+                            for (DeploymentArtifact data : artifacts) {
+                                if (data.getDirective(Constants.BUNDLE_SYMBOLICNAME) != null)
{
+                                    JarInputStream input = null;
+                                    try {
+                                        input = new JarInputStream(new URL(data.getUrl()).openStream(),
false);
+                                        final Attributes attributes = input.getManifest().getMainAttributes();
+                                        Map<String, String> manifest = new HashMap<String,
String>();
+                                        for (Map.Entry<Object, Object> entry : attributes.entrySet())
{
+                                            manifest.put(entry.getKey().toString(), entry.getValue().toString());
+                                        }
+                                        bundles.add(env.addBundle(bundles.size(), manifest));
+                                        if (attributes.getValue("DeploymentPackage-Customizer")
!= null) {
+                                            String typeString = attributes.getValue("Deployment-ProvidesResourceProcessor");
+                                            if (typeString != null) {
+                                                String[] types = typeString.split(",");
+                                                for (String type : types) {
+                                                    customizers.add(type.trim());
+                                                }
+                                            }
+                                        }
+                                    }
+                                    catch (Exception ex) {
+                                        ex.printStackTrace();
+                                    }
+                                    finally {
+                                        if (input != null) {
+                                            try {
+                                                input.close();
+                                            }
+                                            catch (Exception ex) {
+                                                ex.printStackTrace();
+                                            }
+                                        }
+                                    }
+                                }
+                                else {
+                                    String processor = data.getDirective("Resource-Processor");
+                                    if (processor != null) {
+                                        processors.add(processor.trim());
+                                    }
+                                }
+                            }
+                            plainText.setValue(("Customizers match: " + customizers.containsAll(processors)
+ "\n" + " (provided=" + customizers + ",required=" + processors + ")\n\n" + "Resolve: " +
env.verifyResolve(bundles, null, null) + "\n\n" + output.toString()));
+                        }
+                    }
+                    catch (Exception e) {
+                        ByteArrayOutputStream output = new ByteArrayOutputStream();
+                        e.printStackTrace(new PrintStream(output));
+                        plainText.setValue(output.toString());
+                    }
+                    if (popup != null) {
+                        removeComponent(popup);
+                    }
+                    plainText.setReadOnly(true);
+                    popup = new PopupView("Result", plainText);
+                    popup.setHideOnMouseOut(false);
+                    addComponent(popup);
+                    popup.setPopupVisible(true);
+                }
+            });
             addComponent(verify);
             plainText = new TextArea();
             plainText.setImmediate(true);

Modified: incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java?rev=1200658&r1=1200657&r2=1200658&view=diff
==============================================================================
--- incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
(original)
+++ incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
Fri Nov 11 00:22:36 2011
@@ -31,6 +31,7 @@ import java.util.TreeSet;
 
 import org.apache.ace.client.repository.RepositoryObject;
 import org.apache.ace.client.repository.object.GatewayObject;
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 import org.apache.ace.log.AuditEvent;
 import org.apache.ace.log.LogDescriptor;
 import org.apache.ace.log.LogEvent;
@@ -39,73 +40,84 @@ import org.apache.ace.webui.NamedObject;
 import org.apache.ace.webui.UIExtensionFactory;
 
 import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
 import com.vaadin.ui.Table;
 import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
 
 public class LogViewerExtension implements UIExtensionFactory {
-	private volatile LogStore m_store;
+    private volatile LogStore m_store;
 
-	public Component create(Map<String, Object> context) {
-	    RepositoryObject object = getRepositoryObjectFromContext(context);
-			
-	    Table table = new Table();
-	    table.setWidth("100%");
-	    table.setHeight("100%");
-	    table.setCaption("LogViewer");
+    public Component create(Map<String, Object> context) {
+        RepositoryObject object = getRepositoryObjectFromContext(context);
+        Table table = new Table();
+        table.setWidth("100%");
+        table.setHeight("100%");
+        table.setCaption("LogViewer");
         table.addContainerProperty("Time", Date.class, null);
         table.addContainerProperty("Type", String.class, null);
         table.addContainerProperty("Properties", TextArea.class, null);
         table.setColumnExpandRatio("Properties", 1);
-	    try {
-	    	String id = object.getAttribute(GatewayObject.KEY_ID);
-		
-			List<LogDescriptor> desc = m_store.getDescriptors(id);
-			if (desc != null) {
-				for (LogDescriptor log : desc) {
-					for (LogEvent event : m_store.get(log)) {
-						Dictionary props = event.getProperties();
-						Enumeration keys = props.keys();
-						Set<String> keySet = new TreeSet<String>();
-						while (keys.hasMoreElements()) {
-							keySet.add(keys.nextElement().toString());
-						}
-						Iterator<String> keyIter = keySet.iterator();
-						String value = "";
-						String propString = "";
-						String prepend = "";
-						while (keyIter.hasNext()) {
-							String key = keyIter.next();
-							value = props.get(key).toString();
-							propString += prepend + key + ": " + value;
-							prepend = "\n";
-						}
-						TextArea area = new TextArea("", propString);
-						area.setWidth("100%");
-						area.setRows(props.size());
-						area.setWordwrap(false);
-						area.setReadOnly(true);
-						area.setImmediate(true);
-						String type = Integer.toString(event.getType());
-						for (Field f : AuditEvent.class.getFields()) {
-							if (((f.getModifiers() & Modifier.STATIC) == Modifier.STATIC) && (f.getType()
== Integer.TYPE)){
-								if (((Integer) f.get(null)).intValue() == event.getType()) {
-									type = f.getName();
-									break;
-								}
-							}
-						}
-						table.addItem(new Object[] {new Date(event.getTime()), type, area},null);
-					}
-				}
-			}
-			
-		} catch (Exception ex) {
-			ex.printStackTrace();
-		}
-		return table;
-	} 
-	
-	private RepositoryObject getRepositoryObjectFromContext(Map<String, Object> context)
{
+        try {
+            if (object instanceof StatefulGatewayObject) {
+                StatefulGatewayObject statefulTarget = (StatefulGatewayObject) object;
+                if (statefulTarget.isRegistered()) {
+                    String id = object.getAttribute(GatewayObject.KEY_ID);
+                    List<LogDescriptor> desc = m_store.getDescriptors(id);
+                    if (desc != null) {
+                        for (LogDescriptor log : desc) {
+                            for (LogEvent event : m_store.get(log)) {
+                                Dictionary props = event.getProperties();
+                                Enumeration keys = props.keys();
+                                Set<String> keySet = new TreeSet<String>();
+                                while (keys.hasMoreElements()) {
+                                    keySet.add(keys.nextElement().toString());
+                                }
+                                Iterator<String> keyIter = keySet.iterator();
+                                String value = "";
+                                String propString = "";
+                                String prepend = "";
+                                while (keyIter.hasNext()) {
+                                    String key = keyIter.next();
+                                    value = props.get(key).toString();
+                                    propString += prepend + key + ": " + value;
+                                    prepend = "\n";
+                                }
+                                TextArea area = new TextArea("", propString);
+                                area.setWidth("100%");
+                                area.setRows(props.size());
+                                area.setWordwrap(false);
+                                area.setReadOnly(true);
+                                area.setImmediate(true);
+                                String type = Integer.toString(event.getType());
+                                for (Field f : AuditEvent.class.getFields()) {
+                                    if (((f.getModifiers() & Modifier.STATIC) == Modifier.STATIC)
&& (f.getType() == Integer.TYPE)) {
+                                        if (((Integer) f.get(null)).intValue() == event.getType())
{
+                                            type = f.getName();
+                                            break;
+                                        }
+                                    }
+                                }
+                                table.addItem(new Object[] { new Date(event.getTime()), type,
area }, null);
+                            }
+                        }
+                    }
+                }
+                else {
+                    VerticalLayout result = new VerticalLayout();
+                    result.setCaption("VerifyResolve");
+                    result.addComponent(new Label("This target is not yet registered, so
it has no log."));
+                    return result;
+                }
+            }
+        }
+        catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return table;
+    }
+
+    private RepositoryObject getRepositoryObjectFromContext(Map<String, Object> context)
{
         Object contextObject = context.get("object");
         if (contextObject == null) {
             throw new IllegalStateException("No context object found");
@@ -115,8 +127,6 @@ public class LogViewerExtension implemen
         // why ace is using either the object directly or wraps it in a
         // NamedObject first.
         // Its unclear when it does which so for now we cater for both.
-        return ((RepositoryObject) (contextObject instanceof NamedObject ? ((NamedObject)
contextObject)
-                .getObject() : contextObject));
+        return ((RepositoryObject) (contextObject instanceof NamedObject ? ((NamedObject)
contextObject).getObject() : contextObject));
     }
-
 }

Modified: incubator/ace/trunk/ace-tageditor/src/main/java/org/apache/ace/tageditor/ACETagEditorExtension.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-tageditor/src/main/java/org/apache/ace/tageditor/ACETagEditorExtension.java?rev=1200658&r1=1200657&r2=1200658&view=diff
==============================================================================
--- incubator/ace/trunk/ace-tageditor/src/main/java/org/apache/ace/tageditor/ACETagEditorExtension.java
(original)
+++ incubator/ace/trunk/ace-tageditor/src/main/java/org/apache/ace/tageditor/ACETagEditorExtension.java
Fri Nov 11 00:22:36 2011
@@ -23,12 +23,14 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 import org.apache.ace.webui.NamedObject;
 import org.apache.ace.webui.UIExtensionFactory;
 
 import com.vaadin.event.Action;
 import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
 import com.vaadin.ui.Table;
 import com.vaadin.ui.TextField;
 import com.vaadin.ui.VerticalLayout;
@@ -39,48 +41,53 @@ public class ACETagEditorExtension imple
         final RepositoryObject sgo = getRepositoryObjectFromContext(context);
         VerticalLayout result = new VerticalLayout();
         result.setCaption("Tag Editor");
-        final Table table = new Table();
-        table.setWidth("100%");
-        table.addContainerProperty("Tag", TextField.class, null);
-        table.addContainerProperty("Value", TextField.class, null);
-        table.setEditable(false);
-        result.addComponent(table);
-        result.setComponentAlignment(table, Alignment.MIDDLE_CENTER);
-        final Map<Object, TagTableEntry> idToKey = new HashMap<Object, TagTableEntry>();
-        Enumeration<String> keys = sgo.getTagKeys();
-        while (keys.hasMoreElements()) {
-            String keyString = keys.nextElement();
-            String valueString = sgo.getTag(keyString);
-            if ((valueString != null) && (valueString.trim().length() != 0)) {
-                TagTableEntry tte = new TagTableEntry(sgo, keyString,
-                        valueString);
+        if (sgo instanceof StatefulGatewayObject) {
+            StatefulGatewayObject statefulTarget = (StatefulGatewayObject) sgo;
+            if (statefulTarget.isRegistered()) {
+                final Table table = new Table();
+                table.setWidth("100%");
+                table.addContainerProperty("Tag", TextField.class, null);
+                table.addContainerProperty("Value", TextField.class, null);
+                table.setEditable(false);
+                result.addComponent(table);
+                result.setComponentAlignment(table, Alignment.MIDDLE_CENTER);
+                final Map<Object, TagTableEntry> idToKey = new HashMap<Object, TagTableEntry>();
+                Enumeration<String> keys = sgo.getTagKeys();
+                while (keys.hasMoreElements()) {
+                    String keyString = keys.nextElement();
+                    String valueString = sgo.getTag(keyString);
+                    if ((valueString != null) && (valueString.trim().length() !=
0)) {
+                        TagTableEntry tte = new TagTableEntry(sgo, keyString,
+                                valueString);
+                        idToKey.put(tte.addTo(table), tte);
+                    }
+                }
+                final TagTableEntry tte = new TagTableEntry(sgo);
                 idToKey.put(tte.addTo(table), tte);
+                tte.setListener(new TagTableEntry.ChangeListener() {
+                    private volatile TagTableEntry m_lastEntry = tte;
+                    public void changed(TagTableEntry entry) {
+                        TagTableEntry ntte = new TagTableEntry(sgo);
+                        idToKey.put(ntte.addTo(table), ntte);
+                        m_lastEntry.setListener(null);
+                        m_lastEntry = ntte;
+                        ntte.setListener(this);
+                    }
+                });
+                table.addActionHandler(new Action.Handler() {
+                    final Action[] delete = new Action[] { new Action("delete") };
+                    public void handleAction(Action action, Object sender, Object target)
{
+                        idToKey.remove(target).removeFrom(table);
+                    }
+                    public Action[] getActions(Object target, Object sender) {
+                        return delete;
+                    }
+                });
             }
-        }
-        final TagTableEntry tte = new TagTableEntry(sgo);
-        idToKey.put(tte.addTo(table), tte);
-        tte.setListener(new TagTableEntry.ChangeListener() {
-            private volatile TagTableEntry m_lastEntry = tte;
-
-            public void changed(TagTableEntry entry) {
-                TagTableEntry ntte = new TagTableEntry(sgo);
-                idToKey.put(ntte.addTo(table), ntte);
-                m_lastEntry.setListener(null);
-                m_lastEntry = ntte;
-                ntte.setListener(this);
-            }
-        });
-        table.addActionHandler(new Action.Handler() {
-            final Action[] delete = new Action[] { new Action("delete") };
-
-            public void handleAction(Action action, Object sender, Object target) {
-                idToKey.remove(target).removeFrom(table);
+            else {
+                result.addComponent(new Label("This target is not yet registered, so you
cannot add tags."));
             }
-
-            public Action[] getActions(Object target, Object sender) {
-                return delete;
-            }
-        });
+        }
         return result;
     }
 



Mime
View raw message