public ActionSetFieldWidget( RuleModeller mod, EventBus eventBus, ActionSetField set, Boolean readOnly) { super(mod, eventBus); this.model = set; this.layout = new DirtyableFlexTable(); layout.setStyleName("model-builderInner-Background"); SuggestionCompletionEngine completions = this.getModeller().getSuggestionCompletions(); if (completions.isGlobalVariable(set.variable)) { this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable(set.variable); this.variableClass = completions.getGlobalVariable(set.variable); } else { String type = mod.getModel().getLHSBindingType(set.variable); if (type != null) { this.fieldCompletions = completions.getFieldCompletions(FieldAccessorsAndMutators.MUTATOR, type); this.variableClass = type; this.isBoundFact = true; } else { ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact(set.variable); if (patternRhs != null) { this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR, patternRhs.factType); this.variableClass = patternRhs.factType; this.isBoundFact = true; } } } if (this.variableClass == null) { readOnly = true; ErrorPopup.showMessage(Constants.INSTANCE.CouldNotFindTheTypeForVariable0(set.variable)); } this.isFactTypeKnown = completions.containsFactType(this.variableClass); if (readOnly == null) { this.readOnly = !this.isFactTypeKnown; } else { this.readOnly = readOnly; } if (this.readOnly) { layout.addStyleName("editor-disabled-widget"); } doLayout(); initWidget(this.layout); }
public ActionSetFieldWidget(RuleModeller mod, ActionSetField set, Boolean readOnly) { super(mod); this.model = set; this.layout = new DirtyableFlexTable(); layout.setStyleName("model-builderInner-Background"); SuggestionCompletionEngine completions = this.getModeller().getSuggestionCompletions(); if (completions.isGlobalVariable(set.variable)) { this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable(set.variable); this.variableClass = completions.getGlobalVariable(set.variable); } else { String type = mod.getModel().getBindingType(set.variable); if (type != null) { this.fieldCompletions = completions.getFieldCompletions(FieldAccessorsAndMutators.MUTATOR, type); this.variableClass = type; this.isBoundFact = true; } else { ActionInsertFact patternRhs = mod.getModel().getRhsBoundFact(set.variable); if (patternRhs != null) { this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR, patternRhs.factType); this.variableClass = patternRhs.factType; this.isBoundFact = true; } } } if (this.variableClass == null) { throw new IllegalStateException("couldn't find type for variable: " + set.variable); } if (readOnly == null) { this.readOnly = !completions.containsFactType(this.variableClass); } else { this.readOnly = readOnly; } if (this.readOnly) { layout.addStyleName("editor-disabled-widget"); } doLayout(); initWidget(this.layout); }