this.model = set;
this.layout = new DirtyableFlexTable();
layout.setStyleName( "model-builderInner-Background" ); // NON-NLS
PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
if ( completions.isGlobalVariable( set.getVariable() ) ) {
List<MethodInfo> infos = completions.getMethodInfosForGlobalVariable( set.getVariable() );
if ( infos != null ) {
this.fieldCompletionTexts = new String[ infos.size() ];
this.fieldCompletionValues = new String[ infos.size() ];
int i = 0;
for ( MethodInfo info : infos ) {
this.fieldCompletionTexts[ i ] = info.getName();
this.fieldCompletionValues[ i ] = info.getNameWithParameters();
i++;
}
this.variableClass = completions.getGlobalVariable( set.getVariable() );
} else {
this.fieldCompletionTexts = new String[ 0 ];
this.fieldCompletionValues = new String[ 0 ];
readOnly = true;
}
} else {
FactPattern pattern = mod.getModel().getLHSBoundFact( set.getVariable() );
if ( pattern != null ) {
List<String> methodList = completions.getMethodNames( pattern.getFactType() );
fieldCompletionTexts = new String[ methodList.size() ];
fieldCompletionValues = new String[ methodList.size() ];
int i = 0;
for ( String methodName : methodList ) {
fieldCompletionTexts[ i ] = methodName;
fieldCompletionValues[ i ] = methodName;
i++;
}
this.variableClass = pattern.getFactType();
this.isBoundFact = true;
} else {
/*
* if the call method is applied on a bound variable created in
* the rhs
*/
ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact( set.getVariable() );
if ( patternRhs != null ) {
List<String> methodList = completions.getMethodNames( patternRhs.getFactType() );
fieldCompletionTexts = new String[ methodList.size() ];
fieldCompletionValues = new String[ methodList.size() ];
int i = 0;
for ( String methodName : methodList ) {
fieldCompletionTexts[ i ] = methodName;
fieldCompletionValues[ i ] = methodName;
i++;
}
this.variableClass = patternRhs.getFactType();
this.isBoundFact = true;
} else {
readOnly = true;
}
}
}
this.isFactTypeKnown = completions.isFactTypeRecognized( this.variableClass );
if ( readOnly == null ) {
this.readOnly = !this.isFactTypeKnown;
} else {
this.readOnly = readOnly;
}