[jboss-svn-commits] JBL Code SVN: r20863 - in labs/jbossrules/trunk/drools-guvnor: src/main/java/com/google/gwt and 9 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jul 1 15:50:33 EDT 2008
Author: arhan
Date: 2008-07-01 15:50:33 -0400 (Tue, 01 Jul 2008)
New Revision: 20863
Removed:
labs/jbossrules/trunk/drools-guvnor/src/main/java/com/google/gwt/core/
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/Editor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/rebind/
Modified:
labs/jbossrules/trunk/drools-guvnor/build.properties
labs/jbossrules/trunk/drools-guvnor/build.xml
labs/jbossrules/trunk/drools-guvnor/pom.xml
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/DefaultContentUploadEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableXLSWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/ModelAttachmentFileWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DSLRuleEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowUploadWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/AssetItemGrid.java
Log:
rolled back GSOC2008 changes
Modified: labs/jbossrules/trunk/drools-guvnor/build.properties
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/build.properties 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/build.properties 2008-07-01 19:50:33 UTC (rev 20863)
@@ -1,4 +1,2 @@
#this is needed to point to your version of GWT
-gwt.home=/home/ant/lib/gwt-linux-1.4.62
-gwt.platform=linux
-
+gwt.home=/usr/local/share/java/gwt
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/build.xml
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/build.xml 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/build.xml 2008-07-01 19:50:33 UTC (rev 20863)
@@ -17,12 +17,12 @@
<gwt:compile outDir="src/main/webapp"
gwtHome="${gwt.home}"
classBase="org.drools.guvnor.Guvnor"
- sourceclasspath=" ${gwt.home}/gwt-dev-${gwt.platform}.jar;src/main/java;../drools-compiler/src/main/java;../lib/gwtext-2.0.1.jar;target/classes"
+ sourceclasspath="src/main/java; ../drools-compiler/src/main/java; ../lib/gwtext-2.0.1.jar"
/>
</target>
<target name="gwt-shell">
- <gwt:shell sourceclasspath="${gwt.home}/gwt-dev-${gwt.platform}.jar;src/main/java/;../drools-compiler/src/main/java"
+ <gwt:shell sourceclasspath="src/main/java/; ../drools-compiler/src/main/java"
bindir="target/classes"
outDir="src/main/webapp"
gwtHome="${gwt.home}"
Modified: labs/jbossrules/trunk/drools-guvnor/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/pom.xml 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/pom.xml 2008-07-01 19:50:33 UTC (rev 20863)
@@ -87,11 +87,6 @@
<artifactId>gwt-servlet</artifactId>
</dependency>
<dependency>
- <groupId>com.google.gwt</groupId>
- <artifactId>gwt-user</artifactId>
- <version>1.4.62</version>
- </dependency>
- <dependency>
<groupId>com.gwtext</groupId>
<artifactId>gwtext</artifactId>
</dependency>
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml 2008-07-01 19:50:33 UTC (rev 20863)
@@ -20,8 +20,5 @@
<servlet path="/webdav" class="org.drools.guvnor.server.files.WebdavServlet"/>
<servlet path="/api" class="org.drools.guvnor.server.files.RestAPIServlet"/>
- <generate-with class="org.drools.guvnor.rebind.EditorLauncherGenerator">
- <when-type-assignable class="org.drools.guvnor.client.ruleeditor.EditorLauncher"/>
- </generate-with>
</module>
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/DefaultContentUploadEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/DefaultContentUploadEditor.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/DefaultContentUploadEditor.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -1,15 +1,17 @@
package org.drools.guvnor.client.common;
-import com.google.gwt.user.client.ui.HTML;
import org.drools.guvnor.client.packages.AssetAttachmentFileWidget;
import org.drools.guvnor.client.rpc.RuleAsset;
-import org.drools.guvnor.client.ruleeditor.Editor;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
-public class DefaultContentUploadEditor extends AssetAttachmentFileWidget implements Editor {
+import com.google.gwt.user.client.ui.HTML;
- public DefaultContentUploadEditor(RuleAsset asset, RuleViewer viewer) {
- super( asset, viewer );
+public class DefaultContentUploadEditor extends AssetAttachmentFileWidget {
+
+ public DefaultContentUploadEditor(
+ RuleAsset asset, RuleViewer viewer) {
+ super( asset,
+ viewer );
super.addDescription(new HTML("<small><i>Upload new version...</i></small>"));
}
@@ -21,12 +23,4 @@
return "decision-Table-upload";
}
-
- public String getWrapperClass() {
- return null;
- }
-
- public String getAssetFormat() {
- return null;
- }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableXLSWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableXLSWidget.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableXLSWidget.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -16,38 +16,35 @@
*/
-import com.google.gwt.user.client.ui.HTML;
+
import org.drools.guvnor.client.packages.AssetAttachmentFileWidget;
import org.drools.guvnor.client.rpc.RuleAsset;
-import org.drools.guvnor.client.ruleeditor.Editor;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
+import com.google.gwt.user.client.ui.HTML;
+
/**
* This widget deals with XLS files in "classic" decision tables.
- *
+ *
* @author Michael Neale
*/
-public class DecisionTableXLSWidget extends AssetAttachmentFileWidget implements Editor {
+public class DecisionTableXLSWidget extends AssetAttachmentFileWidget {
- public DecisionTableXLSWidget(RuleAsset asset, RuleViewer viewer) {
- super( asset, viewer );
+ public DecisionTableXLSWidget(
+ RuleAsset asset, RuleViewer viewer) {
+ super( asset,
+ viewer );
super.addDescription(new HTML("<small><i>This is a decision table in a spreadsheet (XLS). Typically they contain many rules in one sheet.</i></small>"));
}
public String getIcon() {
return "images/decision_table.png";
}
-
+
public String getOverallStyleName() {
return "decision-Table-upload";
}
- public String getWrapperClass() {
- return null;
- }
- public String getAssetFormat() {
- return null;
- }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -1,46 +1,77 @@
package org.drools.guvnor.client.decisiontable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.guvnor.client.common.FormStylePopup;
+import org.drools.guvnor.client.common.ImageButton;
+import org.drools.guvnor.client.common.PrettyFormLayout;
+import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.guvnor.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.guvnor.client.modeldriven.dt.ActionCol;
+import org.drools.guvnor.client.modeldriven.dt.ActionInsertFactCol;
+import org.drools.guvnor.client.modeldriven.dt.ActionSetFieldCol;
+import org.drools.guvnor.client.modeldriven.dt.AttributeCol;
+import org.drools.guvnor.client.modeldriven.dt.ConditionCol;
+import org.drools.guvnor.client.modeldriven.dt.DTColumnConfig;
+import org.drools.guvnor.client.modeldriven.dt.GuidedDecisionTable;
+import org.drools.guvnor.client.modeldriven.ui.ActionValueEditor;
+import org.drools.guvnor.client.packages.SuggestionCompletionCache;
+import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.ruleeditor.SaveEventListener;
+
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.*;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.KeyboardListener;
+import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
+import com.google.gwt.user.client.ui.ListBox;
+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.core.SortDir;
-import com.gwtext.client.data.*;
+import com.gwtext.client.data.ArrayReader;
+import com.gwtext.client.data.FieldDef;
+import com.gwtext.client.data.GroupingStore;
+import com.gwtext.client.data.MemoryProxy;
+import com.gwtext.client.data.Record;
+import com.gwtext.client.data.RecordDef;
+import com.gwtext.client.data.SortState;
+import com.gwtext.client.data.Store;
+import com.gwtext.client.data.StringFieldDef;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarMenuButton;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.form.FieldSet;
import com.gwtext.client.widgets.form.FormPanel;
-import com.gwtext.client.widgets.grid.*;
+import com.gwtext.client.widgets.grid.BaseColumnConfig;
+import com.gwtext.client.widgets.grid.CellMetadata;
+import com.gwtext.client.widgets.grid.ColumnConfig;
+import com.gwtext.client.widgets.grid.ColumnModel;
+import com.gwtext.client.widgets.grid.GridPanel;
+import com.gwtext.client.widgets.grid.GroupingView;
+import com.gwtext.client.widgets.grid.Renderer;
import com.gwtext.client.widgets.grid.event.GridCellListenerAdapter;
import com.gwtext.client.widgets.grid.event.GridColumnListenerAdapter;
import com.gwtext.client.widgets.menu.BaseItem;
import com.gwtext.client.widgets.menu.Item;
import com.gwtext.client.widgets.menu.Menu;
import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
-import org.drools.guvnor.client.common.FormStylePopup;
-import org.drools.guvnor.client.common.ImageButton;
-import org.drools.guvnor.client.common.PrettyFormLayout;
-import org.drools.guvnor.client.common.SmallLabel;
-import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
-import org.drools.guvnor.client.modeldriven.brl.ISingleFieldConstraint;
-import org.drools.guvnor.client.modeldriven.dt.*;
-import org.drools.guvnor.client.modeldriven.ui.ActionValueEditor;
-import org.drools.guvnor.client.packages.SuggestionCompletionCache;
-import org.drools.guvnor.client.rpc.RuleAsset;
-import org.drools.guvnor.client.ruleeditor.Editor;
-import org.drools.guvnor.client.ruleeditor.SaveEventListener;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
/**
* This is the new guided decision table editor for the web.
* @author Michael Neale
*/
-public class GuidedDecisionTableWidget extends Composite implements SaveEventListener, Editor {
+public class GuidedDecisionTableWidget extends Composite implements SaveEventListener {
private GuidedDecisionTable dt;
private VerticalPanel layout;
@@ -883,11 +914,4 @@
}
- public String getWrapperClass() {
- return null;
- }
-
- public String getAssetFormat() {
- return null;
- }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelWidget.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelWidget.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -1,25 +1,38 @@
package org.drools.guvnor.client.factmodel;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.*;
-import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
-import com.gwtext.client.widgets.form.FormPanel;
+import java.util.ArrayList;
+
import org.drools.guvnor.client.common.FormStylePopup;
import org.drools.guvnor.client.common.ImageButton;
import org.drools.guvnor.client.common.SmallLabel;
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.rpc.RuleContentText;
import org.drools.guvnor.client.ruleeditor.DefaultRuleContentWidget;
-import org.drools.guvnor.client.ruleeditor.Editor;
-import java.util.ArrayList;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.KeyboardListener;
+import com.google.gwt.user.client.ui.ListBox;
+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.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
+import com.gwtext.client.widgets.form.FormPanel;
/**
* The editor for fact models (drl declared types).
*
* @author Michael Neale
*/
-public class FactModelWidget extends Composite implements Editor {
+public class FactModelWidget extends Composite {
private RuleAsset asset;
private VerticalPanel layout;
@@ -288,11 +301,4 @@
}
- public String getWrapperClass() {
- return null;
- }
-
- public String getAssetFormat() {
- return null;
- }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -1,556 +1,577 @@
-package org.drools.guvnor.client.modeldriven.ui;
-/*
- * Copyright 2005 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.
- */
-
-
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.*;
-import org.drools.guvnor.client.common.*;
-import org.drools.guvnor.client.modeldriven.HumanReadable;
-import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
-import org.drools.guvnor.client.modeldriven.brl.*;
-import org.drools.guvnor.client.packages.SuggestionCompletionCache;
-import org.drools.guvnor.client.rpc.RuleAsset;
-import org.drools.guvnor.client.ruleeditor.Editor;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * This is the parent widget that contains the model based rule builder.
- *
- * @author Michael Neale
- *
- */
-public class RuleModeller extends DirtyableComposite implements Editor {
-
- private DirtyableFlexTable layout;
- private SuggestionCompletionEngine completions;
- private RuleModel model;
-
- public RuleModeller(RuleAsset asset) {
- this.model = (RuleModel) asset.content;
-
- this.completions = SuggestionCompletionCache.getInstance().getEngineFromCache( asset.metaData.packageName );
-
- layout = new DirtyableFlexTable();
-
- initWidget();
-
- layout.setStyleName( "model-builder-Background" );
- initWidget( layout );
- setWidth( "100%" );
- setHeight( "100%" );
- }
-
- /**
- * This updates the widget to reflect the state of the model.
- */
- public void initWidget() {
- layout.clear();
-
- Image addPattern = new ImageButton( "images/new_item.gif" );
- addPattern.setTitle( "Add a condition to this rule." );
- addPattern.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- showConditionSelector(w);
- }
- });
-
- layout.setWidget( 0, 0, new SmallLabel("WHEN") );
- layout.setWidget( 0, 2, addPattern );
-
- layout.setWidget( 1, 1, renderLhs(this.model) );
- layout.setWidget( 2, 0, new SmallLabel("THEN") );
-
- Image addAction = new ImageButton("images/new_item.gif");
- addAction.setTitle( "Add an action to this rule." );
- addAction.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- showActionSelector(w);
- }
- });
- layout.setWidget( 2, 2, addAction );
-
- layout.setWidget( 3, 1, renderRhs(this.model) );
-
- layout.setWidget( 4, 0, new SmallLabel("(options)") );
- layout.setWidget( 4, 2, getAddAttribute() );
- layout.setWidget( 5, 1, new RuleAttributeWidget(this, this.model) );
- }
-
- public void refreshWidget() {
- initWidget();
- makeDirty();
- }
-
- private Widget getAddAttribute() {
- Image add = new ImageButton("images/new_item.gif");
- add.setTitle( "Add an option to the rule, to modify its behavior when evaluated or executed." );
-
- add.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- showAttributeSelector(w);
- }
- });
- return add;
- }
-
- protected void showAttributeSelector(Widget w) {
- final FormStylePopup pop = new FormStylePopup("images/config.png", "Add an option to the rule");
- final ListBox list = RuleAttributeWidget.getAttributeList();
-
- list.setSelectedIndex( 0 );
-
- list.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- model.addAttribute( new RuleAttribute(list.getItemText( list.getSelectedIndex() ), "") );
- refreshWidget();
- pop.hide();
- }
- });
-
-
-
- pop.addAttribute( "Attribute", list );
-
- pop.show();
- }
-
- /**
- * Do all the widgets for the RHS.
- */
- /*
- * TODO STILL NEED TO BE CHECKED
- */
- private Widget renderRhs(final RuleModel model) {
- DirtyableVerticalPane vert = new DirtyableVerticalPane();
-
- for ( int i = 0; i < model.rhs.length; i++ ) {
- IAction action = model.rhs[i];
-
- Widget w = null;
- if (action instanceof ActionSetField) {
- w = new ActionSetFieldWidget(this, (ActionSetField) action, completions ) ;
- } else if (action instanceof ActionInsertFact) {
- w = new ActionInsertFactWidget(this, (ActionInsertFact) action, completions );
- } else if (action instanceof ActionRetractFact) {
- w = new ActionRetractFactWidget(this.completions, (ActionRetractFact) action );
- } else if (action instanceof DSLSentence) {
- w = new DSLSentenceWidget((DSLSentence) action);
- w.setStyleName( "model-builderInner-Background" );
- }
-
- //w.setWidth( "100%" );
- vert.add( spacerWidget() );
- //vert.setWidth( "100%" );
-
- DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
-
- Image remove = new ImageButton("images/delete_item_small.gif");
- remove.setTitle( "Remove this action." );
- final int idx = i;
- remove.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- if (Window.confirm("Remove this item?")) {
- model.removeRhsItem(idx);
- refreshWidget();
- }
- }
- } );
- horiz.add( w );
- if (!(w instanceof ActionRetractFactWidget)) {
- w.setWidth( "100%" );
- horiz.setWidth( "100%" );
- }
-
- horiz.add( remove );
- vert.add( horiz );
-
- }
-
- return vert;
- }
-
- /**
- * Pops up the fact selector.
- */
- protected void showConditionSelector(final Widget w) {
- final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a condition to the rule...");
-
- //
- // The list of facts
- //
- String[] facts = completions.getFactTypes();
- final ListBox factTypeBox = new ListBox();
- factTypeBox.addItem( "Choose fact type...", "IGNORE" );
- for ( int i = 0; i < facts.length; i++ ) {
- factTypeBox.addItem( facts[i] );
- }
- factTypeBox.setSelectedIndex( 0 );
- if (facts.length > 0) popup.addAttribute( "Fact", factTypeBox );
- factTypeBox.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- String s = factTypeBox.getItemText( factTypeBox.getSelectedIndex() );
- if (!s.equals( "IGNORE" )) {
- addNewFact(s);
- popup.hide();
- }
- }
- });
-
- //
- // The list of top level CEs
- //
- String ces[] = HumanReadable.CONDITIONAL_ELEMENTS;
- final ListBox ceBox = new ListBox();
- ceBox.addItem( "Choose condition type...", "IGNORE" );
- for ( int i = 0; i < ces.length; i++ ) {
- String ce = ces[i];
- ceBox.addItem( HumanReadable.getCEDisplayName( ce ), ce );
- }
- ceBox.setSelectedIndex( 0 );
-
- if (facts.length > 0) popup.addAttribute( "Condition type", ceBox );
- ceBox.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- String s = ceBox.getValue( ceBox.getSelectedIndex() );
- if (!s.equals( "IGNORE" )) {
- addNewCE(s);
- popup.hide();
- }
- }
- });
-
-
- //
- // The list of DSL sentences
- //
- if (completions.getDSLConditions().length > 0) {
- final ListBox dsls = new ListBox();
- dsls.addItem( "Choose..." );
- for(int i = 0; i < completions.getDSLConditions().length; i++ ) {
- DSLSentence sen = completions.getDSLConditions()[i];
- dsls.addItem( sen.toString(), Integer.toString( i ) );
- }
-
- dsls.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- int idx = Integer.parseInt( dsls.getValue( dsls.getSelectedIndex() ) );
- addNewDSLLhs( (DSLSentence) completions.getDSLConditions()[ idx ] );
- popup.hide();
- }
- });
- popup.addAttribute( "DSL sentence", dsls );
- }
- popup.show();
-
- }
-
- protected void addNewDSLLhs(DSLSentence sentence) {
- model.addLhsItem( sentence.copy() );
- refreshWidget();
-
- }
-
- protected void showActionSelector(Widget w) {
- final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a new action...");
-
-
- //
- // First load up the stuff to do with bound variables or globals
- //
- List vars = model.getBoundFacts();
- final ListBox varBox = new ListBox();
- final ListBox retractBox = new ListBox();
- final ListBox modifyBox = new ListBox();
- varBox.addItem( "Choose ..." );
- retractBox.addItem( "Choose ..." );
- modifyBox.addItem( "Choose ..." );
- for ( Iterator iter = vars.iterator(); iter.hasNext(); ) {
- String v = (String) iter.next();
- varBox.addItem( v );
- retractBox.addItem( v );
- modifyBox.addItem( v );
- }
- String[] globals = this.completions.getGlobalVariables();
- for ( int i = 0; i < globals.length; i++ ) {
- varBox.addItem( globals[i] );
- }
-
- varBox.setSelectedIndex( 0 );
- varBox.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- addActionSetField(varBox.getItemText( varBox.getSelectedIndex() ));
- popup.hide();
- }
- });
-
- retractBox.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- addRetract(retractBox.getItemText( retractBox.getSelectedIndex() ));
- popup.hide();
- }
- });
-
- modifyBox.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- addModify(modifyBox.getItemText( modifyBox.getSelectedIndex() ));
- popup.hide();
- }
- });
-
- if (varBox.getItemCount() > 1) {
- popup.addAttribute( "Set the values of a field on", varBox );
- }
-
-
- if (modifyBox.getItemCount() > 1) {
- HorizontalPanel horiz = new HorizontalPanel();
- horiz.add( modifyBox );
- Image img = new Image("images/information.gif");
- img.setTitle( "Modify a field on a fact, and notify the engine to re-evaluate rules." );
- horiz.add( img );
- popup.addAttribute( "Modify a fact", horiz );
- }
-
- //popup.addRow( new HTML("<hr/>") );
-
- if (retractBox.getItemCount() > 1) {
- popup.addAttribute( "Retract the fact", retractBox );
- }
-
- //popup.addRow( new HTML("<hr/>") );
-
-
- final ListBox factsToAssert = new ListBox();
- final ListBox factsToLogicallyAssert = new ListBox();
- factsToAssert.addItem( "Choose ..." );
- factsToLogicallyAssert.addItem( "Choose ..." );
- for ( int i = 0; i < completions.getFactTypes().length; i++ ) {
- String item = completions.getFactTypes()[i];
- factsToAssert.addItem( item );
- factsToLogicallyAssert.addItem( item );
- }
-
- factsToAssert.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- String fact = factsToAssert.getItemText( factsToAssert.getSelectedIndex() );
- model.addRhsItem( new ActionInsertFact(fact) );
- refreshWidget();
- popup.hide();
-
- }
- });
-
- factsToLogicallyAssert.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- String fact = factsToLogicallyAssert.getItemText( factsToLogicallyAssert.getSelectedIndex() );
- model.addRhsItem( new ActionInsertLogicalFact(fact) );
- refreshWidget();
- popup.hide();
-
- }
- });
-
-
- if (factsToAssert.getItemCount() > 1) {
- popup.addAttribute( "Insert a new fact", factsToAssert );
- HorizontalPanel horiz = new HorizontalPanel();
- horiz.add( factsToLogicallyAssert );
- Image img = new Image("images/information.gif");
- img.setTitle( "Logically assert a fact - the fact will be retracted when the supporting evidence is removed." );
- horiz.add( img );
- popup.addAttribute( "Logically insert a new fact", horiz );
- }
-
-
-
- //
- // The list of DSL sentences
- //
- if (completions.getDSLActions().length > 0) {
- final ListBox dsls = new ListBox();
- dsls.addItem( "Choose..." );
- for(int i = 0; i < completions.getDSLActions().length; i++ ) {
- DSLSentence sen = (DSLSentence) completions.getDSLActions()[ i ];
- dsls.addItem( sen.toString(), Integer.toString( i ) );
- }
-
- dsls.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- int idx = Integer.parseInt( dsls.getValue( dsls.getSelectedIndex() ) );
- addNewDSLRhs( (DSLSentence) completions.getDSLActions()[ idx ] );
- popup.hide();
- }
- });
- popup.addAttribute( "DSL sentence", dsls );
- }
- popup.show();
- }
-
-
-
- protected void addModify(String itemText) {
- this.model.addRhsItem(new ActionUpdateField(itemText));
- refreshWidget();
-
- }
-
- protected void addNewDSLRhs(DSLSentence sentence) {
- this.model.addRhsItem( sentence.copy() );
- refreshWidget();
- }
-
- protected void addRetract(String var) {
- this.model.addRhsItem( new ActionRetractFact(var) );
- refreshWidget();
- }
-
- protected void addActionSetField(String itemText) {
- this.model.addRhsItem(new ActionSetField(itemText));
- refreshWidget();
- }
-
- protected void addNewCE(String s) {
- this.model.addLhsItem( new CompositeFactPattern(s) );
- refreshWidget();
- }
-
- /**
- * Adds a fact to the model, and then refreshes the display.
- */
- protected void addNewFact(String itemText) {
- this.model.addLhsItem( new FactPattern(itemText) );
- refreshWidget();
- }
-
- /**
- * Builds all the condition widgets.
- */
- private Widget renderLhs(final RuleModel model) {
- DirtyableVerticalPane vert = new DirtyableVerticalPane();
-
- for ( int i = 0; i < model.lhs.length; i++ ) {
- IPattern pattern = model.lhs[i];
- Widget w = null;
- if (pattern instanceof FactPattern) {
- w = new FactPatternWidget(this, pattern, completions, true) ;
- vert.add( wrapLHSWidget( model,
- i,
- w ) );
- vert.add( spacerWidget() );
- } else if (pattern instanceof CompositeFactPattern) {
- w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern, completions) ;
- vert.add( wrapLHSWidget( model, i, w ));
- vert.add( spacerWidget() );
- } else if (pattern instanceof DSLSentence) {
- //ignore this time
- } else {
- throw new RuntimeException("I don't know what type of pattern that is.");
- }
-
-
- }
-
-
- DirtyableVerticalPane dsls = new DirtyableVerticalPane();
- for ( int i = 0; i < model.lhs.length; i++ ) {
- IPattern pattern = model.lhs[i];
- Widget w = null;
-
- if (pattern instanceof DSLSentence) {
- w = new DSLSentenceWidget((DSLSentence) pattern);
-
- dsls.add( wrapLHSWidget( model, i, w ) );
- dsls.setStyleName( "model-builderInner-Background" );
- }
- }
- vert.add( dsls );
-
- return vert;
- }
-
- private HTML spacerWidget() {
- HTML h = new HTML(" ");
- h.setHeight( "2px" );
- return h;
- }
-
- /**
- * This adds the widget to the UI, also adding the remove icon.
- */
- private Widget wrapLHSWidget(final RuleModel model, int i, Widget w) {
- DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
-
- Image remove = new ImageButton("images/delete_item_small.gif");
- remove.setTitle( "Remove this ENTIRE condition, and all the field constraints that belong to it." );
- final int idx = i;
- remove.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- if (Window.confirm("Remove this entire condition?")) {
- if (model.removeLhsItem(idx)) {
- refreshWidget();
- } else {
- ErrorPopup.showMessage( "Can't remove that item as it is used in the action part of the rule." );
- }
- }
- }
- } );
-
-
- horiz.setWidth( "100%" );
- w.setWidth( "100%" );
-
- horiz.add( w );
- horiz.add( remove );
-
- return horiz;
- }
-
-
-
- public RuleModel getModel() {
- return model;
- }
-
- /**
- * Returns true is a var name has already been used
- * either by the rule, or as a global.
- */
-
- public boolean isVariableNameUsed(String name) {
-
- return model.isVariableNameUsed( name ) || completions.isGlobalVariable( name );
- }
-
- public boolean isDirty() {
- return ( layout.hasDirty() || dirtyflag) ;
- }
-
- public SuggestionCompletionEngine getSuggestionCompletions() {
- return this.completions;
- }
-
-
- public String getWrapperClass() {
- return null;
- }
-
- public String getAssetFormat() {
- return null;
- }
+package org.drools.guvnor.client.modeldriven.ui;
+/*
+ * Copyright 2005 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.
+ */
+
+
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.guvnor.client.common.DirtyableComposite;
+import org.drools.guvnor.client.common.DirtyableFlexTable;
+import org.drools.guvnor.client.common.DirtyableHorizontalPane;
+import org.drools.guvnor.client.common.DirtyableVerticalPane;
+import org.drools.guvnor.client.common.ErrorPopup;
+import org.drools.guvnor.client.common.FormStylePopup;
+import org.drools.guvnor.client.common.ImageButton;
+import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.modeldriven.HumanReadable;
+import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.guvnor.client.modeldriven.brl.ActionInsertFact;
+import org.drools.guvnor.client.modeldriven.brl.ActionInsertLogicalFact;
+import org.drools.guvnor.client.modeldriven.brl.ActionRetractFact;
+import org.drools.guvnor.client.modeldriven.brl.ActionSetField;
+import org.drools.guvnor.client.modeldriven.brl.ActionUpdateField;
+import org.drools.guvnor.client.modeldriven.brl.CompositeFactPattern;
+import org.drools.guvnor.client.modeldriven.brl.DSLSentence;
+import org.drools.guvnor.client.modeldriven.brl.FactPattern;
+import org.drools.guvnor.client.modeldriven.brl.IAction;
+import org.drools.guvnor.client.modeldriven.brl.IPattern;
+import org.drools.guvnor.client.modeldriven.brl.RuleAttribute;
+import org.drools.guvnor.client.modeldriven.brl.RuleModel;
+import org.drools.guvnor.client.packages.SuggestionCompletionCache;
+import org.drools.guvnor.client.rpc.RuleAsset;
+
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * This is the parent widget that contains the model based rule builder.
+ *
+ * @author Michael Neale
+ *
+ */
+public class RuleModeller extends DirtyableComposite {
+
+ private DirtyableFlexTable layout;
+ private SuggestionCompletionEngine completions;
+ private RuleModel model;
+
+ public RuleModeller(RuleAsset asset) {
+ this.model = (RuleModel) asset.content;
+
+ this.completions = SuggestionCompletionCache.getInstance().getEngineFromCache( asset.metaData.packageName );
+
+ layout = new DirtyableFlexTable();
+
+ initWidget();
+
+ layout.setStyleName( "model-builder-Background" );
+ initWidget( layout );
+ setWidth( "100%" );
+ setHeight( "100%" );
+ }
+
+ /**
+ * This updates the widget to reflect the state of the model.
+ */
+ public void initWidget() {
+ layout.clear();
+
+ Image addPattern = new ImageButton( "images/new_item.gif" );
+ addPattern.setTitle( "Add a condition to this rule." );
+ addPattern.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ showConditionSelector(w);
+ }
+ });
+
+ layout.setWidget( 0, 0, new SmallLabel("WHEN") );
+ layout.setWidget( 0, 2, addPattern );
+
+ layout.setWidget( 1, 1, renderLhs(this.model) );
+ layout.setWidget( 2, 0, new SmallLabel("THEN") );
+
+ Image addAction = new ImageButton("images/new_item.gif");
+ addAction.setTitle( "Add an action to this rule." );
+ addAction.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ showActionSelector(w);
+ }
+ });
+ layout.setWidget( 2, 2, addAction );
+
+ layout.setWidget( 3, 1, renderRhs(this.model) );
+
+ layout.setWidget( 4, 0, new SmallLabel("(options)") );
+ layout.setWidget( 4, 2, getAddAttribute() );
+ layout.setWidget( 5, 1, new RuleAttributeWidget(this, this.model) );
+ }
+
+ public void refreshWidget() {
+ initWidget();
+ makeDirty();
+ }
+
+ private Widget getAddAttribute() {
+ Image add = new ImageButton("images/new_item.gif");
+ add.setTitle( "Add an option to the rule, to modify its behavior when evaluated or executed." );
+
+ add.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ showAttributeSelector(w);
+ }
+ });
+ return add;
+ }
+
+ protected void showAttributeSelector(Widget w) {
+ final FormStylePopup pop = new FormStylePopup("images/config.png", "Add an option to the rule");
+ final ListBox list = RuleAttributeWidget.getAttributeList();
+
+ list.setSelectedIndex( 0 );
+
+ list.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ model.addAttribute( new RuleAttribute(list.getItemText( list.getSelectedIndex() ), "") );
+ refreshWidget();
+ pop.hide();
+ }
+ });
+
+
+
+ pop.addAttribute( "Attribute", list );
+
+ pop.show();
+ }
+
+ /**
+ * Do all the widgets for the RHS.
+ */
+ /*
+ * TODO STILL NEED TO BE CHECKED
+ */
+ private Widget renderRhs(final RuleModel model) {
+ DirtyableVerticalPane vert = new DirtyableVerticalPane();
+
+ for ( int i = 0; i < model.rhs.length; i++ ) {
+ IAction action = model.rhs[i];
+
+ Widget w = null;
+ if (action instanceof ActionSetField) {
+ w = new ActionSetFieldWidget(this, (ActionSetField) action, completions ) ;
+ } else if (action instanceof ActionInsertFact) {
+ w = new ActionInsertFactWidget(this, (ActionInsertFact) action, completions );
+ } else if (action instanceof ActionRetractFact) {
+ w = new ActionRetractFactWidget(this.completions, (ActionRetractFact) action );
+ } else if (action instanceof DSLSentence) {
+ w = new DSLSentenceWidget((DSLSentence) action);
+ w.setStyleName( "model-builderInner-Background" );
+ }
+
+ //w.setWidth( "100%" );
+ vert.add( spacerWidget() );
+ //vert.setWidth( "100%" );
+
+ DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
+
+ Image remove = new ImageButton("images/delete_item_small.gif");
+ remove.setTitle( "Remove this action." );
+ final int idx = i;
+ remove.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ if (Window.confirm("Remove this item?")) {
+ model.removeRhsItem(idx);
+ refreshWidget();
+ }
+ }
+ } );
+ horiz.add( w );
+ if (!(w instanceof ActionRetractFactWidget)) {
+ w.setWidth( "100%" );
+ horiz.setWidth( "100%" );
+ }
+
+ horiz.add( remove );
+ vert.add( horiz );
+
+ }
+
+ return vert;
+ }
+
+ /**
+ * Pops up the fact selector.
+ */
+ protected void showConditionSelector(final Widget w) {
+ final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a condition to the rule...");
+
+ //
+ // The list of facts
+ //
+ String[] facts = completions.getFactTypes();
+ final ListBox factTypeBox = new ListBox();
+ factTypeBox.addItem( "Choose fact type...", "IGNORE" );
+ for ( int i = 0; i < facts.length; i++ ) {
+ factTypeBox.addItem( facts[i] );
+ }
+ factTypeBox.setSelectedIndex( 0 );
+ if (facts.length > 0) popup.addAttribute( "Fact", factTypeBox );
+ factTypeBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ String s = factTypeBox.getItemText( factTypeBox.getSelectedIndex() );
+ if (!s.equals( "IGNORE" )) {
+ addNewFact(s);
+ popup.hide();
+ }
+ }
+ });
+
+ //
+ // The list of top level CEs
+ //
+ String ces[] = HumanReadable.CONDITIONAL_ELEMENTS;
+ final ListBox ceBox = new ListBox();
+ ceBox.addItem( "Choose condition type...", "IGNORE" );
+ for ( int i = 0; i < ces.length; i++ ) {
+ String ce = ces[i];
+ ceBox.addItem( HumanReadable.getCEDisplayName( ce ), ce );
+ }
+ ceBox.setSelectedIndex( 0 );
+
+ if (facts.length > 0) popup.addAttribute( "Condition type", ceBox );
+ ceBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ String s = ceBox.getValue( ceBox.getSelectedIndex() );
+ if (!s.equals( "IGNORE" )) {
+ addNewCE(s);
+ popup.hide();
+ }
+ }
+ });
+
+
+ //
+ // The list of DSL sentences
+ //
+ if (completions.getDSLConditions().length > 0) {
+ final ListBox dsls = new ListBox();
+ dsls.addItem( "Choose..." );
+ for(int i = 0; i < completions.getDSLConditions().length; i++ ) {
+ DSLSentence sen = completions.getDSLConditions()[i];
+ dsls.addItem( sen.toString(), Integer.toString( i ) );
+ }
+
+ dsls.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ int idx = Integer.parseInt( dsls.getValue( dsls.getSelectedIndex() ) );
+ addNewDSLLhs( (DSLSentence) completions.getDSLConditions()[ idx ] );
+ popup.hide();
+ }
+ });
+ popup.addAttribute( "DSL sentence", dsls );
+ }
+ popup.show();
+
+ }
+
+ protected void addNewDSLLhs(DSLSentence sentence) {
+ model.addLhsItem( sentence.copy() );
+ refreshWidget();
+
+ }
+
+ protected void showActionSelector(Widget w) {
+ final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a new action...");
+
+
+ //
+ // First load up the stuff to do with bound variables or globals
+ //
+ List vars = model.getBoundFacts();
+ final ListBox varBox = new ListBox();
+ final ListBox retractBox = new ListBox();
+ final ListBox modifyBox = new ListBox();
+ varBox.addItem( "Choose ..." );
+ retractBox.addItem( "Choose ..." );
+ modifyBox.addItem( "Choose ..." );
+ for ( Iterator iter = vars.iterator(); iter.hasNext(); ) {
+ String v = (String) iter.next();
+ varBox.addItem( v );
+ retractBox.addItem( v );
+ modifyBox.addItem( v );
+ }
+ String[] globals = this.completions.getGlobalVariables();
+ for ( int i = 0; i < globals.length; i++ ) {
+ varBox.addItem( globals[i] );
+ }
+
+ varBox.setSelectedIndex( 0 );
+ varBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ addActionSetField(varBox.getItemText( varBox.getSelectedIndex() ));
+ popup.hide();
+ }
+ });
+
+ retractBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ addRetract(retractBox.getItemText( retractBox.getSelectedIndex() ));
+ popup.hide();
+ }
+ });
+
+ modifyBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ addModify(modifyBox.getItemText( modifyBox.getSelectedIndex() ));
+ popup.hide();
+ }
+ });
+
+ if (varBox.getItemCount() > 1) {
+ popup.addAttribute( "Set the values of a field on", varBox );
+ }
+
+
+ if (modifyBox.getItemCount() > 1) {
+ HorizontalPanel horiz = new HorizontalPanel();
+ horiz.add( modifyBox );
+ Image img = new Image("images/information.gif");
+ img.setTitle( "Modify a field on a fact, and notify the engine to re-evaluate rules." );
+ horiz.add( img );
+ popup.addAttribute( "Modify a fact", horiz );
+ }
+
+ //popup.addRow( new HTML("<hr/>") );
+
+ if (retractBox.getItemCount() > 1) {
+ popup.addAttribute( "Retract the fact", retractBox );
+ }
+
+ //popup.addRow( new HTML("<hr/>") );
+
+
+ final ListBox factsToAssert = new ListBox();
+ final ListBox factsToLogicallyAssert = new ListBox();
+ factsToAssert.addItem( "Choose ..." );
+ factsToLogicallyAssert.addItem( "Choose ..." );
+ for ( int i = 0; i < completions.getFactTypes().length; i++ ) {
+ String item = completions.getFactTypes()[i];
+ factsToAssert.addItem( item );
+ factsToLogicallyAssert.addItem( item );
+ }
+
+ factsToAssert.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ String fact = factsToAssert.getItemText( factsToAssert.getSelectedIndex() );
+ model.addRhsItem( new ActionInsertFact(fact) );
+ refreshWidget();
+ popup.hide();
+
+ }
+ });
+
+ factsToLogicallyAssert.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ String fact = factsToLogicallyAssert.getItemText( factsToLogicallyAssert.getSelectedIndex() );
+ model.addRhsItem( new ActionInsertLogicalFact(fact) );
+ refreshWidget();
+ popup.hide();
+
+ }
+ });
+
+
+ if (factsToAssert.getItemCount() > 1) {
+ popup.addAttribute( "Insert a new fact", factsToAssert );
+ HorizontalPanel horiz = new HorizontalPanel();
+ horiz.add( factsToLogicallyAssert );
+ Image img = new Image("images/information.gif");
+ img.setTitle( "Logically assert a fact - the fact will be retracted when the supporting evidence is removed." );
+ horiz.add( img );
+ popup.addAttribute( "Logically insert a new fact", horiz );
+ }
+
+
+
+ //
+ // The list of DSL sentences
+ //
+ if (completions.getDSLActions().length > 0) {
+ final ListBox dsls = new ListBox();
+ dsls.addItem( "Choose..." );
+ for(int i = 0; i < completions.getDSLActions().length; i++ ) {
+ DSLSentence sen = (DSLSentence) completions.getDSLActions()[ i ];
+ dsls.addItem( sen.toString(), Integer.toString( i ) );
+ }
+
+ dsls.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ int idx = Integer.parseInt( dsls.getValue( dsls.getSelectedIndex() ) );
+ addNewDSLRhs( (DSLSentence) completions.getDSLActions()[ idx ] );
+ popup.hide();
+ }
+ });
+ popup.addAttribute( "DSL sentence", dsls );
+ }
+ popup.show();
+ }
+
+
+
+ protected void addModify(String itemText) {
+ this.model.addRhsItem(new ActionUpdateField(itemText));
+ refreshWidget();
+
+ }
+
+ protected void addNewDSLRhs(DSLSentence sentence) {
+ this.model.addRhsItem( sentence.copy() );
+ refreshWidget();
+ }
+
+ protected void addRetract(String var) {
+ this.model.addRhsItem( new ActionRetractFact(var) );
+ refreshWidget();
+ }
+
+ protected void addActionSetField(String itemText) {
+ this.model.addRhsItem(new ActionSetField(itemText));
+ refreshWidget();
+ }
+
+ protected void addNewCE(String s) {
+ this.model.addLhsItem( new CompositeFactPattern(s) );
+ refreshWidget();
+ }
+
+ /**
+ * Adds a fact to the model, and then refreshes the display.
+ */
+ protected void addNewFact(String itemText) {
+ this.model.addLhsItem( new FactPattern(itemText) );
+ refreshWidget();
+ }
+
+ /**
+ * Builds all the condition widgets.
+ */
+ private Widget renderLhs(final RuleModel model) {
+ DirtyableVerticalPane vert = new DirtyableVerticalPane();
+
+ for ( int i = 0; i < model.lhs.length; i++ ) {
+ IPattern pattern = model.lhs[i];
+ Widget w = null;
+ if (pattern instanceof FactPattern) {
+ w = new FactPatternWidget(this, pattern, completions, true) ;
+ vert.add( wrapLHSWidget( model,
+ i,
+ w ) );
+ vert.add( spacerWidget() );
+ } else if (pattern instanceof CompositeFactPattern) {
+ w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern, completions) ;
+ vert.add( wrapLHSWidget( model, i, w ));
+ vert.add( spacerWidget() );
+ } else if (pattern instanceof DSLSentence) {
+ //ignore this time
+ } else {
+ throw new RuntimeException("I don't know what type of pattern that is.");
+ }
+
+
+ }
+
+
+ DirtyableVerticalPane dsls = new DirtyableVerticalPane();
+ for ( int i = 0; i < model.lhs.length; i++ ) {
+ IPattern pattern = model.lhs[i];
+ Widget w = null;
+
+ if (pattern instanceof DSLSentence) {
+ w = new DSLSentenceWidget((DSLSentence) pattern);
+
+ dsls.add( wrapLHSWidget( model, i, w ) );
+ dsls.setStyleName( "model-builderInner-Background" );
+ }
+ }
+ vert.add( dsls );
+
+ return vert;
+ }
+
+ private HTML spacerWidget() {
+ HTML h = new HTML(" ");
+ h.setHeight( "2px" );
+ return h;
+ }
+
+ /**
+ * This adds the widget to the UI, also adding the remove icon.
+ */
+ private Widget wrapLHSWidget(final RuleModel model,
+ int i,
+ Widget w) {
+ DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
+
+ Image remove = new ImageButton("images/delete_item_small.gif");
+ remove.setTitle( "Remove this ENTIRE condition, and all the field constraints that belong to it." );
+ final int idx = i;
+ remove.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ if (Window.confirm("Remove this entire condition?")) {
+ if (model.removeLhsItem(idx)) {
+ refreshWidget();
+ } else {
+ ErrorPopup.showMessage( "Can't remove that item as it is used in the action part of the rule." );
+ }
+ }
+ }
+ } );
+
+
+ horiz.setWidth( "100%" );
+ w.setWidth( "100%" );
+
+ horiz.add( w );
+ horiz.add( remove );
+
+ return horiz;
+ }
+
+
+
+ public RuleModel getModel() {
+ return model;
+ }
+
+ /**
+ * Returns true is a var name has already been used
+ * either by the rule, or as a global.
+ */
+
+ public boolean isVariableNameUsed(String name) {
+
+ return model.isVariableNameUsed( name ) || completions.isGlobalVariable( name );
+ }
+
+ public boolean isDirty() {
+ return ( layout.hasDirty() || dirtyflag) ;
+ }
+
+ public SuggestionCompletionEngine getSuggestionCompletions() {
+ return this.completions;
+ }
+
+
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/ModelAttachmentFileWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/ModelAttachmentFileWidget.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/ModelAttachmentFileWidget.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -16,21 +16,21 @@
*/
+
import org.drools.guvnor.client.rpc.RuleAsset;
-import org.drools.guvnor.client.ruleeditor.Editor;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
/**
* This wraps a file uploader utility for model packages.
- * Model packages are jar files.
- *
+ * Model packages are jar files.
+ *
* @author Michael Neale
* @author Fernando Meyer
*/
-public class ModelAttachmentFileWidget extends AssetAttachmentFileWidget implements Editor {
+public class ModelAttachmentFileWidget extends AssetAttachmentFileWidget {
-
+
public ModelAttachmentFileWidget(RuleAsset asset, RuleViewer viewer) {
super( asset, viewer );
}
@@ -39,18 +39,11 @@
public String getIcon() {
return "images/model_large.png";
}
-
+
public String getOverallStyleName() {
return "editable-Surface";
}
- public String getWrapperClass() {
- return null;
- }
-
- public String getAssetFormat() {
- return null;
- }
}
/*Composite {
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -1,13 +1,33 @@
package org.drools.guvnor.client.qa;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.*;
-import org.drools.guvnor.client.common.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.guvnor.client.common.DirtyableComposite;
+import org.drools.guvnor.client.common.DirtyableFlexTable;
+import org.drools.guvnor.client.common.ErrorPopup;
+import org.drools.guvnor.client.common.FormStylePopup;
+import org.drools.guvnor.client.common.GenericCallback;
+import org.drools.guvnor.client.common.ImageButton;
+import org.drools.guvnor.client.common.LoadingPopup;
+import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.common.ValueChanged;
import org.drools.guvnor.client.modeldriven.DropDownData;
import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
-import org.drools.guvnor.client.modeldriven.testing.*;
+import org.drools.guvnor.client.modeldriven.testing.ExecutionTrace;
+import org.drools.guvnor.client.modeldriven.testing.FactData;
+import org.drools.guvnor.client.modeldriven.testing.FieldData;
+import org.drools.guvnor.client.modeldriven.testing.Fixture;
+import org.drools.guvnor.client.modeldriven.testing.RetractFact;
+import org.drools.guvnor.client.modeldriven.testing.Scenario;
+import org.drools.guvnor.client.modeldriven.testing.VerifyFact;
+import org.drools.guvnor.client.modeldriven.testing.VerifyField;
+import org.drools.guvnor.client.modeldriven.testing.VerifyRuleFired;
import org.drools.guvnor.client.modeldriven.ui.ActionValueEditor;
import org.drools.guvnor.client.modeldriven.ui.ConstraintValueEditor;
import org.drools.guvnor.client.packages.SuggestionCompletionCache;
@@ -15,11 +35,30 @@
import org.drools.guvnor.client.rpc.RepositoryServiceFactory;
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.rpc.ScenarioRunResult;
-import org.drools.guvnor.client.ruleeditor.Editor;
-import java.util.*;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HasVerticalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.KeyboardListener;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.ScrollPanel;
+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 class ScenarioWidget extends Composite implements Editor {
+public class ScenarioWidget extends Composite {
private ListBox availableRules;
private SuggestionCompletionEngine sce;
@@ -538,13 +577,9 @@
}
- public String getWrapperClass() {
- return null;
- }
- public String getAssetFormat() {
- return null;
- }
+
+
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DSLRuleEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DSLRuleEditor.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DSLRuleEditor.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -42,7 +42,7 @@
* @author michael neale
*/
-public class DSLRuleEditor extends DirtyableComposite implements Editor{
+public class DSLRuleEditor extends DirtyableComposite {
private TextArea text;
final private RuleContentText data;
@@ -165,11 +165,4 @@
this.data.content = text.getText();
}
- public String getWrapperClass() {
- return null;
- }
-
- public String getAssetFormat() {
- return null;
- }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -29,7 +29,7 @@
* This is the default rule editor widget (just text editor based) - more to come later.
* @author michael neale
*/
-public class DefaultRuleContentWidget extends DirtyableComposite implements Editor {
+public class DefaultRuleContentWidget extends DirtyableComposite {
private TextArea text;
final private RuleContentText data;
@@ -88,11 +88,4 @@
this.data.content = text.getText();
}
- public String getWrapperClass() {
- return null;
- }
-
- public String getAssetFormat() {
- return null;
- }
}
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/Editor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/Editor.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/Editor.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -1,35 +0,0 @@
-package org.drools.guvnor.client.ruleeditor;
-
-import org.drools.guvnor.client.rpc.RuleAsset;
-
-/*
- * Copyright 2008 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.
- */
-
-
-/**
- * A marker interface to indicate the content editor to be included to EditorLauncher code generation
- *
- * we can replace this interface with annotation if we upgrade to GWT v1.5
- *
- * @author Anton Arhipov
- */
-public interface Editor {
-
- String getWrapperClass();
-
- public String getAssetFormat();
-
-}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+
+
import java.util.HashMap;
import java.util.Map;
@@ -43,24 +45,17 @@
*
* @author Michael Neale
*/
-
-public interface EditorLauncher {
- public Widget getEditorViewer(RuleAsset asset, RuleViewer viewer);
- public String getAssetFormatIcon(String format);
-}
-
-/*
public class EditorLauncher {
public static final Map TYPE_IMAGES = getTypeImages();
- */
-/**
+ /**
* This will return the appropriate viewer for the asset.
*
+ * TODO: the method to be changed in order to make the editors pluggable
+ * TODO: look at http://gwtreflection.sourceforge.net/
*/
-/*
public static Widget getEditorViewer(RuleAsset asset,
RuleViewer viewer) {
//depending on the format, load the appropriate editor
@@ -110,12 +105,10 @@
return result;
}
- */
-/**
+ /**
* Get the icon name (not the path), including the extension, for the appropriate
* asset format.
*/
-/*
public static String getAssetFormatIcon(String format) {
String result = (String) TYPE_IMAGES.get( format );
if (result == null) {
@@ -130,4 +123,4 @@
-}*/
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowUploadWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowUploadWidget.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowUploadWidget.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -27,7 +27,7 @@
*
* @author Michael Neale
*/
-public class RuleFlowUploadWidget extends AssetAttachmentFileWidget implements Editor {
+public class RuleFlowUploadWidget extends AssetAttachmentFileWidget {
public RuleFlowUploadWidget(
RuleAsset asset, RuleViewer viewer) {
@@ -40,16 +40,11 @@
public String getIcon() {
return "images/ruleflow_large.png";
}
-
+
public String getOverallStyleName() {
return "decision-Table-upload";
}
- public String getWrapperClass() {
- return null;
- }
- public String getAssetFormat() {
- return null;
- }
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -16,14 +16,31 @@
*/
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.*;
-import org.drools.guvnor.client.common.*;
+
+import org.drools.guvnor.client.common.AssetFormats;
+import org.drools.guvnor.client.common.DirtyableComposite;
+import org.drools.guvnor.client.common.ErrorPopup;
+import org.drools.guvnor.client.common.FormStylePopup;
+import org.drools.guvnor.client.common.GenericCallback;
+import org.drools.guvnor.client.common.LoadingPopup;
import org.drools.guvnor.client.packages.SuggestionCompletionCache;
import org.drools.guvnor.client.rpc.RepositoryServiceFactory;
import org.drools.guvnor.client.rpc.RuleAsset;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.DisclosurePanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.HorizontalSplitPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.VerticalSplitPanel;
+import com.google.gwt.user.client.ui.Widget;
+
/**
* The main layout parent/controller the rule viewer.
*
@@ -50,7 +67,9 @@
}
/**
- * @param asset The rule asset to open.
+ * @param UUID The resource to open.
+ * @param format The type of resource (may determine what editor is used).
+ * @param name The name to be displayed.
* @param historicalReadOnly true if this is a read only view for historical purposes.
*/
public RuleViewer(RuleAsset asset, boolean historicalReadOnly) {
@@ -79,10 +98,10 @@
private void doWidgets() {
layout.clear();
- //editor = EditorLauncher.getEditorViewer(asset, this);
- EditorLauncher editorLauncher = (EditorLauncher) GWT.create(EditorLauncher.class);
- editor = editorLauncher.getEditorViewer(asset, this);
+ editor = EditorLauncher.getEditorViewer(asset, this);
+
+
//the action widgets (checkin/close etc).
toolbar = new ActionToolbar( asset,
new Command() {
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/AssetItemGrid.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/AssetItemGrid.java 2008-07-01 18:46:34 UTC (rev 20862)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/AssetItemGrid.java 2008-07-01 19:50:33 UTC (rev 20863)
@@ -30,7 +30,6 @@
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
-import com.google.gwt.core.client.GWT;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.data.ArrayReader;
import com.gwtext.client.data.FieldDef;
@@ -246,11 +245,7 @@
public String render(Object value,
CellMetadata cellMetadata, Record record,
int rowIndex, int colNum, Store store) {
-
- EditorLauncher editorLauncher = (EditorLauncher) GWT.create(EditorLauncher.class);
-
- //String fmtIcon = "images/" + EditorLauncher.getAssetFormatIcon(record.getAsString("format"));
- String fmtIcon = "images/" + editorLauncher.getAssetFormatIcon(record.getAsString("format"));
+ String fmtIcon = "images/" + EditorLauncher.getAssetFormatIcon(record.getAsString("format"));
String desc = record.getAsString("Description");
if (desc == null) {
desc = "";
More information about the jboss-svn-commits
mailing list