[jboss-svn-commits] JBL Code SVN: r12565 - in labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin: META-INF and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 13 18:11:50 EDT 2007
Author: arhan
Date: 2007-06-13 18:11:50 -0400 (Wed, 13 Jun 2007)
New Revision: 12565
Modified:
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/META-INF/MANIFEST.MF
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/build.properties
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java
Log:
adjusting the widgets for new core API, several TODOs left, all conserning FactPatternWidget
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/META-INF/MANIFEST.MF
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/META-INF/MANIFEST.MF 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/META-INF/MANIFEST.MF 2007-06-13 22:11:50 UTC (rev 12565)
@@ -16,8 +16,8 @@
org.drools.eclipse,
org.eclipse.jdt.core
Eclipse-LazyStart: true
-Bundle-ClassPath: lib/drools-core-4.0.0.SNAPSHOT.jar,
- lib/drools-compiler-4.0.0.SNAPSHOT.jar,
- lib/antlr-3.0b7.jar,
- lib/xstream-1.1.3.jar,
- .
+Bundle-ClassPath: .,
+ lib/drools-core.jar,
+ lib/drools-compiler.jar,
+ lib/antlr.jar,
+ lib/xstream.jar
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/build.properties
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/build.properties 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/build.properties 2007-06-13 22:11:50 UTC (rev 12565)
@@ -4,8 +4,8 @@
META-INF/,\
.,\
icons/,\
- lib/xstream-1.1.3.jar,\
- lib/drools-compiler-4.0.0.SNAPSHOT.jar,\
- lib/drools-core-4.0.0.SNAPSHOT.jar,\
- lib/antlr-3.0b7.jar
+ lib/drools-compiler.jar,\
+ lib/drools-core.jar,\
+ lib/antlr.jar,\
+ lib/xstream.jar
src.includes = icons/
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java 2007-06-13 22:11:50 UTC (rev 12565)
@@ -16,117 +16,91 @@
*/
public class HumanReadable {
- public static Map operatorDisplayMap = new HashMap();
+ public static Map operatorDisplayMap = new HashMap();
- public static Map ceDisplayMap = new HashMap();
+ public static Map ceDisplayMap = new HashMap();
- public static Map actionDisplayMap = new HashMap();
+ public static Map actionDisplayMap = new HashMap();
- public static final String[] CONDITIONAL_ELEMENTS = new String[]{"not", "exists", "or"};
+ public static final String[] CONDITIONAL_ELEMENTS = new String[] { "not",
+ "exists", "or" };
- static {
- operatorDisplayMap.put( "==",
- "is equal to" );
- operatorDisplayMap.put( "!=",
- "is not equal to" );
- operatorDisplayMap.put( "<",
- "is less than" );
- operatorDisplayMap.put( "<=",
- "less than or equal to" );
- operatorDisplayMap.put( ">",
- "greater than" );
- operatorDisplayMap.put( ">=",
- "greater than or equal to" );
+ static {
+ operatorDisplayMap.put( "==", "is equal to" );
+ operatorDisplayMap.put( "!=", "is not equal to" );
+ operatorDisplayMap.put( "<", "is less than" );
+ operatorDisplayMap.put( "<=", "less than or equal to" );
+ operatorDisplayMap.put( ">", "greater than" );
+ operatorDisplayMap.put( ">=", "greater than or equal to" );
+
+ operatorDisplayMap.put( "|| ==", "or equal to" );
+ operatorDisplayMap.put( "|| !=", "or not equal to" );
+ operatorDisplayMap.put( "&& !=", "and not equal to" );
+ operatorDisplayMap.put( "&& >", "and greater than" );
+ operatorDisplayMap.put( "&& <", "and less than" );
+ operatorDisplayMap.put( "|| >", "or greater than" );
+ operatorDisplayMap.put( "|| <", "or less than" );
+
+ operatorDisplayMap.put( "|| >=", "or greater than (or equal to)" );
+ operatorDisplayMap.put( "|| <=", "or less than (or equal to)" );
+ operatorDisplayMap.put( "&& >=", "and greater than (or equal to)" );
+ operatorDisplayMap.put( "&& <=", "or less than (or equal to)" );
+ operatorDisplayMap.put( "&& contains", "and contains" );
+ operatorDisplayMap.put( "|| contains", "or contains" );
+ operatorDisplayMap.put( "&& matches", "and matches" );
+ operatorDisplayMap.put( "|| matches", "or matches" );
+ operatorDisplayMap.put( "|| excludes", "or excludes" );
+ operatorDisplayMap.put( "&& excludes", "and excludes" );
- operatorDisplayMap.put( "| ==",
- "or equal to" );
- operatorDisplayMap.put( "| !=",
- "or not equal to" );
- operatorDisplayMap.put( "& !=",
- "and not equal to" );
- operatorDisplayMap.put( "& >",
- "and greater than" );
- operatorDisplayMap.put( "| >=",
- "or greater than (or equal to)" );
- operatorDisplayMap.put( "| <=",
- "or less than (or equal to)" );
- operatorDisplayMap.put( "& >=",
- "and greater than (or equal to)" );
- operatorDisplayMap.put( "& <=",
- "or less than (or equal to)" );
- operatorDisplayMap.put( "& contains",
- "and contains" );
- operatorDisplayMap.put( "| contains",
- "or contains" );
- operatorDisplayMap.put( "& matches",
- "and matches" );
- operatorDisplayMap.put( "| matches",
- "or matches" );
- operatorDisplayMap.put( "| excludes",
- "or excludes" );
- operatorDisplayMap.put( "& excludes",
- "and excludes" );
+ ceDisplayMap.put("not", "There is no");
+ ceDisplayMap.put("exists", "There exists");
+ ceDisplayMap.put("or", "Any of");
- ceDisplayMap.put( "not",
- "There is no" );
- ceDisplayMap.put( "exists",
- "There exists" );
- ceDisplayMap.put( "or",
- "Any of" );
+ actionDisplayMap.put( "assert", "Assert" );
+ actionDisplayMap.put( "assertLogical", "Logically assert" );
+ actionDisplayMap.put( "retract", "Retract" );
+ actionDisplayMap.put( "set", "Set" );
+ actionDisplayMap.put( "modify", "Modify" );
- actionDisplayMap.put( "insert",
- "Insert" );
- actionDisplayMap.put( "insertLogical",
- "Logically insert" );
- actionDisplayMap.put( "retract",
- "Retract" );
- actionDisplayMap.put( "set",
- "Set" );
- actionDisplayMap.put( "update",
- "Update" );
+ }
- }
+ public static String getActionDisplayName(String action) {
+ return lookup(action, actionDisplayMap);
+ }
- public static String getActionDisplayName(String action) {
- return lookup( action,
- actionDisplayMap );
- }
+ public static String getOperatorDisplayName(String op) {
+ return lookup(op, operatorDisplayMap);
+ }
- public static String getOperatorDisplayName(String op) {
- return lookup( op,
- operatorDisplayMap );
- }
+ public static String getCEDisplayName(String ce) {
+ return lookup(ce, ceDisplayMap);
+ }
- public static String getCEDisplayName(String ce) {
- return lookup( ce,
- ceDisplayMap );
- }
+ private static String lookup(String ce, Map map) {
+ if (map.containsKey(ce)) {
+ return (String) map.get(ce);
+ } else {
+ return ce;
+ }
+ }
- private static String lookup(String ce,
- Map map) {
- if ( map.containsKey( ce ) ) {
- return (String) map.get( ce );
- } else {
- return ce;
- }
- }
+ /**
+ * get operator by its display name
+ *
+ * @param op
+ * operator display name
+ * @return operator
+ */
+ public static String getOperatorName(String op) {
+ Set keys = operatorDisplayMap.keySet();
+ for (Iterator iter = keys.iterator(); iter.hasNext();) {
+ String key = (String) iter.next();
+ if (op.equals(operatorDisplayMap.get(key))) {
+ return key;
+ }
+ }
+ throw new RuntimeException("No operator display name '" + op
+ + "' was found.");
+ }
- /**
- * get operator by its display name
- *
- * @param op
- * operator display name
- * @return operator
- */
- public static String getOperatorName(String op) {
- Set keys = operatorDisplayMap.keySet();
- for ( Iterator iter = keys.iterator(); iter.hasNext(); ) {
- String key = (String) iter.next();
- if ( op.equals( operatorDisplayMap.get( key ) ) ) {
- return key;
- }
- }
- throw new RuntimeException( "No operator display name '" + op + "' was found." );
- }
-
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java 2007-06-13 22:11:50 UTC (rev 12565)
@@ -3,6 +3,7 @@
import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
import org.drools.brms.client.modeldriven.brxml.ActionInsertFact;
import org.drools.brms.client.modeldriven.brxml.ActionFieldValue;
+import org.drools.brms.client.modeldriven.brxml.ActionInsertLogicalFact;
import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -54,8 +55,14 @@
}
private void create() {
+
+ String assertType = "assert";
+ if (fact instanceof ActionInsertLogicalFact) {
+ assertType = "assertLogical";
+ }
+
toolkit.createLabel( parent,
- HumanReadable.getActionDisplayName( this.fact.getType() ) + " " + this.fact.factType );
+ HumanReadable.getActionDisplayName( assertType ) + " " + this.fact.factType );
addDeleteRHSAction();
addMoreOptionsAction();
Composite constraintComposite = toolkit.createComposite( parent );
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java 2007-06-13 22:11:50 UTC (rev 12565)
@@ -3,6 +3,7 @@
import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
import org.drools.brms.client.modeldriven.brxml.ActionFieldValue;
import org.drools.brms.client.modeldriven.brxml.ActionSetField;
+import org.drools.brms.client.modeldriven.brxml.ActionUpdateField;
import org.drools.brms.client.modeldriven.brxml.FactPattern;
import org.drools.brms.client.modeldriven.brxml.RuleModel;
import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
@@ -71,8 +72,13 @@
}
private void create() {
+ String modifyType = "set";
+ if (this.set instanceof ActionUpdateField) {
+ modifyType = "modify";
+ }
+
toolkit.createLabel( parent,
- HumanReadable.getActionDisplayName( this.set.getType() ) + " [" + this.set.variable + "]" );
+ HumanReadable.getActionDisplayName( modifyType ) + " [" + this.set.variable + "]" );
addDeleteRHSAction();
addMoreOptionsAction();
addRows();
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java 2007-06-13 22:11:50 UTC (rev 12565)
@@ -1,9 +1,7 @@
package org.drools.eclipse.rulebuilder.ui;
import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
-import org.drools.brms.client.modeldriven.brxml.Constraint;
import org.drools.brms.client.modeldriven.brxml.FactPattern;
-import org.drools.brms.client.modeldriven.brxml.IConstraint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -108,7 +106,8 @@
"New formula",
SWT.PUSH );
- formulaButton.addListener( SWT.Selection,
+ //TODO: adjust to new API
+ /* formulaButton.addListener( SWT.Selection,
new Listener() {
public void handleEvent(Event event) {
Constraint con = new Constraint();
@@ -118,7 +117,7 @@
modeller.reloadLhs();
close();
}
- } );
+ } );*/
formulaButton.setLayoutData( gd );
}
@@ -137,7 +136,9 @@
}
fieldsCombo.select( 0 );
- fieldsCombo.addListener( SWT.Selection,
+
+ //TODO: adjust to new API
+ /* fieldsCombo.addListener( SWT.Selection,
new Listener() {
public void handleEvent(Event event) {
if ( fieldsCombo.getSelectionIndex() == 0 ) {
@@ -151,7 +152,7 @@
modeller.reloadLhs();
close();
}
- } );
+ } );*/
}
private SuggestionCompletionEngine getCompletion() {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java 2007-06-13 22:11:50 UTC (rev 12565)
@@ -5,10 +5,12 @@
import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
import org.drools.brms.client.modeldriven.brxml.CompositeFactPattern;
+import org.drools.brms.client.modeldriven.brxml.CompositeFieldConstraint;
import org.drools.brms.client.modeldriven.brxml.ConnectiveConstraint;
-import org.drools.brms.client.modeldriven.brxml.Constraint;
import org.drools.brms.client.modeldriven.brxml.FactPattern;
-import org.drools.brms.client.modeldriven.brxml.IConstraint;
+import org.drools.brms.client.modeldriven.brxml.FieldConstraint;
+import org.drools.brms.client.modeldriven.brxml.ISingleFieldConstraint;
+import org.drools.brms.client.modeldriven.brxml.SingleFieldConstraint;
import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -37,436 +39,418 @@
*/
public class FactPatternWidget extends Widget {
- private final CompositeFactPattern parentPattern;
+ private final CompositeFactPattern parentPattern;
- private final FactPattern pattern;
+ private final FactPattern pattern;
- public FactPatternWidget(FormToolkit toolkit,
- Composite parent,
- RuleModeller mod,
- FactPattern factPattern,
- CompositeFactPattern parentPattern,
- int idx) {
+ public FactPatternWidget(FormToolkit toolkit, Composite parent,
+ RuleModeller mod, FactPattern factPattern,
+ CompositeFactPattern parentPattern, int idx) {
- super( parent,
- toolkit,
- mod,
- idx );
+ super(parent, toolkit, mod, idx);
- this.pattern = factPattern;
- this.parentPattern = parentPattern;
+ this.pattern = factPattern;
+ this.parentPattern = parentPattern;
- GridLayout l = new GridLayout();
- l.numColumns = 4;
- l.marginBottom = 0;
- l.marginHeight = 0;
- l.marginLeft = 0;
- l.marginRight = 0;
- l.marginTop = 0;
- l.marginWidth = 0;
- l.verticalSpacing = 0;
- parent.setLayout( l );
+ GridLayout l = new GridLayout();
+ l.numColumns = 4;
+ l.marginBottom = 0;
+ l.marginHeight = 0;
+ l.marginLeft = 0;
+ l.marginRight = 0;
+ l.marginTop = 0;
+ l.marginWidth = 0;
+ l.verticalSpacing = 0;
+ parent.setLayout(l);
- create();
- }
+ create();
+ }
- private void create() {
- toolkit.createLabel( parent,
- getPatternLabel() );
- addDeleteAction();
- addMoreOptionsAction();
- Composite constraintComposite = toolkit.createComposite( parent );
- GridLayout constraintLayout = new GridLayout();
- constraintLayout.numColumns = 6;
- constraintComposite.setLayout( constraintLayout );
- createConstraintRows( constraintComposite );
- toolkit.paintBordersFor( constraintComposite );
- }
+ private void create() {
+ toolkit.createLabel(parent, getPatternLabel());
+ addDeleteAction();
+ addMoreOptionsAction();
+ Composite constraintComposite = toolkit.createComposite(parent);
+ GridLayout constraintLayout = new GridLayout();
+ constraintLayout.numColumns = 6;
+ constraintComposite.setLayout(constraintLayout);
+ renderFieldConstraints(constraintComposite, true);
+ toolkit.paintBordersFor(constraintComposite);
+ }
- private void addMoreOptionsAction() {
- ImageHyperlink link = addImage( parent,
- "icons/new_item.gif" );
+ private void addMoreOptionsAction() {
+ ImageHyperlink link = addImage(parent, "icons/new_item.gif");
- link.addHyperlinkListener( new IHyperlinkListener() {
- public void linkActivated(HyperlinkEvent e) {
- RuleDialog popup = new AddNewFieldConstraintDialog( parent.getShell(),
- toolkit,
- getModeller(),
- pattern,
- parentPattern != null );
- popup.open();
- }
+ link.addHyperlinkListener(new IHyperlinkListener() {
+ public void linkActivated(HyperlinkEvent e) {
+ RuleDialog popup = new AddNewFieldConstraintDialog(parent
+ .getShell(), toolkit, getModeller(), pattern,
+ parentPattern != null);
+ popup.open();
+ }
- public void linkEntered(HyperlinkEvent e) {
- }
+ public void linkEntered(HyperlinkEvent e) {
+ }
- public void linkExited(HyperlinkEvent e) {
- }
- } );
- link.setToolTipText( "Add a field to this condition, or bind a varible to this fact." );
- }
+ public void linkExited(HyperlinkEvent e) {
+ }
+ });
+ link.setToolTipText("Add a field to this condition, or bind a varible to this fact.");
+ }
- private void addDeleteAction() {
- ImageHyperlink delWholeLink = addImage( parent,
- "icons/delete_obj.gif" );
- delWholeLink.addHyperlinkListener( new IHyperlinkListener() {
- public void linkActivated(HyperlinkEvent e) {
- MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
- SWT.YES | SWT.NO | SWT.ICON_WARNING );
- dialog.setMessage( "Remove this ENTIRE condition, " + "and all the field constraints that belong to it." );
- dialog.setText( "Remove this entire condition?" );
- if ( dialog.open() == SWT.YES ) {
- if ( parentPattern == null ) {
- if ( getModeller().getModel().removeLhsItem( index ) ) {
- getModeller().reloadLhs();
- } else {
- showMessage( "Can't remove that item as it is used in the action part of the rule." );
- }
- } else {
- deleteBindedFact();
- }
- getModeller().setDirty( true );
- }
- }
+ private void addDeleteAction() {
+ ImageHyperlink delWholeLink = addImage(parent, "icons/delete_obj.gif");
+ delWholeLink.addHyperlinkListener(new IHyperlinkListener() {
+ public void linkActivated(HyperlinkEvent e) {
+ MessageBox dialog = new MessageBox(Display.getCurrent()
+ .getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
+ dialog.setMessage("Remove this ENTIRE condition, "
+ + "and all the field constraints that belong to it.");
+ dialog.setText("Remove this entire condition?");
+ if (dialog.open() == SWT.YES) {
+ if (parentPattern == null) {
+ if (getModeller().getModel().removeLhsItem(index)) {
+ getModeller().reloadLhs();
+ } else {
+ showMessage("Can't remove that item as it is used in the action part of the rule.");
+ }
+ } else {
+ deleteBindedFact();
+ }
+ getModeller().setDirty(true);
+ }
+ }
- public void linkEntered(HyperlinkEvent e) {
- }
+ public void linkEntered(HyperlinkEvent e) {
+ }
- public void linkExited(HyperlinkEvent e) {
- }
- } );
- delWholeLink.setToolTipText( "Remove this condition." );
- }
+ public void linkExited(HyperlinkEvent e) {
+ }
+ });
+ delWholeLink.setToolTipText("Remove this condition.");
+ }
- private void createConstraintRows(Composite constraintComposite) {
- for ( int row = 0; row < pattern.constraints.length; row++ ) {
- final Constraint c = pattern.constraints[row];
- if ( c.constraintValueType != IConstraint.TYPE_PREDICATE ) {
- createConstraintRow( constraintComposite,
- row,
- c );
- } else {
- createPredicateConstraintRow( constraintComposite,
- row,
- c );
- }
- }
- }
+ private void renderFieldConstraints(Composite constraintComposite, boolean showBinding) {
+ for (int row = 0; row < pattern.getFieldConstraints().length; row++) {
+ FieldConstraint constraint = pattern.getFieldConstraints()[row];
- private void createPredicateConstraintRow(Composite constraintComposite,
- int row,
- final Constraint c) {
- GridData gd = new GridData( GridData.FILL_HORIZONTAL );
- gd.horizontalSpan = 4;
- addImage( constraintComposite, "icons/function_assets.gif" );
- formulaValueEditor( constraintComposite, c, gd );
- addRemoveFieldAction( constraintComposite, row );
- }
+ if (constraint instanceof SingleFieldConstraint) {
+ renderSingleFieldConstraint(constraintComposite, row, constraint, showBinding);
+ } else if (constraint instanceof CompositeFieldConstraint) {
+ //TODO:
+ // compositeFieldConstraintEditor
+ }
+ }
+ }
- private void createConstraintRow(Composite constraintComposite,
- int row,
- final Constraint c) {
- toolkit.createLabel( constraintComposite, c.fieldName );
- if ( c.connectives == null || c.connectives.length == 0 ) {
- addRemoveFieldAction( constraintComposite, row );
- } else {
- toolkit.createLabel( constraintComposite, "" );
- }
- operatorDropDown( constraintComposite, c );
- constraintValueEditor( constraintComposite, c );
- createConnectives( constraintComposite, c );
- addConnectiveAction( constraintComposite, c );
- }
+ private void renderSingleFieldConstraint(Composite constraintComposite,
+ int row, FieldConstraint constraint, boolean showBinding) {
+ final SingleFieldConstraint c = (SingleFieldConstraint) constraint;
+ if (c.constraintValueType != SingleFieldConstraint.TYPE_PREDICATE) {
+ createConstraintRow(constraintComposite, row, c);
+ } else {
+ createPredicateConstraintRow(constraintComposite, row, c);
+ }
+ }
- private void createConnectives(Composite parent,
- Constraint c) {
- if ( c.connectives != null && c.connectives.length > 0 ) {
- for ( int i = 0; i < c.connectives.length; i++ ) {
+ private void createConstraintRow(Composite constraintComposite, int row,
+ final SingleFieldConstraint c) {
+ toolkit.createLabel(constraintComposite, c.fieldName);
+ if (c.connectives == null || c.connectives.length == 0) {
+ addRemoveFieldAction(constraintComposite, row);
+ } else {
+ toolkit.createLabel(constraintComposite, "");
+ }
+ operatorDropDown(constraintComposite, c);
+ constraintValueEditor(constraintComposite, c);
+ createConnectives(constraintComposite, c);
+ addConnectiveAction(constraintComposite, c);
+ }
- toolkit.createLabel( parent, "" ); // dummy
- toolkit.createLabel( parent, "" ); // dummy
- // toolkit.createLabel(parent, ""); // dummy
+ private void createPredicateConstraintRow(Composite constraintComposite,
+ int row, final SingleFieldConstraint c) {
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 4;
+ addImage(constraintComposite, "icons/function_assets.gif");
+ formulaValueEditor(constraintComposite, c, gd);
+ addRemoveFieldAction(constraintComposite, row);
+ }
- ConnectiveConstraint con = c.connectives[i];
- addRemoveConstraintAction( parent, c, con );
- connectiveOperatorDropDown( parent, con, c.fieldName );
- constraintValueEditor( parent, con );
+ private void createConnectives(Composite parent, SingleFieldConstraint c) {
+ if (c.connectives != null && c.connectives.length > 0) {
+ for (int i = 0; i < c.connectives.length; i++) {
- }
- }
- }
+ toolkit.createLabel(parent, ""); // dummy
+ toolkit.createLabel(parent, ""); // dummy
+ // toolkit.createLabel(parent, ""); // dummy
- private void addConnectiveAction(Composite constraintComposite,
- final Constraint c) {
- ImageHyperlink link = addImage( constraintComposite,
- "icons/add_connective.gif" );
- link.setToolTipText( "Add more options to this fields values." );
- link.addHyperlinkListener( new IHyperlinkListener() {
- public void linkActivated(HyperlinkEvent e) {
- c.addNewConnective();
- getModeller().reloadLhs();
- getModeller().setDirty( true );
- }
+ ConnectiveConstraint con = c.connectives[i];
+ addRemoveConstraintAction(parent, c, con);
+ connectiveOperatorDropDown(parent, con, c.fieldName);
+ constraintValueEditor(parent, con);
- public void linkEntered(HyperlinkEvent e) {
- }
+ }
+ }
+ }
- public void linkExited(HyperlinkEvent e) {
- }
- } );
- }
+ private void addConnectiveAction(Composite constraintComposite,
+ final SingleFieldConstraint c) {
+ ImageHyperlink link = addImage(constraintComposite,
+ "icons/add_connective.gif");
+ link.setToolTipText("Add more options to this fields values.");
+ link.addHyperlinkListener(new IHyperlinkListener() {
+ public void linkActivated(HyperlinkEvent e) {
+ c.addNewConnective();
+ getModeller().reloadLhs();
+ getModeller().setDirty(true);
+ }
- private void addRemoveFieldAction(Composite constraintComposite,
- final int currentRow) {
- ImageHyperlink delLink = addImage( constraintComposite,
- "icons/delete_item_small.gif" );
- delLink.setToolTipText( "Remove this fieldconstraint" );
- delLink.addHyperlinkListener( new IHyperlinkListener() {
- public void linkActivated(HyperlinkEvent e) {
- MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
- SWT.YES | SWT.NO | SWT.ICON_WARNING );
- dialog.setMessage( "Remove this item?" );
- dialog.setText( "Remove this item?" );
- if ( dialog.open() == SWT.YES ) {
- pattern.removeConstraint( currentRow );
- getModeller().reloadLhs();
- getModeller().setDirty( true );
- }
- }
+ public void linkEntered(HyperlinkEvent e) {
+ }
- public void linkEntered(HyperlinkEvent e) {
- }
+ public void linkExited(HyperlinkEvent e) {
+ }
+ });
+ }
- public void linkExited(HyperlinkEvent e) {
- }
- } );
- delLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END ) );
- }
+ private void addRemoveFieldAction(Composite constraintComposite,
+ final int currentRow) {
+ ImageHyperlink delLink = addImage(constraintComposite,
+ "icons/delete_item_small.gif");
+ delLink.setToolTipText("Remove this fieldconstraint");
+ delLink.addHyperlinkListener(new IHyperlinkListener() {
+ public void linkActivated(HyperlinkEvent e) {
+ MessageBox dialog = new MessageBox(Display.getCurrent()
+ .getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
+ dialog.setMessage("Remove this item?");
+ dialog.setText("Remove this item?");
+ if (dialog.open() == SWT.YES) {
+ pattern.removeConstraint(currentRow);
+ getModeller().reloadLhs();
+ getModeller().setDirty(true);
+ }
+ }
- private void addRemoveConstraintAction(Composite composite,
- final Constraint constraint,
- final ConnectiveConstraint connConstraint) {
- ImageHyperlink delLink = addImage( composite,
- "icons/delete_item_small.gif" );
- delLink.setToolTipText( "Remove this field constraint" );
- delLink.addHyperlinkListener( new IHyperlinkListener() {
- public void linkActivated(HyperlinkEvent e) {
- MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
- SWT.YES | SWT.NO | SWT.ICON_WARNING );
- dialog.setMessage( "Remove this item?" );
- dialog.setText( "Remove this item?" );
- if ( dialog.open() == SWT.YES ) {
- ConnectiveConstraint[] connectives = constraint.connectives;
- List nConnectives = new ArrayList();
- for ( int i = 0; i < connectives.length; i++ ) {
- if ( connectives[i] != connConstraint ) {
- nConnectives.add( connectives[i] );
- }
- }
- constraint.connectives = (ConnectiveConstraint[]) nConnectives.toArray( new ConnectiveConstraint[nConnectives.size()] );
+ public void linkEntered(HyperlinkEvent e) {
+ }
- getModeller().reloadLhs();
- getModeller().setDirty( true );
- }
- }
+ public void linkExited(HyperlinkEvent e) {
+ }
+ });
+ delLink.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_END));
+ }
- public void linkEntered(HyperlinkEvent e) {
- }
+ private void addRemoveConstraintAction(Composite composite,
+ final FieldConstraint constraint,
+ final ConnectiveConstraint connConstraint) {
+ ImageHyperlink delLink = addImage(composite,
+ "icons/delete_item_small.gif");
+ delLink.setToolTipText("Remove this field constraint");
+ delLink.addHyperlinkListener(new IHyperlinkListener() {
+ public void linkActivated(HyperlinkEvent e) {
+ MessageBox dialog = new MessageBox(Display.getCurrent()
+ .getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
+ dialog.setMessage("Remove this item?");
+ dialog.setText("Remove this item?");
+ if (dialog.open() == SWT.YES) {
+ //TODO: how to delete constraints
+
+ /*ConnectiveConstraint[] connectives = constraint.connectives;
+ List nConnectives = new ArrayList();
+ for (int i = 0; i < connectives.length; i++) {
+ if (connectives[i] != connConstraint) {
+ nConnectives.add(connectives[i]);
+ }
+ }
+ constraint.connectives = (ConnectiveConstraint[]) nConnectives
+ .toArray(new ConnectiveConstraint[nConnectives
+ .size()]);
- public void linkExited(HyperlinkEvent e) {
- }
- } );
- delLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END ) );
- }
+ getModeller().reloadLhs();
+ getModeller().setDirty(true);*/
+ }
+ }
- /**
- * This returns the pattern label.
- */
- private String getPatternLabel() {
- if ( pattern.boundName != null ) {
- return pattern.factType + " [" + pattern.boundName + "]";
- }
- return pattern.factType;
- }
+ public void linkEntered(HyperlinkEvent e) {
+ }
- private void operatorDropDown(Composite parent,
- final Constraint c) {
- String[] ops = getCompletions().getOperatorCompletions( pattern.factType,
- c.fieldName );
- final Combo box = new Combo( parent,
- SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY );
- for ( int i = 0; i < ops.length; i++ ) {
- String op = ops[i];
- box.add( HumanReadable.getOperatorDisplayName( op ) );
- if ( op.equals( c.operator ) ) {
- box.select( i );
- }
- }
- box.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
- box.addListener( SWT.Selection,
- new Listener() {
- public void handleEvent(Event event) {
- c.operator = HumanReadable.getOperatorName( box.getText() );
- getModeller().setDirty( true );
- }
- } );
- }
+ public void linkExited(HyperlinkEvent e) {
+ }
+ });
+ delLink.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_END));
+ }
- private void connectiveOperatorDropDown(Composite parent,
- final ConnectiveConstraint con,
- String fieldName) {
- String[] ops = getCompletions().getConnectiveOperatorCompletions( pattern.factType,
- fieldName );
- final Combo box = new Combo( parent,
- SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY );
- for ( int i = 0; i < ops.length; i++ ) {
- String op = ops[i];
- box.add( HumanReadable.getOperatorDisplayName( op ) );
- if ( op.equals( con.operator ) ) {
- box.select( i );
- }
- }
- box.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
- box.addModifyListener( new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- con.operator = HumanReadable.getOperatorName( box.getText() );
- getModeller().setDirty( true );
- }
- } );
- }
+ /**
+ * This returns the pattern label.
+ */
+ private String getPatternLabel() {
+ if (pattern.boundName != null) {
+ return pattern.factType + " [" + pattern.boundName + "]";
+ }
+ return pattern.factType;
+ }
- // from org.drools.brms.client.modeldriven.ui.ConstraintValueEditor
- private void constraintValueEditor(final Composite parent,
- final IConstraint c) {
- if ( c.constraintValueType == IConstraint.TYPE_UNDEFINED ) {
- ImageHyperlink link = addImage( parent,
- "icons/edit.gif" );
- link.setToolTipText( "Choose value editor type" );
- link.addHyperlinkListener( new IHyperlinkListener() {
- public void linkActivated(HyperlinkEvent e) {
- RuleDialog popup = new ValueEditorTypeSelectionDialog( parent.getShell(),
- toolkit,
- getModeller(),
- c );
- popup.open();
- }
+ private void operatorDropDown(Composite parent, final SingleFieldConstraint c) {
+ String[] ops = getCompletions().getOperatorCompletions(
+ pattern.factType, c.fieldName);
+ final Combo box = new Combo(parent, SWT.SIMPLE | SWT.DROP_DOWN
+ | SWT.READ_ONLY);
+ for (int i = 0; i < ops.length; i++) {
+ String op = ops[i];
+ box.add(HumanReadable.getOperatorDisplayName(op));
+ if (op.equals(c.operator)) {
+ box.select(i);
+ }
+ }
+ box.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ box.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ c.operator = HumanReadable.getOperatorName(box.getText());
+ getModeller().setDirty(true);
+ }
+ });
+ }
- public void linkEntered(HyperlinkEvent e) {
- }
+ private void connectiveOperatorDropDown(Composite parent,
+ final ConnectiveConstraint con, String fieldName) {
+ String[] ops = getCompletions().getConnectiveOperatorCompletions(
+ pattern.factType, fieldName);
+ final Combo box = new Combo(parent, SWT.SIMPLE | SWT.DROP_DOWN
+ | SWT.READ_ONLY);
+ for (int i = 0; i < ops.length; i++) {
+ String op = ops[i];
+ box.add(HumanReadable.getOperatorDisplayName(op));
+ if (op.equals(con.operator)) {
+ box.select(i);
+ }
+ }
+ box.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ box.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ con.operator = HumanReadable.getOperatorName(box.getText());
+ getModeller().setDirty(true);
+ }
+ });
+ }
- public void linkExited(HyperlinkEvent e) {
- }
- } );
+ // from org.drools.brms.client.modeldriven.ui.ConstraintValueEditor
+ private void constraintValueEditor(final Composite parent, final ISingleFieldConstraint c) {
+ if (c.constraintValueType == SingleFieldConstraint.TYPE_UNDEFINED) {
+ ImageHyperlink link = addImage(parent, "icons/edit.gif");
+ link.setToolTipText("Choose value editor type");
+ link.addHyperlinkListener(new IHyperlinkListener() {
+ public void linkActivated(HyperlinkEvent e) {
+ /*RuleDialog popup = new ValueEditorTypeSelectionDialog(
+ parent.getShell(), toolkit, getModeller(), c);
+ popup.open();*/
+ }
- toolkit.createLabel( parent,
- "" );// dummy
- } else {
- switch ( c.constraintValueType ) {
- case IConstraint.TYPE_LITERAL :
- literalValueEditor( parent,
- c,
- new GridData( GridData.FILL_HORIZONTAL ) );
- break;
- case IConstraint.TYPE_RET_VALUE :
- addImage( parent,
- "icons/function_assets.gif" );
- formulaValueEditor( parent,
- c,
- new GridData( GridData.FILL_HORIZONTAL ) );
- break;
- case IConstraint.TYPE_VARIABLE :
- variableEditor( parent,
- c );
- break;
- default :
- break;
- }
- }
- }
+ public void linkEntered(HyperlinkEvent e) {
+ }
- private void variableEditor(Composite composite,
- final IConstraint c) {
- List vars = getModeller().getModel().getBoundVariablesInScope( c );
+ public void linkExited(HyperlinkEvent e) {
+ }
+ });
- final Combo combo = new Combo( composite,
- SWT.READ_ONLY );
+ toolkit.createLabel(parent, "");// dummy
+ } else {
+ switch (c.constraintValueType) {
+ case SingleFieldConstraint.TYPE_LITERAL:
+ literalValueEditor(parent, c, new GridData(GridData.FILL_HORIZONTAL));
+ break;
+ case SingleFieldConstraint.TYPE_RET_VALUE:
+ addImage(parent, "icons/function_assets.gif");
+ formulaValueEditor(parent, c, new GridData(GridData.FILL_HORIZONTAL));
+ break;
+ case SingleFieldConstraint.TYPE_VARIABLE:
+ variableEditor(parent, c);
+ break;
+ default:
+ break;
+ }
+ }
+ }
- if ( c.value == null ) {
- combo.add( "Choose ..." );
- }
+ private void variableEditor(Composite composite, final ISingleFieldConstraint c) {
+ List vars = getModeller().getModel().getBoundVariablesInScope(c);
- for ( int i = 0; i < vars.size(); i++ ) {
- String var = (String) vars.get( i );
- if ( c.value != null && c.value.equals( var ) ) {
- combo.select( i );
- }
- combo.add( var );
- }
+ final Combo combo = new Combo(composite, SWT.READ_ONLY);
- combo.addModifyListener( new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- c.value = combo.getText();
- }
- } );
+ if (c.value == null) {
+ combo.add("Choose ...");
+ }
- }
+ for (int i = 0; i < vars.size(); i++) {
+ String var = (String) vars.get(i);
+ if (c.value != null && c.value.equals(var)) {
+ combo.select(i);
+ }
+ combo.add(var);
+ }
- private void literalValueEditor(Composite parent,
- final IConstraint c,
- GridData gd) {
- final Text box = toolkit.createText( parent,
- "" );
+ combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ c.value = combo.getText();
+ }
+ });
- if ( c.value != null ) {
- box.setText( c.value );
- }
+ }
- gd.horizontalSpan = 2;
- box.setLayoutData( gd );
+ private void literalValueEditor(Composite parent, final ISingleFieldConstraint c,
+ GridData gd) {
+ final Text box = toolkit.createText(parent, "");
- box.addModifyListener( new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- c.value = box.getText();
- getModeller().setDirty( true );
- }
- } );
- }
+ if (c.value != null) {
+ box.setText(c.value);
+ }
- private void formulaValueEditor(Composite parent,
- final IConstraint c,
- GridData gd) {
+ gd.horizontalSpan = 2;
+ box.setLayoutData(gd);
- final Text box = toolkit.createText( parent,
- "" );
+ box.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ c.value = box.getText();
+ getModeller().setDirty(true);
+ }
+ });
+ }
- if ( c.value != null ) {
- box.setText( c.value );
- }
+ private void formulaValueEditor(Composite parent, final ISingleFieldConstraint c,
+ GridData gd) {
- box.setLayoutData( gd );
+ final Text box = toolkit.createText(parent, "");
- box.addModifyListener( new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- c.value = box.getText();
- getModeller().setDirty( true );
- }
- } );
+ if (c.value != null) {
+ box.setText(c.value);
+ }
- }
+ box.setLayoutData(gd);
- private void deleteBindedFact() {
- List newPatterns = new ArrayList();
- for ( int i = 0; i < parentPattern.patterns.length; i++ ) {
- if ( parentPattern.patterns[i] != pattern ) {
- newPatterns.add( parentPattern.patterns[i] );
- }
- }
- parentPattern.patterns = (FactPattern[]) newPatterns.toArray( new FactPattern[newPatterns.size()] );
- getModeller().reloadLhs();
- }
+ box.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ c.value = box.getText();
+ getModeller().setDirty(true);
+ }
+ });
- private SuggestionCompletionEngine getCompletions() {
- return getModeller().getSuggestionCompletionEngine();
- }
+ }
+ private void deleteBindedFact() {
+ List newPatterns = new ArrayList();
+ for (int i = 0; i < parentPattern.patterns.length; i++) {
+ if (parentPattern.patterns[i] != pattern) {
+ newPatterns.add(parentPattern.patterns[i]);
+ }
+ }
+ parentPattern.patterns = (FactPattern[]) newPatterns
+ .toArray(new FactPattern[newPatterns.size()]);
+ getModeller().reloadLhs();
+ }
+
+ private SuggestionCompletionEngine getCompletions() {
+ return getModeller().getSuggestionCompletionEngine();
+ }
+
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java 2007-06-13 21:41:45 UTC (rev 12564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java 2007-06-13 22:11:50 UTC (rev 12565)
@@ -1,6 +1,5 @@
package org.drools.eclipse.rulebuilder.ui;
-import org.drools.brms.client.modeldriven.brxml.IConstraint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -16,16 +15,18 @@
private RuleModeller modeller;
- private IConstraint constraint;
+ // private IConstraint constraint;
public ValueEditorTypeSelectionDialog(Shell parent,
FormToolkit toolkit,
- RuleModeller modeller,
- IConstraint constraint) {
+ RuleModeller modeller
+ //,
+ //IConstraint constraint
+ ) {
super(parent,"Select value editor type","Select value editor type" );
this.toolkit = toolkit;
this.modeller = modeller;
- this.constraint = constraint;
+ //this.constraint = constraint;
}
protected Control createDialogArea(final Composite parent) {
@@ -38,7 +39,10 @@
valueTypeCombo.add( "Literal value" ); // 0
valueTypeCombo.add( "A formula" ); // 1
- if ( modeller.getModel().getBoundVariablesInScope( constraint ).size() > 0 ) {
+
+ //TODO: adjust to new API
+
+ /* if ( modeller.getModel().getBoundVariablesInScope( constraint ).size() > 0 ) {
valueTypeCombo.add( "Bound variable" ); // 2
}
@@ -46,7 +50,7 @@
public void modifyText(ModifyEvent e) {
switch ( valueTypeCombo.getSelectionIndex() ) {
case 0 :
- constraint.constraintValueType = IConstraint.TYPE_LITERAL;
+ constraint.constraintValueType = IFieldConstraint.TYPE_LITERAL;
break;
case 1 :
constraint.constraintValueType = IConstraint.TYPE_RET_VALUE;
@@ -59,7 +63,7 @@
modeller.setDirty( true );
close();
}
- } );
+ } );*/
toolkit.paintBordersFor( composite );
return composite;
More information about the jboss-svn-commits
mailing list