/** * @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; }
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); }
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() ); } } }
public void visitActionSetField( final ActionSetField action ) { if ( action instanceof ActionCallMethod ) { this.generateSetMethodCallsMethod( (ActionCallMethod) action, action.getFieldValues() ); } else { this.generateSetMethodCalls( action.getVariable(), action.getFieldValues() ); } }
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; }
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; }
assertEquals( asf.getVariable(), "$r" ); assertEquals( 1,
a1.getVariable() ); assertEquals( 2, a1.getFieldValues().length );
assertEquals( asf.getVariable(), "$r" ); assertEquals( 4,
a.getVariable() ); assertEquals( 1, a.getFieldValues().length );
final ActionSetField a1 = (ActionSetField) m.rhs[ 1 ]; assertEquals( "$a", a1.getVariable() ); assertEquals( 2, a1.getFieldValues().length );