[jboss-svn-commits] JBL Code SVN: r33311 - in labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools: guvnor/client/explorer/grid/model and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 2 09:50:12 EDT 2010


Author: diegoll
Date: 2010-06-02 09:50:11 -0400 (Wed, 02 Jun 2010)
New Revision: 33311

Added:
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/DirectoryInstanceView.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/ExecutionEnvironmentView.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/HornetQFactoryPanel.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/MinaFactoryPanel.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/NewGridResourcePanel.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/RioFactoryPanel.java
Removed:
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/HornetQFactoryPanel.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/MinaFactoryPanel.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/RioFactoryPanel.java
Modified:
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/BrowseGridResourcesTreeBuilder.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridResourceView.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridTopologyView.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsService.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsServiceAsync.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/repository/services/TopologyAssetsServiceImpl.java
Log:
refactor to include create directories and execution environments

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/BrowseGridResourcesTreeBuilder.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/BrowseGridResourcesTreeBuilder.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/BrowseGridResourcesTreeBuilder.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -1,23 +1,11 @@
 package org.drools.guvnor.client.explorer.grid;
 
-import org.drools.guvnor.client.common.GenericCallback;
 import org.drools.guvnor.client.explorer.ExplorerViewCenterPanel;
-import org.drools.guvnor.client.explorer.grid.model.GridResourceView;
+import org.drools.guvnor.client.explorer.grid.model.DirectoryInstanceView;
+import org.drools.guvnor.client.explorer.grid.model.ExecutionEnvironmentView;
 import org.drools.guvnor.client.explorer.grid.model.GridTopologyView;
-import org.drools.guvnor.client.explorer.grid.services.TopologyAssetsService;
-import org.drools.guvnor.client.explorer.grid.services.TopologyAssetsServiceAsync;
+import org.drools.guvnor.client.explorer.grid.panels.NewGridResourcePanel;
 
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.Panel;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
 import com.gwtext.client.core.EventObject;
 import com.gwtext.client.data.Node;
 import com.gwtext.client.widgets.tree.TreeNode;
@@ -25,8 +13,6 @@
 
 public final class BrowseGridResourcesTreeBuilder {
 
-	private TopologyAssetsServiceAsync assetService;
-
     public Node build(final ExplorerViewCenterPanel targetPanel, final GridTopologyView gridTopology) {
 		final TreeNode resourcesItem = new TreeNode(gridTopology.getName().trim());
 		resourcesItem.addListener(new TreeNodeListenerAdapter(){
@@ -36,93 +22,39 @@
 			}
 		});
 		
-		for(GridResourceView gridResource : gridTopology.getGridResources()){
-			addResourceNode(targetPanel, resourcesItem, gridResource);
+		for(ExecutionEnvironmentView executionEnvironment : gridTopology.getExecutionEnvironments()){
+			addExecutionEnvironmentNode(targetPanel, resourcesItem, executionEnvironment);
 		}
 		
+		for(DirectoryInstanceView directoryInstance : gridTopology.getDirectoryInstances()){
+			addDirectoryInstanceNode(targetPanel, resourcesItem, directoryInstance);
+		}
+		
 		return resourcesItem;
     }
 
-    private void addResourceNode(ExplorerViewCenterPanel targetPanel, TreeNode resourcesItem, GridResourceView gridResource) {
-    	resourcesItem.appendChild(new TreeNode(gridResource.getName()));
+    private void addDirectoryInstanceNode(ExplorerViewCenterPanel targetPanel,
+			TreeNode resourcesItem, DirectoryInstanceView directoryInstance) {
+    	resourcesItem.appendChild(new TreeNode("directory - " + directoryInstance.getName()));
 	}
 
-    private void openCreateNewGridResourcePanel(ExplorerViewCenterPanel targetPanel, TreeNode resourcesItem, GridTopologyView gridTopology) {
-        if (!targetPanel.showIfOpen(gridTopology.getName())) {
-        	buildCreateNewGridResourcePanel(targetPanel, resourcesItem, gridTopology);
-        }
-    }
-
-    private void buildCreateNewGridResourcePanel(final ExplorerViewCenterPanel targetPanel, final TreeNode resourcesItem, final GridTopologyView gridTopology) {
-		Panel panel = new VerticalPanel();
-		final TextBox resourceName = new TextBox();
-		
-		Button addResourceAction = new Button("Create");
-		addResourceAction.addClickHandler(new ClickHandler() {
-			public void onClick(ClickEvent event) {
-				getService().createNewResource(resourceName.getText(), gridTopology, new GenericCallback<GridResourceView>() {
-					public void onSuccess(GridResourceView gridResource) {
-						addResourceNode(targetPanel, resourcesItem, gridResource);
-					}
-				});
-			}
-		});
-		
-        final VerticalPanel factoryPanel = new VerticalPanel();
-		
-        final ListBox optionProviders = new ListBox();
-        optionProviders.setVisibleItemCount(1);
-        final GridImplementations[] gridImplementantions = GridImplementations.values();
-		for (GridImplementations gridImplementation : gridImplementantions) {
-			optionProviders.addItem(gridImplementation.getLabel());
-		}
-        optionProviders.addChangeHandler(new ChangeHandler() {
-			public void onChange(ChangeEvent event) {
-				GridImplementations gridImplementation = gridImplementantions[optionProviders.getSelectedIndex()];
-				GWT.log(gridImplementation.getLabel());
-	            factoryPanel.clear();
-	            factoryPanel.add(gridImplementation.getFactoryWidget());
-			}
-		});
-
-		panel.add(resourceName);
-		panel.add(addResourceAction);
-		panel.add(optionProviders);
-		panel.add(factoryPanel);
-        targetPanel.addTab("New Resource", true, panel, gridTopology.getName());
+	private void addExecutionEnvironmentNode(ExplorerViewCenterPanel targetPanel, TreeNode resourcesItem, ExecutionEnvironmentView executionEnvironment) {
+    	resourcesItem.appendChild(new TreeNode("environment - " + executionEnvironment.getName()));
 	}
 
-
-	private TopologyAssetsServiceAsync getService() {
-		if(assetService == null)
-			assetService =  GWT.create(TopologyAssetsService.class);
-		return assetService;
-	}
-
-    private enum GridImplementations {
-        MINA("Mina", new MinaFactoryPanel()), 
-        HORNETQ("HornetQ", new HornetQFactoryPanel()), 
-        RIO("Rio", new RioFactoryPanel());
-
-        private String label;
-        private Widget factoryWidget;
-
-        private GridImplementations(String label, Widget widget) {
-            this.label = label;
-            this.factoryWidget = widget;
+    private void openCreateNewGridResourcePanel(final ExplorerViewCenterPanel targetPanel, final TreeNode resourcesItem, GridTopologyView gridTopology) {
+        if (!targetPanel.showIfOpen(gridTopology.getName())) {
+            targetPanel.addTab("New Resource", true, new NewGridResourcePanel(gridTopology) {
+				@Override
+				public void onExecutionEnvironmentCreation(ExecutionEnvironmentView executionEnvironment) {
+					addExecutionEnvironmentNode(targetPanel, resourcesItem, executionEnvironment);
+				}
+				
+				@Override
+				public void onDirectoryInstanceCreation(DirectoryInstanceView directoryInstance) {
+					addDirectoryInstanceNode(targetPanel, resourcesItem, directoryInstance);
+				}
+			}, gridTopology.getName());
         }
-
-        public String getLabel() {
-            return label;
-        }
-        
-        public Widget getFactoryWidget() {
-            return factoryWidget;
-        }
-
-        @Override
-        public String toString() {
-            return getLabel();
-        }
     }
 }

Deleted: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/HornetQFactoryPanel.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/HornetQFactoryPanel.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/HornetQFactoryPanel.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -1,18 +0,0 @@
-package org.drools.guvnor.client.explorer.grid;
-
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class HornetQFactoryPanel extends Composite {
-
-    public HornetQFactoryPanel() {
-        VerticalPanel panel = new VerticalPanel();
-        fillPanel(panel);
-        initWidget(panel);
-    }
-
-    private void fillPanel(VerticalPanel panel) {
-        panel.add(new Label("Hornyyyyy"));
-    }
-}

Deleted: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/MinaFactoryPanel.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/MinaFactoryPanel.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/MinaFactoryPanel.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -1,18 +0,0 @@
-package org.drools.guvnor.client.explorer.grid;
-
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class MinaFactoryPanel extends Composite {
-
-    public MinaFactoryPanel() {
-        VerticalPanel panel = new VerticalPanel();
-        fillPanel(panel);
-        initWidget(panel);
-    }
-
-    private void fillPanel(VerticalPanel panel) {
-        panel.add(new Label("Minooon"));
-    }
-}

Deleted: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/RioFactoryPanel.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/RioFactoryPanel.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/RioFactoryPanel.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -1,18 +0,0 @@
-package org.drools.guvnor.client.explorer.grid;
-
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class RioFactoryPanel extends Composite {
-
-    public RioFactoryPanel() {
-        VerticalPanel panel = new VerticalPanel();
-        fillPanel(panel);
-        initWidget(panel);
-    }
-
-    private void fillPanel(VerticalPanel panel) {
-        panel.add(new Label("Riooooo"));
-    }
-}

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/DirectoryInstanceView.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/DirectoryInstanceView.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/DirectoryInstanceView.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -0,0 +1,13 @@
+package org.drools.guvnor.client.explorer.grid.model;
+
+public class DirectoryInstanceView extends GridResourceView {
+
+	public DirectoryInstanceView() {
+		super();
+	}
+	
+	public DirectoryInstanceView(String name) {
+		super(name);
+	}
+
+}

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/ExecutionEnvironmentView.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/ExecutionEnvironmentView.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/ExecutionEnvironmentView.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -0,0 +1,13 @@
+package org.drools.guvnor.client.explorer.grid.model;
+
+public class ExecutionEnvironmentView extends GridResourceView {
+
+	public ExecutionEnvironmentView() {
+		super();
+	}
+	
+	public ExecutionEnvironmentView(String name) {
+		super(name);
+	}
+
+}

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridResourceView.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridResourceView.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridResourceView.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -2,7 +2,7 @@
 
 import java.io.Serializable;
 
-public class GridResourceView implements Serializable{
+public abstract class GridResourceView implements Serializable{
 
 	private String name;
 	

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridTopologyView.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridTopologyView.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/model/GridTopologyView.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -5,8 +5,10 @@
 import java.util.List;
 
 public class GridTopologyView implements Serializable{
+	
 	private String name;
-	private List<GridResourceView> gridResources;
+	private List<ExecutionEnvironmentView> executionEnvironments;
+	private List<DirectoryInstanceView> directoryInstances;
 
 	public GridTopologyView() { }
 	
@@ -22,14 +24,24 @@
 		this.name = name;
 	}
 
-	public List<GridResourceView> getGridResources() {
-		if(gridResources == null)
-			gridResources = new ArrayList<GridResourceView>();
-		return gridResources;
+	public List<ExecutionEnvironmentView> getExecutionEnvironments() {
+		if(executionEnvironments == null)
+			executionEnvironments = new ArrayList<ExecutionEnvironmentView>();
+		return executionEnvironments;
 	}
+	
+	public List<DirectoryInstanceView> getDirectoryInstances() {
+		if(directoryInstances == null)
+			directoryInstances = new ArrayList<DirectoryInstanceView>();
+		return directoryInstances;
+	}
 
-	public void addGridResource(GridResourceView newResource) {
-		getGridResources().add(newResource);
+	public void addExecutionEnvironment(ExecutionEnvironmentView newExecutionEnvironment) {
+		getExecutionEnvironments().add(newExecutionEnvironment);
 	}
 	
+	public void addDirectoryInstance(DirectoryInstanceView newDirectoryInstance){
+		getDirectoryInstances().add(newDirectoryInstance);
+	}
+	
 }

Copied: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/HornetQFactoryPanel.java (from rev 33216, labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/HornetQFactoryPanel.java)
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/HornetQFactoryPanel.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/HornetQFactoryPanel.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -0,0 +1,18 @@
+package org.drools.guvnor.client.explorer.grid.panels;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class HornetQFactoryPanel extends Composite {
+
+    public HornetQFactoryPanel() {
+        VerticalPanel panel = new VerticalPanel();
+        fillPanel(panel);
+        initWidget(panel);
+    }
+
+    private void fillPanel(VerticalPanel panel) {
+        panel.add(new Label("Hornyyyyy"));
+    }
+}

Copied: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/MinaFactoryPanel.java (from rev 33216, labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/MinaFactoryPanel.java)
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/MinaFactoryPanel.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/MinaFactoryPanel.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -0,0 +1,18 @@
+package org.drools.guvnor.client.explorer.grid.panels;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class MinaFactoryPanel extends Composite {
+
+    public MinaFactoryPanel() {
+        VerticalPanel panel = new VerticalPanel();
+        fillPanel(panel);
+        initWidget(panel);
+    }
+
+    private void fillPanel(VerticalPanel panel) {
+        panel.add(new Label("Minooon"));
+    }
+}

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/NewGridResourcePanel.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/NewGridResourcePanel.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/NewGridResourcePanel.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -0,0 +1,116 @@
+package org.drools.guvnor.client.explorer.grid.panels;
+
+import org.drools.guvnor.client.common.GenericCallback;
+import org.drools.guvnor.client.explorer.grid.model.DirectoryInstanceView;
+import org.drools.guvnor.client.explorer.grid.model.ExecutionEnvironmentView;
+import org.drools.guvnor.client.explorer.grid.model.GridTopologyView;
+import org.drools.guvnor.client.explorer.grid.services.TopologyAssetsService;
+import org.drools.guvnor.client.explorer.grid.services.TopologyAssetsServiceAsync;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.Panel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public abstract class NewGridResourcePanel extends Composite {
+
+	private TopologyAssetsServiceAsync assetService;
+
+	public NewGridResourcePanel(final GridTopologyView gridTopology) {
+
+		Panel panel = new VerticalPanel();
+		final TextBox resourceName = new TextBox();
+		
+		Button addEnvironmentAction = new Button("Create As Environment");
+		addEnvironmentAction.addClickHandler(new ClickHandler() {
+			public void onClick(ClickEvent event) {
+				getService().createExecutionEnvironment(resourceName.getText(), gridTopology, new GenericCallback<ExecutionEnvironmentView>() {
+					public void onSuccess(ExecutionEnvironmentView executionEnvironment) {
+						onExecutionEnvironmentCreation(executionEnvironment);
+					};
+				});
+			}
+		});
+		
+		Button addDirectoryAction = new Button("Create As Directory");
+		addDirectoryAction.addClickHandler(new ClickHandler() {
+			public void onClick(ClickEvent event) {
+				getService().createDirectoryInstance(resourceName.getText(), gridTopology, new GenericCallback<DirectoryInstanceView>() {
+					public void onSuccess(DirectoryInstanceView directoryInstance) {
+						onDirectoryInstanceCreation(directoryInstance);
+					}
+				});
+			}
+		});
+
+		
+        final VerticalPanel factoryPanel = new VerticalPanel();
+        final ListBox optionProviders = new ListBox();
+        optionProviders.setVisibleItemCount(1);
+        final GridImplementations[] gridImplementantions = GridImplementations.values();
+		for (GridImplementations gridImplementation : gridImplementantions) {
+			optionProviders.addItem(gridImplementation.getLabel());
+		}
+        optionProviders.addChangeHandler(new ChangeHandler() {
+			public void onChange(ChangeEvent event) {
+				GridImplementations gridImplementation = gridImplementantions[optionProviders.getSelectedIndex()];
+				GWT.log(gridImplementation.getLabel());
+	            factoryPanel.clear();
+	            factoryPanel.add(gridImplementation.getFactoryWidget());
+			}
+		});
+
+		panel.add(resourceName);
+		panel.add(optionProviders);
+		panel.add(factoryPanel);
+		panel.add(addEnvironmentAction);
+		panel.add(addDirectoryAction);
+	
+		initWidget(panel);
+	}
+	
+	public abstract void onExecutionEnvironmentCreation(ExecutionEnvironmentView executionEnvironment);
+	public abstract void onDirectoryInstanceCreation(DirectoryInstanceView directoryInstance);
+	
+    private enum GridImplementations {
+        MINA("Mina", new MinaFactoryPanel()), 
+        HORNETQ("HornetQ", new HornetQFactoryPanel()), 
+        RIO("Rio", new RioFactoryPanel());
+
+        private String label;
+        private Widget factoryWidget;
+
+        private GridImplementations(String label, Widget widget) {
+            this.label = label;
+            this.factoryWidget = widget;
+        }
+
+        public String getLabel() {
+            return label;
+        }
+        
+        public Widget getFactoryWidget() {
+            return factoryWidget;
+        }
+
+        @Override
+        public String toString() {
+            return getLabel();
+        }
+    }
+
+	private TopologyAssetsServiceAsync getService() {
+		if(assetService == null)
+			assetService =  GWT.create(TopologyAssetsService.class);
+		return assetService;
+	}
+
+}

Copied: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/RioFactoryPanel.java (from rev 33216, labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/RioFactoryPanel.java)
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/RioFactoryPanel.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/panels/RioFactoryPanel.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -0,0 +1,18 @@
+package org.drools.guvnor.client.explorer.grid.panels;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class RioFactoryPanel extends Composite {
+
+    public RioFactoryPanel() {
+        VerticalPanel panel = new VerticalPanel();
+        fillPanel(panel);
+        initWidget(panel);
+    }
+
+    private void fillPanel(VerticalPanel panel) {
+        panel.add(new Label("Riooooo"));
+    }
+}

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsService.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsService.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsService.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -1,6 +1,7 @@
 package org.drools.guvnor.client.explorer.grid.services;
 
-import org.drools.guvnor.client.explorer.grid.model.GridResourceView;
+import org.drools.guvnor.client.explorer.grid.model.DirectoryInstanceView;
+import org.drools.guvnor.client.explorer.grid.model.ExecutionEnvironmentView;
 import org.drools.guvnor.client.explorer.grid.model.GridTopologyView;
 
 import com.google.gwt.user.client.rpc.RemoteService;
@@ -12,11 +13,19 @@
 	GridTopologyView createNewTopology(String name);
 	
 	/**
-	 * Creates a new {@link GridResourceView} and adds it to the {@link GridTopologyView} parameter
-	 * @param name of the new {@link GridResourceView}
-	 * @param gridTopology is the topology where the new {@link GridResourceView} will be added
-	 * @return a new {@link GridResourceView} already added to a topology
+	 * Creates a new {@link ExecutionEnvironmentView} and adds it to the {@link GridTopologyView} parameter
+	 * @param name of the new {@link ExecutionEnvironmentView}
+	 * @param gridTopology is the topology where the newly {@link ExecutionEnvironmentView} will be added
+	 * @return a new {@link ExecutionEnvironmentView} already added to a topology
 	 */
-	GridResourceView createNewResource(String name, GridTopologyView gridTopology);
+	ExecutionEnvironmentView createExecutionEnvironment(String name, GridTopologyView gridTopology);
+	
+	/**
+	 * Creates a new {@link DirectoryInstanceView} and adds it to the {@link GridTopologyView} parameter
+	 * @param name of the new {@link DirectoryInstanceView}
+	 * @param gridTopology is the topology where the newly {@link DirectoryInstanceView} will be added
+	 * @return a new {@link DirectoryInstanceView} already added to a topology
+	 */
+	DirectoryInstanceView createDirectoryInstance(String name, GridTopologyView gridTopology);
 
 }

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsServiceAsync.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsServiceAsync.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/grid/services/TopologyAssetsServiceAsync.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -1,6 +1,7 @@
 package org.drools.guvnor.client.explorer.grid.services;
 
-import org.drools.guvnor.client.explorer.grid.model.GridResourceView;
+import org.drools.guvnor.client.explorer.grid.model.DirectoryInstanceView;
+import org.drools.guvnor.client.explorer.grid.model.ExecutionEnvironmentView;
 import org.drools.guvnor.client.explorer.grid.model.GridTopologyView;
 
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -10,7 +11,10 @@
 	void createNewTopology(String text,
 			AsyncCallback<GridTopologyView> callback);
 
-	void createNewResource(String name, GridTopologyView gridTopology,
-			AsyncCallback<GridResourceView> callback);
+	void createExecutionEnvironment(String name, GridTopologyView gridTopology,
+			AsyncCallback<ExecutionEnvironmentView> callback);
 
+	void createDirectoryInstance(String name, GridTopologyView gridTopology,
+			AsyncCallback<DirectoryInstanceView> callback);
+
 }

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/repository/services/TopologyAssetsServiceImpl.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/repository/services/TopologyAssetsServiceImpl.java	2010-06-02 13:49:59 UTC (rev 33310)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-guvnor/src/main/java/org/drools/repository/services/TopologyAssetsServiceImpl.java	2010-06-02 13:50:11 UTC (rev 33311)
@@ -1,6 +1,7 @@
 package org.drools.repository.services;
 
-import org.drools.guvnor.client.explorer.grid.model.GridResourceView;
+import org.drools.guvnor.client.explorer.grid.model.DirectoryInstanceView;
+import org.drools.guvnor.client.explorer.grid.model.ExecutionEnvironmentView;
 import org.drools.guvnor.client.explorer.grid.model.GridTopologyView;
 import org.drools.guvnor.client.explorer.grid.services.TopologyAssetsService;
 
@@ -13,9 +14,16 @@
 		return newTopology;
 	}
 
-	public GridResourceView createNewResource(String name, GridTopologyView gridTopology) {
-		GridResourceView newResource = new GridResourceView(name);
-		gridTopology.addGridResource(newResource);
-		return newResource;
+	public ExecutionEnvironmentView createExecutionEnvironment(String name, GridTopologyView gridTopology) {
+		ExecutionEnvironmentView newExecutionEnvironment = new ExecutionEnvironmentView(name);
+		gridTopology.addExecutionEnvironment(newExecutionEnvironment);
+		return newExecutionEnvironment;
 	}
+
+	public DirectoryInstanceView createDirectoryInstance(String name,
+			GridTopologyView gridTopology) {
+		DirectoryInstanceView newDirectoryInstance = new DirectoryInstanceView(name);
+		gridTopology.addDirectoryInstance(newDirectoryInstance);
+		return newDirectoryInstance;
+	}
 }



More information about the jboss-svn-commits mailing list