ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1411151 - in /ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin: VaadinClient.java component/MainActionToolbar.java
Date Mon, 19 Nov 2012 12:36:27 GMT
Author: marrs
Date: Mon Nov 19 12:36:26 2012
New Revision: 1411151

URL: http://svn.apache.org/viewvc?rev=1411151&view=rev
Log:
ACE-303 passed on the user to every method that is invoked while initializing the UI

Modified:
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1411151&r1=1411150&r2=1411151&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
Mon Nov 19 12:36:26 2012
@@ -292,12 +292,12 @@ public class VaadinClient extends com.va
         m_grid.setSpacing(true);
         m_grid.setSizeFull();
 
-        m_grid.addComponent(createToolbar(), 0, 0, count - 1, 0);
+        m_grid.addComponent(createToolbar(user), 0, 0, count - 1, 0);
 
-        m_artifactsPanel = createArtifactsPanel();
+        m_artifactsPanel = createArtifactsPanel(user);
 
         m_artifactToolbar = new HorizontalLayout();
-        m_artifactToolbar.addComponent(createAddArtifactButton());
+        m_artifactToolbar.addComponent(createAddArtifactButton(user));
 
         CheckBox dynamicCheckBox = new CheckBox("Dynamic Links");
         dynamicCheckBox.setImmediate(true);
@@ -316,8 +316,8 @@ public class VaadinClient extends com.va
             count++;
         }
 
-        m_featuresPanel = createFeaturesPanel();
-        m_featureToolbar = createAddFeatureButton();
+        m_featuresPanel = createFeaturesPanel(user);
+        m_featureToolbar = createAddFeatureButton(user);
 
         if (auth.hasRole("viewFeature")) {
             m_grid.addComponent(m_featuresPanel, count, 2);
@@ -325,8 +325,8 @@ public class VaadinClient extends com.va
             count++;
         }
 
-        m_distributionsPanel = createDistributionsPanel();
-        m_distributionToolbar = createAddDistributionButton();
+        m_distributionsPanel = createDistributionsPanel(user);
+        m_distributionToolbar = createAddDistributionButton(user);
 
         if (auth.hasRole("viewDistribution")) {
             m_grid.addComponent(m_distributionsPanel, count, 2);
@@ -334,8 +334,8 @@ public class VaadinClient extends com.va
             count++;
         }
 
-        m_targetsPanel = createTargetsPanel();
-        m_targetToolbar = createAddTargetButton();
+        m_targetsPanel = createTargetsPanel(user);
+        m_targetToolbar = createAddTargetButton(user);
 
         if (auth.hasRole("viewTarget")) {
             m_grid.addComponent(m_targetsPanel, count, 2);
@@ -541,10 +541,10 @@ public class VaadinClient extends com.va
         }
     }
 
-    private GridLayout createToolbar() {
+    private GridLayout createToolbar(User user) {
         final boolean showLogoutButton = m_useAuth;
         final DependencyManager manager = m_manager;
-        MainActionToolbar mainActionToolbar = new MainActionToolbar(manager, showLogoutButton)
{
+        MainActionToolbar mainActionToolbar = new MainActionToolbar(user, manager, showLogoutButton)
{
             @Override
             protected RepositoryAdmin getRepositoryAdmin() {
                 return m_admin;
@@ -582,7 +582,7 @@ public class VaadinClient extends com.va
         return mainActionToolbar;
     }
 
-    private ArtifactsPanel createArtifactsPanel() {
+    private ArtifactsPanel createArtifactsPanel(User user) {
         return new ArtifactsPanel(m_associations, this) {
             @Override
             protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
@@ -612,7 +612,7 @@ public class VaadinClient extends com.va
         };
     }
 
-    private FeaturesPanel createFeaturesPanel() {
+    private FeaturesPanel createFeaturesPanel(User user) {
         return new FeaturesPanel(m_associations, this) {
             @Override
             protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
@@ -642,7 +642,7 @@ public class VaadinClient extends com.va
         };
     }
 
-    private DistributionsPanel createDistributionsPanel() {
+    private DistributionsPanel createDistributionsPanel(User user) {
         return new DistributionsPanel(m_associations, this) {
             @Override
             protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
@@ -672,7 +672,7 @@ public class VaadinClient extends com.va
         };
     }
 
-    private TargetsPanel createTargetsPanel() {
+    private TargetsPanel createTargetsPanel(User user) {
         return new TargetsPanel(m_associations, this) {
             @Override
             protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
@@ -771,11 +771,12 @@ public class VaadinClient extends com.va
 
     /**
      * Create a button to show a pop window for adding new features.
+     * @param user 
      * 
      * @param main Main Window
      * @return Button
      */
-    private Button createAddArtifactButton() {
+    private Button createAddArtifactButton(User user) {
         Button button = new Button("Add artifact...");
         button.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
@@ -788,10 +789,11 @@ public class VaadinClient extends com.va
     /***
      * Create a button to show popup window for adding a new feature. On success
      * this calls the createFeature() method.
+     * @param user 
      * 
      * @return the add-feature button instance.
      */
-    private Button createAddFeatureButton() {
+    private Button createAddFeatureButton(User user) {
         Button button = new Button("Add Feature...");
         button.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
@@ -815,10 +817,11 @@ public class VaadinClient extends com.va
     /**
      * Create a button to show a popup window for adding a new distribution. On
      * success this calls the createDistribution() method.
+     * @param user 
      * 
      * @return the add-distribution button instance.
      */
-    private Button createAddDistributionButton() {
+    private Button createAddDistributionButton(User user) {
         Button button = new Button("Add Distribution...");
         button.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
@@ -843,10 +846,11 @@ public class VaadinClient extends com.va
     /**
      * Create a button to show a popup window for adding a new target. On
      * success this calls the createTarget() method
+     * @param user 
      * 
      * @return the add-target button instance.
      */
-    private Button createAddTargetButton() {
+    private Button createAddTargetButton(User user) {
         Button button = new Button("Add target...");
         button.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java?rev=1411151&r1=1411150&r2=1411151&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
Mon Nov 19 12:36:26 2012
@@ -20,8 +20,9 @@ package org.apache.ace.webui.vaadin.comp
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.ace.client.repository.RepositoryAdmin;
@@ -29,6 +30,7 @@ import org.apache.ace.webui.UIExtensionF
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.event.EventHandler;
+import org.osgi.service.useradmin.User;
 
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
@@ -279,14 +281,18 @@ public abstract class MainActionToolbar 
     private final DependencyManager m_manager;
     private final ConcurrentHashMap<ServiceReference, UIExtensionFactory> m_extensions
= new ConcurrentHashMap<ServiceReference, UIExtensionFactory>();
 
+    private final User m_user;
+
     /**
      * Creates a new {@link MainActionToolbar} instance.
+     * @param user 
      * @param manager 
      * 
      * @param showLogoutButton <code>true</code> if a logout button should be
shown, <code>false</code> if it should not.
      */
-    public MainActionToolbar(DependencyManager manager, boolean showLogoutButton) {
+    public MainActionToolbar(User user, DependencyManager manager, boolean showLogoutButton)
{
         super(5, 1);
+        m_user = user;
         m_manager = manager;
 
         m_showLogoutButton = showLogoutButton;
@@ -408,7 +414,9 @@ public abstract class MainActionToolbar 
     protected List<Component> getExtraComponents() {
         List<Component> result = new ArrayList<Component>();
         for (UIExtensionFactory f : m_extensions.values()) {
-            result.add(f.create(Collections.EMPTY_MAP));
+            Map<String, Object> context = new HashMap<String, Object>();
+            context.put("user", m_user);
+            result.add(f.create(context));
         }
         return result;
     }



Mime
View raw message