[jboss-svn-commits] JBL Code SVN: r31356 - in labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban: drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Feb 2 01:18:26 EST 2010


Author: baunax
Date: 2010-02-02 01:18:25 -0500 (Tue, 02 Feb 2010)
New Revision: 31356

Added:
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionCollection.java
Modified:
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionField.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionFormLine.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionMethod.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionPart.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionVariable.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/ClassMethodInspector.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java
   labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
Log:
- refactor ExpressionParts to have classType and genericType

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -7,7 +7,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.TreeMap;
 
 import org.drools.guvnor.client.modeldriven.brl.ActionFieldValue;
 import org.drools.guvnor.client.modeldriven.brl.DSLSentence;
@@ -153,9 +152,9 @@
 
     private Map<String, List<MethodInfo>> methodInfos            = new HashMap<String, List<MethodInfo>>();
 
-
     private Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>();
 
+    
     public SuggestionCompletionEngine() {
 
     }
@@ -472,7 +471,7 @@
                               methodInfos );
     }
     
-    public List<String> getMethodFields(String factName,
+    public List<String> getMethodParams(String factName,
                                         String methodNameWithParams) {
         if ( methodInfos.get( factName ) != null ) {
             List<MethodInfo> infos = methodInfos.get( factName );
@@ -500,6 +499,20 @@
         return methodList;
     }
 
+    public MethodInfo getMethodinfo(String factName, String methodFullName) {
+    	List<MethodInfo> infos = methodInfos.get( factName );
+
+        if ( infos != null ) {
+            for ( MethodInfo info : infos ) {
+                if (info.getNameWithParameters().equals(methodFullName)) {
+                	return info;
+                }
+            }
+        }
+
+        return null;
+    }
+    
     public String getMethodClassType(String factName, String methodFullName) {
     	List<MethodInfo> infos = methodInfos.get( factName );
 
@@ -716,6 +729,4 @@
         ModelField field = this.getField(modelClassName, fieldName);
         return field==null?null:field.getType();
     }
-
-
 }

Added: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionCollection.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionCollection.java	                        (rev 0)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionCollection.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -0,0 +1,19 @@
+package org.drools.guvnor.client.modeldriven.brl;
+
+public class ExpressionCollection extends ExpressionPart {
+
+	@SuppressWarnings("unused")
+	private ExpressionCollection() {
+	}
+
+	public ExpressionCollection(String name, String classType,
+			String genericType, String parametricType) {
+		super(name, classType, genericType, parametricType);
+	}
+
+	@Override
+	public String getText() {
+		return getName();
+	}
+
+}


Property changes on: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionCollection.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionField.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionField.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionField.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -2,38 +2,15 @@
 
 
 public class ExpressionField extends ExpressionPart {
-	private String fieldName;
-	private String fieldType; 
-	
 	@SuppressWarnings("unused")
 	private ExpressionField() {}
-
-	public ExpressionField(String fieldName, String fieldType) {
-		super();
-		this.fieldName = fieldName;
-		this.fieldType = fieldType;
+	
+	public ExpressionField(String fieldName, String fieldClassType, String fieldGenericType) {
+		super(fieldName, fieldClassType, fieldGenericType);
 	}
 
 	@Override
 	public String getText() {
-		return "." + getFieldName() + (getNext() == null ? "" : getNext().getText());
+		return "." + getName() + (getNext() == null ? "" : getNext().getText());
 	}
-
-	public String getFieldName() {
-		return fieldName;
-	}
-
-	public String getFieldType() {
-		return fieldType;
-	}
-	
-	@Override
-	public String getType() {
-		return fieldType;
-	}
-
-	@Override
-	public String getName() {
-		return getFieldName();
-	}
 }

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionFormLine.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionFormLine.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionFormLine.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -29,8 +29,12 @@
 		}
 	}
 	
+	private ExpressionPart getPreviousPart() {
+		return parts.getLast();
+	}
+	
 	public String getPreviousType() {
-		ExpressionPart last = parts.getLast();
+		ExpressionPart last = getPreviousPart();
 		return last.getPrevious() == null ? null : last.getPrevious().getType(); 
 	}
 	
@@ -41,4 +45,13 @@
 	public boolean isEmpty() {
 		return parts.isEmpty();
 	}
+	
+	public String getCurrentName() {
+		return parts.getLast().getName();
+	}
+	
+	public String getPreviousName() {
+		ExpressionPart previousPart = getPreviousPart();
+		return previousPart == null ? null : previousPart.getName(); 
+	}
 }

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionMethod.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionMethod.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionMethod.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -4,25 +4,16 @@
 import java.util.Map;
 
 public class ExpressionMethod extends ExpressionPart {
-	private String methodName;
-	private String returnType;
 
 	private Map<String, ExpressionPart> params = new LinkedHashMap<String, ExpressionPart>();
 
 	@SuppressWarnings("unused")
-	private ExpressionMethod() {
-	}
+	private ExpressionMethod() {}
 	
-	public ExpressionMethod(String methodName, String returnType) {
-		super();
-		this.methodName = methodName;
-		this.returnType = returnType;
+	public ExpressionMethod(String methodName, String returnClassType, String returnGenericType) {
+		super(methodName, returnClassType, returnGenericType);
 	}
 
-	public String getMethodName() {
-		return methodName;
-	}
-
 	public Map<String, ExpressionPart> getParams() {
 		return params;
 	}
@@ -31,21 +22,9 @@
 		this.params = params;
 	}
 
-	public void setMethodName(String methodName) {
-		this.methodName = methodName;
-	}
-
-	public String getReturnType() {
-		return returnType;
-	}
-
-	public void setReturnType(String returnType) {
-		this.returnType = returnType;
-	}
-
 	@Override
 	public String getText() {
-		return "." + methodName + paramsToString()
+		return "." + getName() + paramsToString()
 				+ (getNext() == null ? "" : getNext().getText());
 	}
 
@@ -60,14 +39,5 @@
 		}
 		return "(" + s.substring(sep.length()) + ")";
 	}
-
-	@Override
-	public String getType() {
-		return returnType;
-	}
 	
-	@Override
-	public String getName() {
-		return getMethodName();
-	}
 }

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionPart.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionPart.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionPart.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -3,15 +3,43 @@
 public abstract class ExpressionPart implements IPattern, IAction {
 	private ExpressionPart prev;
 	private ExpressionPart next;
+	private String name;
+	private String classType;
+	private String genericType;
+	private String parametricType;
 
-	public ExpressionPart() {}
+	protected ExpressionPart() {
+	}
+	
+	public ExpressionPart(String name, String classType, String genericType) {
+		this.name = name;
+		this.classType = classType;
+		this.genericType = genericType;
+	}
+	
+	public ExpressionPart(String name, String classType, String genericType, String parametricType ) {
+		this(name, classType, genericType);
+		this.parametricType = parametricType;
+	}
 
-	public abstract String getName();
+	public String getName() {
+		return name;
+	}
 	
 	public abstract String getText();
 
-	public abstract String getType();
+	public final String getType() {
+		return classType;
+	}
 	
+	public final String getGenericType() {
+		return genericType;
+	}
+	
+	public String getParametricType() {
+		return parametricType;
+	}
+
 	public ExpressionPart getPrevious() {
 		return prev;
 	}

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionVariable.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionVariable.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/brl/ExpressionVariable.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -8,6 +8,7 @@
 	private ExpressionVariable() {}
 
 	public ExpressionVariable(FactPattern fact) {
+		super(fact.boundName, fact.factType, fact.factType);
 		if (!fact.isBound()) {
 			throw new RuntimeException("the fact is not bounded: " + fact);
 		}
@@ -22,14 +23,4 @@
 	public FactPattern getFact() {
 		return fact;
 	}
-
-	@Override
-	public String getType() {
-		return fact.factType;
-	}
-	
-	@Override
-	public String getName() {
-		return fact.boundName;
-	}
 }

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/ClassMethodInspector.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/ClassMethodInspector.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/ClassMethodInspector.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -39,7 +39,8 @@
                 Class<?>[] listParam = aMethod.getParameterTypes();
                 
 				MethodInfo info = new MethodInfo(methodName,
-						solveParams(listParam), aMethod.getReturnType(),
+						solveParams(listParam), 
+						aMethod.getReturnType(),
 						SuggestionCompletionEngineBuilder
 								.obtainGenericType(aMethod.getGenericReturnType()),
 						converter.translateClassToGenericType(clazz));

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -189,7 +189,7 @@
                 model.methodName = methodName;
                 List<String> fieldList = new ArrayList<String>();
 
-                fieldList.addAll( completions.getMethodFields( variableClass,
+                fieldList.addAll( completions.getMethodParams( variableClass,
                                                                methodNameWithParams ) );
 
                 // String fieldType = completions.getFieldType( variableClass,

Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java	2010-02-02 06:05:46 UTC (rev 31355)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java	2010-02-02 06:18:25 UTC (rev 31356)
@@ -7,7 +7,9 @@
 
 import org.drools.guvnor.client.common.DirtyableComposite;
 import org.drools.guvnor.client.messages.Constants;
+import org.drools.guvnor.client.modeldriven.MethodInfo;
 import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.guvnor.client.modeldriven.brl.ExpressionCollection;
 import org.drools.guvnor.client.modeldriven.brl.ExpressionField;
 import org.drools.guvnor.client.modeldriven.brl.ExpressionFormLine;
 import org.drools.guvnor.client.modeldriven.brl.ExpressionMethod;
@@ -24,6 +26,7 @@
 
 public class ExpressionBuilder extends DirtyableComposite {
 
+	private static final String DELETE_VALUE = "_delete_";
 	private static final String FIElD_VALUE_PREFIX = "fl";
 	private static final String VARIABLE_VALUE_PREFIX = "va";
 	private static final String GLOBAL_COLLECTION_VALUE_PREFIX = "gc";
@@ -45,7 +48,7 @@
 			panel.add(createStartPointWidget());
 		} else {
 			panel.add(new Label(expression.getText()));
-			panel.add(getWidgetForCurrentType());
+			panel.add(getWidgetForCurrentType(null));
 		}
 		initWidget(panel);
 	}
@@ -89,7 +92,7 @@
 					value.substring(VARIABLE_VALUE_PREFIX.length() + 1));
 			ExpressionVariable variable = new ExpressionVariable(fact);
 			expression.appendPart(variable);
-			w = getWidgetForCurrentType();
+			w = getWidgetForCurrentType(null);
 
 			if (!expression.isEmpty()) {
 				panel.add(new Label(expression.getText()));
@@ -103,7 +106,7 @@
 		// ExpressionBuilder.this.expression.appendText(v);
 	}
 
-	private Widget getWidgetForCurrentType() {
+	private Widget getWidgetForCurrentType(String prevFactName) {
 		if (expression.isEmpty()) {
 			return createStartPointWidget();
 		}
@@ -113,7 +116,7 @@
 			ListBox lb = new ListBox();
 			lb.setVisibleItemCount(1);
 			lb.addItem(constants.ChooseDotDotDot(), "");
-			lb.addItem("<==" + constants.DeleteItem(), "_delete_");
+			lb.addItem("<==" + constants.DeleteItem(), DELETE_VALUE);
 			for (Map.Entry<String, String> entry : getCompletionsForCurrentType()
 					.entrySet()) {
 				lb.addItem(entry.getKey(), entry.getValue());
@@ -134,10 +137,17 @@
 			lb.setVisibleItemCount(1);
 			lb.addItem(constants.ChooseDotDotDot(), "");
 			return lb;
+		} else if (isDate()) {
+			
 		}
 		return null;
 	}
 
+	private boolean isDate() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
 	private boolean isCollection() {
 		String previousType = expression.getPreviousType();
 		String factName = getCompletionEngine().getFactNameFromType(
@@ -146,29 +156,36 @@
 	}
 
 	private void onChangeSelection(String value) {
-		if ("_delete_".equals(value)) {
+		String prevFactName = null;
+		if (DELETE_VALUE.equals(value)) {
 			expression.removeLast();
 		} else {
 			int dotPos = value.indexOf('.');
 			String prefix = value.substring(0, dotPos);
-			String option = value.substring(dotPos + 1);
+			String attrib = value.substring(dotPos + 1);
 
-			String factName = getCompletionEngine().getFactNameFromType(
+			prevFactName = getCompletionEngine().getFactNameFromType(
 					getCurrentType());
-
+			String genericType = SuggestionCompletionEngine.TYPE_OBJECT;
 			if (FIElD_VALUE_PREFIX.equals(prefix)) {
-				String fieldClassName = getCompletionEngine()
-						.getFieldClassName(factName, option);
-				expression.appendPart(new ExpressionField(option,
-						fieldClassName));
+				String fieldClassName = getCompletionEngine().getFieldClassName(prevFactName, attrib);
+				String fieldGenericType = getCompletionEngine().getFieldType(prevFactName, attrib);
+				if (SuggestionCompletionEngine.TYPE_COLLECTION.equals(fieldGenericType)) {
+					String fieldParametricType = getCompletionEngine().getParametricFieldType(prevFactName, attrib);
+					expression.appendPart(new ExpressionCollection(attrib, fieldClassName, fieldGenericType, fieldParametricType));
+				} else {
+					expression.appendPart(new ExpressionField(attrib, fieldClassName, fieldGenericType));
+				}
 			} else if (METHOD_VALUE_PREFIX.equals(prefix)) {
-				String methodType = getCompletionEngine().getMethodClassType(
-						factName, option);
-				expression.appendPart(new ExpressionMethod(option.substring(0,
-						option.indexOf('(')), methodType));
+				MethodInfo mi = getCompletionEngine().getMethodinfo(prevFactName, attrib);
+				if (SuggestionCompletionEngine.TYPE_COLLECTION.equals(mi.getGenericType())) {
+					expression.appendPart(new ExpressionCollection(attrib, mi.getReturnClassType(), mi.getGenericType(), mi.getParametricReturnType()));
+				} else {
+					expression.appendPart( new ExpressionMethod(mi.getName(), mi.getReturnClassType(), mi.getGenericType()));
+				}
 			}
 		}
-		Widget w = getWidgetForCurrentType();
+		Widget w = getWidgetForCurrentType(prevFactName);
 
 		panel.clear();
 		if (!expression.isEmpty()) {
@@ -180,70 +197,40 @@
 	}
 
 	private Map<String, String> getCompletionsForCurrentType() {
-		String factName = getCompletionEngine().getFactNameFromType(
-				getCurrentType());
-		List<String> methodNames = getCompletionEngine().getMethodFullNames(
-				factName);
 		Map<String, String> completions = new LinkedHashMap<String, String>();
+		String factName = getCompletionEngine().getFactNameFromType(getCurrentType());
+		if (factName != null) {
+			List<String> methodNames = getCompletionEngine()
+					.getMethodFullNames(factName);
 
-		for (String field : getCompletionEngine().getFieldCompletions(factName)) {
-			boolean changed = false;
-			for (Iterator<String> i = methodNames.iterator(); i.hasNext();) {
-				String method = i.next();
-				if (method.startsWith(field)) {
-					completions.put(method, METHOD_VALUE_PREFIX + "." + method);
-					i.remove();
-					changed = true;
+			for (String field : getCompletionEngine().getFieldCompletions(
+					factName)) {
+				boolean changed = false;
+				for (Iterator<String> i = methodNames.iterator(); i.hasNext();) {
+					String method = i.next();
+					if (method.startsWith(field)) {
+						completions.put(method, METHOD_VALUE_PREFIX + "."
+								+ method);
+						i.remove();
+						changed = true;
+					}
 				}
+				if (!changed) {
+					completions.put(field, FIElD_VALUE_PREFIX + "." + field);
+				}
 			}
-			if (!changed) {
-				completions.put(field, FIElD_VALUE_PREFIX + "." + field);
+		} else {
+			String prevFactName = getCompletionEngine().getFactNameFromType(getPreviousType());
+			if (prevFactName != null) {
+//				getCompletionEngine().get
 			}
 		}
 		return completions;
 	}
 
-	/*
-	 * protected Widget getWidgetFor(String value) { if (value == null ||
-	 * value.isEmpty()) { throw new IllegalArgumentException("value is empty");
-	 * } if (value.startsWith(VARIABLE_VALUE_PREFIX)) { FactPattern fact =
-	 * getRuleModel
-	 * ().getBoundFact(value.substring(VARIABLE_VALUE_PREFIX.length() + 1));
-	 * 
-	 * ListBox lb = new ListBox(); lb.setVisibleItemCount(1);
-	 * lb.addItem(constants.ChooseDotDotDot(), "");
-	 * 
-	 * List<String> methodNames =
-	 * getCompletionEngine().getMethodFullNames(fact.factType);
-	 * 
-	 * for (String field :
-	 * getCompletionEngine().getFieldCompletions(fact.factType)) { boolean
-	 * changed = false; for (Iterator<String> i = methodNames.iterator();
-	 * i.hasNext();) { String method = i.next(); if (method.startsWith(field)) {
-	 * lb.addItem(method, METHOD_VALUE_PREFIX + "." + method); i.remove();
-	 * changed = true; } } if (!changed) { lb.addItem(field, FIElD_VALUE_PREFIX
-	 * + "." + field); } }
-	 * 
-	 * lb.addChangeListener(new ChangeListener() {
-	 * 
-	 * public void onChange(Widget sender) { ExpressionBuilder.this.makeDirty();
-	 * ListBox box = (ListBox) sender; if (box.getSelectedIndex() > 0);
-	 * panel.remove(panel.getWidgetCount() - 1); String v =
-	 * box.getValue(box.getSelectedIndex()); panel.add(new
-	 * Label(v.substring(v.indexOf('.') + 1))); panel.add(getWidgetFor(v)); }
-	 * });
-	 * 
-	 * return lb; } else if (value.startsWith(GLOBAL_COLLECTION_VALUE_PREFIX)) {
-	 * return new Label("GLOBAL_COLLECTION_VALUE_PREFIX not implemented"); }
-	 * else if (value.startsWith(GLOBAL_VARIABLE_VALUE_PREFIX)) { return new
-	 * Label("GLOBAL_COLLECTION_VALUE_PREFIX not implemented"); } else if
-	 * (value.startsWith(METHOD_VALUE_PREFIX)) { return new
-	 * Label("GLOBAL_COLLECTION_VALUE_PREFIX not implemented"); } else if
-	 * (value.startsWith(FIElD_VALUE_PREFIX)) { return new
-	 * Label("GLOBAL_COLLECTION_VALUE_PREFIX not implemented"); } throw new
-	 * IllegalArgumentException("value has invalidad prefix: '" + value + "'");
-	 * }
-	 */
+	private String getCurrentPartName() {
+		return expression.getCurrentName();
+	}
 
 	private RuleModel getRuleModel() {
 		return modeller.getModel();
@@ -256,4 +243,8 @@
 	public String getCurrentType() {
 		return expression.getType();
 	}
+	
+	public String getPreviousType() {
+		return expression.getPreviousType();
+	}
 }



More information about the jboss-svn-commits mailing list