private void visitActionFieldList( ActionInsertFact afl ) { String factType = afl.getFactType(); 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() ); } } }
buf.append( ( isLogic ) ? "insertLogical( new " : "insert( new " ); buf.append( action.getFactType() ); buf.append( "() );\n" ); } else { buf.append( action.getFactType() ); if ( action.getBoundName() == null ) { buf.append( " fact" ); buf.append( action.getFactType() ); buf.append( "();\n" ); if ( action.getBoundName() == null ) {
private boolean isRHSFieldTypeEquivalent( String boundVariable ) { String boundFactType = modeller.getModel().getRHSBoundFact( boundVariable ).getFactType(); if ( boundFactType == null ) { return false; } if ( this.variableType == null ) { return false; } //If the types are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if ( boundFactType.equals( DataType.TYPE_COMPARABLE ) ) { if ( !this.variableType.equals( DataType.TYPE_COMPARABLE ) ) { return false; } String[] dd = this.modeller.getSuggestionCompletions().getEnumValues( boundFactType, this.value.getField() ); return isEnumEquivalent( dd ); } //If the types are identical (and not SuggestionCompletionEngine.TYPE_COMPARABLE) then return true if ( boundFactType.equals( this.variableType ) ) { return true; } return false; }
private Widget getAssertLabel() { ClickHandler cl = new ClickHandler() { public void onClick( ClickEvent event ) { Widget w = (Widget) event.getSource(); showAddFieldPopup( w ); } }; String assertType = "assert"; //NON-NLS if ( this.model instanceof ActionInsertLogicalFact) { assertType = "assertLogical"; //NON-NLS } String lbl = ( model.isBound() == false ) ? HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" : HumanReadable.getActionDisplayName( assertType ) + " <b>" + this.model.getFactType() + "</b>" + " <b>[" + model.getBoundName() + "]</b>"; if ( this.model.getFieldValues() != null && model.getFieldValues().length > 0 ) { lbl = lbl + ":"; } return new ClickableLabel( lbl, cl, !this.readOnly ); }
public ActionInsertFactWidget( RuleModeller mod, EventBus eventBus, ActionInsertFact set, Boolean readOnly ) { super( mod, eventBus ); this.model = set; this.layout = new DirtyableFlexTable(); this.factType = set.getFactType(); DataModelOracle completions = this.getModeller().getSuggestionCompletions(); this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR, set.getFactType() ); layout.setStyleName( "model-builderInner-Background" ); //NON-NLS this.isFactTypeKnown = completions.isFactTypeRecognized( set.getFactType() ); if ( readOnly == null ) { this.readOnly = !this.isFactTypeKnown; } else { this.readOnly = readOnly; } if ( this.readOnly ) { layout.addStyleName( "editor-disabled-widget" ); } doLayout(); initWidget( this.layout ); }
public void onChange( ChangeEvent event ) { String fieldName = box.getItemText( box.getSelectedIndex() ); String fieldType = completions.getFieldType( model.getFactType(), fieldName ); model.addFieldValue( new ActionFieldValue( fieldName, "", fieldType ) ); setModified( true ); getModeller().refreshWidget(); popup.hide(); } } );
List<String> methodList = completions.getMethodNames( patternRhs.getFactType() ); fieldCompletionTexts = new String[ methodList.size() ]; fieldCompletionValues = new String[ methodList.size() ]; i++; this.variableClass = patternRhs.getFactType(); this.isBoundFact = true; } else {
private ActionInsertFact visitActionFieldList( ActionInsertFact afl ) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType( afl.getFactType() ); clone.setBoundName( afl.getBoundName() ); 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; }
for ( String v : vars2 ) { ActionInsertFact factPattern = model.getModel().getRHSBoundFact( v ); if ( factPattern.getFactType().equals( this.methodParameter.getType() ) ) {
if ( factPattern.getFactType().equals( this.parameterType ) ) { createButton = true;
if ( patternRhs != null ) { this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR, patternRhs.getFactType() ); this.variableClass = patternRhs.getFactType(); this.isBoundFact = true;
private Widget valueEditor( final ActionFieldFunction 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() ); if ( type == null ) { type = this.getModeller().getModel().getRHSBoundFact( this.model.getVariable() ).getFactType(); } } DropDownData enums = completions.getEnums( type, val.getField(), FieldNatureUtil.toMap( this.model.getFieldValues() ) ); return new MethodParameterValueEditor( val, enums, this.getModeller(), val.getType(), new Command() { public void execute() { setModified( true ); } } ); }
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; }
ActionInsertFact raif2 = (ActionInsertFact) r2; assertEquals( "Person", raif2.getFactType() ); assertEquals( "rating", raif2.getFieldValues()[ 0 ].getField() );
a3.getFactType() ); assertEquals( 2, a3.getFieldValues().length );
rm.rhs.length ); assertEquals( "Baddie", ( (ActionInsertFact) rm.rhs[ 0 ] ).getFactType() ); assertEquals( "Smurf", ( (ActionInsertFact) rm.rhs[ 1 ] ).getFactType() ); rm.rhs.length ); assertEquals( "Baddie", ( (ActionInsertFact) rm.rhs[ 0 ] ).getFactType() ); rm.rhs.length ); assertEquals( "Baddie", ( (ActionInsertFact) rm.rhs[ 0 ] ).getFactType() );
ActionInsertFact raif2 = (ActionInsertFact) r2; assertEquals( "Person", raif2.getFactType() ); assertEquals( "rating", raif2.getFieldValues()[ 0 ].getField() );
ActionInsertFact raif3 = (ActionInsertFact) r3; assertEquals( "Person", raif3.getFactType() ); assertEquals( "rating", raif3.getFieldValues()[ 0 ].getField() );
ActionInsertFact raif2 = (ActionInsertFact) r2; assertEquals( "Person", raif2.getFactType() ); assertEquals( "rating", raif2.getFieldValues()[ 0 ].getField() );