ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1310292 - in /ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin: ./ component/
Date Fri, 06 Apr 2012 12:02:14 GMT
Author: jawi
Date: Fri Apr  6 12:02:14 2012
New Revision: 1310292

URL: http://svn.apache.org/viewvc?rev=1310292&view=rev
Log:
ACE-248: some additional code cleanups.

Added:
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/AssociationRemover.java
  (with props)
Removed:
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/RemoveAssociationHandler.java
Modified:
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/DistributionsPanel.java
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/FeaturesPanel.java
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/TargetsPanel.java

Added: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/AssociationRemover.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/AssociationRemover.java?rev=1310292&view=auto
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/AssociationRemover.java
(added)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/AssociationRemover.java
Fri Apr  6 12:02:14 2012
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ace.webui.vaadin;
+
+import org.apache.ace.client.repository.object.Artifact2FeatureAssociation;
+import org.apache.ace.client.repository.object.Distribution2TargetAssociation;
+import org.apache.ace.client.repository.object.Feature2DistributionAssociation;
+
+/**
+ * Defines methods for removing associations.
+ */
+public interface AssociationRemover {
+
+    /**
+     * @param association
+     */
+    void removeAssociation(Artifact2FeatureAssociation association);
+
+    /**
+     * @param association
+     */
+    void removeAssociation(Feature2DistributionAssociation association);
+    
+    /**
+     * @param association
+     */
+    void removeAssociation(Distribution2TargetAssociation association);
+
+}

Propchange: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/AssociationRemover.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1310292&r1=1310291&r2=1310292&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Fri Apr  6 12:02:14 2012
@@ -98,12 +98,12 @@ import com.vaadin.ui.Window;
  - Add buttons to create new items in all of the tables (done for those that make sense)
  */
 @SuppressWarnings("serial")
-public class VaadinClient extends com.vaadin.Application {
+public class VaadinClient extends com.vaadin.Application implements AssociationRemover {
 
     private static final long serialVersionUID = 1L;
-    
+
     private static long SESSION_ID = 12345;
-    
+
     private static String targetRepo = "target";
     private static String shopRepo = "shop";
     private static String deployRepo = "deployment";
@@ -123,7 +123,7 @@ public class VaadinClient extends com.va
     private volatile Distribution2TargetAssociationRepository m_distribution2targetAssociationRepository;
     private volatile RepositoryAdmin m_admin;
     private volatile LogService m_log;
-    
+
     private String m_sessionID;
     private ArtifactsPanel m_artifactsPanel;
     private FeaturesPanel m_featuresPanel;
@@ -140,7 +140,7 @@ public class VaadinClient extends com.va
 
     private final URL m_aceHost;
     private final URL m_obrUrl;
-    
+
     private final Associations m_associations = new Associations();
     private final AtomicBoolean m_dependenciesResolved = new AtomicBoolean(false);
 
@@ -199,28 +199,29 @@ public class VaadinClient extends com.va
 
     public void init() {
         setTheme("ace");
-        
+
         if (!m_dependenciesResolved.get()) {
             final Window message = new Window("Apache ACE");
             message.getContent().setSizeFull();
             setMainWindow(message);
-            
-            Label richText = new Label(
+
+            Label richText =
+                new Label(
                     "<h1>Apache ACE User Interface</h1>"
                         + "<p>Due to missing component dependencies on the server,
probably due to misconfiguration, "
                         + "the user interface cannot be properly started. Please contact
your server administrator. "
                         + "You can retry accessing the user interface by <a href=\"?restartApplication\">following
this link</a>.</p>");
             richText.setContentMode(Label.CONTENT_XHTML);
-            
+
             // TODO we might want to add some more details here as to what's
             // missing on the other hand, the user probably can't fix that anyway
             message.addComponent(richText);
             return;
         }
-        
+
         m_mainWindow = new Window("Apache ACE");
         m_mainWindow.getContent().setSizeFull();
-        
+
         setMainWindow(m_mainWindow);
 
         showLoginWindow();
@@ -253,7 +254,7 @@ public class VaadinClient extends com.va
 
         m_grid.addComponent(createToolbar(), 0, 0, count - 1, 0);
 
-        m_artifactsPanel = createArtifactsPanel(m_mainWindow);
+        m_artifactsPanel = createArtifactsPanel();
 
         m_artifactToolbar = new HorizontalLayout();
         m_artifactToolbar.addComponent(createAddArtifactButton());
@@ -275,7 +276,7 @@ public class VaadinClient extends com.va
             count++;
         }
 
-        m_featuresPanel = createFeaturesPanel(m_mainWindow);
+        m_featuresPanel = createFeaturesPanel();
         m_featureToolbar = createAddFeatureButton(m_mainWindow);
 
         if (auth.hasRole("viewFeature")) {
@@ -284,7 +285,7 @@ public class VaadinClient extends com.va
             count++;
         }
 
-        m_distributionsPanel = createDistributionsPanel(m_mainWindow);
+        m_distributionsPanel = createDistributionsPanel();
         m_distributionToolbar = createAddDistributionButton(m_mainWindow);
 
         if (auth.hasRole("viewDistribution")) {
@@ -293,24 +294,24 @@ public class VaadinClient extends com.va
             count++;
         }
 
-        m_targetsPanel = createTargetsPanel(m_mainWindow);
+        m_targetsPanel = createTargetsPanel();
         m_targetToolbar = createAddTargetButton(m_mainWindow);
 
         if (auth.hasRole("viewTarget")) {
             m_grid.addComponent(m_targetsPanel, count, 2);
             m_grid.addComponent(m_targetToolbar, count, 1);
         }
-        
+
         // Wire up all panels so they have the correct associations...
         m_artifactsPanel.setLeftTable(null);
         m_artifactsPanel.setRightTable(m_featuresPanel);
-        
+
         m_featuresPanel.setLeftTable(m_artifactsPanel);
         m_featuresPanel.setRightTable(m_distributionsPanel);
-        
+
         m_distributionsPanel.setLeftTable(m_featuresPanel);
         m_distributionsPanel.setRightTable(m_targetsPanel);
-        
+
         m_targetsPanel.setLeftTable(m_distributionsPanel);
         m_targetsPanel.setRightTable(null);
 
@@ -319,7 +320,7 @@ public class VaadinClient extends com.va
         m_progress = new ProgressIndicator(0f);
         m_progress.setStyleName("invisible");
         m_progress.setPollingInterval(500);
-        
+
         m_grid.addComponent(m_progress, 0, 3);
 
         m_artifactsPanel.addListener(m_associations.createSelectionListener(m_artifactsPanel,
m_artifactRepository,
@@ -328,9 +329,10 @@ public class VaadinClient extends com.va
         m_featuresPanel.addListener(m_associations.createSelectionListener(m_featuresPanel,
m_featureRepository,
             new Class[] { ArtifactObject.class }, new Class[] { DistributionObject.class,
TargetObject.class },
             new Table[] { m_artifactsPanel, m_distributionsPanel, m_targetsPanel }));
-        m_distributionsPanel.addListener(m_associations.createSelectionListener(m_distributionsPanel,
m_distributionRepository,
-                new Class[] { FeatureObject.class, ArtifactObject.class }, new Class[] {
TargetObject.class },
-                new Table[] { m_artifactsPanel, m_featuresPanel, m_targetsPanel }));
+        m_distributionsPanel.addListener(m_associations.createSelectionListener(m_distributionsPanel,
+            m_distributionRepository,
+            new Class[] { FeatureObject.class, ArtifactObject.class }, new Class[] { TargetObject.class
},
+            new Table[] { m_artifactsPanel, m_featuresPanel, m_targetsPanel }));
         m_targetsPanel.addListener(m_associations.createSelectionListener(m_targetsPanel,
m_statefulTargetRepository,
             new Class[] { DistributionObject.class, FeatureObject.class, ArtifactObject.class
}, new Class[] {},
             new Table[] { m_artifactsPanel, m_featuresPanel, m_distributionsPanel }));
@@ -426,6 +428,27 @@ public class VaadinClient extends com.va
         m_mainWindow.addComponent(m_grid);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public void removeAssociation(Artifact2FeatureAssociation association) {
+        m_artifact2featureAssociationRepository.remove(association);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void removeAssociation(Distribution2TargetAssociation association) {
+        m_distribution2targetAssociationRepository.remove(association);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void removeAssociation(Feature2DistributionAssociation association) {
+        m_feature2distributionAssociationRepository.remove(association);
+    }
+
     boolean login(String username, String password) {
         try {
             User user = m_userAdmin.getUser("username", username);
@@ -487,7 +510,7 @@ public class VaadinClient extends com.va
             protected void doAfterCommit() throws IOException {
                 updateTableData();
             }
-            
+
             @Override
             protected void doAfterLogout() throws IOException {
                 // Close the application and reload the main window...
@@ -505,91 +528,59 @@ public class VaadinClient extends com.va
         return mainActionToolbar;
     }
 
-    private ArtifactsPanel createArtifactsPanel(Window main) {
-        return new ArtifactsPanel(m_associations) {
-
+    private ArtifactsPanel createArtifactsPanel() {
+        return new ArtifactsPanel(m_associations, this) {
             @Override
             protected ArtifactRepository getRepository() {
                 return m_artifactRepository;
             }
-            
+
             @Override
             protected RepositoryAdmin getRepositoryAdmin() {
                 return m_admin;
             }
-            
-            @Override
-            protected void removeAssociation(Artifact2FeatureAssociation association) {
-                m_artifact2featureAssociationRepository.remove(association);
-            }
         };
     }
 
-    private FeaturesPanel createFeaturesPanel(Window main) {
-        return new FeaturesPanel(m_associations) {
+    private FeaturesPanel createFeaturesPanel() {
+        return new FeaturesPanel(m_associations, this) {
             @Override
             protected FeatureRepository getRepository() {
                 return m_featureRepository;
             }
-            
+
             @Override
             protected RepositoryAdmin getRepositoryAdmin() {
                 return m_admin;
             }
-            
-            @Override
-            protected void removeAssocation(Artifact2FeatureAssociation association) {
-                m_artifact2featureAssociationRepository.remove(association);
-            }
-            
-            @Override
-            protected void removeAssocation(Feature2DistributionAssociation association)
{
-                m_feature2distributionAssociationRepository.remove(association);
-            }
         };
     }
 
-    private DistributionsPanel createDistributionsPanel(Window main) {
-        return new DistributionsPanel(m_associations) {
-
+    private DistributionsPanel createDistributionsPanel() {
+        return new DistributionsPanel(m_associations, this) {
             @Override
             protected DistributionRepository getRepository() {
                 return m_distributionRepository;
             }
-            
+
             @Override
             protected RepositoryAdmin getRepositoryAdmin() {
                 return m_admin;
             }
-            
-            @Override
-            protected void removeAssocation(Distribution2TargetAssociation association) {
-                m_distribution2targetAssociationRepository.remove(association);
-            }
-            
-            @Override
-            protected void removeAssocation(Feature2DistributionAssociation association)
{
-                m_feature2distributionAssociationRepository.remove(association);        
       
-            }
         };
     }
 
-    private TargetsPanel createTargetsPanel(Window main) {
-        return new TargetsPanel(m_associations) {
+    private TargetsPanel createTargetsPanel() {
+        return new TargetsPanel(m_associations, this) {
             @Override
             protected StatefulTargetRepository getRepository() {
                 return m_statefulTargetRepository;
             }
-            
+
             @Override
             protected RepositoryAdmin getRepositoryAdmin() {
                 return m_admin;
             }
-            
-            @Override
-            protected void removeAssocation(Distribution2TargetAssociation association) {
-                m_distribution2targetAssociationRepository.remove(association);
-            }
         };
     }
 
@@ -609,7 +600,8 @@ public class VaadinClient extends com.va
                 TableTransferable tt = (TableTransferable) transferable;
                 Object fromItemId = tt.getItemId();
                 // get the active selection, but only if we drag from the same table
-                Set<?> selection = m_associations.isActiveTable(tt.getSourceComponent())
? m_associations.getActiveSelection() : null;
+                Set<?> selection =
+                    m_associations.isActiveTable(tt.getSourceComponent()) ? m_associations.getActiveSelection()
: null;
                 if (targetDetails instanceof AbstractSelectTargetDetails) {
                     AbstractSelectTargetDetails ttd = (AbstractSelectTargetDetails) targetDetails;
                     Object toItemId = ttd.getItemIdOver();
@@ -633,8 +625,8 @@ public class VaadinClient extends com.va
                             associateFromRight((String) toItemId, (String) fromItemId);
                         }
                     }
-                    // TODO add to highlighting (it's probably easiest to 
-                    // recalculate the whole set of related and associated 
+                    // TODO add to highlighting (it's probably easiest to
+                    // recalculate the whole set of related and associated
                     // items here, see SelectionListener, or to manually figure
                     // out the changes in all cases
                 }
@@ -681,10 +673,11 @@ public class VaadinClient extends com.va
                     public void onOk(String name, String description) {
                         createFeature(name, description);
                     }
-                    
+
                     public void handleError(Exception e) {
                         // ACE-241: notify user when the feature-creation failed!
-                        main.showNotification("Failed to add new feature!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+                        main.showNotification("Failed to add new feature!", "<br/>Reason:
" + e.getMessage(),
+                            Notification.TYPE_ERROR_MESSAGE);
                     }
                 };
                 addFeatureWindow.show(main);
@@ -708,10 +701,11 @@ public class VaadinClient extends com.va
                     public void onOk(String name, String description) {
                         createDistribution(name, description);
                     }
-                    
+
                     public void handleError(Exception e) {
                         // ACE-241: notify user when the distribution-creation failed!
-                        main.showNotification("Failed to add new distribution!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+                        main.showNotification("Failed to add new distribution!", "<br/>Reason:
" + e.getMessage(),
+                            Notification.TYPE_ERROR_MESSAGE);
                     }
                 };
                 addDistributionWindow.show(main);
@@ -736,10 +730,11 @@ public class VaadinClient extends com.va
                     public void onOk(String id, String description) {
                         createTarget(id, description);
                     }
-                    
+
                     public void handleError(Exception e) {
                         // ACE-241: notify user when the target-creation failed!
-                        main.showNotification("Failed to add new target!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+                        main.showNotification("Failed to add new target!", "<br/>Reason:
" + e.getMessage(),
+                            Notification.TYPE_ERROR_MESSAGE);
                     }
                 };
                 addTargetWindow.show(main);
@@ -814,7 +809,7 @@ public class VaadinClient extends com.va
         // when the session times out
         // TODO: clean up the ace client session?
     }
-     
+
     private void showAddArtifactDialog() {
         final AddArtifactWindow featureWindow = new AddArtifactWindow(m_sessionDir, m_obrUrl)
{
             @Override
@@ -827,7 +822,7 @@ public class VaadinClient extends com.va
                 return m_log;
             }
         };
-        
+
         if (featureWindow.getParent() != null) {
             // window is already showing
             getMainWindow().showNotification("Window is already open");

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java?rev=1310292&r1=1310291&r2=1310292&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
Fri Apr  6 12:02:14 2012
@@ -28,43 +28,42 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.object.FeatureObject;
 import org.apache.ace.client.repository.repository.ArtifactRepository;
 import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.ace.webui.vaadin.AssociationRemover;
 import org.apache.ace.webui.vaadin.Associations;
 
 import com.vaadin.data.Item;
 
 /**
- *
+ * Provides an object panel for displaying artifacts.
  */
 public abstract class ArtifactsPanel extends BaseObjectPanel<ArtifactObject, ArtifactRepository>
{
 
     /**
-     * @param associations
+     * Creates a new {@link ArtifactsPanel} instance.
+     * 
+     * @param associations the assocation-holder object;
+     * @param associationRemover the helper for removing associations.
      */
-    public ArtifactsPanel(Associations associations) {
-        super(associations, "Artifact", UIExtensionFactory.EXTENSION_POINT_VALUE_ARTIFACT,
true);
+    public ArtifactsPanel(Associations associations, AssociationRemover associationRemover)
{
+        super(associations, associationRemover, "Artifact", UIExtensionFactory.EXTENSION_POINT_VALUE_ARTIFACT,
true);
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void add(ArtifactObject artifact) {
-        String resourceProcessorPID = artifact.getAttribute(BundleHelper.KEY_RESOURCE_PROCESSOR_PID);
-        if (resourceProcessorPID != null) {
-            // if it's a resource processor we don't add it to our list, as
-            // resource processors don't show up there (you can query for them
-            // separately)
-            return;
-        }
-        Item item = addItem(artifact.getDefinition());
-        if (item != null) {
-            populateItem(artifact, item);
+    @Override
+    protected boolean doRemoveRightSideAssociation(ArtifactObject object, RepositoryObject
other) {
+        List<Artifact2FeatureAssociation> associations = object.getAssociationsWith((FeatureObject)
other);
+        for (Artifact2FeatureAssociation association : associations) {
+            m_associationRemover.removeAssociation(association);
         }
+        return true;
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void doHandleEvent(String topic, ArtifactObject artifact, org.osgi.service.event.Event
event) {
+    protected void handleEvent(String topic, ArtifactObject artifact, org.osgi.service.event.Event
event) {
         if (ArtifactObject.TOPIC_ADDED.equals(topic)) {
             add(artifact);
         }
@@ -80,30 +79,10 @@ public abstract class ArtifactsPanel ext
      * {@inheritDoc}
      */
     @Override
-    protected boolean doRemoveLeftSideAssociation(ArtifactObject object, RepositoryObject
other) {
-        return false;
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected boolean doRemoveRightSideAssociation(ArtifactObject object, RepositoryObject
other) {
-        List<Artifact2FeatureAssociation> associations = object.getAssociationsWith((FeatureObject)
other);
-        for (Artifact2FeatureAssociation association : associations) {
-            removeAssociation(association);
-        }
-        return true;
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     protected boolean isSupportedEntity(RepositoryObject entity) {
-        return entity instanceof ArtifactObject;
+        return (entity instanceof ArtifactObject) && !isResourceProcessor((ArtifactObject)
entity);
     }
-    
+
     /**
      * {@inheritDoc}
      */
@@ -116,7 +95,12 @@ public abstract class ArtifactsPanel ext
     }
 
     /**
-     * @param association
+     * Returns whether or not the given artifact is actually a resource processor.
+     * 
+     * @param artifact the artifact to test, cannot be <code>null</code>.
+     * @return <code>true</code> if the given artifact is a resource processor,
<code>false</code> otherwise.
      */
-    protected abstract void removeAssociation(Artifact2FeatureAssociation association);
+    private boolean isResourceProcessor(ArtifactObject artifact) {
+        return artifact.getAttribute(BundleHelper.KEY_RESOURCE_PROCESSOR_PID) != null;
+    }
 }

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java?rev=1310292&r1=1310291&r2=1310292&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
Fri Apr  6 12:02:14 2012
@@ -30,6 +30,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.RepositoryObject.WorkingState;
 import org.apache.ace.webui.NamedObject;
 import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.ace.webui.vaadin.AssociationRemover;
 import org.apache.ace.webui.vaadin.Associations;
 import org.apache.ace.webui.vaadin.EditWindow;
 import org.apache.felix.dm.Component;
@@ -51,8 +52,7 @@ import com.vaadin.ui.Window.Notification
 /**
  * Provides a custom table for displaying artifacts, features and so on.
  */
-abstract class BaseObjectPanel<REPO_OBJ extends RepositoryObject, REPO extends ObjectRepository<REPO_OBJ>>
extends
-    Table implements EventHandler, RemoveAssociationHandler<REPO_OBJ> {
+abstract class BaseObjectPanel<REPO_OBJ extends RepositoryObject, REPO extends ObjectRepository<REPO_OBJ>>
extends Table implements EventHandler {
 
     /**
      * Provides a generic remove item button.
@@ -82,7 +82,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
      */
     private class RemoveLinkButton<REPO_OBJECT extends RepositoryObject> extends Button
{
         public RemoveLinkButton(final REPO_OBJECT object, final Table toLeft, final Table
toRight,
-            final RemoveAssociationHandler<REPO_OBJECT> removeHandler) {
+            final BaseObjectPanel removeHandler) {
             super("-");
             setStyleName("small");
 
@@ -173,6 +173,8 @@ abstract class BaseObjectPanel<REPO_OBJ 
     protected static final int ICON_WIDTH = 16;
 
     private final Associations m_associations;
+    protected final AssociationRemover m_associationRemover;
+
     private final List<UIExtensionFactoryHolder> m_extensionFactories;
     private final String m_extensionPoint;
 
@@ -186,15 +188,18 @@ abstract class BaseObjectPanel<REPO_OBJ 
      * Creates a new {@link BaseObjectPanel} instance.
      * 
      * @param associations the associations for this panel;
+     * @param associationRemover the association remove to use for removing associations;
      * @param name the name of this panel;
      * @param extensionPoint the extension point to listen for;
      * @param hasEdit <code>true</code> if double clicking an row in this table
should show an editor, <code>false</code> to disallow editing.
      */
-    public BaseObjectPanel(Associations associations, final String name, String extensionPoint,
final boolean hasEdit) {
+    public BaseObjectPanel(final Associations associations, final AssociationRemover associationRemover,
+        final String name, final String extensionPoint, final boolean hasEdit) {
         super(name + "s");
 
-        m_extensionFactories = new ArrayList<UIExtensionFactoryHolder>();
         m_associations = associations;
+        m_associationRemover = associationRemover;
+        m_extensionFactories = new ArrayList<UIExtensionFactoryHolder>();
         m_extensionPoint = extensionPoint;
 
         defineTableColumns();
@@ -243,7 +248,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
         synchronized (getApplication()) {
             if (isSupportedEntity(entity)) {
                 try {
-                    doHandleEvent(topic, (REPO_OBJ) entity, event);
+                    handleEvent(topic, (REPO_OBJ) entity, event);
                 }
                 finally {
                     refreshRenderedCells();
@@ -253,18 +258,6 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
-     * @param entity
-     */
-    public void updateEntity(REPO_OBJ entity) {
-        try {
-            update(entity);
-        }
-        finally {
-            refreshRenderedCells();
-        }
-    }
-
-    /**
      * Called by the dependency manager upon initialization of this component.
      * 
      * @param component the component representing this object.
@@ -276,8 +269,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
         component.add(dm
             .createServiceDependency()
             .setInstanceBound(true)
-            .setService(UIExtensionFactory.class,
-                "(" + UIExtensionFactory.EXTENSION_POINT_KEY + "=" + m_extensionPoint + ")")
+            .setService(UIExtensionFactory.class, "(" + UIExtensionFactory.EXTENSION_POINT_KEY
+ "=" + m_extensionPoint + ")")
             .setCallbacks("addExtension", "removeExtension"));
     }
 
@@ -305,26 +297,6 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public final void removeLeftSideAssociation(REPO_OBJ object, RepositoryObject other)
{
-        if (doRemoveLeftSideAssociation(object, other)) {
-            m_associations.removeAssociatedItem(object);
-            requestRepaint();
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public final void removeRightSideAssocation(REPO_OBJ object, RepositoryObject other)
{
-        if (doRemoveRightSideAssociation(object, other)) {
-            m_associations.removeAssociatedItem(object);
-            requestRepaint();
-        }
-    }
-
-    /**
      * Sets the left-side table, that defines the left-hand side of the assocations of the
entities.
      * 
      * @param leftTable the table to set, can be <code>null</code>.
@@ -343,6 +315,32 @@ abstract class BaseObjectPanel<REPO_OBJ 
     }
 
     /**
+     * Removes the left-hand side associations for a given repository object.
+     * 
+     * @param object the repository object to remove the left-hand side associations;
+     * @param other the (left-hand side) repository object to remove the associations for.
+     */
+    final void removeLeftSideAssociation(REPO_OBJ object, RepositoryObject other) {
+        if (doRemoveLeftSideAssociation(object, other)) {
+            m_associations.removeAssociatedItem(object);
+            requestRepaint();
+        }
+    }
+
+    /**
+     * Removes the right-hand side associations for a given repository object.
+     * 
+     * @param object the repository object to remove the right-hand side associations;
+     * @param other the (right-hand side) repository object to remove the associations for.
+     */
+    final void removeRightSideAssocation(REPO_OBJ object, RepositoryObject other) {
+        if (doRemoveRightSideAssociation(object, other)) {
+            m_associations.removeAssociatedItem(object);
+            requestRepaint();
+        }
+    }
+
+    /**
      * Adds a given repository object to this table.
      * 
      * @param object the repository object to add, cannot be <code>null</code>.
@@ -381,7 +379,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
      * @param res the resource denoting the actual icon.
      * @return an embeddable icon, never <code>null</code>.
      */
-    protected final Embedded createIcon(String name, Resource res) {
+    protected Embedded createIcon(String name, Resource res) {
         Embedded embedded = new Embedded(name, res);
         embedded.setType(Embedded.TYPE_IMAGE);
         embedded.setDescription(name);
@@ -396,7 +394,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
      * @param iconName the base name of the icon to use, it will be appended with '.png'.
      * @return a {@link Resource} denoting the icon.
      */
-    protected final Resource createIconResource(String iconName) {
+    protected Resource createIconResource(String iconName) {
         return new ThemeResource("icons/" + iconName.toLowerCase() + ".png");
     }
 
@@ -439,7 +437,7 @@ abstract class BaseObjectPanel<REPO_OBJ 
      * 
      * @see org.osgi.service.event.EventHandler#handleEvent(org.osgi.service.event.Event)
      */
-    protected void doHandleEvent(String topic, REPO_OBJ entity, org.osgi.service.event.Event
event) {
+    protected void handleEvent(String topic, REPO_OBJ entity, org.osgi.service.event.Event
event) {
         // Nop...
     }
 

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/DistributionsPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/DistributionsPanel.java?rev=1310292&r1=1310291&r2=1310292&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/DistributionsPanel.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/DistributionsPanel.java
Fri Apr  6 12:02:14 2012
@@ -29,35 +29,25 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.object.TargetObject;
 import org.apache.ace.client.repository.repository.DistributionRepository;
 import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.ace.webui.vaadin.AssociationRemover;
 import org.apache.ace.webui.vaadin.Associations;
 
 import com.vaadin.data.Item;
 
 /**
- *
+ * Provides an object panel for displaying distributions.
  */
 public abstract class DistributionsPanel extends BaseObjectPanel<DistributionObject, DistributionRepository>
{
 
     /**
-     * @param associations
-     */
-    public DistributionsPanel(Associations associations) {
-        super(associations, "Distribution", UIExtensionFactory.EXTENSION_POINT_VALUE_DISTRIBUTION,
true /* hasEdit */);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void doHandleEvent(String topic, DistributionObject distribution, org.osgi.service.event.Event
event) {
-        if (DistributionObject.TOPIC_ADDED.equals(topic)) {
-            add(distribution);
-        }
-        if (DistributionObject.TOPIC_REMOVED.equals(topic)) {
-            remove(distribution);
-        }
-        if (DistributionObject.TOPIC_CHANGED.equals(topic) || RepositoryAdmin.TOPIC_STATUSCHANGED.equals(topic))
{
-            update(distribution);
-        }
+     * Creates a new {@link DistributionsPanel} instance.
+     * 
+     * @param associations the assocation-holder object;
+     * @param associationRemover the helper for removing associations.
+     */
+    public DistributionsPanel(Associations associations, AssociationRemover associationRemover)
{
+        super(associations, associationRemover, "Distribution", UIExtensionFactory.EXTENSION_POINT_VALUE_DISTRIBUTION,
+            true /* hasEdit */);
     }
 
     /**
@@ -67,11 +57,11 @@ public abstract class DistributionsPanel
     protected boolean doRemoveLeftSideAssociation(DistributionObject object, RepositoryObject
other) {
         List<Feature2DistributionAssociation> associations = object.getAssociationsWith((FeatureObject)
other);
         for (Feature2DistributionAssociation association : associations) {
-            removeAssocation(association);
+            m_associationRemover.removeAssociation(association);
         }
         return true;
     }
-    
+
     /**
      * {@inheritDoc}
      */
@@ -79,11 +69,26 @@ public abstract class DistributionsPanel
     protected boolean doRemoveRightSideAssociation(DistributionObject object, RepositoryObject
other) {
         List<Distribution2TargetAssociation> associations = object.getAssociationsWith((TargetObject)
other);
         for (Distribution2TargetAssociation association : associations) {
-            removeAssocation(association);
+            m_associationRemover.removeAssociation(association);
         }
         return true;
     }
-    
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void handleEvent(String topic, DistributionObject distribution, org.osgi.service.event.Event
event) {
+        if (DistributionObject.TOPIC_ADDED.equals(topic)) {
+            add(distribution);
+        }
+        if (DistributionObject.TOPIC_REMOVED.equals(topic)) {
+            remove(distribution);
+        }
+        if (DistributionObject.TOPIC_CHANGED.equals(topic) || RepositoryAdmin.TOPIC_STATUSCHANGED.equals(topic))
{
+            update(distribution);
+        }
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -102,14 +107,4 @@ public abstract class DistributionsPanel
         item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription());
         item.getItemProperty(ACTIONS).setValue(createActionButtons(distribution));
     }
-    
-    /**
-     * @param association
-     */
-    protected abstract void removeAssocation(Distribution2TargetAssociation association);
-    
-    /**
-     * @param association
-     */
-    protected abstract void removeAssocation(Feature2DistributionAssociation association);
 }

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/FeaturesPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/FeaturesPanel.java?rev=1310292&r1=1310291&r2=1310292&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/FeaturesPanel.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/FeaturesPanel.java
Fri Apr  6 12:02:14 2012
@@ -29,45 +29,34 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.object.FeatureObject;
 import org.apache.ace.client.repository.repository.FeatureRepository;
 import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.ace.webui.vaadin.AssociationRemover;
 import org.apache.ace.webui.vaadin.Associations;
 
 import com.vaadin.data.Item;
 
 /**
- *
+ * Provides an object panel for displaying features.
  */
 public abstract class FeaturesPanel extends BaseObjectPanel<FeatureObject, FeatureRepository>
{
 
     /**
-     * @param associations
+     * Creates a new {@link FeaturesPanel} instance.
+     * 
+     * @param associations the assocation-holder object;
+     * @param associationRemover the helper for removing associations.
      */
-    public FeaturesPanel(Associations associations) {
-        super(associations, "Feature", UIExtensionFactory.EXTENSION_POINT_VALUE_FEATURE,
true);
+    public FeaturesPanel(Associations associations, AssociationRemover associationRemover)
{
+        super(associations, associationRemover, "Feature", UIExtensionFactory.EXTENSION_POINT_VALUE_FEATURE,
true);
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void doHandleEvent(String topic, FeatureObject feature, org.osgi.service.event.Event
event) {
-        if (FeatureObject.TOPIC_ADDED.equals(topic)) {
-            add(feature);
-        }
-        if (FeatureObject.TOPIC_REMOVED.equals(topic)) {
-            remove(feature);
-        }
-        if (FeatureObject.TOPIC_CHANGED.equals(topic) || RepositoryAdmin.TOPIC_STATUSCHANGED.equals(topic))
{
-            update(feature);
-        }
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
     @Override
     protected boolean doRemoveLeftSideAssociation(FeatureObject object, RepositoryObject
other) {
         List<Artifact2FeatureAssociation> associations = object.getAssociationsWith((ArtifactObject)
other);
         for (Artifact2FeatureAssociation association : associations) {
-            removeAssocation(association);
+            m_associationRemover.removeAssociation(association);
         }
         return true;
     }
@@ -79,7 +68,7 @@ public abstract class FeaturesPanel exte
     protected boolean doRemoveRightSideAssociation(FeatureObject object, RepositoryObject
other) {
         List<Feature2DistributionAssociation> associations = object.getAssociationsWith((DistributionObject)
other);
         for (Feature2DistributionAssociation association : associations) {
-            removeAssocation(association);
+            m_associationRemover.removeAssociation(association);
         }
         return true;
     }
@@ -87,6 +76,21 @@ public abstract class FeaturesPanel exte
     /**
      * {@inheritDoc}
      */
+    protected void handleEvent(String topic, FeatureObject feature, org.osgi.service.event.Event
event) {
+        if (FeatureObject.TOPIC_ADDED.equals(topic)) {
+            add(feature);
+        }
+        if (FeatureObject.TOPIC_REMOVED.equals(topic)) {
+            remove(feature);
+        }
+        if (FeatureObject.TOPIC_CHANGED.equals(topic) || RepositoryAdmin.TOPIC_STATUSCHANGED.equals(topic))
{
+            update(feature);
+        }
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
     @Override
     protected boolean isSupportedEntity(RepositoryObject entity) {
         return entity instanceof FeatureObject;
@@ -102,15 +106,5 @@ public abstract class FeaturesPanel exte
         item.getItemProperty(OBJECT_DESCRIPTION).setValue(feature.getDescription());
         item.getItemProperty(ACTIONS).setValue(createActionButtons(feature));
     }
-    
-    /**
-     * @param association
-     */
-    protected abstract void removeAssocation(Artifact2FeatureAssociation association);
-    
-    /**
-     * @param association
-     */
-    protected abstract void removeAssocation(Feature2DistributionAssociation association);
 }
 

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/TargetsPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/TargetsPanel.java?rev=1310292&r1=1310291&r2=1310292&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/TargetsPanel.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/TargetsPanel.java
Fri Apr  6 12:02:14 2012
@@ -28,6 +28,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.stateful.StatefulTargetObject;
 import org.apache.ace.client.repository.stateful.StatefulTargetRepository;
 import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.ace.webui.vaadin.AssociationRemover;
 import org.apache.ace.webui.vaadin.Associations;
 
 import com.vaadin.data.Item;
@@ -37,7 +38,7 @@ import com.vaadin.ui.Embedded;
 import com.vaadin.ui.HorizontalLayout;
 
 /**
- *
+ * Provides an object panel for displaying (stateful) targets.
  */
 public abstract class TargetsPanel extends BaseObjectPanel<StatefulTargetObject, StatefulTargetRepository>
{
 
@@ -48,12 +49,16 @@ public abstract class TargetsPanel exten
     /**
      * Creates a new {@link TargetsPanel} instance.
      * 
-     * @param associations the assocation-holder object.
+     * @param associations the assocation-holder object;
+     * @param associationRemover the helper for removing associations.
      */
-    public TargetsPanel(Associations associations) {
-        super(associations, "Target", UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET, true
/* hasEdit */);
+    public TargetsPanel(Associations associations, AssociationRemover associationRemover)
{
+        super(associations, associationRemover, "Target", UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET,
true /* hasEdit */);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     protected Button createRemoveItemButton(StatefulTargetObject object) {
         Button b = super.createRemoveItemButton(object);
@@ -84,28 +89,11 @@ public abstract class TargetsPanel exten
     /**
      * {@inheritDoc}
      */
-    protected void doHandleEvent(String topic, StatefulTargetObject statefulTarget, org.osgi.service.event.Event
event) {
-        if (StatefulTargetObject.TOPIC_ADDED.equals(topic)) {
-            add(statefulTarget);
-        }
-        if (StatefulTargetObject.TOPIC_REMOVED.equals(topic)) {
-            remove(statefulTarget);
-        }
-        if (StatefulTargetObject.TOPIC_CHANGED.equals(topic) || StatefulTargetObject.TOPIC_STATUS_CHANGED.equals(topic)
-            || StatefulTargetObject.TOPIC_AUDITEVENTS_CHANGED.equals(topic)
-            || RepositoryAdmin.TOPIC_STATUSCHANGED.equals(topic)) {
-            update(statefulTarget);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     @Override
     protected boolean doRemoveLeftSideAssociation(StatefulTargetObject object, RepositoryObject
other) {
         List<Distribution2TargetAssociation> associations = object.getAssociationsWith((DistributionObject)
other);
         for (Distribution2TargetAssociation association : associations) {
-            removeAssocation(association);
+            m_associationRemover.removeAssociation(association);
         }
         return true;
     }
@@ -125,6 +113,23 @@ public abstract class TargetsPanel exten
     /**
      * {@inheritDoc}
      */
+    protected void handleEvent(String topic, StatefulTargetObject statefulTarget, org.osgi.service.event.Event
event) {
+        if (StatefulTargetObject.TOPIC_ADDED.equals(topic)) {
+            add(statefulTarget);
+        }
+        if (StatefulTargetObject.TOPIC_REMOVED.equals(topic)) {
+            remove(statefulTarget);
+        }
+        if (StatefulTargetObject.TOPIC_CHANGED.equals(topic) || StatefulTargetObject.TOPIC_STATUS_CHANGED.equals(topic)
+            || StatefulTargetObject.TOPIC_AUDITEVENTS_CHANGED.equals(topic)
+            || RepositoryAdmin.TOPIC_STATUSCHANGED.equals(topic)) {
+            update(statefulTarget);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     @Override
     protected boolean isSupportedEntity(RepositoryObject entity) {
         return entity instanceof StatefulTargetObject;
@@ -146,11 +151,6 @@ public abstract class TargetsPanel exten
     }
 
     /**
-     * @param association
-     */
-    protected abstract void removeAssocation(Distribution2TargetAssociation association);
-
-    /**
      * @param object
      * @return
      */



Mime
View raw message