[jboss-svn-commits] JBL Code SVN: r31111 - in labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban: drools-compiler/src/main/java/org/drools/guvnor/server/rules and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jan 15 22:53:17 EST 2010
Author: baunax
Date: 2010-01-15 22:53:16 -0500 (Fri, 15 Jan 2010)
New Revision: 31111
Modified:
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/rules/SuggestionCompletionLoader.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngineTest.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/dt/GuidedDecisionTableTest.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/server/rules/SuggestionCompletionLoaderTest.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/DataInputWidget.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/FieldDataConstraintEditor.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFactWidget.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFieldConstraintEditor.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FactTypeBrowser.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/PopulateDataTest.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/rules/BRMSSuggestionCompletionLoaderTest.java
Log:
merge with previous branch
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -53,13 +53,13 @@
/**
* A list of fact types (never fully qualified).
*/
- public String[] factTypes;
+ private String[] factTypes;
/**
* A map of types to the fields. key is type, value is (String[] of fields)
*
*/
- public Map<String, String[]> fieldsForType;
+ private Map<String, String[]> fieldsForType;
/**
* A map of the Fields to their types, needed for operator completions, as
@@ -68,33 +68,33 @@
* perhaps just a high level interface, eg "Comparable".
*
*/
- public Map<String, String> fieldTypes;
+ private Map<String, String> fieldTypes;
/**
* A map of the field that containts the parametrized type of a collection
* List<String> name
* key = "name"
- * value = "Strint"
+ * value = "String"
*
*/
- public Map<String, String> fieldParametersType = new HashMap<String, String>();
+ private Map<String, String> fieldParametersType = new HashMap<String, String>();
/**
* Contains a map of globals (name is key) and their type (value).
*/
- public Map<String, String> globalTypes = new HashMap();
+ private Map<String, String> globalTypes = new HashMap();
/**
* A map of types to the modifying methods they expose. key is type, value
* is (Sting[] of modifying methods)
*
**/
- public Map<String, String> modifiers;
+ private Map<String, String[]> modifiers;
/**
* Contains a map of { TypeName.field : String[] } - where a list is valid
* values to display in a drop down for a given Type.field combination.
*/
- public Map<String, String[]> dataEnumLists = new HashMap<String, String[]>(); // TODO this is
+ private Map<String, String[]> dataEnumLists = new HashMap<String, String[]>(); // TODO this is
// a PROBLEM as
// its not
// always
@@ -103,7 +103,7 @@
/**
* This will show the names of globals that are a collection type.
*/
- public String[] globalCollections;
+ private String[] globalCollections;
/** Operators (from the grammar):
* op=( '=='
@@ -187,7 +187,7 @@
public String[] getConnectiveOperatorCompletions(final String factType,
final String fieldName) {
- final String type = (String) this.fieldTypes.get( factType + "." + fieldName );
+ final String type = (String) this.getFieldType( factType + "." + fieldName );
if ( type == null ) {
return STANDARD_CONNECTIVES;
} else if ( type.equals( TYPE_STRING ) ) {
@@ -202,18 +202,16 @@
}
- public String[] getFactTypes() {
- return this.factTypes;
- }
+
public String[] getFieldCompletions(final String factType) {
- return (String[]) this.fieldsForType.get( factType );
+ return this.getFieldsForType( factType );
}
public String[] getOperatorCompletions(final String factType,
final String fieldName) {
- final String type = (String) this.fieldTypes.get( factType + "." + fieldName );
+ final String type = (String) this.getFieldType( factType + "." + fieldName );
if ( type == null ) {
return STANDARD_OPERATORS;
} else if ( type.equals( TYPE_STRING ) ) {
@@ -228,41 +226,16 @@
}
- /**
- * A map of the Fields to their types, needed for operator completions, as
- * well as other things like rendering strings, dates etc. This is in the
- * format of: { 'Type.field' => 'typename' }. Should not be the exact type,
- * perhaps just a high level interface, eg "Comparable", "Numeric",
- * "String".
- *
- */
- public String getFieldType(final String factType,
- final String fieldName) {
- return (String) this.fieldTypes.get( factType + "." + fieldName );
- }
- /*
- * returns the type of parametric class
- * List<String> a in a class called Toto
- * key = "Toto.a"
- * value = "String"
- */
- public String getParametricFieldType(final String factType,
- final String fieldName) {
- return (String) this.fieldParametersType.get( factType + "." + fieldName );
- }
+
- public boolean isGlobalVariable(final String variable) {
- return this.globalTypes.containsKey( variable );
- }
-
public String[] getFieldCompletionsForGlobalVariable(final String varName) {
- final String type = (String) this.globalTypes.get( varName );
- return (String[]) this.fieldsForType.get( type );
+ final String type = (String) this.getGlobalVariable( varName );
+ return (String[]) this.getFieldsForType( type );
}
public List<MethodInfo> getMethodInfosForGlobalVariable(final String varName) {
- final String type = (String) this.globalTypes.get( varName );
+ final String type = (String) this.getGlobalVariable( varName );
return this.methodInfos.get( type );
}
@@ -276,10 +249,6 @@
return f;
}
- public String[] getGlobalVariables() {
- return toStringArray( this.globalTypes.keySet() );
- }
-
/**
* This returns a list of enums options (values) that can be used for the
* given field of the given FactPattern.
@@ -331,7 +300,7 @@
key += "]";
}
- return DropDownData.create( (String[]) this.dataEnumLists.get( key ) );
+ return DropDownData.create( (String[]) this.getDataEnumList(key) );
} else if ( _typeFields != null ) {
// these enums are calculated on demand, server side...
@@ -385,7 +354,7 @@
ActionFieldValue val = currentValues[i];
if ( val.field.equals( typeField ) ) {
String key = type + "." + field + "[" + typeField + "=" + val.value + "]";
- return DropDownData.create( (String[]) this.dataEnumLists.get( key ) );
+ return DropDownData.create( (String[]) this.getDataEnumList( key ) );
}
}
} else if ( _typeField != null ) {
@@ -412,7 +381,7 @@
}
}
- String[] vals = (String[]) this.dataEnumLists.get( type + "." + field );
+ String[] vals = (String[]) this.getDataEnumList( type + "." + field );
return DropDownData.create( vals );
}
@@ -451,10 +420,10 @@
continue;
}
- String[] qry = (String[]) dataEnumLists.get( key );
+ String[] qry = getDataEnumList( key );
return qry[0];
} else if ( key.startsWith( factType + "." + field ) && (fieldsNeeded == null || fieldsNeeded.length == 0) ) {
- String[] qry = (String[]) dataEnumLists.get( key );
+ String[] qry = getDataEnumList( key );
return qry[0];
}
}
@@ -466,7 +435,7 @@
*/
public String[] getEnumValues(String factType,
String field) {
- return (String[]) this.dataEnumLists.get( factType + "." + field );
+ return this.getDataEnumList( factType + "." + field );
}
/**
@@ -548,4 +517,138 @@
return methodList;
}
+
+
+
+
+ /**
+ * A map of the Fields to their types, needed for operator completions, as
+ * well as other things like rendering strings, dates etc. This is in the
+ * format of: { 'Type.field' => 'typename' }. Should not be the exact type,
+ * perhaps just a high level interface, eg "Comparable", "Numeric",
+ * "String".
+ *
+ */
+ public String getFieldType(final String factType,
+ final String fieldName) {
+ return this.getFieldType( factType + "." + fieldName );
+ }
+
+ public String getFieldType(String fieldName){
+ return this.fieldTypes.get(fieldName);
+ }
+
+ public void setFieldTypes(Map<String,String> fieldTypes){
+ this.fieldTypes = fieldTypes;
+ }
+
+ public void putFieldType(String fieldName, String type){
+ this.fieldTypes.put(fieldName, type);
+ }
+
+
+
+ public void setFactTypes(String[] factTypes) {
+ this.factTypes = factTypes;
+ }
+
+ public String[] getFactTypes() {
+ return this.factTypes;
+ }
+
+
+
+ public String[] getFieldsForType(String type){
+ return this.fieldsForType.get(type);
+ }
+
+ public void setFieldsForType(Map<String,String[]> fieldsForType){
+ this.fieldsForType = fieldsForType;
+ }
+
+
+ /*
+ * returns the type of parametric class
+ * List<String> a in a class called Toto
+ * key = "Toto.a"
+ * value = "String"
+ */
+ public String getParametricFieldType(final String factType,
+ final String fieldName) {
+ return this.getParametricFieldType( factType + "." + fieldName );
+ }
+
+ public String getParametricFieldType(String fieldName){
+ return this.fieldParametersType.get(fieldName);
+ }
+
+ public void putParametricFieldType(String fieldName, String type){
+ this.fieldParametersType.put(fieldName, type);
+ }
+
+
+
+ public String getGlobalVariable(String name){
+ return this.globalTypes.get(name);
+ }
+
+ public boolean isGlobalVariable(String name){
+ return this.globalTypes.containsKey(name);
+ }
+
+ public void setGlobalVariables(Map<String, String> globalTypes){
+ this.globalTypes = globalTypes;
+ }
+
+ public String[] getGlobalVariables() {
+ return toStringArray( this.globalTypes.keySet() );
+ }
+
+
+
+ public void setModifiers(Map<String,String[]> map){
+ this.modifiers = map;
+ }
+
+ public String[] getModifiers(String name){
+ return this.modifiers.get(name);
+ }
+
+
+
+ public void setGlobalCollections(String[] globalCollections){
+ this.globalCollections = globalCollections;
+ }
+
+ public String[] getGlobalCollections() {
+ return this.globalCollections;
+ }
+
+
+
+
+ public String[] getDataEnumList(String type){
+ return this.dataEnumLists.get(type);
+ }
+
+ public void setDataEnumLists(Map<String,String[]> data){
+ this.dataEnumLists = data;
+ }
+
+ public void putDataEnumList(String name,String[] value){
+ this.dataEnumLists.put(name, value);
+ }
+
+ public void putAllDataEnumLists(Map<String,String[]> value){
+ this.dataEnumLists.putAll(value);
+ }
+
+ public int getDataEnumListsSize(){
+ return this.dataEnumLists.size();
+ }
+
+ public boolean hasDataEnumLists(){
+ return this.dataEnumLists != null && this.dataEnumLists.size() > 0;
+ }
+
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/rules/SuggestionCompletionLoader.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/rules/SuggestionCompletionLoader.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/rules/SuggestionCompletionLoader.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -141,7 +141,7 @@
populateDateEnums(dataEnums, sce);
- Arrays.sort(sce.factTypes);
+ Arrays.sort(sce.getFactTypes());
return sce;
}
@@ -153,7 +153,7 @@
if (enumLoader.hasErrors()) {
this.errors.addAll(enumLoader.getErrors());
} else {
- sce.dataEnumLists.putAll(enumLoader.getData());
+ sce.putAllDataEnumLists(enumLoader.getData());
}
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -171,10 +171,10 @@
* @return
*/
public SuggestionCompletionEngine getInstance() {
- this.instance.factTypes = (String[]) this.factTypes.toArray( new String[this.factTypes.size()] );
- this.instance.fieldsForType = this.fieldsForType;
- this.instance.modifiers = this.modifiersForType;
- this.instance.fieldTypes = this.fieldTypes;
+ this.instance.setFactTypes((String[]) this.factTypes.toArray( new String[this.factTypes.size()] ));
+ this.instance.setFieldsForType(this.fieldsForType);
+ this.instance.setModifiers(this.modifiersForType);
+ this.instance.setFieldTypes(this.fieldTypes);
for (String fieldName : this.fieldTypesField.keySet()){
Field field = (Field) this.fieldTypesField.get(fieldName);
if (field != null){
@@ -187,7 +187,7 @@
}
int index = goodType.toString().lastIndexOf(".");
String className = goodType.toString().substring(index + 1);
- this.instance.fieldParametersType.put(fieldName, className);
+ this.instance.putParametricFieldType(fieldName, className);
}
@@ -208,17 +208,17 @@
a[i] = value;
i++;
}
- this.instance.dataEnumLists.put(fieldName, a);
+ this.instance.putDataEnumList(fieldName, a);
}
}
}
- this.instance.globalTypes = this.globalTypes;
+ this.instance.setGlobalVariables(this.globalTypes);
this.instance.actionDSLSentences = makeArray(this.actionDSLSentences);
this.instance.conditionDSLSentences = makeArray(this.conditionDSLSentences);
this.instance.keywordDSLItems = makeArray(this.keywordDSLItems);
this.instance.anyScopeDSLItems = makeArray(this.anyScopeDSLItems);
- this.instance.globalCollections = this.globalCollections.toArray(new String[globalCollections.size()]);
+ this.instance.setGlobalCollections(this.globalCollections.toArray(new String[globalCollections.size()]));
return this.instance;
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngineTest.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngineTest.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngineTest.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -60,8 +60,8 @@
"name" ) );
assertEquals( 3,
- engine.dataEnumLists.size() );
- String[] items = (String[]) engine.dataEnumLists.get( "Person.age" );
+ engine.getDataEnumListsSize());
+ String[] items = (String[]) engine.getDataEnumList( "Person.age" );
assertEquals( 2,
items.length );
assertEquals( "42",
@@ -108,9 +108,9 @@
"field2" ) );
assertEquals( 4,
- engine.dataEnumLists.size() );
+ engine.getDataEnumListsSize() );
- String[] items = (String[]) engine.dataEnumLists.get( "Fact.field2" );
+ String[] items = (String[]) engine.getDataEnumList( "Fact.field2" );
assertEquals( 2,
items.length );
assertEquals( "val3",
@@ -130,7 +130,7 @@
assertEquals( "val4",
items[1] );
- items = (String[]) engine.dataEnumLists.get( "Fact.field1" );
+ items = (String[]) engine.getDataEnumList( "Fact.field1" );
assertEquals( 2,
items.length );
assertEquals( "val1",
@@ -153,16 +153,16 @@
final SuggestionCompletionEngine com = new SuggestionCompletionEngine();
- com.factTypes = new String[]{"Person", "Vehicle"};
- com.fieldsForType = new HashMap() {
+ com.setFactTypes(new String[]{"Person", "Vehicle"});
+ com.setFieldsForType(new HashMap() {
{
put( "Person",
new String[]{"age", "name", "rank"} );
put( "Vehicle",
new String[]{"type", "make"} );
}
- };
- com.fieldTypes = new HashMap() {
+ });
+ com.setFieldTypes(new HashMap() {
{
put( "Person.age",
"Numeric" );
@@ -175,15 +175,15 @@
put( "Vehicle.type",
"String" );
}
- };
- com.globalTypes = new HashMap() {
+ });
+ com.setGlobalVariables(new HashMap() {
{
put( "bar",
"Person" );
put( "baz",
"Vehicle" );
}
- };
+ });
String[] c = com.getConditionalElements();
assertEquals( "not",
@@ -295,13 +295,13 @@
public void testAdd() {
final SuggestionCompletionEngine com = new SuggestionCompletionEngine();
- com.factTypes = new String[]{"Foo"};
- com.fieldsForType = new HashMap() {
+ com.setFactTypes(new String[]{"Foo"});
+ com.setFieldsForType(new HashMap() {
{
put( "Foo",
new String[]{"a"} );
}
- };
+ });
assertEquals( 1,
com.getFactTypes().length );
@@ -317,12 +317,12 @@
public void testSmartEnums() {
final SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists = new HashMap();
- sce.dataEnumLists.put( "Fact.type",
+ sce.setDataEnumLists(new HashMap());
+ sce.putDataEnumList( "Fact.type",
new String[]{"sex", "colour"} );
- sce.dataEnumLists.put( "Fact.value[type=sex]",
+ sce.putDataEnumList( "Fact.value[type=sex]",
new String[]{"M", "F"} );
- sce.dataEnumLists.put( "Fact.value[type=colour]",
+ sce.putDataEnumList( "Fact.value[type=colour]",
new String[]{"RED", "WHITE", "BLUE"} );
FactPattern pat = new FactPattern( "Fact" );
@@ -389,14 +389,14 @@
public void testSmartEnumsDependingOfSeveralFieldsTwo() {
final SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists = new HashMap();
- sce.dataEnumLists.put( "Fact.field1",
+ sce.setDataEnumLists(new HashMap());
+ sce.putDataEnumList( "Fact.field1",
new String[]{"a1", "a2"} );
- sce.dataEnumLists.put( "Fact.field2",
+ sce.putDataEnumList( "Fact.field2",
new String[]{"b1", "b2"} );
- sce.dataEnumLists.put( "Fact.field3[field1=a1,field2=b1]",
+ sce.putDataEnumList( "Fact.field3[field1=a1,field2=b1]",
new String[]{"c1", "c2", "c3"} );
- sce.dataEnumLists.put( "Fact.field4[field1=a1]",
+ sce.putDataEnumList( "Fact.field4[field1=a1]",
new String[]{"d1", "d2"} );
FactPattern pat = new FactPattern( "Fact" );
@@ -422,18 +422,18 @@
public void testSmartEnumsDependingOfSeveralFieldsFive() {
final SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists = new HashMap();
- sce.dataEnumLists.put( "Fact.field1",
+ sce.setDataEnumLists(new HashMap());
+ sce.putDataEnumList( "Fact.field1",
new String[]{"a1", "a2"} );
- sce.dataEnumLists.put( "Fact.field2",
+ sce.putDataEnumList( "Fact.field2",
new String[]{"b1", "b2"} );
- sce.dataEnumLists.put( "Fact.field3",
+ sce.putDataEnumList( "Fact.field3",
new String[]{"c1", "c2", "c3"} );
- sce.dataEnumLists.put( "Fact.longerField4",
+ sce.putDataEnumList( "Fact.longerField4",
new String[]{"d1", "d2"} );
- sce.dataEnumLists.put( "Fact.field5",
+ sce.putDataEnumList( "Fact.field5",
new String[]{"e1", "e2"} );
- sce.dataEnumLists.put( "Fact.field6[field1=a1, field2=b2, field3=c3,longerField4=d1,field5=e2]",
+ sce.putDataEnumList( "Fact.field6[field1=a1, field2=b2, field3=c3,longerField4=d1,field5=e2]",
new String[]{"f1", "f2"} );
FactPattern pat = new FactPattern( "Fact" );
@@ -469,10 +469,10 @@
public void testSmarterLookupEnums() {
final SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists = new HashMap();
- sce.dataEnumLists.put( "Fact.type",
+ sce.setDataEnumLists(new HashMap());
+ sce.putDataEnumList( "Fact.type",
new String[]{"sex", "colour"} );
- sce.dataEnumLists.put( "Fact.value[f1, f2]",
+ sce.putDataEnumList( "Fact.value[f1, f2]",
new String[]{"select something from database where x=@{f1} and y=@{f2}"} );
FactPattern fp = new FactPattern( "Fact" );
@@ -546,12 +546,12 @@
public void testSmarterLookupEnumsDifferentOrder() {
final SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists = new HashMap();
- sce.dataEnumLists.put( "Fact.type",
+ sce.setDataEnumLists(new HashMap());
+ sce.putDataEnumList( "Fact.type",
new String[]{"sex", "colour"} );
- sce.dataEnumLists.put( "Fact.value[e1, e2]",
+ sce.putDataEnumList( "Fact.value[e1, e2]",
new String[]{"select something from database where x=@{e1} and y=@{e2}"} );
- sce.dataEnumLists.put( "Fact.value[f1, f2]",
+ sce.putDataEnumList( "Fact.value[f1, f2]",
new String[]{"select something from database where x=@{f1} and y=@{f2}"} );
FactPattern fp = new FactPattern( "Fact" );
@@ -625,8 +625,8 @@
public void testSimpleEnums() {
final SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists = new HashMap();
- sce.dataEnumLists.put( "Fact.type",
+ sce.setDataEnumLists(new HashMap());
+ sce.putDataEnumList( "Fact.type",
new String[]{"sex", "colour"} );
assertEquals( 2,
sce.getEnumValues( "Fact",
@@ -655,18 +655,19 @@
public void testGlobalAndFacts() {
final SuggestionCompletionEngine com = new SuggestionCompletionEngine();
- com.globalTypes = new HashMap() {
+ com.setGlobalVariables(new HashMap() {
{
put( "y",
"Foo" );
}
- };
- com.fieldsForType = new HashMap() {
+ });
+
+ com.setFieldsForType(new HashMap() {
{
put( "Foo",
new String[]{"a"} );
}
- };
+ });
assertFalse( com.isGlobalVariable( "x" ) );
assertTrue( com.isGlobalVariable( "y" ) );
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/dt/GuidedDecisionTableTest.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/dt/GuidedDecisionTableTest.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/modeldriven/dt/GuidedDecisionTableTest.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -138,8 +138,8 @@
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists.put("Driver.name", new String[] {"bob", "michael"});
- sce.dataEnumLists.put("Person.rating", new String[] {"1", "2"});
+ sce.putDataEnumList("Driver.name", new String[] {"bob", "michael"});
+ sce.putDataEnumList("Person.rating", new String[] {"1", "2"});
@@ -204,9 +204,9 @@
public void testNumeric() {
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.fieldTypes = new HashMap();
- sce.fieldTypes.put("Driver.age", SuggestionCompletionEngine.TYPE_NUMERIC);
- sce.fieldTypes.put("Driver.name", SuggestionCompletionEngine.TYPE_STRING);
+ sce.setFieldTypes(new HashMap());
+ sce.putFieldType("Driver.age", SuggestionCompletionEngine.TYPE_NUMERIC);
+ sce.putFieldType("Driver.name", SuggestionCompletionEngine.TYPE_STRING);
GuidedDecisionTable dt = new GuidedDecisionTable();
@@ -296,7 +296,7 @@
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists.put("Driver.name", new String[] {"bob", "michael"});
+ sce.putDataEnumList("Driver.name", new String[] {"bob", "michael"});
assertEquals(0, dt.getValueList(c1, sce).length);
assertEquals(3, dt.getValueList(c2, sce).length);
@@ -315,9 +315,9 @@
dt.conditionCols.add(c1);
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.fieldTypes = new HashMap();
- sce.fieldTypes.put("Driver.age", SuggestionCompletionEngine.TYPE_NUMERIC);
- sce.fieldTypes.put("Driver.name", SuggestionCompletionEngine.TYPE_STRING);
+ sce.setFieldTypes(new HashMap());
+ sce.putFieldType("Driver.age", SuggestionCompletionEngine.TYPE_NUMERIC);
+ sce.putFieldType("Driver.name", SuggestionCompletionEngine.TYPE_STRING);
assertFalse(dt.isNumeric(c1, sce));
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/server/rules/SuggestionCompletionLoaderTest.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/server/rules/SuggestionCompletionLoaderTest.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/test/java/org/drools/guvnor/server/rules/SuggestionCompletionLoaderTest.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -55,9 +55,9 @@
assertFalse(loader.hasErrors());
assertNotNull(eng);
- assertEquals(2, eng.factTypes.length);
- assertEquals("GenBean", eng.factTypes[0]);
- assertEquals("GenBean2", eng.factTypes[1]);
+ assertEquals(2, eng.getFactTypes().length);
+ assertEquals("GenBean", eng.getFactTypes()[0]);
+ assertEquals("GenBean2", eng.getFactTypes()[1]);
assertEquals(SuggestionCompletionEngine.TYPE_NUMERIC, eng.getFieldType( "GenBean", "id" ));
assertEquals(SuggestionCompletionEngine.TYPE_STRING, eng.getFieldType( "GenBean", "name"));
@@ -75,11 +75,11 @@
assertEquals(1, eng.getGlobalVariables().length);
assertEquals("p", eng.getGlobalVariables()[0]);
- assertEquals("Person", eng.globalTypes.get("p"));
- String[] flds = (String[]) eng.fieldsForType.get("Person");
+ assertEquals("Person", eng.getGlobalVariable("p"));
+ String[] flds = (String[]) eng.getFieldsForType("Person");
assertNotNull(flds);
- assertEquals(0, eng.globalCollections.length);
+ assertEquals(0, eng.getGlobalCollections().length);
}
@@ -92,11 +92,11 @@
assertEquals(1, eng.getGlobalVariables().length);
assertEquals("ls", eng.getGlobalVariables()[0]);
- assertEquals("List", eng.globalTypes.get("ls"));
+ assertEquals("List", eng.getGlobalVariable("ls"));
- assertNotNull(eng.globalCollections);
- assertEquals(1, eng.globalCollections.length);
- assertEquals("ls", eng.globalCollections[0]);
+ assertNotNull(eng.getGlobalCollections());
+ assertEquals(1, eng.getGlobalCollections().length);
+ assertEquals("ls", eng.getGlobalCollections()[0]);
}
@@ -120,9 +120,9 @@
SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.drools.guvnor.server.rules.SomeFact", new ArrayList(), new ArrayList() );
assertNotNull(eng);
- assertNotNull(eng.dataEnumLists);
- assertEquals(eng.dataEnumLists.get("SomeFact.anEnum").length,3);
- String a[] = eng.dataEnumLists.get("SomeFact.anEnum") ;
+ assertTrue(eng.hasDataEnumLists());
+ assertEquals(eng.getDataEnumList("SomeFact.anEnum").length,3);
+ String a[] = eng.getDataEnumList("SomeFact.anEnum") ;
assertEquals(a[0],"0="+EnumClass.v1);
assertEquals(a[1],"1="+EnumClass.v2);
assertEquals(a[2],"2="+EnumClass.v3);
@@ -148,7 +148,7 @@
SuggestionCompletionLoader loader = new SuggestionCompletionLoader(mcl);
SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.foo.Bar", new ArrayList(), new ArrayList() );
assertNotNull(eng);
- assertNotNull(eng.dataEnumLists);
+ //assertNotNull(eng.dataEnumLists);
assertTrue(mcl.called);
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -261,8 +261,8 @@
final FormStylePopup pop = new FormStylePopup();
pop.setTitle( constants.NewFactSelectTheType() );
final ListBox types = new ListBox();
- for ( int i = 0; i < sce.factTypes.length; i++ ) {
- types.addItem( sce.factTypes[i] );
+ for ( int i = 0; i < sce.getFactTypes().length; i++ ) {
+ types.addItem( sce.getFactTypes()[i] );
}
pop.addAttribute( constants.FactType(),
types );
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -226,8 +226,8 @@
}
private String getFactType() {
- if ( sce.globalTypes.containsKey( editingCol.boundName ) ) {
- return sce.globalTypes.get( editingCol.boundName );
+ if ( sce.isGlobalVariable( editingCol.boundName ) ) {
+ return sce.getGlobalVariable( editingCol.boundName );
}
return getFactType( this.editingCol.boundName );
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -436,8 +436,8 @@
final FormStylePopup pop = new FormStylePopup();
pop.setTitle( constants.CreateANewFactPattern() );
final ListBox types = new ListBox();
- for ( int i = 0; i < sce.factTypes.length; i++ ) {
- types.addItem( sce.factTypes[i] );
+ for ( int i = 0; i < sce.getFactTypes().length; i++ ) {
+ types.addItem( sce.getFactTypes()[i] );
}
pop.addAttribute( constants.FactType(),
types );
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -72,7 +72,7 @@
i++;
}
- this.variableClass = (String) completions.globalTypes.get( set.variable );
+ this.variableClass = (String) completions.getGlobalVariable( set.variable );
} else {
FactPattern pattern = mod.getModel().getBoundFact( set.variable );
if ( pattern != null ) {
@@ -216,7 +216,7 @@
String type = "";
if ( this.completions.isGlobalVariable( this.model.variable ) ) {
- type = (String) this.completions.globalTypes.get( this.model.variable );
+ type = (String) this.completions.getGlobalVariable( this.model.variable );
} else {
if ( this.modeller.getModel().getBoundFact( this.model.variable ) != null ) {
type = this.modeller.getModel().getBoundFact( this.model.variable ).factType;
@@ -273,9 +273,8 @@
private Widget actionSelector(final ActionFieldFunction val) {
final ListBox box = new ListBox();
- final Map modMap = this.completions.modifiers;
final String fieldType = val.type;
- final String[] modifiers = (String[]) modMap.get( fieldType );
+ final String[] modifiers = this.completions.getModifiers( fieldType );
if ( modifiers != null ) {
for ( int i = 0; i < modifiers.length; i++ ) {
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -67,7 +67,7 @@
layout.setStyleName( "model-builderInner-Background" );
if (completions.isGlobalVariable( set.variable )) {
this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable( set.variable );
- this.variableClass = (String) completions.globalTypes.get( set.variable );
+ this.variableClass = (String) completions.getGlobalVariable( set.variable );
} else {
FactPattern pattern = mod.getModel().getBoundFact( set.variable );
if (pattern !=null){
@@ -204,7 +204,7 @@
String type = "";
if (this.completions.isGlobalVariable(this.model.variable)) {
- type = (String) this.completions.globalTypes.get(this.model.variable);
+ type = (String) this.completions.getGlobalVariable(this.model.variable);
} else {
type = this.modeller.getModel().getBoundFact(this.model.variable).factType;
/*
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -629,10 +629,10 @@
//now global collections
- if (completions.globalCollections.length > 0 && vars.size() > 0) {
+ if (completions.getGlobalCollections().length > 0 && vars.size() > 0) {
for (String bf : vars) {
- for(int i = 0; i < completions.globalCollections.length; i++) {
- final String glob = completions.globalCollections[i];
+ for(int i = 0; i < completions.getGlobalCollections().length; i++) {
+ final String glob = completions.getGlobalCollections()[i];
final String var = bf;
choices.addItem(Format.format(constants.Append0ToList1(), var, glob), "GLOBCOL" + glob + var); //NON-NLS
cmds.put("GLOBCOL" + glob + var, new Command() { //NON-NLS
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -203,7 +203,7 @@
public void onChange(Widget w) {
String fieldName = box.getItemText( box.getSelectedIndex() );
String qualifiedName = factType + "." + fieldName;
- String fieldType = (String) completions.fieldTypes.get(qualifiedName);
+ String fieldType = (String) completions.getFieldType(qualifiedName);
pattern.addConstraint( new SingleFieldConstraint( fieldName, fieldType, con ) );
modeller.refreshWidget();
popup.hide();
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/DataInputWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/DataInputWidget.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/DataInputWidget.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -104,7 +104,7 @@
}
}
- String[] fields = (String[]) sce.fieldsForType.get(type);
+ String[] fields = (String[]) sce.getFieldsForType(type);
final FormStylePopup pop = new FormStylePopup(); //NON-NLS
pop.setTitle(constants.ChooseDotDotDot());
final ListBox b = new ListBox();
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/FieldDataConstraintEditor.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/FieldDataConstraintEditor.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/FieldDataConstraintEditor.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -56,7 +56,7 @@
private void refreshEditor() {
String key = factType + "." + field.name;
- String flType = sce.fieldTypes.get( key );
+ String flType = sce.getFieldType(key);
panel.clear();
if ( flType.equals( SuggestionCompletionEngine.TYPE_NUMERIC ) ) {
final TextBox box = editableTextBox( callback,
@@ -75,7 +75,7 @@
},
DropDownData.create( c ) ) );
} else {
- String[] enums = sce.dataEnumLists.get( key );
+ String[] enums = sce.getDataEnumList( key );
if ( enums != null ) {
panel.add( new EnumDropDown( field.value,
new DropDownValueChanged() {
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/ScenarioWidget.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -53,12 +53,12 @@
public class ScenarioWidget extends Composite {
- private String[] availableRules;
- private SuggestionCompletionEngine sce;
- private ChangeListener ruleSelectionCL;
- RuleAsset asset;
- VerticalPanel layout;
- boolean showResults;
+ private String[] availableRules;
+ private SuggestionCompletionEngine sce;
+ private ChangeListener ruleSelectionCL;
+ RuleAsset asset;
+ VerticalPanel layout;
+ boolean showResults;
private Constants constants = ((Constants) GWT.create(Constants.class));
public ScenarioWidget(RuleAsset asset, RuleViewer viewer) {
@@ -66,22 +66,22 @@
}
public ScenarioWidget(RuleAsset asset) {
- this.asset = asset;
- this.layout = new VerticalPanel();
- this.showResults = false;
+ this.asset = asset;
+ this.layout = new VerticalPanel();
+ this.showResults = false;
- this.sce = SuggestionCompletionCache.getInstance().getEngineFromCache(asset.metaData.packageName);
+ this.sce = SuggestionCompletionCache.getInstance().getEngineFromCache(asset.metaData.packageName);
- Scenario scenario = (Scenario) asset.content;
- if (scenario.fixtures.size() == 0) {
- scenario.fixtures.add(new ExecutionTrace());
- }
+ Scenario scenario = (Scenario) asset.content;
+ if (scenario.fixtures.size() == 0) {
+ scenario.fixtures.add(new ExecutionTrace());
+ }
- if (!asset.isreadonly) {
+ if (!asset.isreadonly) {
// layout.setWidget(0, 0, new TestRunnerWidget(this, asset.metaData.packageName));
- layout.add(new TestRunnerWidget(this, asset.metaData.packageName));
- }
+ layout.add(new TestRunnerWidget(this, asset.metaData.packageName));
+ }
renderEditor();
@@ -98,128 +98,128 @@
}
+ void renderEditor() {
+ if (this.layout.getWidgetCount() == 2) {
+ this.layout.remove(1);
+ }
- void renderEditor() {
- if (this.layout.getWidgetCount() == 2) {
- this.layout.remove(1);
- }
-
-
- final Scenario scenario = (Scenario) asset.content;
- DirtyableFlexTable editorLayout = new DirtyableFlexTable();
- editorLayout.clear();
- editorLayout.setWidth("100%");
- editorLayout.setStyleName("model-builder-Background");
+ final Scenario scenario = (Scenario) asset.content;
+ DirtyableFlexTable editorLayout = new DirtyableFlexTable();
+ editorLayout.clear();
+ editorLayout.setWidth("100%");
+ editorLayout.setStyleName("model-builder-Background");
// this.layout.setWidget(1, 0, editorLayout);
- this.layout.add(editorLayout);
- ScenarioHelper hlp = new ScenarioHelper();
- List fixtures = hlp.lumpyMap(scenario.fixtures);
+ this.layout.add(editorLayout);
+ ScenarioHelper hlp = new ScenarioHelper();
+ List fixtures = hlp.lumpyMap(scenario.fixtures);
List<ExecutionTrace> listExecutionTrace = new ArrayList<ExecutionTrace>();
for (int i = 0; i < fixtures.size(); i++) {
- final Object f = fixtures.get(i);
- if (f instanceof ExecutionTrace) {
- listExecutionTrace.add((ExecutionTrace)f);
+ final Object f = fixtures.get(i);
+ if (f instanceof ExecutionTrace) {
+ listExecutionTrace.add((ExecutionTrace) f);
}
- }
+ }
int layoutRow = 1;
- int executionTraceLine=0;
+ int executionTraceLine = 0;
ExecutionTrace previousEx = null;
for (int i = 0; i < fixtures.size(); i++) {
- final Object f = fixtures.get(i);
- if (f instanceof ExecutionTrace) {
- previousEx = (ExecutionTrace) f;
- HorizontalPanel h = new HorizontalPanel();
- h.add(getNewExpectationButton(previousEx, scenario));
- h.add(new SmallLabel(constants.EXPECT()));
- editorLayout.setWidget(layoutRow, 0, h);
+ final Object f = fixtures.get(i);
+ if (f instanceof ExecutionTrace) {
+ previousEx = (ExecutionTrace) f;
+ HorizontalPanel h = new HorizontalPanel();
+ h.add(getNewExpectationButton(previousEx, scenario));
+ h.add(new SmallLabel(constants.EXPECT()));
+ editorLayout.setWidget(layoutRow, 0, h);
final ExecutionTrace et = (ExecutionTrace) previousEx;
Image del = new ImageButton("images/delete_item_small.gif", constants.DeleteItem(), new ClickListener() {
+
public void onClick(Widget w) {
- if ( Window.confirm(constants.AreYouSureYouWantToRemoveThisItem()) ) {
- scenario.removeExecutionTrace( et );
- renderEditor();
- }
+ if (Window.confirm(constants.AreYouSureYouWantToRemoveThisItem())) {
+ scenario.removeExecutionTrace(et);
+ renderEditor();
+ }
}
});
h.add(del);
executionTraceLine++;
- if (executionTraceLine>= listExecutionTrace.size()){
- executionTraceLine= listExecutionTrace.size()-1;
+ if (executionTraceLine >= listExecutionTrace.size()) {
+ executionTraceLine = listExecutionTrace.size() - 1;
}
- editorLayout.setWidget(layoutRow, 1, new ExecutionWidget(previousEx, showResults));
- //layout.setWidget(layoutRow, 2, getNewExpectationButton(previousEx, scenario, availableRules));
- editorLayout.getFlexCellFormatter().setHorizontalAlignment(layoutRow, 2, HasHorizontalAlignment.ALIGN_LEFT);
+ editorLayout.setWidget(layoutRow, 1, new ExecutionWidget(previousEx, showResults));
+ //layout.setWidget(layoutRow, 2, getNewExpectationButton(previousEx, scenario, availableRules));
+ editorLayout.getFlexCellFormatter().setHorizontalAlignment(layoutRow, 2, HasHorizontalAlignment.ALIGN_LEFT);
- } else if (f instanceof Map) {
- HorizontalPanel h = new HorizontalPanel();
- h.add(getNewDataButton(previousEx, scenario,listExecutionTrace.get(executionTraceLine)));
- h.add(new SmallLabel(constants.GIVEN()));
+ } else if (f instanceof Map) {
+ HorizontalPanel h = new HorizontalPanel();
+ h.add(getNewDataButton(previousEx, scenario, listExecutionTrace.get(executionTraceLine)));
+ h.add(new SmallLabel(constants.GIVEN()));
- editorLayout.setWidget(layoutRow, 0, h);
+ editorLayout.setWidget(layoutRow, 0, h);
- layoutRow++;
- Map given = (Map) f;
- VerticalPanel vert = new VerticalPanel();
- for (Iterator iterator = given.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry e = (Map.Entry) iterator.next();
- List itemList = (List) given.get(e.getKey());
- if ( e.getKey().equals( ScenarioHelper.RETRACT_KEY ) ) {
- vert.add( new RetractWidget( itemList,
- scenario ) );
- } else if ( e.getKey().equals( ScenarioHelper.ACTIVATE_RULE_FLOW_GROUP ) ) {
- vert.add( new ActivateRuleFlowWidget( itemList,
- scenario ) );
+ layoutRow++;
+ Map given = (Map) f;
+ VerticalPanel vert = new VerticalPanel();
+ for (Iterator iterator = given.entrySet().iterator(); iterator.hasNext();) {
+ Map.Entry e = (Map.Entry) iterator.next();
+ List itemList = (List) given.get(e.getKey());
+ if (e.getKey().equals(ScenarioHelper.RETRACT_KEY)) {
+ vert.add(new RetractWidget(itemList,
+ scenario));
+ } else if (e.getKey().equals(ScenarioHelper.ACTIVATE_RULE_FLOW_GROUP)) {
+ vert.add(new ActivateRuleFlowWidget(itemList,
+ scenario));
} else {
- vert.add( new DataInputWidget( (String) e.getKey(),
- itemList,
- false,
- scenario,
- sce,
- this,
- listExecutionTrace.get( executionTraceLine ) ) );
+ vert.add(new DataInputWidget((String) e.getKey(),
+ itemList,
+ false,
+ scenario,
+ sce,
+ this,
+ listExecutionTrace.get(executionTraceLine)));
}
- }
+ }
- if (given.size() > 0) {
- editorLayout.setWidget(layoutRow, 1, vert);
- } else {
- editorLayout.setWidget(layoutRow, 1, new HTML("<i><small>" + constants.AddInputDataAndExpectationsHere() + "</small></i>"));
- }
- } else {
- List l = (List) f;
- Fixture first = (Fixture) l.get(0);
- if ( first instanceof VerifyFact ) {
- doVerifyFacts( l,
- editorLayout,
- layoutRow,
- scenario,
- listExecutionTrace.get( executionTraceLine ) );
- } else if ( first instanceof VerifyRuleFired ) {
- editorLayout.setWidget( layoutRow,
- 1,
- new VerifyRulesFiredWidget( l,
- scenario,
- showResults ) );
+ if (given.size() > 0) {
+ editorLayout.setWidget(layoutRow, 1, vert);
+ } else {
+ editorLayout.setWidget(layoutRow, 1, new HTML("<i><small>" + constants.AddInputDataAndExpectationsHere() + "</small></i>"));
}
+ } else {
+ List l = (List) f;
+ Fixture first = (Fixture) l.get(0);
+ if (first instanceof VerifyFact) {
+ doVerifyFacts(l,
+ editorLayout,
+ layoutRow,
+ scenario,
+ listExecutionTrace.get(executionTraceLine));
+ } else if (first instanceof VerifyRuleFired) {
+ editorLayout.setWidget(layoutRow,
+ 1,
+ new VerifyRulesFiredWidget(l,
+ scenario,
+ showResults));
+ }
- }
- layoutRow++;
- }
+ }
+ layoutRow++;
+ }
//add more execution sections.
- Button addExecute = new Button(constants.MoreDotDot());
- addExecute.setTitle(constants.AddAnotherSectionOfDataAndExpectations());
- addExecute.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- scenario.fixtures.add(new ExecutionTrace());
- renderEditor();
- }
- });
+ Button addExecute = new Button(constants.MoreDotDot());
+ addExecute.setTitle(constants.AddAnotherSectionOfDataAndExpectations());
+ addExecute.addClickListener(new ClickListener() {
+
+ public void onClick(Widget w) {
+ scenario.fixtures.add(new ExecutionTrace());
+ renderEditor();
+ }
+ });
editorLayout.setWidget(layoutRow, 0, addExecute);
//layout.getFlexCellFormatter().setHorizontalAlignment(layoutRow, 1, HasHorizontalAlignment.ALIGN_CENTER);
layoutRow++;
@@ -239,7 +239,7 @@
VerticalPanel globalPanel = new VerticalPanel();
for (Iterator iterator = globals.entrySet().iterator(); iterator.hasNext();) {
Map.Entry e = (Map.Entry) iterator.next();
- globalPanel.add(new DataInputWidget((String)e.getKey(), (List) globals.get(e.getKey()), true, scenario, sce, this,previousEx));
+ globalPanel.add(new DataInputWidget((String) e.getKey(), (List) globals.get(e.getKey()), true, scenario, sce, this, previousEx));
}
HorizontalPanel h = new HorizontalPanel();
h.add(getNewGlobalButton(scenario));
@@ -248,338 +248,351 @@
//layoutRow++;
editorLayout.setWidget(layoutRow, 1, globalPanel);
- }
+ }
+ private Widget getNewGlobalButton(final Scenario scenario) {
+ Image newItem = new ImageButton("images/new_item.gif", constants.AddANewGlobalToThisScenario(), new ClickListener() {
+ public void onClick(Widget w) {
+ final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.NewGlobal());
- private Widget getNewGlobalButton(final Scenario scenario) {
- Image newItem = new ImageButton("images/new_item.gif", constants.AddANewGlobalToThisScenario(), new ClickListener() {
- public void onClick(Widget w) {
+ final ListBox factTypes = new ListBox();
- final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.NewGlobal());
+ for (String g : sce.getGlobalVariables()) {
+ factTypes.addItem(g);
+ }
- final ListBox factTypes = new ListBox();
- for (Iterator iterator = sce.globalTypes.keySet().iterator(); iterator
- .hasNext();) {
- String g = (String) iterator.next();
- factTypes.addItem(g);
- }
+ Button add = new Button("Add");
+ add.addClickListener(new ClickListener() {
- Button add = new Button("Add");
- add.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String fn = factTypes.getItemText(factTypes.getSelectedIndex());
- if (scenario.isFactNameExisting(fn)) {
- Window.alert(Format.format(constants.TheName0IsAlreadyInUsePleaseChooseAnotherName(), fn));
- } else {
- FactData ng = new FactData((String) sce.globalTypes.get(fn), fn, new ArrayList(), false);
- scenario.globals.add(ng);
- renderEditor();
- pop.hide();
- }
- }
- });
+ public void onClick(Widget w) {
+ String fn = factTypes.getItemText(factTypes.getSelectedIndex());
+ if (scenario.isFactNameExisting(fn)) {
+ Window.alert(Format.format(constants.TheName0IsAlreadyInUsePleaseChooseAnotherName(), fn));
+ } else {
+ FactData ng = new FactData((String) sce.getGlobalVariable(fn), fn, new ArrayList(), false);
+ scenario.globals.add(ng);
+ renderEditor();
+ pop.hide();
+ }
+ }
+ });
- HorizontalPanel insertFact = new HorizontalPanel();
- insertFact.add(factTypes); insertFact.add(add);
- pop.addAttribute(constants.GlobalColon(), insertFact);
+ HorizontalPanel insertFact = new HorizontalPanel();
+ insertFact.add(factTypes);
+ insertFact.add(add);
+ pop.addAttribute(constants.GlobalColon(), insertFact);
- pop.show();
- }
- });
+ pop.show();
+ }
+ });
- return newItem;
- }
+ return newItem;
+ }
+ /**
+ * This button gives a choice of modifying data, based on the positional context.
+ * @param previousEx
+ */
+ private Widget getNewDataButton(final ExecutionTrace previousEx, final Scenario scenario, final ExecutionTrace currentEx) {
+ Image newItem = new ImageButton("images/new_item.gif", constants.AddANewDataInputToThisScenario(), new ClickListener() {
- /**
- * This button gives a choice of modifying data, based on the positional context.
- * @param previousEx
- */
- private Widget getNewDataButton(final ExecutionTrace previousEx, final Scenario scenario,final ExecutionTrace currentEx) {
- Image newItem = new ImageButton("images/new_item.gif", constants.AddANewDataInputToThisScenario(), new ClickListener() {
- public void onClick(Widget w) {
+ public void onClick(Widget w) {
- final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.NewInput());
+ final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.NewInput());
- final ListBox factTypes = new ListBox();
- for (int i = 0; i < sce.factTypes.length; i++) {
- factTypes.addItem(sce.factTypes[i]);
- }
- final TextBox factName = new TextBox();
- factName.setVisibleLength(5);
+ final ListBox factTypes = new ListBox();
+ for (int i = 0; i < sce.getFactTypes().length; i++) {
+ factTypes.addItem(sce.getFactTypes()[i]);
+ }
+ final TextBox factName = new TextBox();
+ factName.setVisibleLength(5);
- Button add = new Button(constants.Add());
- add.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String fn = ("" + factName.getText()).trim();
- if (fn.equals("")
- || factName.getText().indexOf(' ') > -1) {
- Window.alert(constants.YouMustEnterAValidFactName());
- } else {
- if (scenario.isFactNameExisting(fn)) {
+ Button add = new Button(constants.Add());
+ add.addClickListener(new ClickListener() {
+
+ public void onClick(Widget w) {
+ String fn = ("" + factName.getText()).trim();
+ if (fn.equals("")
+ || factName.getText().indexOf(' ') > -1) {
+ Window.alert(constants.YouMustEnterAValidFactName());
+ } else {
+ if (scenario.isFactNameExisting(fn)) {
Window.alert(Format.format(constants.TheFactName0IsAlreadyInUsePleaseChooseAnotherName(), fn));
- } else {
- scenario.insertBetween(previousEx, new FactData(factTypes.getItemText(factTypes.getSelectedIndex()), factName.getText(), new ArrayList(), false ));
- renderEditor();
- pop.hide();
- }
- }
- }
- });
+ } else {
+ scenario.insertBetween(previousEx, new FactData(factTypes.getItemText(factTypes.getSelectedIndex()), factName.getText(), new ArrayList(), false));
+ renderEditor();
+ pop.hide();
+ }
+ }
+ }
+ });
- HorizontalPanel insertFact = new HorizontalPanel();
- insertFact.add(factTypes); insertFact.add(new SmallLabel(constants.FactName())); insertFact.add(factName); insertFact.add(add);
- pop.addAttribute(constants.InsertANewFact1(), insertFact);
+ HorizontalPanel insertFact = new HorizontalPanel();
+ insertFact.add(factTypes);
+ insertFact.add(new SmallLabel(constants.FactName()));
+ insertFact.add(factName);
+ insertFact.add(add);
+ pop.addAttribute(constants.InsertANewFact1(), insertFact);
- List varsInScope = scenario.getFactNamesInScope(currentEx, false);
- //now we do modifies & retracts
- if (varsInScope.size() > 0) {
- final ListBox modifyFacts = new ListBox();
- for (int j = 0; j < varsInScope.size(); j++) { modifyFacts.addItem((String) varsInScope.get(j));}
- add = new Button(constants.Add());
- add.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String fn = modifyFacts.getItemText(modifyFacts.getSelectedIndex());
- String type = (String) scenario.getVariableTypes().get(fn);
- scenario.insertBetween(previousEx, new FactData(type, fn, new ArrayList(), true));
- renderEditor();
- pop.hide();
- }
- });
- HorizontalPanel modifyFact = new HorizontalPanel();
- modifyFact.add(modifyFacts); modifyFact.add(add);
- pop.addAttribute(constants.ModifyAnExistingFactScenario(), modifyFact);
+ List varsInScope = scenario.getFactNamesInScope(currentEx, false);
+ //now we do modifies & retracts
+ if (varsInScope.size() > 0) {
+ final ListBox modifyFacts = new ListBox();
+ for (int j = 0; j < varsInScope.size(); j++) {
+ modifyFacts.addItem((String) varsInScope.get(j));
+ }
+ add = new Button(constants.Add());
+ add.addClickListener(new ClickListener() {
- //now we do retracts
- final ListBox retractFacts = new ListBox();
- for (int j = 0; j < varsInScope.size(); j++) { retractFacts.addItem((String) varsInScope.get(j));}
- add = new Button(constants.Add());
- add.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String fn = retractFacts.getItemText(retractFacts.getSelectedIndex());
- scenario.insertBetween(previousEx, new RetractFact(fn));
- renderEditor();
- pop.hide();
- }
- });
- HorizontalPanel retractFact = new HorizontalPanel();
- retractFact.add(retractFacts); retractFact.add(add);
- pop.addAttribute(constants.RetractAnExistingFactScenario(), retractFact);
+ public void onClick(Widget w) {
+ String fn = modifyFacts.getItemText(modifyFacts.getSelectedIndex());
+ String type = (String) scenario.getVariableTypes().get(fn);
+ scenario.insertBetween(previousEx, new FactData(type, fn, new ArrayList(), true));
+ renderEditor();
+ pop.hide();
+ }
+ });
+ HorizontalPanel modifyFact = new HorizontalPanel();
+ modifyFact.add(modifyFacts);
+ modifyFact.add(add);
+ pop.addAttribute(constants.ModifyAnExistingFactScenario(), modifyFact);
+ //now we do retracts
+ final ListBox retractFacts = new ListBox();
+ for (int j = 0; j < varsInScope.size(); j++) {
+ retractFacts.addItem((String) varsInScope.get(j));
+ }
+ add = new Button(constants.Add());
+ add.addClickListener(new ClickListener() {
- }
+ public void onClick(Widget w) {
+ String fn = retractFacts.getItemText(retractFacts.getSelectedIndex());
+ scenario.insertBetween(previousEx, new RetractFact(fn));
+ renderEditor();
+ pop.hide();
+ }
+ });
+ HorizontalPanel retractFact = new HorizontalPanel();
+ retractFact.add(retractFacts);
+ retractFact.add(add);
+ pop.addAttribute(constants.RetractAnExistingFactScenario(), retractFact);
- // Activate rule flows
- final TextBox ruleFlowName = new TextBox();
- final HorizontalPanel settingsPanel = new HorizontalPanel();
- settingsPanel.add( ruleFlowName);
-
- add = new Button( constants.Add() );
- add.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- scenario.insertBetween( previousEx,
- new ActivateRuleFlowGroup( ruleFlowName.getText() ) );
+
+ }
+
+ // Activate rule flows
+ final TextBox ruleFlowName = new TextBox();
+ final HorizontalPanel settingsPanel = new HorizontalPanel();
+ settingsPanel.add(ruleFlowName);
+
+ add = new Button(constants.Add());
+ add.addClickListener(new ClickListener() {
+
+ public void onClick(Widget w) {
+ scenario.insertBetween(previousEx,
+ new ActivateRuleFlowGroup(ruleFlowName.getText()));
// new RetractFact( ruleFlowName.getText() ) );
- renderEditor();
- pop.hide();
- }
- } );
+ renderEditor();
+ pop.hide();
+ }
+ });
- settingsPanel.add( add );
-
- pop.addAttribute( "Activate rule flow group", settingsPanel );
-
+ settingsPanel.add(add);
- pop.show();
+ pop.addAttribute("Activate rule flow group", settingsPanel);
- }
- });
- return newItem;
- }
+ pop.show();
+ }
+ });
+ return newItem;
+ }
- private Widget getNewExpectationButton(final ExecutionTrace ex,
- final Scenario sc) {
+ private Widget getNewExpectationButton(final ExecutionTrace ex,
+ final Scenario sc) {
- Image add = new ImageButton("images/new_item.gif", constants.AddANewExpectation(), new ClickListener() {
- public void onClick(Widget w) {
- final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.NewExpectation());
+ Image add = new ImageButton("images/new_item.gif", constants.AddANewExpectation(), new ClickListener() {
- Widget selectRule = getRuleSelectionWidget(asset.metaData.packageName, new RuleSelectionEvent() {
+ public void onClick(Widget w) {
+ final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.NewExpectation());
- public void ruleSelected(String name) {
- VerifyRuleFired vr = new VerifyRuleFired(name, null, new Boolean(true));
- sc.insertBetween(ex, vr);
- renderEditor();
- pop.hide();
- }
+ Widget selectRule = getRuleSelectionWidget(asset.metaData.packageName, new RuleSelectionEvent() {
- });
+ public void ruleSelected(String name) {
+ VerifyRuleFired vr = new VerifyRuleFired(name, null, new Boolean(true));
+ sc.insertBetween(ex, vr);
+ renderEditor();
+ pop.hide();
+ }
+ });
- pop.addAttribute(constants.Rule(), selectRule);
+ pop.addAttribute(constants.Rule(), selectRule);
- final ListBox facts = new ListBox();
- List names = sc.getFactNamesInScope(ex, true);
- for (Iterator iterator = names.iterator(); iterator.hasNext();) {
- facts.addItem((String) iterator.next());
- }
+ final ListBox facts = new ListBox();
+ List names = sc.getFactNamesInScope(ex, true);
+ for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+ facts.addItem((String) iterator.next());
+ }
- Button ok = new Button(constants.Add());
- ok.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String factName = facts.getItemText(facts.getSelectedIndex());
- sc.insertBetween(ex, new VerifyFact(factName, new ArrayList()));
- renderEditor();
- pop.hide();
- }
- });
+ Button ok = new Button(constants.Add());
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ String factName = facts.getItemText(facts.getSelectedIndex());
+ sc.insertBetween(ex, new VerifyFact(factName, new ArrayList()));
+ renderEditor();
+ pop.hide();
+ }
+ });
- HorizontalPanel h = new HorizontalPanel();
- h.add(facts);
- h.add(ok);
- pop.addAttribute(constants.FactValue(), h);
- //add in list box for anon facts
- final ListBox factTypes = new ListBox();
- for (int i = 0; i < sce.factTypes.length; i++) {
- String ft = sce.factTypes[i];
- factTypes.addItem(ft);
- }
+ HorizontalPanel h = new HorizontalPanel();
+ h.add(facts);
+ h.add(ok);
+ pop.addAttribute(constants.FactValue(), h);
- ok = new Button(constants.Add());
- ok.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String t = factTypes.getItemText(factTypes.getSelectedIndex());
- sc.insertBetween(ex, new VerifyFact(t, new ArrayList(), true));
- renderEditor();
- pop.hide();
- }
+ //add in list box for anon facts
+ final ListBox factTypes = new ListBox();
+ for (int i = 0; i < sce.getFactTypes().length; i++) {
+ String ft = sce.getFactTypes()[i];
+ factTypes.addItem(ft);
+ }
- });
+ ok = new Button(constants.Add());
+ ok.addClickListener(new ClickListener() {
- h = new HorizontalPanel();
- h.add(factTypes);
- h.add(ok);
- pop.addAttribute(constants.AnyFactThatMatches(), h);
+ public void onClick(Widget w) {
+ String t = factTypes.getItemText(factTypes.getSelectedIndex());
+ sc.insertBetween(ex, new VerifyFact(t, new ArrayList(), true));
+ renderEditor();
+ pop.hide();
+ }
+ });
+ h = new HorizontalPanel();
+ h.add(factTypes);
+ h.add(ok);
+ pop.addAttribute(constants.AnyFactThatMatches(), h);
- pop.show();
- }
- });
+ pop.show();
+ }
+ });
- return add;
- }
+ return add;
+ }
+ private void doVerifyFacts(List l, FlexTable layout, int layoutRow, final Scenario scenario, ExecutionTrace executionTrace) {
+ VerticalPanel vert = new VerticalPanel();
+ for (Iterator iterator = l.iterator(); iterator.hasNext();) {
+ final VerifyFact f = (VerifyFact) iterator.next();
+ HorizontalPanel h = new HorizontalPanel();
+ h.add(new VerifyFactWidget(f, scenario, sce, executionTrace, showResults));
+ Image del = new ImageButton("images/delete_item_small.gif", constants.DeleteTheExpectationForThisFact(), new ClickListener() { //NON-NLS
+ public void onClick(Widget w) {
+ if (Window.confirm(constants.AreYouSureYouWantToRemoveThisExpectation())) {
+ scenario.removeFixture(f);
+ renderEditor();
+ }
+ }
+ });
+ h.add(del);
+ vert.add(h);
+ }
+ layout.setWidget(layoutRow, 1, vert);
+ }
+ public Widget getRuleSelectionWidget(final String packageName, final RuleSelectionEvent selected) {
+ final HorizontalPanel h = new HorizontalPanel();
+ final TextBox t = new TextBox();
+ t.setTitle(constants.EnterRuleNameScenario());
+ h.add(t);
+ if (!(availableRules == null)) {
+ final ListBox availableRulesBox = new ListBox();
- private void doVerifyFacts(List l, FlexTable layout, int layoutRow, final Scenario scenario,ExecutionTrace executionTrace) {
- VerticalPanel vert = new VerticalPanel();
- for (Iterator iterator = l.iterator(); iterator.hasNext();) {
- final VerifyFact f = (VerifyFact) iterator.next();
- HorizontalPanel h = new HorizontalPanel();
- h.add(new VerifyFactWidget(f, scenario, sce,executionTrace,showResults));
- Image del = new ImageButton("images/delete_item_small.gif", constants.DeleteTheExpectationForThisFact(), new ClickListener() { //NON-NLS
- public void onClick(Widget w) {
- if (Window.confirm(constants.AreYouSureYouWantToRemoveThisExpectation())) {
- scenario.removeFixture(f);
- renderEditor();
- }
- }
- });
- h.add(del);
- vert.add(h);
- }
- layout.setWidget(layoutRow, 1, vert);
+ availableRulesBox.addItem(constants.pleaseChoose1());
+ for (int i = 0; i < availableRules.length; i++) {
+ availableRulesBox.addItem(availableRules[i]);
+ }
+ availableRulesBox.setSelectedIndex(0);
+ availableRulesBox.removeChangeListener(ruleSelectionCL);
+ ruleSelectionCL = new ChangeListener() {
- }
+ public void onChange(Widget w) {
+ t.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
+ }
+ };
- public Widget getRuleSelectionWidget(final String packageName, final RuleSelectionEvent selected) {
- final HorizontalPanel h = new HorizontalPanel();
- final TextBox t = new TextBox();
- t.setTitle(constants.EnterRuleNameScenario());
- h.add(t);
- if (!(availableRules == null)) {
- final ListBox availableRulesBox = new ListBox();
+ availableRulesBox.addChangeListener(ruleSelectionCL);
+ h.add(availableRulesBox);
- availableRulesBox.addItem(constants.pleaseChoose1());
- for (int i = 0; i < availableRules.length; i++) {
- availableRulesBox.addItem(availableRules[i]);
- }
- availableRulesBox.setSelectedIndex(0);
- availableRulesBox.removeChangeListener(ruleSelectionCL);
- ruleSelectionCL = new ChangeListener() {
- public void onChange(Widget w) {
- t.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
- }
- };
+ } else {
- availableRulesBox.addChangeListener(ruleSelectionCL);
- h.add(availableRulesBox);
+ final Button showList = new Button(constants.showListButton());
+ h.add(showList);
+ showList.addClickListener(new ClickListener() {
- } else {
+ public void onClick(Widget w) {
+ h.remove(showList);
+ final Image busy = new Image("images/searching.gif"); //NON-NLS
+ final Label loading = new SmallLabel(constants.loadingList1());
+ h.add(busy);
+ h.add(loading);
- final Button showList = new Button(constants.showListButton());
- h.add(showList);
- showList.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- h.remove(showList);
- final Image busy = new Image("images/searching.gif"); //NON-NLS
- final Label loading = new SmallLabel(constants.loadingList1());
- h.add(busy);
- h.add(loading);
+ DeferredCommand.addCommand(new Command() {
- DeferredCommand.addCommand(new Command() {
- public void execute() {
- RepositoryServiceFactory.getService().listRulesInPackage(packageName, new GenericCallback<String[]>() {
- public void onSuccess(String[] list) {
- availableRules = (list);
- final ListBox availableRulesBox = new ListBox();
- availableRulesBox.addItem(constants.pleaseChoose1());
- for (int i = 0; i < list.length; i++) {
- availableRulesBox.addItem(list[i]);
- }
- ruleSelectionCL = new ChangeListener() {
- public void onChange(Widget w) {
- t.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
- }
- };
- availableRulesBox.addChangeListener(ruleSelectionCL);
- availableRulesBox.setSelectedIndex(0);
- h.add(availableRulesBox);
- h.remove(busy);
- h.remove(loading);
- }
- });
- }
- });
+ public void execute() {
+ RepositoryServiceFactory.getService().listRulesInPackage(packageName, new GenericCallback<String[]>() {
+ public void onSuccess(String[] list) {
+ availableRules = (list);
+ final ListBox availableRulesBox = new ListBox();
+ availableRulesBox.addItem(constants.pleaseChoose1());
+ for (int i = 0; i < list.length; i++) {
+ availableRulesBox.addItem(list[i]);
+ }
+ ruleSelectionCL = new ChangeListener() {
- }
- });
+ public void onChange(Widget w) {
+ t.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
+ }
+ };
+ availableRulesBox.addChangeListener(ruleSelectionCL);
+ availableRulesBox.setSelectedIndex(0);
+ h.add(availableRulesBox);
+ h.remove(busy);
+ h.remove(loading);
+ }
+ });
+ }
+ });
- }
- Button ok = new Button(constants.OK());
- ok.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- selected.ruleSelected(t.getText());
- }
- });
- h.add(ok);
- return h;
- }
+ }
+ });
+ }
+
+ Button ok = new Button(constants.OK());
+ ok.addClickListener(new ClickListener() {
+
+ public void onClick(Widget w) {
+ selected.ruleSelected(t.getText());
+ }
+ });
+ h.add(ok);
+ return h;
+ }
+
// public static Widget editableCell(final ValueChanged changeEvent, String factType, String fieldName, String initialValue, SuggestionCompletionEngine sce) {
// String key = factType + "." + fieldName;
// String flType = sce.fieldTypes.get(key);
@@ -615,34 +628,27 @@
//
// return tb;
// }
+ /**
+ * Use some CSS trickery to get a percent bar.
+ */
+ public static Widget getBar(String colour, int width, float percent) {
+ int pixels = (int) (width * (percent / 100));
+ String h = "<div class=\"smallish-progress-wrapper\" style=\"width: " + width + "px\">"
+ + "<div class=\"smallish-progress-bar\" style=\"width: " + pixels + "px; background-color: " + colour + ";\"></div>"
+ + "<div class=\"smallish-progress-text\" style=\"width: " + width + "px\">" + (int) percent
+ + "%</div></div>"; //NON-NLS
+ return new HTML(h);
+ }
- /**
- * Use some CSS trickery to get a percent bar.
- */
- public static Widget getBar(String colour, int width, float percent) {
- int pixels = (int) (width * (percent / 100));
- String h = "<div class=\"smallish-progress-wrapper\" style=\"width: " + width + "px\">" +
- "<div class=\"smallish-progress-bar\" style=\"width: " + pixels + "px; background-color: " + colour + ";\"></div>" +
- "<div class=\"smallish-progress-text\" style=\"width: " + width + "px\">" + (int)percent
- + "%</div></div>"; //NON-NLS
- return new HTML(h);
+ public static Widget getBar(String colour, int width, int numerator, int denominator) {
+ int percent = 0;
- }
-
- public static Widget getBar(String colour, int width, int numerator, int denominator) {
- int percent = 0;
-
- if (denominator != 0) {
- percent = (int) ((((float)denominator - (float)numerator) / (float)denominator) * 100);
- }
- return getBar(colour, width, percent);
- }
-
-
-
-
-
+ if (denominator != 0) {
+ percent = (int) ((((float) denominator - (float) numerator) / (float) denominator) * 100);
+ }
+ return getBar(colour, width, percent);
+ }
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFactWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFactWidget.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFactWidget.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -52,7 +52,7 @@
Image add = new ImageButton("images/add_field_to_fact.gif", constants.AddAFieldToThisExpectation(), new ClickListener() { //NON-NLS
public void onClick(Widget w) {
- String[] fields = (String[]) sce.fieldsForType.get(type);
+ String[] fields = (String[]) sce.getFieldsForType(type);
final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.ChooseAFieldToAdd()); //NON-NLS
final ListBox b = new ListBox();
for (int i = 0; i < fields.length; i++) {
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFieldConstraintEditor.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFieldConstraintEditor.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/VerifyFieldConstraintEditor.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -56,7 +56,7 @@
private void refreshEditor() {
String key = factType + "." + field.fieldName;
- String flType = sce.fieldTypes.get( key );
+ String flType = sce.getFieldType( key );
panel.clear();
if ( flType.equals( SuggestionCompletionEngine.TYPE_NUMERIC ) ) {
final TextBox box = editableTextBox( callback,
@@ -75,7 +75,7 @@
},
DropDownData.create( c ) ) );
} else {
- String[] enums = sce.dataEnumLists.get( key );
+ String[] enums = sce.getDataEnumList( key );
if ( enums != null ) {
panel.add( new EnumDropDown( field.expected,
new DropDownValueChanged() {
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FactTypeBrowser.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FactTypeBrowser.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FactTypeBrowser.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -28,14 +28,14 @@
panel.add(hp);
panel.add(tree);
- if (sce.factTypes != null) {
- for (String type : sce.factTypes) {
+ if (sce.getFactTypes() != null) {
+ for (String type : sce.getFactTypes()) {
TreeItem it = new TreeItem();
it.setHTML("<img src=\"images/class.gif\"/><small>" + type + "</small>");
it.setUserObject(type + "( )");
tree.addItem(it);
- String[] fields = (String[]) sce.fieldsForType.get(type);
+ String[] fields = (String[]) sce.getFieldsForType(type);
if (fields != null) {
for (String field : fields) {
TreeItem fi = new TreeItem();
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/PopulateDataTest.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/PopulateDataTest.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/PopulateDataTest.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -109,8 +109,8 @@
SuggestionCompletionEngine eng = serv.loadSuggestionCompletionEngine( "com.billasurf.manufacturing.plant" );
assertNotNull(eng);
- assertEquals(2, eng.factTypes.length);
- String[] fields = (String[]) eng.fieldsForType.get( "Board" );
+ assertEquals(2, eng.getFactTypes().length);
+ String[] fields = (String[]) eng.getFieldsForType( "Board" );
assertTrue(fields.length >= 3);
String[] globalVars = eng.getGlobalVariables();
@@ -118,7 +118,7 @@
assertEquals("prs", globalVars[0]);
assertTrue(eng.getFieldCompletionsForGlobalVariable( "prs" ).length >= 2);
- fields = (String[]) eng.fieldsForType.get( "Person" );
+ fields = (String[]) eng.getFieldsForType( "Person" );
assertTrue(fields.length >= 2);
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -1471,9 +1471,9 @@
SuggestionCompletionEngine eng = impl
.loadSuggestionCompletionEngine(pkg.getName());
assertNotNull(eng);
- assertEquals(2, eng.factTypes.length);
+ assertEquals(2, eng.getFactTypes().length);
- for (String ft : eng.factTypes) {
+ for (String ft : eng.getFactTypes()) {
if (!(ft.equals("Board") || ft.equals("Whee"))) {
fail("Should be one of the above...");
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/rules/BRMSSuggestionCompletionLoaderTest.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/rules/BRMSSuggestionCompletionLoaderTest.java 2010-01-16 01:29:51 UTC (rev 31110)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/test/java/org/drools/guvnor/server/rules/BRMSSuggestionCompletionLoaderTest.java 2010-01-16 03:53:16 UTC (rev 31111)
@@ -134,8 +134,7 @@
SuggestionCompletionEngine eng = loader.getSuggestionEngine( item );
- assertNotNull(eng.dataEnumLists);
- assertEquals(Collections.EMPTY_MAP, eng.dataEnumLists);
+ assertFalse(eng.hasDataEnumLists());
assertFalse(loader.hasErrors());
assertEquals(1, eng.actionDSLSentences.length);
assertEquals(1, eng.conditionDSLSentences.length);
@@ -159,7 +158,7 @@
SuggestionCompletionEngine sce = loader.getSuggestionEngine( item );
assertFalse(loader.hasErrors());
- assertEquals(1, sce.dataEnumLists.size());
+ assertEquals(1, sce.getDataEnumListsSize());
asset.updateContent( "goober boy" );
More information about the jboss-svn-commits
mailing list