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 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 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 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; } } }
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 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; }