public void visitActionSetField( final ActionSetField action ) { if ( action instanceof ActionCallMethod ) { this.generateSetMethodCallsMethod( (ActionCallMethod) action, action.getFieldValues() ); } else { this.generateSetMethodCalls( action.getVariable(), action.getFieldValues() ); } }
private ActionSetField visitActionFieldList( ActionSetField afl ) { ActionSetField clone = new ActionSetField(); clone.setVariable( afl.getVariable() ); for ( ActionFieldValue afv : afl.getFieldValues() ) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField( afv.getField() ); afvClone.setNature( afv.getNature() ); afvClone.setType( afv.getType() ); afvClone.setValue( afv.getValue() ); clone.addFieldValue( afvClone ); } return clone; }
ActionSetField asf = new ActionSetField(); asf.setVariable( "$r" ); ActionWorkItemFieldValue fv1 = new ActionWorkItemFieldValue( "ResultsBooleanResult", DataType.TYPE_BOOLEAN, "BooleanResult", Boolean.class.getName() ); asf.addFieldValue( fv1 ); ActionWorkItemFieldValue fv2 = new ActionWorkItemFieldValue( "ResultsFloatResult", DataType.TYPE_NUMERIC_FLOAT, "FloatResult", Float.class.getName() ); asf.addFieldValue( fv2 ); ActionWorkItemFieldValue fv3 = new ActionWorkItemFieldValue( "ResultsIntegerResult", DataType.TYPE_NUMERIC_INTEGER, "IntegerResult", Integer.class.getName() ); asf.addFieldValue( fv3 ); ActionWorkItemFieldValue fv4 = new ActionWorkItemFieldValue( "ResultsStringResult", DataType.TYPE_STRING, "StringResult", String.class.getName() ); asf.addFieldValue( fv4 );
private void addActionSetField( String itemText, int position ) { this.model.addRhsItem( new ActionSetField( itemText ), position ); }
/** * @param binding The name of the LHS fact binding. * @return Returns true if the specified binding is used on the RHS. */ public boolean isBoundFactUsed( final String binding ) { if ( this.rhs == null ) { return false; } for ( int i = 0; i < this.rhs.length; i++ ) { if ( this.rhs[ i ] instanceof ActionSetField ) { final ActionSetField set = (ActionSetField) this.rhs[ i ]; if ( set.getVariable().equals( binding ) ) { return true; } } else if ( this.rhs[ i ] instanceof ActionRetractFact ) { final ActionRetractFact ret = (ActionRetractFact) this.rhs[ i ]; if ( ret.getVariableName().equals( binding ) ) { return true; } } } return false; }
ActionSetField au = new ActionSetField( "$p" ); au.addFieldValue( new ActionFieldValue( "dob", "31-Jan-2000", DataType.TYPE_DATE ) );
final ActionSetField set = new ActionSetField(); set.setVariable( "x" ); model.rhs[0] = set;
public void visitActionSetField( final ActionSetField action ) { getClasses( action.getFieldValues() ); }
public void addFieldValue( final ActionFieldValue val ) { if ( val instanceof ActionFieldFunction ) { super.addFieldValue( val ); } else { throw new IllegalArgumentException( "Cannot assign field values of types other than ActionFieldFunction." ); } } }
public void onClick( ClickEvent event ) { if ( Window.confirm( Constants.INSTANCE.RemoveThisItem() ) ) { model.removeField( idx ); setModified( true ); getModeller().refreshWidget(); //Signal possible change in Template variables TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent( getModeller().getModel() ); getEventBus().fireEventFromSource( tvce, getModeller().getModel() ); } } } );
ActionSetField action = new ActionSetField( entry.getKey() ); addSettersToAction( entry.getValue(), action, isJavaDialect ); m.addRhsItem( action );
private Widget getSetterLabel() { ClickHandler clk = new ClickHandler() { public void onClick( ClickEvent event ) { //Widget w = (Widget)event.getSource(); showAddFieldPopup( event ); } }; String modifyType = "set"; if ( this.model instanceof ActionUpdateField) { modifyType = "modify"; } String type = this.getModeller().getModel().getLHSBindingType( model.getVariable() ); String descFact = ( type != null ) ? type + " <b>[" + model.getVariable() + "]</b>" : model.getVariable(); String sl = Constants.INSTANCE.setterLabel( HumanReadable.getActionDisplayName(modifyType), descFact ); return new ClickableLabel( sl, clk, !this.readOnly );//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk); }
final ActionSetField set = new ActionSetField(); set.setVariable( "x"); model.rhs[0] = set;
private void doLayout() { layout.clear(); for ( int i = 0; i < model.getFieldValues().length; i++ ) { ActionFieldValue val = model.getFieldValues()[ i ]; if ( model.getFieldValues().length == 0 ) { HorizontalPanel h = new HorizontalPanel(); h.add( getSetterLabel() );
public void onChange( ChangeEvent event ) { String fieldName = box.getItemText( box.getSelectedIndex() ); String fieldType = completions.getFieldType( variableClass, fieldName ); model.addFieldValue( new ActionFieldValue( fieldName, "", fieldType ) ); setModified( true ); getModeller().refreshWidget(); popup.hide(); } } );
private void visitActionFieldList( ActionSetField afl ) { String factType = model.getLHSBindingType( afl.getVariable() ); for ( ActionFieldValue afv : afl.getFieldValues() ) { InterpolationVariable var = new InterpolationVariable( afv.getValue(), afv.getType(), factType, afv.getField() ); if ( afv.getNature() == FieldNatureType.TYPE_TEMPLATE && !vars.containsKey( var ) ) { vars.put( var, vars.size() ); } } }
@Test public void testAddItemRhs() { final RuleModel model = new RuleModel(); final IAction a0 = new ActionSetField(); final IAction a1 = new ActionSetField(); model.addRhsItem( a0 ); assertEquals( 1, model.rhs.length ); model.addRhsItem( a1 ); assertEquals( 2, model.rhs.length ); assertEquals( a0, model.rhs[0] ); assertEquals( a1, model.rhs[1] ); }
if ( completions.isGlobalVariable( set.getVariable() ) ) { this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable( set.getVariable() ); this.variableClass = completions.getGlobalVariable( set.getVariable() ); } else { String type = mod.getModel().getLHSBindingType( set.getVariable() ); if ( type != null ) { this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR, this.isBoundFact = true; } else { ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact( set.getVariable() ); if ( patternRhs != null ) { this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR, ErrorPopup.showMessage( Constants.INSTANCE.CouldNotFindTheTypeForVariable0( set.getVariable() ) );
private Widget valueEditor( final ActionFieldValue val ) { DataModelOracle completions = this.getModeller().getSuggestionCompletions(); String type = ""; if ( completions.isGlobalVariable( this.model.getVariable() ) ) { type = completions.getGlobalVariable( this.model.getVariable() ); } else { type = this.getModeller().getModel().getLHSBindingType( this.model.getVariable() ); /* * to take in account if the using a rhs bound variable */ if ( type == null && !this.readOnly ) { type = this.getModeller().getModel().getRHSBoundFact( this.model.getVariable() ).getFactType(); } } DropDownData enums = completions.getEnums( type, val.getField(), FieldNatureUtil.toMap( this.model.getFieldValues() ) ); ActionValueEditor actionValueEditor = new ActionValueEditor( val, enums, this.getModeller(), this.getEventBus(), val.getType(), this.readOnly ); actionValueEditor.setOnChangeCommand( new Command() { public void execute() { setModified( true ); } } ); return actionValueEditor; }
final RuleModel model = new RuleModel(); final ActionSetField a = new ActionSetField(); model.addRhsItem( a ); model.rhs.length ); final ActionSetField b = new ActionSetField(); model.addRhsItem( b ); model.rhs.length ); final ActionSetField c = new ActionSetField(); model.addRhsItem( c, true ); final ActionSetField d = new ActionSetField(); model.addRhsItem( d, false ); final ActionSetField e = new ActionSetField(); model.addRhsItem( e, 2 ); final ActionSetField f = new ActionSetField(); final ActionSetField g = new ActionSetField(); model.addRhsItem( f, -1 );