[jboss-svn-commits] JBL Code SVN: r31248 - labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jan 27 07:20:44 EST 2010


Author: baunax
Date: 2010-01-27 07:20:44 -0500 (Wed, 27 Jan 2010)
New Revision: 31248

Modified:
   labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
Log:
changes to support collections

Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java	2010-01-27 12:20:04 UTC (rev 31247)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java	2010-01-27 12:20:44 UTC (rev 31248)
@@ -1,5 +1,6 @@
 package org.drools.guvnor.client.modeldriven.ui;
 
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -95,42 +96,60 @@
 	}
 	
 	private Widget getWidgetForCurrentType() {
-		ListBox lb = new ListBox();
-		lb.setVisibleItemCount(1);
-		lb.addItem(constants.ChooseDotDotDot(), "");
-		for (Map.Entry<String, String> entry: getCompletionsForCurrentType().entrySet()) {
-			lb.addItem(entry.getKey(), entry.getValue());
+		String factName = getCompletionEngine().getFactNameFromType(getCurrentType());
+		if (factName != null) {
+			ListBox lb = new ListBox();
+			lb.setVisibleItemCount(1);
+			lb.addItem(constants.ChooseDotDotDot(), "");
+			for (Map.Entry<String, String> entry : getCompletionsForCurrentType()
+					.entrySet()) {
+				lb.addItem(entry.getKey(), entry.getValue());
+			}
+
+			lb.addChangeListener(new ChangeListener() {
+				public void onChange(Widget sender) {
+					ListBox box = (ListBox) sender;
+					panel.remove(box);
+					if (box.getSelectedIndex() > 0) {
+						onChangeSelection(box.getValue(box.getSelectedIndex()));
+					}
+				}
+			});
+			return lb;
+		} else if (isCollection()) {
+			ListBox lb = new ListBox();
+			lb.setVisibleItemCount(1);
+			lb.addItem(constants.ChooseDotDotDot(), "");
+			return lb;
 		}
-		
-		lb.addChangeListener(new ChangeListener() {
-			public void onChange(Widget sender) {
-				ListBox box = (ListBox) sender;
-				panel.remove(box);
-				if (box.getSelectedIndex() > 0) {
-					onChangeSelection(box.getValue(box.getSelectedIndex()));
-				}
-			}
-		});
-		return lb;
+		return null;
 	}
 	
+	private boolean isCollection() {
+		String previousType = expression.getPreviousType();
+		String factName = getCompletionEngine().getFactNameFromType(previousType);
+		return true;
+	}
+
 	private void onChangeSelection(String value) {
 		int dotPos = value.indexOf('.');
 		String prefix = value.substring(0, dotPos);
 		String option = value.substring(dotPos + 1);
 		Widget w = null;
+		String factName = getCompletionEngine().getFactNameFromType(getCurrentType());
+		
 		if (FIElD_VALUE_PREFIX.equals(prefix)) {
-			String factName = getCompletionEngine().getFactNameFromType(getCurrentType());
 			String fieldClassName = getCompletionEngine().getFieldClassName(factName, option);
 			expression.appendPart(new ExpressionField(option, fieldClassName));
 		} else if (METHOD_VALUE_PREFIX.equals(prefix)) {
-			String factName = getCompletionEngine().getFactNameFromType(getCurrentType());
-			String methodType = getCompletionEngine().getMethodType(factName, option);
+			String methodType = getCompletionEngine().getMethodClassType(factName, option);
 			expression.appendPart(new ExpressionMethod(
 					option.substring(0, option.indexOf('(')), 
 					methodType));
-		}
+		} 
 		w = getWidgetForCurrentType();
+		
+		
 		panel.clear();
 		panel.add(new Label(expression.getText()));
 		if (w != null) {



More information about the jboss-svn-commits mailing list