incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1043766 - in /incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui: UIExtensionFactory.java vaadin/Activator.java vaadin/VaadinClient.java
Date Wed, 08 Dec 2010 23:11:08 GMT
Author: marrs
Date: Wed Dec  8 23:11:07 2010
New Revision: 1043766

URL: http://svn.apache.org/viewvc?rev=1043766&view=rev
Log:
First go at implementing UI extensions.

Modified:
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/UIExtensionFactory.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/UIExtensionFactory.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/UIExtensionFactory.java?rev=1043766&r1=1043765&r2=1043766&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/UIExtensionFactory.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/UIExtensionFactory.java
Wed Dec  8 23:11:07 2010
@@ -23,7 +23,7 @@ import java.util.Map;
 import com.vaadin.ui.Component;
 
 /**
- * A {@link org.apache.ace.webui.UIExtensionFactory} creates components for named extension
points in the Vaadin UI.
+ * Creates components for named extension points in the Vaadin UI.
  */
 public interface UIExtensionFactory {
     public static final String EXTENSION_POINT = "extension_point";

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java?rev=1043766&r1=1043765&r2=1043766&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
Wed Dec  8 23:11:07 2010
@@ -18,16 +18,23 @@
  */
 package org.apache.ace.webui.vaadin;
 
+import java.util.Map;
 import java.util.Properties;
 
 import javax.servlet.http.HttpServlet;
 
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 import org.apache.ace.http.listener.constants.HttpConstants;
+import org.apache.ace.webui.UIExtensionFactory;
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.http.HttpService;
 
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Button.ClickEvent;
+
 public class Activator extends DependencyActivatorBase {
     @Override
     public void init(BundleContext context, DependencyManager manager) throws Exception {
@@ -59,6 +66,22 @@ public class Activator extends Dependenc
 //            })
 //            .setInterface(EventHandler.class.getName(), new Properties() {{ put(EventConstants.EVENT_TOPIC,
"*"); }} )
 //        );
+        
+        // shows off components that are contributed by extensions
+        manager.add(createComponent()
+            .setInterface(UIExtensionFactory.class.getName(), null)
+            .setImplementation(new UIExtensionFactory() {
+                public Component create(Map<String, Object> context) {
+                    final StatefulGatewayObject target = (StatefulGatewayObject) context.get("object");
+                    return new Button("i", new Button.ClickListener() {
+                        public void buttonClick(ClickEvent event) {
+                            event.getButton().getWindow().showNotification(
+                                target.getID(), "current version is " + target.getCurrentVersion());
+                        }
+                    });
+                }
+            })
+        );
     }
     
     @Override

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1043766&r1=1043765&r2=1043766&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Wed Dec  8 23:11:07 2010
@@ -56,6 +56,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.repository.LicenseRepository;
 import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 import org.apache.ace.client.repository.stateful.StatefulGatewayRepository;
+import org.apache.ace.webui.UIExtensionFactory;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.BundleContext;
@@ -570,6 +571,20 @@ public class VaadinClient extends com.va
             private void init(Component component) {
                 populate();
                 DependencyManager dm = component.getDependencyManager();
+                component.add(dm.createServiceDependency()
+                    .setInstanceBound(true)
+                    .setService(UIExtensionFactory.class)
+                    .setCallbacks("addExtension", "removeExtension")
+                );
+            }
+            private List<UIExtensionFactory> m_factories = new ArrayList<UIExtensionFactory>();
+            public void addExtension(UIExtensionFactory factory) {
+                m_factories.add(factory);
+                populate();
+            }
+            public void removeExtension(UIExtensionFactory factory) {
+                m_factories.remove(factory);
+                populate();
             }
             public void populate() {
                 removeAllItems();
@@ -595,22 +610,12 @@ public class VaadinClient extends com.va
                 item.getItemProperty(OBJECT_NAME).setValue(statefulTarget.getID());
                 item.getItemProperty(OBJECT_DESCRIPTION).setValue("TODO");
                 HorizontalLayout buttons = new HorizontalLayout();
-                Button startStopButton = new Button("start");
-                startStopButton.addListener(new Button.ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        // TODO start/stop the cloud node
-                        String caption = event.getButton().getCaption();
-                        System.out.println("Action: " + caption);
-                        if ("start".equals(caption)) {
-                            event.getButton().setCaption("stop");
-                        }
-                        else {
-                            event.getButton().setCaption("start");
-                        }
-                        m_table.requestRepaint();
-                    }
-                });
-                buttons.addComponent(startStopButton);
+                Map<String, Object> context = new HashMap<String, Object>();
+                context.put("object", statefulTarget);
+                for (UIExtensionFactory factory : m_factories) {
+                    com.vaadin.ui.Component component = factory.create(context);
+                    buttons.addComponent(component);
+                }
                 item.getItemProperty(ACTIONS).setValue(buttons);
             }
             private void change(StatefulGatewayObject statefulTarget) {



Mime
View raw message