ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1404958 - in /ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui: UIExtensionFactory.java vaadin/Activator.java vaadin/VaadinClient.java vaadin/component/MainActionToolbar.java
Date Fri, 02 Nov 2012 13:15:26 GMT
Author: marrs
Date: Fri Nov  2 13:15:26 2012
New Revision: 1404958

URL: http://svn.apache.org/viewvc?rev=1404958&view=rev
Log:
ACE-298 Created an initial implementation, including a 'Hello world' button (which will be
removed later).

Modified:
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/UIExtensionFactory.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
    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/UIExtensionFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/UIExtensionFactory.java?rev=1404958&r1=1404957&r2=1404958&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/UIExtensionFactory.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/UIExtensionFactory.java
Fri Nov  2 13:15:26 2012
@@ -32,6 +32,7 @@ public interface UIExtensionFactory {
     public static final String EXTENSION_POINT_VALUE_FEATURE = "feature";
     public static final String EXTENSION_POINT_VALUE_DISTRIBUTION = "distribution";
     public static final String EXTENSION_POINT_VALUE_TARGET = "target";
+    public static final String EXTENSION_POINT_VALUE_MENU = "menu";
     
     /**
      * Creates a UI component for use in the extension point. The contents of the

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java?rev=1404958&r1=1404957&r2=1404958&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java (original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java Fri
Nov  2 13:15:26 2012
@@ -32,6 +32,7 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.service.http.HttpService;
 
+import com.vaadin.ui.Button;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.VerticalLayout;
@@ -79,7 +80,17 @@ public class Activator extends Dependenc
                     return vl;
                 }
             })
-            );
+        );
+        
+        manager.add(createComponent()
+            .setInterface(UIExtensionFactory.class.getName(), new Properties() {{ put(UIExtensionFactory.EXTENSION_POINT_KEY,
UIExtensionFactory.EXTENSION_POINT_VALUE_MENU); }} )
+            .setImplementation(new UIExtensionFactory() {
+                @Override
+                public Component create(Map<String, Object> context) {
+                    return new Button("Hello world");
+                }
+            })
+        );
     }
 
     @Override

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=1404958&r1=1404957&r2=1404958&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
Fri Nov  2 13:15:26 2012
@@ -522,12 +522,10 @@ public class VaadinClient extends com.va
         Properties props = new Properties();
         props.put(EventConstants.EVENT_TOPIC, topics);
         props.put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + m_sessionID
+ ")");
-        // @formatter:off
         m_manager.add(
             m_manager.createComponent()
                 .setInterface(EventHandler.class.getName(), props)
                 .setImplementation(implementation));
-        // @formatter:on
     }
 
     /**
@@ -545,7 +543,8 @@ public class VaadinClient extends com.va
 
     private GridLayout createToolbar() {
         final boolean showLogoutButton = m_useAuth;
-        MainActionToolbar mainActionToolbar = new MainActionToolbar(showLogoutButton) {
+        final DependencyManager manager = m_manager;
+        MainActionToolbar mainActionToolbar = new MainActionToolbar(manager, showLogoutButton)
{
             @Override
             protected RepositoryAdmin getRepositoryAdmin() {
                 return m_admin;

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=1404958&r1=1404957&r2=1404958&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
Fri Nov  2 13:15:26 2012
@@ -19,13 +19,22 @@
 package org.apache.ace.webui.vaadin.component;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.ace.client.repository.RepositoryAdmin;
+import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.event.EventHandler;
 
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
 import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.Window.Notification;
 
@@ -267,21 +276,42 @@ public abstract class MainActionToolbar 
     private Button m_revertButton;
     private Button m_logoutButton;
 
+    private final DependencyManager m_manager;
+    private final ConcurrentHashMap<ServiceReference, UIExtensionFactory> m_extensions
= new ConcurrentHashMap<ServiceReference, UIExtensionFactory>();
+
     /**
      * Creates a new {@link MainActionToolbar} instance.
+     * @param manager 
      * 
      * @param showLogoutButton <code>true</code> if a logout button should be
shown, <code>false</code> if it should not.
      */
-    public MainActionToolbar(boolean showLogoutButton) {
+    public MainActionToolbar(DependencyManager manager, boolean showLogoutButton) {
         super(5, 1);
+        m_manager = manager;
 
         m_showLogoutButton = showLogoutButton;
 
         setWidth("100%");
         setSpacing(true);
+        
+        m_manager.add(m_manager.createComponent()
+            .setImplementation(this)
+            .add(m_manager.createServiceDependency()
+                .setService(UIExtensionFactory.class, "(" + UIExtensionFactory.EXTENSION_POINT_KEY
+ "=" + UIExtensionFactory.EXTENSION_POINT_VALUE_MENU + ")")
+                .setCallbacks("add", "remove")
+            )
+        );
 
         initComponent();
     }
+    
+    public void add(ServiceReference ref, UIExtensionFactory factory) {
+        m_extensions.put(ref, factory);
+    }
+    
+    public void remove(ServiceReference ref,  UIExtensionFactory factory) {
+        m_extensions.remove(ref);
+    }
 
     /**
      * {@inheritDoc}
@@ -355,8 +385,14 @@ public abstract class MainActionToolbar 
         m_revertButton.addListener(new RevertButtonListener());
         addComponent(m_revertButton, 2, 0);
 
-        Label spacer = new Label(" ");
-        addComponent(spacer, 3, 0);
+        HorizontalLayout bar = new HorizontalLayout();
+        Label spacer = new Label("");
+        spacer.setWidth("2em");
+        bar.addComponent(spacer);
+        for (Component c : getExtraComponents()) {
+            bar.addComponent(c);
+        }
+        addComponent(bar, 3, 0);
 
         m_logoutButton = new Button("Logout");
         m_logoutButton.addListener(new LogoutButtonListener());
@@ -368,4 +404,12 @@ public abstract class MainActionToolbar 
         // button to appear at the right side of the screen....
         setColumnExpandRatio(3, 5);
     }
+    
+    protected List<Component> getExtraComponents() {
+        List<Component> result = new ArrayList<Component>();
+        for (UIExtensionFactory f : m_extensions.values()) {
+            result.add(f.create(Collections.EMPTY_MAP));
+        }
+        return result;
+    }
 }



Mime
View raw message