ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1539648 - in /ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component: BaseObjectPanel.java TargetsPanel.java
Date Thu, 07 Nov 2013 14:08:55 GMT
Author: jawi
Date: Thu Nov  7 14:08:55 2013
New Revision: 1539648

URL: http://svn.apache.org/r1539648
Log:
Fixed a bug where unregistered targets did not show up, even when the repository configuration
allowed for this.


Modified:
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/TargetsPanel.java

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java?rev=1539648&r1=1539647&r2=1539648&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
Thu Nov  7 14:08:55 2013
@@ -308,12 +308,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
             addListener(new ItemClickListener() {
                 public void itemClick(ItemClickEvent event) {
                     if (event.isDoubleClick()) {
-                        RepositoryObject object = getFromId(event.getItemId());
-
-                        NamedObject namedObject = NamedObjectFactory.getNamedObject(object);
-                        if (namedObject != null) {
-                            showEditWindow(namedObject);
-                        }
+                        handleItemDoubleClick(event.getItemId());
                     }
                 }
             });
@@ -506,17 +501,6 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
-     * Updates the active table and recalculates all relations.
-     */
-    final void updateActiveTable() {
-        m_associations.clear();
-        m_associations.updateActiveTable(this);
-        recalculateRelations(Direction.BOTH);
-        // request the focus...
-        focus();
-    }
-
-    /**
      * Recalculates all relations.
      */
     final void recalculateRelations(Direction direction) {
@@ -568,6 +552,17 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
+     * Updates the active table and recalculates all relations.
+     */
+    final void updateActiveTable() {
+        m_associations.clear();
+        m_associations.updateActiveTable(this);
+        recalculateRelations(Direction.BOTH);
+        // request the focus...
+        focus();
+    }
+
+    /**
      * Adds a given repository object to this table.
      * 
      * @param object
@@ -816,6 +811,21 @@ abstract class BaseObjectPanel<REPO_OBJ 
     protected abstract void handleEvent(String topic, RepositoryObject entity, org.osgi.service.event.Event
event);
 
     /**
+     * Called whenever the user double clicks on a row.
+     * 
+     * @param itemId
+     *            the row/item ID of the double clicked item.
+     */
+    protected void handleItemDoubleClick(Object itemId) {
+        RepositoryObject object = getFromId(itemId);
+
+        NamedObject namedObject = NamedObjectFactory.getNamedObject(object);
+        if (namedObject != null) {
+            showEditWindow(namedObject);
+        }
+    }
+
+    /**
      * Returns whether the given {@link RepositoryObject} can be handled by this panel.
      * 
      * @param entity
@@ -899,6 +909,19 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
+     * Shows an edit window for the given named object.
+     * 
+     * @param object
+     *            the named object to edit;
+     * @param main
+     *            the main window to use.
+     */
+    protected final void showEditWindow(NamedObject object) {
+        List<UIExtensionFactory> extensions = getExtensionFactories();
+        createEditor(object, extensions).show(getParent().getWindow());
+    }
+
+    /**
      * Updates a given repository object in this table.
      * 
      * @param object
@@ -985,17 +1008,4 @@ abstract class BaseObjectPanel<REPO_OBJ 
         }
         return extensions;
     }
-
-    /**
-     * Shows an edit window for the given named object.
-     * 
-     * @param object
-     *            the named object to edit;
-     * @param main
-     *            the main window to use.
-     */
-    private void showEditWindow(NamedObject object) {
-        List<UIExtensionFactory> extensions = getExtensionFactories();
-        createEditor(object, extensions).show(getParent().getWindow());
-    }
 }

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/TargetsPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/TargetsPanel.java?rev=1539648&r1=1539647&r2=1539648&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/TargetsPanel.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/TargetsPanel.java
Thu Nov  7 14:08:55 2013
@@ -28,7 +28,9 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.repository.TargetRepository;
 import org.apache.ace.client.repository.stateful.StatefulTargetObject;
 import org.apache.ace.client.repository.stateful.StatefulTargetRepository;
+import org.apache.ace.webui.NamedObject;
 import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.ace.webui.domain.NamedObjectFactory;
 import org.apache.ace.webui.vaadin.AssociationManager;
 
 import com.vaadin.data.Item;
@@ -57,6 +59,23 @@ public abstract class TargetsPanel exten
         super(associations, associationRemover, "Target", UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET,
true, TargetObject.class);
     }
 
+    /**
+     * Called to populate this table.
+     */
+    public void populate() {
+        removeAllItems();
+        // All unregistered items aren't yet present in our TargetRepo, so we must add them
explicitly...
+        for (StatefulTargetObject object : getStatefulTargetRepository().get()) {
+            if (!object.isRegistered()) {
+                Item item = addItem(object.getDefinition());
+                populateItem(object, item);
+            }
+        }
+        for (TargetObject object : getRepository().get()) {
+            add(object);
+        }
+    }
+
     protected void defineTableColumns() {
         addContainerProperty(ICON, Resource.class, null, "", null, ALIGN_CENTER);
         addContainerProperty(OBJECT_NAME, String.class, null);
@@ -110,15 +129,35 @@ public abstract class TargetsPanel exten
 
     @Override
     protected void handleEvent(String topic, RepositoryObject entity, org.osgi.service.event.Event
event) {
-        TargetObject target = asTargetObject(entity);
-        if (TargetObject.TOPIC_ADDED.equals(topic)) {
-            add(target);
+        try {
+            TargetObject target = asTargetObject(entity);
+            if (TargetObject.TOPIC_ADDED.equals(topic)) {
+                add(target);
+            }
+            if (TargetObject.TOPIC_REMOVED.equals(topic)) {
+                remove(target);
+            }
+            if (topic.endsWith("CHANGED")) {
+                update(target);
+            }
         }
-        if (TargetObject.TOPIC_REMOVED.equals(topic)) {
-            remove(target);
+        catch (IllegalStateException exception) {
+            // Ignore...
         }
-        if (topic.endsWith("CHANGED")) {
-            update(target);
+    }
+
+    /**
+     * Called whenever the user double clicks on a row.
+     * 
+     * @param itemId
+     *            the row/item ID of the double clicked item.
+     */
+    protected void handleItemDoubleClick(Object itemId) {
+        StatefulTargetObject object = getStatefulTargetRepository().get((String) itemId);
+
+        NamedObject namedObject = NamedObjectFactory.getNamedObject(object);
+        if (namedObject != null) {
+            showEditWindow(namedObject);
         }
     }
 
@@ -129,13 +168,7 @@ public abstract class TargetsPanel exten
 
     protected void populateItem(TargetObject target, Item item) {
         StatefulTargetObject statefulTarget = asStatefulTargetObject(target);
-
-        item.getItemProperty(OBJECT_NAME).setValue(target.getID());
-        item.getItemProperty(REGISTRATION_STATE_ICON).setValue(getRegistrationStateIcon(statefulTarget));
-        item.getItemProperty(STORE_STATE_ICON).setValue(getStoreStateIcon(statefulTarget));
-        item.getItemProperty(PROVISIONING_STATE_ICON).setValue(getProvisioningStateIcon(statefulTarget));
-        item.getItemProperty(ACTION_UNLINK).setValue(new RemoveLinkButton(target));
-        item.getItemProperty(ACTION_DELETE).setValue(createRemoveItemButton(statefulTarget));
+        populateItem(statefulTarget, item);
     }
 
     private StatefulTargetObject asStatefulTargetObject(RepositoryObject entity) {
@@ -152,12 +185,6 @@ public abstract class TargetsPanel exten
         return ((StatefulTargetObject) entity).getTargetObject();
     }
 
-    private RemoveItemButton createRemoveItemButton(StatefulTargetObject object) {
-        RemoveItemButton b = new RemoveItemButton(object.getTargetObject());
-        b.setEnabled(object.isRegistered());
-        return b;
-    }
-
     private Embedded getProvisioningStateIcon(StatefulTargetObject object) {
         String name = object.getProvisioningState().name();
         Resource res = createIconResource("target_provisioning_" + name);
@@ -175,4 +202,17 @@ public abstract class TargetsPanel exten
         Resource res = createIconResource("target_store_" + name);
         return createIcon(name, res);
     }
+
+    private void populateItem(StatefulTargetObject statefulTarget, Item item) {
+        item.getItemProperty(OBJECT_NAME).setValue(statefulTarget.getID());
+        item.getItemProperty(REGISTRATION_STATE_ICON).setValue(getRegistrationStateIcon(statefulTarget));
+        item.getItemProperty(STORE_STATE_ICON).setValue(getStoreStateIcon(statefulTarget));
+        item.getItemProperty(PROVISIONING_STATE_ICON).setValue(getProvisioningStateIcon(statefulTarget));
+        if (statefulTarget.isRegistered()) {
+            TargetObject targetObject = statefulTarget.getTargetObject();
+
+            item.getItemProperty(ACTION_UNLINK).setValue(new RemoveLinkButton(targetObject));
+            item.getItemProperty(ACTION_DELETE).setValue(new RemoveItemButton(targetObject));
+        }
+    }
 }



Mime
View raw message