[jboss-svn-commits] JBL Code SVN: r35939 - in labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor: client/ruleeditor and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Nov 10 12:35:30 EST 2010


Author: eaa
Date: 2010-11-10 12:35:29 -0500 (Wed, 10 Nov 2010)
New Revision: 35939

Added:
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultMultiViewEditorMenuBarCreator.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditorMenuBarCreator.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/RealAssetsMultiViewEditorMenuBarCreator.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/TemporalAssetsMultiViewEditorMenuBarCreator.java
Modified:
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuidedEditorManager.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/StandaloneGuidedEditorInvocationParameters.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java
Log:
GUVNOR-681: Create a new top component to display and run the Guided Editor (RuleModeller) and all the things it needs in a "standalone" way
	- MultiViewEditor now shows different buttons when editing temporal assets or not. 
	- Individuals editors in MultiViewEditor don't display the "Save" button anymore.
	- JS interface to interact with guided editor was completed refactorized. 

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -2155,4 +2155,6 @@
     String NewColumn();
     
     String NoRulesFound();
+    
+    String Done();
 }

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties	2010-11-10 17:35:29 UTC (rev 35939)
@@ -1062,4 +1062,5 @@
 GlobalArea=Global Area
 InvalidDateFormatMessage=Date format is invalid. Please follow the correct date format: dd-MMM-yyyy
 NewColumn=New column
-NoRulesFound=No rules found
\ No newline at end of file
+NoRulesFound=No rules found
+Done=Done
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties	2010-11-10 17:35:29 UTC (rev 35939)
@@ -933,4 +933,5 @@
 TemplateEditor=Edici\u00f3n del Template
 TemplateData=Datos del Template
 LoadTemplateData=Carga Datos del Template
-NoRulesFound=No se encontr\u00f3 ninguna regla
\ No newline at end of file
+NoRulesFound=No se encontr\u00f3 ninguna regla
+Done=Listo
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultMultiViewEditorMenuBarCreator.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultMultiViewEditorMenuBarCreator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultMultiViewEditorMenuBarCreator.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed 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.drools.guvnor.client.ruleeditor;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.MenuBar;
+import org.drools.guvnor.client.messages.Constants;
+
+/**
+ * Default implementation of EditorMenuBarCreator that includes 2 button:
+ * "Save All Changes" and "Save And Close All" 
+ * @author esteban.aliverti
+ */
+public class DefaultMultiViewEditorMenuBarCreator implements MultiViewEditorMenuBarCreator {
+
+    private Constants constants = GWT.create(Constants.class);
+
+    public MenuBar createMenuBar(final MultiViewEditor editor) {
+        MenuBar toolbar = new MenuBar();
+
+        toolbar.addItem(constants.SaveAllChanges(),
+                new Command() {
+
+                    public void execute() {
+                        editor.checkin(false);
+                    }
+                });
+        toolbar.addItem(constants.SaveAndCloseAll(),
+                new Command() {
+
+                    public void execute() {
+                        editor.checkin(true);
+                    }
+                });
+
+        return toolbar;
+    }
+}

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuidedEditorManager.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuidedEditorManager.java	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuidedEditorManager.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -17,7 +17,9 @@
 import org.drools.guvnor.client.modeldriven.ui.RuleModellerConfiguration;
 import org.drools.guvnor.client.rpc.StandaloneGuidedEditorService;
 import org.drools.guvnor.client.rpc.StandaloneGuidedEditorServiceAsync;
+import org.drools.guvnor.client.ruleeditor.standalone.RealAssetsMultiViewEditorMenuBarCreator;
 import org.drools.guvnor.client.ruleeditor.standalone.StandaloneGuidedEditorInvocationParameters;
+import org.drools.guvnor.client.ruleeditor.standalone.TemporalAssetsMultiViewEditorMenuBarCreator;
 import org.drools.guvnor.client.ruleeditor.toolbar.StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider;
 
 /**
@@ -28,24 +30,20 @@
 public class GuidedEditorManager {
 
     private DockLayoutPanel mainLayout;
-
     private Constants constants = GWT.create(Constants.class);
-    
     private MultiViewEditor editor;
-    
-    private StandaloneGuidedEditorServiceAsync standaloneGuidedEditorService = GWT.create( StandaloneGuidedEditorService.class );
-    
+    private StandaloneGuidedEditorServiceAsync standaloneGuidedEditorService = GWT.create(StandaloneGuidedEditorService.class);
     private RuleAsset[] assets;
-    
+
     public Panel getBaseLayout() {
-        
+
         //init JS hooks
         this.setHooks(this);
-        
+
         mainLayout = new DockLayoutPanel(Unit.EM);
-        
-        final ScrollPanel mainPanel = new ScrollPanel(); 
-        
+
+        final ScrollPanel mainPanel = new ScrollPanel();
+
         mainLayout.add(mainPanel);
 
         //The package must exist (because we need at least a model to work with)
@@ -53,23 +51,23 @@
         standaloneGuidedEditorService.getInvocationParameters(new GenericCallback<StandaloneGuidedEditorInvocationParameters>() {
 
             public void onSuccess(final StandaloneGuidedEditorInvocationParameters parameters) {
-                
+
                 //no assets? This is an error!
-                if (parameters.getAssetsToBeEdited().length == 0){
+                if (parameters.getAssetsToBeEdited().length == 0) {
                     Window.alert(constants.NoRulesFound());
                     return;
                 }
-               
+
                 //we need to store the assets.
                 GuidedEditorManager.this.assets = parameters.getAssetsToBeEdited();
-                
+
                 //Load SCE and create a MultiViewEditor for the assets.
                 //We take the package from the first asset (because all the assets
                 //must belong to the same package)
                 SuggestionCompletionCache.getInstance().loadPackage(parameters.getAssetsToBeEdited()[0].metaData.packageName, new Command() {
 
                     public void execute() {
-                        
+
 //                        Set<String> validFacts = new HashSet<String>();
 //                        validFacts.add("LoanApplication");
 //                        
@@ -79,7 +77,7 @@
 //                                throw new UnsupportedOperationException("Not supported yet.");
 //                            }
 //                        });
-                        
+
                         LoadingPopup.close();
 
                         //Configure RuleModeller
@@ -87,8 +85,30 @@
                         ruleModellerConfiguration.setHideLHS(parameters.isHideLHS());
                         ruleModellerConfiguration.setHideRHS(parameters.isHideRHS());
                         ruleModellerConfiguration.setHideAttributes(parameters.isHideAttributes());
-                        
+
                         //Create the editor
+                        MultiViewEditorMenuBarCreator editorMenuBarCreator;
+                        if (parameters.isTemporalAssets()) {
+                            editorMenuBarCreator = new TemporalAssetsMultiViewEditorMenuBarCreator(new Command() {
+                                //"Done" buton command
+                                public void execute() {
+                                    afterSaveAndClose();
+                                }
+                            }, new Command() {
+                                //"Cancel button command
+                                public void execute() {
+                                    afterCancelButtonCallbackFunction();
+                                }
+                            });
+                        } else {
+                            editorMenuBarCreator = new RealAssetsMultiViewEditorMenuBarCreator(new Command() {
+                                //"Cancel" button command
+                                public void execute() {
+                                    afterCancelButtonCallbackFunction();
+                                }
+                            });
+                        }
+
                         editor = new MultiViewEditor(parameters.getAssetsToBeEdited(), new EditItemEvent() {
 
                             public void open(MultiViewRow[] rows) {
@@ -98,7 +118,8 @@
                             public void open(String key) {
                                 // TODO Auto-generated method stub
                             }
-                        }, new StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider());
+                        }, new StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider(),
+                                editorMenuBarCreator);
 
                         editor.setCloseCommand(new Command() {
 
@@ -106,37 +127,36 @@
                                 afterSaveAndClose();
                             }
                         });
-                        
+
                         //Add the editor to main panel
                         mainPanel.add(editor);
                     }
                 });
             }
-
         });
 
-        
+
         return mainLayout;
     }
-    
+
     /**
      * This method should be invoked from JS using window.getEditorDRL().
      * Returns the DRL of the assets we are editing. Because this method is 
      * asynchronous, the DRL code is passed to a callback function specified
      * in the JS invocation.
      */
-    public void getDRLs(){        
-        if (assets == null || assets.length == 0){
+    public void getDRLs() {
+        if (assets == null || assets.length == 0) {
             returnDRL("");
         }
-        
+
         standaloneGuidedEditorService.getAsstesDRL(assets, new GenericCallback<String[]>() {
 
             public void onSuccess(String[] drls) {
                 String result = "";
-                if (drls != null){
+                if (drls != null) {
                     for (String drl : drls) {
-                        result+=drl+"\n\n";
+                        result += drl + "\n\n";
                     }
                 }
 
@@ -144,25 +164,25 @@
             }
         });
     }
-    
+
     /**
      * This method should be invoked from JS using window.getEditorBRL().
      * Returns the BRL of the assets we are editing. Because this method is 
      * asynchronous, the BRL code is passed to a callback function specified
      * in the JS invocation.
      */
-    public void getBRLs(){        
-        if (assets == null || assets.length == 0){
+    public void getBRLs() {
+        if (assets == null || assets.length == 0) {
             returnDRL("");
         }
-        
+
         standaloneGuidedEditorService.getAsstesBRL(assets, new GenericCallback<String[]>() {
 
             public void onSuccess(String[] drls) {
                 String result = "";
-                if (drls != null){
+                if (drls != null) {
                     for (String drl : drls) {
-                        result+=drl+"\n\n";
+                        result += drl + "\n\n";
                     }
                 }
 
@@ -170,7 +190,7 @@
             }
         });
     }
-    
+
     /**
      * Creates 2 JS functions in window object: getDRLs() and getBRLs(). These
      * functions are used to retrieve the source code of the assets this component
@@ -178,50 +198,71 @@
      * @param app
      */
     public native void setHooks(GuidedEditorManager app)/*-{
-        
-        $wnd.getEditorDRL = function (callbackFunction) {
-            $wnd.guvnorGuidedEditorDRLCallbackFunction = callbackFunction;
-            app. at org.drools.guvnor.client.ruleeditor.GuidedEditorManager::getDRLs()();
-        };
+    
+    var guidedEditorObject = {
+    	drlCallbackFunction: null,
+    	brlCallbackFunction: null,
+    	
+    	//close function listener. The function you register here will be called
+    	//after the "Save and Close" button is pressed                                                                                                                 
+    	afterSaveAndCloseButtonCallbackFunction: null,
+    	
+    	afterCancelButtonCallbackFunction: null,
+    	
+    	getDRL: function (callbackFunction){
+    		this.drlCallbackFunction = callbackFunction;
+    		app. at org.drools.guvnor.client.ruleeditor.GuidedEditorManager::getDRLs()();
+    	},
+    	
+    	getBRL: function (callbackFunction){
+    		this.brlCallbackFunction = callbackFunction;
+    		app. at org.drools.guvnor.client.ruleeditor.GuidedEditorManager::getBRLs()();
+    	},
+    	
+    	registerAfterSaveAndCloseButtonCallbackFunction: function (callbackFunction){
+    		this.afterSaveAndCloseButtonCallbackFunction = callbackFunction;
+    	},
+    	
+    	registerAfterCancelButtonCallbackFunction: function (callbackFunction){
+    		this.afterCancelButtonCallbackFunction = callbackFunction;
+    	}
+    }    
+    $wnd.guidedEditorObject = guidedEditorObject;                                                                                                      
                                                           
-        $wnd.getEditorBRL = function (callbackFunction) {
-            $wnd.guvnorGuidedEditorBRLCallbackFunction = callbackFunction;
-            app. at org.drools.guvnor.client.ruleeditor.GuidedEditorManager::getBRLs()();
-        };
-                                                          
-        //close function listener. The function you register here will be called
-        //after the "Save and Close" button is pressed                                                                                                                 
-        $wnd.guvnorGuidedEditorOnSaveAndCloseFunction=null;
-                                                         
-                                                         
     }-*/;
-    
+
     /**
      * Callback method invoked from getDRLs().
      * @param drl
      */
     public native void returnDRL(String drl)/*-{
-        if ($wnd.guvnorGuidedEditorDRLCallbackFunction){
-            $wnd.guvnorGuidedEditorDRLCallbackFunction(drl);
-        }
+	    if ($wnd.guidedEditorObject.drlCallbackFunction){
+	    	$wnd.guidedEditorObject.drlCallbackFunction(drl);
+	    }
     }-*/;
-    
+
     /**
      * Callback method invoked from getDRLs().
      * @param drl
      */
     public native void returnBRL(String brl)/*-{
-        if ($wnd.guvnorGuidedEditorBRLCallbackFunction){
-            $wnd.guvnorGuidedEditorBRLCallbackFunction(brl);
-        }
-    }-*/;    
-    
+	    if ($wnd.guidedEditorObject.brlCallbackFunction){
+	    	$wnd.guidedEditorObject.brlCallbackFunction(brl);
+	    }
+    }-*/;
+
     /**
      * Method invoked after the "Save an Close" button is pressed. 
      */
     public native void afterSaveAndClose()/*-{
-        if ($wnd.guvnorGuidedEditorOnSaveAndCloseFunction){
-            $wnd.guvnorGuidedEditorOnSaveAndCloseFunction();
-        }
+	    if ($wnd.guidedEditorObject.afterSaveAndCloseButtonCallbackFunction){
+	    	$wnd.guidedEditorObject.afterSaveAndCloseButtonCallbackFunction();
+	    }
     }-*/;
+
+    public native void afterCancelButtonCallbackFunction()/*-{
+    	if ($wnd.guidedEditorObject.afterCancelButtonCallbackFunction){
+	    	$wnd.guidedEditorObject.afterCancelButtonCallbackFunction();
+	    }
+    }-*/;
 }

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -60,6 +60,8 @@
     private ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider;
 
     private Map<String, RuleAsset>                    assets          = new HashMap<String, RuleAsset>();
+    
+    private MultiViewEditorMenuBarCreator menuBarCreator;
 
     public MultiViewEditor(MultiViewRow[] rows,
                            EditItemEvent editItemEvent) {
@@ -67,18 +69,42 @@
               editItemEvent,
               null );
     }
+    
+    public MultiViewEditor(MultiViewRow[] rows,
+                           EditItemEvent editItemEvent,
+                           ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
+        this( Arrays.asList( rows ),
+              editItemEvent,
+              individualActionToolbarButtonsConfigurationProvider );
+    }
+    
+    public MultiViewEditor(List<MultiViewRow> rows,
+                           EditItemEvent editItemEvent,
+                           ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
+        this.rows.addAll( rows );
+        this.editItemEvent = editItemEvent;
+        this.individualActionToolbarButtonsConfigurationProvider = individualActionToolbarButtonsConfigurationProvider;
 
+        init();
+    }
+    
     public MultiViewEditor(RuleAsset[] assets,
                            EditItemEvent editItemEvent,
                            ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
+        this(assets, editItemEvent, individualActionToolbarButtonsConfigurationProvider, null);
+    }
+
+    public MultiViewEditor(RuleAsset[] assets,
+                           EditItemEvent editItemEvent,
+                           ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider, MultiViewEditorMenuBarCreator menuBarCreator) {
         this.rows.addAll( createRows( assets ) );
         this.editItemEvent = editItemEvent;
         this.individualActionToolbarButtonsConfigurationProvider = individualActionToolbarButtonsConfigurationProvider;
-
+        this.menuBarCreator = menuBarCreator;
         addAssets( assets );
         init();
     }
-
+    
     private void addAssets(RuleAsset[] assets) {
         for ( RuleAsset ruleAsset : assets ) {
             this.assets.put( ruleAsset.uuid,
@@ -98,24 +124,6 @@
         return rows;
     }
 
-    public MultiViewEditor(MultiViewRow[] rows,
-                           EditItemEvent editItemEvent,
-                           ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
-        this( Arrays.asList( rows ),
-              editItemEvent,
-              individualActionToolbarButtonsConfigurationProvider );
-    }
-
-    public MultiViewEditor(List<MultiViewRow> rows,
-                           EditItemEvent editItemEvent,
-                           ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
-        this.rows.addAll( rows );
-        this.editItemEvent = editItemEvent;
-        this.individualActionToolbarButtonsConfigurationProvider = individualActionToolbarButtonsConfigurationProvider;
-
-        init();
-    }
-
     private void init() {
         VerticalPanel rootPanel = new VerticalPanel();
 
@@ -148,24 +156,14 @@
     //    toolbar.addItem( constants.Show(),
     //                     layoutMenu );
     private MenuBar createToolbar() {
-        MenuBar toolbar = new MenuBar();
-
-        toolbar.addItem( constants.SaveAllChanges(),
-                         new Command() {
-
-                             public void execute() {
-                                 checkin( false );
-                             }
-                         } );
-        toolbar.addItem( constants.SaveAndCloseAll(),
-                         new Command() {
-
-                             public void execute() {
-                                 checkin( true );
-                             }
-                         } );
-
-        return toolbar;
+        
+        //if no MultiViewEditorMenuBarCreator is set, then use the Default
+        //implementation.
+        if (this.menuBarCreator == null){
+            this.menuBarCreator = new DefaultMultiViewEditorMenuBarCreator();
+        }
+        
+        return this.menuBarCreator.createMenuBar(this);
     }
 
     private void doViews() {
@@ -275,7 +273,7 @@
                                                           } );
     }
 
-    private void checkin(final boolean closeAfter) {
+    public void checkin(final boolean closeAfter) {
         final CheckinPopup pop = new CheckinPopup( constants.CheckInChanges() );
         pop.setCommand( new Command() {
 
@@ -297,15 +295,18 @@
         closeCommand.execute();
     }
 
+    @Override
     public boolean isDirty() {
         // TODO Auto-generated method stub
         return false;
     }
 
+    @Override
     public void makeDirty() {
         // TODO Auto-generated method stub
     }
 
+    @Override
     public void resetDirty() {
         // TODO Auto-generated method stub
     }

Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditorMenuBarCreator.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditorMenuBarCreator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditorMenuBarCreator.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed 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.drools.guvnor.client.ruleeditor;
+
+import com.google.gwt.user.client.ui.MenuBar;
+
+/**
+ * Creates a MenuBar component for a MultiViewEditor instance
+ * @author esteban.aliverti
+ */
+public interface MultiViewEditorMenuBarCreator {
+
+    MenuBar createMenuBar(MultiViewEditor editor);
+    
+}

Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/RealAssetsMultiViewEditorMenuBarCreator.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/RealAssetsMultiViewEditorMenuBarCreator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/RealAssetsMultiViewEditorMenuBarCreator.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed 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.drools.guvnor.client.ruleeditor.standalone;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.MenuBar;
+import org.drools.guvnor.client.messages.Constants;
+import org.drools.guvnor.client.ruleeditor.DefaultMultiViewEditorMenuBarCreator;
+import org.drools.guvnor.client.ruleeditor.MultiViewEditor;
+
+/**
+ * Creates a default menu bar with an additional "Cancel" button.
+ * @author esteban.aliverti
+ */
+public class RealAssetsMultiViewEditorMenuBarCreator extends DefaultMultiViewEditorMenuBarCreator {
+
+    private Command cancelCommand;
+    private Constants constants = GWT.create(Constants.class);
+
+    /**
+     * Constructor that takes 1 command as parameters for "Cancel" Button. 
+     * If you want to add a command for "Save and Close" button you cold use
+     * {@link MultiViewEditor#setCloseCommand(com.google.gwt.user.client.Command)}
+     * @param saveCommand
+     * @param cancelCommand
+     */
+    public RealAssetsMultiViewEditorMenuBarCreator(Command cancelCommand) {
+        this.cancelCommand = cancelCommand;
+    }
+
+    
+    
+    @Override
+    public MenuBar createMenuBar(final MultiViewEditor editor) {
+        MenuBar toolbar = super.createMenuBar(editor);
+        toolbar.addItem(constants.Cancel(),this.cancelCommand);
+        return toolbar;
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/StandaloneGuidedEditorInvocationParameters.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/StandaloneGuidedEditorInvocationParameters.java	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/StandaloneGuidedEditorInvocationParameters.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -31,6 +31,8 @@
     
     private RuleAsset[] assetsToBeEdited;
     
+    private boolean temporalAssets;
+    
     private boolean hideLHS;
     private boolean hideRHS;
     private boolean hideAttributes;
@@ -66,6 +68,15 @@
     public void setHideRHS(boolean hideRHS) {
         this.hideRHS = hideRHS;
     }
+
+    public boolean isTemporalAssets() {
+        return temporalAssets;
+    }
+
+    public void setTemporalAssets(boolean temporalAssets) {
+        this.temporalAssets = temporalAssets;
+    }
     
     
+    
 }

Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/TemporalAssetsMultiViewEditorMenuBarCreator.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/TemporalAssetsMultiViewEditorMenuBarCreator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/standalone/TemporalAssetsMultiViewEditorMenuBarCreator.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed 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.drools.guvnor.client.ruleeditor.standalone;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.MenuBar;
+import org.drools.guvnor.client.messages.Constants;
+import org.drools.guvnor.client.ruleeditor.MultiViewEditor;
+import org.drools.guvnor.client.ruleeditor.MultiViewEditorMenuBarCreator;
+
+/**
+ * Creates a menu bar with 2 buttons: "Done" and "Cancel".
+ * @author esteban.aliverti
+ */
+public class TemporalAssetsMultiViewEditorMenuBarCreator implements MultiViewEditorMenuBarCreator {
+
+    private Command doneCommand;
+    private Command cancelCommand;
+    private Constants constants = GWT.create(Constants.class);
+
+    public TemporalAssetsMultiViewEditorMenuBarCreator(Command doneCommand, Command cancelCommand) {
+        this.doneCommand = doneCommand;
+        this.cancelCommand = cancelCommand;
+    }
+
+    /**
+     * Creates a menu bar with 2 buttons: "Done" and "Cancel". Because this is 
+     * meant for temporal rules, this toolbar doesn't check-in any asset. The
+     * buttons just call doneCommand and cancelCommand respectively.
+     * @param editor
+     * @return
+     */
+    public MenuBar createMenuBar(final MultiViewEditor editor) {
+        MenuBar toolbar = new MenuBar();
+
+        toolbar.addItem(constants.Done(), doneCommand);
+        toolbar.addItem(constants.Cancel(), cancelCommand);
+
+        return toolbar;
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider.java	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -23,7 +23,7 @@
 public class StandaloneGuidedEditorIndividualActionToolbarButtonsConfigurationProvider implements ActionToolbarButtonsConfigurationProvider {
 
     public boolean showSaveButton() {
-        return true;
+        return false;
     }
 
     public boolean showSaveAndCloseButton() {

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java	2010-11-10 16:41:47 UTC (rev 35938)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java	2010-11-10 17:35:29 UTC (rev 35939)
@@ -79,7 +79,7 @@
 
         StandaloneGuidedEditorInvocationParameters parameters = new StandaloneGuidedEditorInvocationParameters();
 
-        parameters.setAssetsToBeEdited( this.loadRuleAssetsFromSession() );
+         this.loadRuleAssetsFromSession(parameters);
 
         parameters.setHideLHS( hideLHSInEditor );
         parameters.setHideRHS( hideRHSInEditor );
@@ -93,12 +93,11 @@
      * GuidedEditorServlet first. This servlet put all the POST parameters into
      * session. This method takes those parameters and load the corresponding
      * assets.
-     * If you are passing BRLs to the Guided Editor, this method will create
-     * one asset per BRL with a unique name.
-     * @return
+     * This method will set the assets in parameters 
+     * @param parameters 
      * @throws DetailedSerializationException
      */
-    private RuleAsset[] loadRuleAssetsFromSession() throws DetailedSerializationException {
+    private void loadRuleAssetsFromSession(StandaloneGuidedEditorInvocationParameters parameters) throws DetailedSerializationException {
 
         //Get the parameters from the session
         HttpSession session = this.getThreadLocalRequest().getSession();
@@ -120,16 +119,19 @@
             provider = new NewRuleAssetProvider( packageName,
                                                  categoryName,
                                                  ruleName );
+            parameters.setTemporalAssets(false);
         } else if ( assetsUUIDs != null ) {
             provider = new UUIDRuleAssetProvider( assetsUUIDs );
+            parameters.setTemporalAssets(false);
         } else if ( initialBRL != null ) {
             provider = new BRLRuleAssetProvider( packageName,
                                                  initialBRL );
+            parameters.setTemporalAssets(true);
         } else {
             throw new IllegalStateException();
         }
 
-        return provider.getRuleAssets();
+        parameters.setAssetsToBeEdited(provider.getRuleAssets());
 
     }
 



More information about the jboss-svn-commits mailing list