private ActionCallMethod visitActionCallMethod(ActionCallMethod acm) { ActionCallMethod clone = new ActionCallMethod(); clone.setVariable(acm.getVariable()); clone.setState(acm.getState()); clone.setMethodName(acm.getMethodName()); for (ActionFieldValue aff : acm.getFieldValues()) { clone.addFieldValue(cloneActionFieldFunction((ActionFieldFunction) aff)); } return clone; }
private ActionSetField clone(final ActionSetField action) { if (action instanceof ActionUpdateField) { final ActionUpdateField auf = (ActionUpdateField) action; final ActionUpdateField clone = new ActionUpdateField(auf.getVariable()); clone.setFieldValues(auf.getFieldValues()); return clone; } else if (action instanceof ActionCallMethod) { final ActionCallMethod acm = (ActionCallMethod) action; final ActionCallMethod clone = new ActionCallMethod(acm.getVariable()); clone.setState(acm.getState()); clone.setMethodName(acm.getMethodName()); clone.setFieldValues(acm.getFieldValues()); return clone; } else if (action instanceof ActionSetField) { final ActionSetField clone = new ActionSetField(action.getVariable()); clone.setFieldValues(action.getFieldValues()); return clone; } else { return action; } } }
public ActionCallMethod get(String variable, String methodName, String[] parameters) { this.variable = variable; this.methodName = methodName; this.parameters = parameters; ActionCallMethod actionCallMethod = new ActionCallMethod(); actionCallMethod.setMethodName(methodName); actionCallMethod.setVariable(variable); actionCallMethod.setState(ActionCallMethod.TYPE_DEFINED); for (ActionFieldFunction parameter : getActionFieldFunctions()) { actionCallMethod.addFieldValue(parameter); } return actionCallMethod; }
private RuleModel updateMethodCall(RuleModel model) { for (int i = 0; i < model.rhs.length; i++) { if (model.rhs[i] instanceof ActionCallMethod) { ActionCallMethod action = (ActionCallMethod) model.rhs[i]; // Check if method name is filled, if not this was made with an older Guvnor version if (action.getMethodName() == null || "".equals(action.getMethodName())) { if (action.getFieldValues() != null && action.getFieldValues().length >= 1) { action.setMethodName(action.getFieldValues()[0].getField()); action.setFieldValues(new ActionFieldValue[0]); action.setState(ActionCallMethod.TYPE_DEFINED); } } } } return model; } }
private Widget getSetterLabel() { HorizontalPanel horiz = new HorizontalPanel(); if (model.getState() == ActionCallMethod.TYPE_UNDEFINED) { Image edit = GuidedRuleEditorImages508.INSTANCE.AddFieldToFact(); edit.setAltText(GuidedRuleEditorResources.CONSTANTS.AddAnotherFieldToThisSoYouCanSetItsValue()); edit.setTitle(GuidedRuleEditorResources.CONSTANTS.AddAnotherFieldToThisSoYouCanSetItsValue()); edit.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Widget w = (Widget) event.getSource(); showAddFieldPopup(w); } }); horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + model.getVariable() + "]")); // NON-NLS if (!this.readOnly) { horiz.add(edit); } } else { horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + model.getVariable() + "." + model.getMethodName() + "]")); // NON-NLS } return horiz; }
private BRLActionColumn actionCallMethod(final String boundName) { final ActionCallMethod action = new ActionCallMethod(); action.setVariable(boundName); action.setMethodName("toString()"); final BRLActionColumn brl = new BRLActionColumn(); brl.setHeader("brl-action"); brl.setDefinition(Collections.singletonList(action)); brl.getChildColumns().add(new BRLActionVariableColumn() {{ setHeader("brl-action-v0"); }}); return brl; }
@Override public void callback(final List<MethodInfo> methodInfos) { if (methodInfos != null) { checkIfFactTypeKnown(methodInfos); setMethodInfos(methodInfos, oracle.getGlobalVariable(model.getVariable())); checkIfReadOnly(null); } else { ActionCallMethodWidget.this.fieldCompletionTexts = new String[0]; ActionCallMethodWidget.this.fieldCompletionValues = new String[0]; checkIfReadOnly(true); } } });
public ActionFieldFunction getFieldValue(int i) { return (ActionFieldFunction) this.getFieldValues()[i]; }
private void doLayout() { layout.clear(); layout.setWidget(0, 0, getSetterLabel()); FlexTable inner = new FlexTable(); for (int i = 0; i < model.getFieldValues().length; i++) { ActionFieldFunction val = model.getFieldValue(i); inner.setWidget(i, 0, typeLabel(val.getType())); inner.setWidget(i, 1, valueEditor(val)); } layout.setWidget(0, 1, inner); }
private void generateSetMethodCallsMethod(final ActionCallMethod action, final FieldNature[] fieldValues) { buf.append(indentation); if (isDSLEnhanced) { buf.append(">"); } buf.append(action.getVariable()); buf.append("."); buf.append(action.getMethodName()); buf.append("( "); boolean isFirst = true; for (int i = 0; i < fieldValues.length; i++) { ActionFieldFunction valueFunction = (ActionFieldFunction) fieldValues[i]; if (isFirst == true) { isFirst = false; } else { buf.append(", "); } if (valueFunction.isFormula()) { buf.append(valueFunction.getValue()); } else if (valueFunction.getNature() == FieldNatureType.TYPE_VARIABLE) { buf.append(valueFunction.getValue()); } else { buildDefaultFieldValue(valueFunction, buf); } } buf.append(" );\n"); } }
private void addCallMethod(String itemText, int position) { this.model.addRhsItem(new ActionCallMethod(itemText), position); }
model.addRhsItem( arf ); ActionCallMethod callMethod1 = new ActionCallMethod(); callMethod1.setVariable( "var1" ); callMethod1.setMethodName( "testMethod1 " ); callMethod1.setState( ActionCallMethod.TYPE_DEFINED ); callMethod1.addFieldValue( new ActionFieldFunction( "field1", "value1", "type1" ) ); model.addRhsItem( callMethod1 ); ActionCallMethod callMethod2 = new ActionCallMethod(); callMethod2.setVariable( "var2" ); callMethod2.setMethodName( "testMethod2 " ); callMethod2.setState( ActionCallMethod.TYPE_UNDEFINED ); callMethod2.addFieldValue( new ActionFieldFunction( "field2", "value2", "type2" ) ); model.addRhsItem( callMethod2 );
private Widget getSetterLabel() { HorizontalPanel horiz = new HorizontalPanel(); if (model.getState() == ActionCallMethod.TYPE_UNDEFINED) { Image edit = GuidedRuleEditorImages508.INSTANCE.AddFieldToFact(); edit.setAltText(GuidedRuleEditorResources.CONSTANTS.AddAnotherFieldToThisSoYouCanSetItsValue()); edit.setTitle(GuidedRuleEditorResources.CONSTANTS.AddAnotherFieldToThisSoYouCanSetItsValue()); edit.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Widget w = (Widget) event.getSource(); showAddFieldPopup(w); } }); horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + model.getVariable() + "]")); // NON-NLS if (!this.readOnly) { horiz.add(edit); } } else { horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + model.getVariable() + "." + model.getMethodName() + "]")); // NON-NLS } return horiz; }
@Override public void callback(final List<MethodInfo> methodInfos) { if (methodInfos != null) { checkIfFactTypeKnown(methodInfos); setMethodInfos(methodInfos, oracle.getGlobalVariable(model.getVariable())); checkIfReadOnly(null); } else { ActionCallMethodWidget.this.fieldCompletionTexts = new String[0]; ActionCallMethodWidget.this.fieldCompletionValues = new String[0]; checkIfReadOnly(true); } } });
private DropDownData getEnums(String field) { return oracle.getEnums(getVariableType(), field, FieldNatureUtil.toMap(this.model.getFieldValues())); }
private void doLayout() { layout.clear(); layout.setWidget(0, 0, getSetterLabel()); FlexTable inner = new FlexTable(); for (int i = 0; i < model.getFieldValues().length; i++) { ActionFieldFunction val = model.getFieldValue(i); inner.setWidget(i, 0, typeLabel(val.getType())); inner.setWidget(i, 1, valueEditor(val)); } layout.setWidget(0, 1, inner); }
private void addCallMethod(String itemText, int position) { this.model.addRhsItem(new ActionCallMethod(itemText), position); }
private ActionCallMethod visitActionCallMethod(ActionCallMethod acm) { ActionCallMethod clone = new ActionCallMethod(); clone.setVariable(acm.getVariable()); clone.setState(acm.getState()); clone.setMethodName(acm.getMethodName()); for (ActionFieldValue aff : acm.getFieldValues()) { clone.addFieldValue(cloneActionFieldFunction((ActionFieldFunction) aff)); } return clone; }
private void getMethodInfosForGlobalVariable() { oracle.getMethodInfosForGlobalVariable(model.getVariable(), new Callback<List<MethodInfo>>() { @Override public void callback(final List<MethodInfo> methodInfos) { if (methodInfos != null) { checkIfFactTypeKnown(methodInfos); setMethodInfos(methodInfos, oracle.getGlobalVariable(model.getVariable())); checkIfReadOnly(null); } else { ActionCallMethodWidget.this.fieldCompletionTexts = new String[0]; ActionCallMethodWidget.this.fieldCompletionValues = new String[0]; checkIfReadOnly(true); } } }); }
private DropDownData getEnums(String field) { return oracle.getEnums(getVariableType(), field, FieldNatureUtil.toMap(this.model.getFieldValues())); }