/** * Returns the completions. */ public DataModelOracle getCompletions() { return this.modeller.getSuggestionCompletions(); }
private DataModelOracle getCompletionEngine() { return this.getModeller().getSuggestionCompletions(); }
/** * Returns true is a var name has already been used either by the rule, or * as a global. */ public boolean isVariableNameUsed( String name ) { return model.isVariableNameUsed( name ) || getSuggestionCompletions().isGlobalVariable( name ); }
/** * Pops up the fact selector. */ protected void showConditionSelector( Integer position ) { RuleModellerConditionSelectorPopup popup = new RuleModellerConditionSelectorPopup( model, this, position, getSuggestionCompletions() ); popup.show(); }
protected void showActionSelector( Widget w, Integer position ) { RuleModellerActionSelectorPopup popup = new RuleModellerActionSelectorPopup( model, this, position, getSuggestionCompletions() ); popup.show(); }
private boolean isLHSFactTypeEquivalent( String boundVariable ) { String boundFactType = modeller.getModel().getLHSBoundFact( boundVariable ).getFactType(); //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 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; }
protected void calculateReadOnly() { if ( this.pattern.getFactPattern() != null ) { this.isFactTypeKnown = this.getModeller().getSuggestionCompletions().isFactTypeRecognized( this.pattern.getFactPattern().getFactType() ); this.readOnly = !this.isFactTypeKnown; } }
@Override protected void calculateReadOnly() { if ( this.pattern.getFactPattern() != null ) { this.readOnly = !( this.getExtraLeftSidePatternFactTypes().containsValue( this.pattern.getFactPattern().getFactType() ) || this.getModeller().getSuggestionCompletions().isFactTypeRecognized( this.pattern.getFactPattern().getFactType() ) ); } }
private boolean isLHSFieldTypeEquivalent( String boundVariable ) { String boundFieldType = modeller.getModel().getLHSBindingType( boundVariable ); //If the fieldTypes are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if ( boundFieldType.equals( DataType.TYPE_COMPARABLE ) ) { if ( !this.variableType.equals( DataType.TYPE_COMPARABLE ) ) { return false; } FieldConstraint fc = this.modeller.getModel().getLHSBoundField( boundVariable ); if ( fc instanceof SingleFieldConstraint ) { String fieldName = ( (SingleFieldConstraint) fc ).getFieldName(); String parentFactTypeForBinding = this.modeller.getModel().getLHSParentFactPatternForBinding( boundVariable ).getFactType(); String[] dd = this.modeller.getSuggestionCompletions().getEnumValues( parentFactTypeForBinding, fieldName ); return isEnumEquivalent( dd ); } return false; } //If the fieldTypes are identical (and not SuggestionCompletionEngine.TYPE_COMPARABLE) then return true if ( boundFieldType.equals( this.variableType ) ) { return true; } return false; }
private Widget valueEditor( final ActionFieldValue val ) { DataModelOracle completions = this.getModeller().getSuggestionCompletions(); DropDownData enums = completions.getEnums( this.factType, 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; }
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 ); }
private Widget createCEPWindowWidget( final RuleModeller modeller, final HasCEPWindow c ) { if ( modeller.getSuggestionCompletions().isFactTypeAnEvent( pattern.getFactType() ) ) { HorizontalPanel hp = new HorizontalPanel(); Label lbl = new Label( HumanReadableConstants.INSTANCE.OverCEPWindow() ); lbl.setStyleName( "paddedLabel" ); hp.add( lbl ); CEPWindowOperatorsDropdown cwo = new CEPWindowOperatorsDropdown( c, readOnly ); if ( !this.isReadOnly() ) { cwo.addValueChangeHandler( new ValueChangeHandler<OperatorSelection>() { public void onValueChange( ValueChangeEvent<OperatorSelection> event ) { setModified( true ); OperatorSelection selection = event.getValue(); String selected = selection.getValue(); c.getWindow().setOperator( selected ); getModeller().makeDirty(); } } ); } hp.add( cwo ); return hp; } return new HTML(); }
protected void showAddFieldPopup( ClickEvent w ) { final DataModelOracle completions = this.getModeller().getSuggestionCompletions(); final FormStylePopup popup = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(), Constants.INSTANCE.AddAField() ); final ListBox box = new ListBox(); box.addItem( "..." ); for ( int i = 0; i < fieldCompletions.length; i++ ) { box.addItem( fieldCompletions[ i ] ); } box.setSelectedIndex( 0 ); popup.addAttribute( Constants.INSTANCE.AddField(), box ); box.addChangeHandler( new ChangeHandler() { 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(); } } ); popup.show(); }
/** * Pops up the fact selector. */ protected void showFactTypeSelector( final Widget w ) { DataModelOracle completions = this.getModeller().getSuggestionCompletions(); final ListBox box = new ListBox(); String[] facts = completions.getFactTypes(); box.addItem( Constants.INSTANCE.Choose() ); for ( int i = 0; i < facts.length; i++ ) { box.addItem( facts[ i ] ); } box.setSelectedIndex( 0 ); final FormStylePopup popup = new FormStylePopup(); popup.setTitle( Constants.INSTANCE.NewFactPattern() ); popup.addAttribute( Constants.INSTANCE.chooseFactType(), box ); box.addChangeHandler( new ChangeHandler() { public void onChange( ChangeEvent event ) { pattern.setFactPattern( new FactPattern( box.getItemText( box.getSelectedIndex() ) ) ); setModified( true ); getModeller().refreshWidget(); popup.hide(); } } ); popup.show(); }
/** * Pops up the fact selector. */ @Override protected void showFactTypeSelector( final Widget w ) { final ListBox box = new ListBox(); DataModelOracle completions = this.getModeller().getSuggestionCompletions(); String[] facts = completions.getFactTypes(); box.addItem( Constants.INSTANCE.Choose() ); for ( int i = 0; i < facts.length; i++ ) { box.addItem( facts[ i ] ); } box.setSelectedIndex( 0 ); final FormStylePopup popup = new FormStylePopup(); popup.setTitle( Constants.INSTANCE.NewFactPattern() ); popup.addAttribute( Constants.INSTANCE.chooseFactType(), box ); box.addChangeHandler( new ChangeHandler() { public void onChange( ChangeEvent event ) { pattern.setFactPattern( new FactPattern( box.getItemText( box.getSelectedIndex() ) ) ); setModified( true ); getModeller().refreshWidget(); popup.hide(); } } ); popup.show(); }
public ActionRetractFactWidget( RuleModeller modeller, EventBus eventBus, ActionRetractFact model, Boolean readOnly ) { super( modeller, eventBus ); HorizontalPanel layout = new HorizontalPanel(); layout.setWidth( "100%" ); layout.setStyleName( "model-builderInner-Background" ); this.isFactTypeKnown = modeller.getSuggestionCompletions().isFactTypeRecognized( modeller.getModel().getLHSBindingType( model.getVariableName() ) ); if ( readOnly == null ) { this.readOnly = !this.isFactTypeKnown; } else { this.readOnly = readOnly; } if ( this.readOnly ) { layout.addStyleName( "editor-disabled-widget" ); } String desc = modeller.getModel().getLHSBindingType( model.getVariableName() ) + " [" + model.getVariableName() + "]"; layout.add( new SmallLabel( HumanReadable.getActionDisplayName("retract") + " <b>" + desc + "</b>" ) ); //This widget couldn't be modified. this.setModified( false ); initWidget( layout ); }
this.constraint = con; this.constraintList = constraintList; this.sce = modeller.getSuggestionCompletions(); this.model = modeller.getModel();
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; }