this.model = actionCallMethod;
this.layout = new DirtyableFlexTable();
layout.setStyleName( "model-builderInner-Background" ); // NON-NLS
final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
if ( oracle.isGlobalVariable( actionCallMethod.getVariable() ) ) {
oracle.getMethodInfosForGlobalVariable( actionCallMethod.getVariable(),
new Callback<List<MethodInfo>>() {
@Override
public void callback( final List<MethodInfo> infos ) {
if ( infos != null ) {
ActionCallMethodWidget.this.fieldCompletionTexts = new String[ infos.size() ];
ActionCallMethodWidget.this.fieldCompletionValues = new String[ infos.size() ];
int i = 0;
for ( MethodInfo info : infos ) {
ActionCallMethodWidget.this.fieldCompletionTexts[ i ] = info.getName();
ActionCallMethodWidget.this.fieldCompletionValues[ i ] = info.getNameWithParameters();
i++;
}
ActionCallMethodWidget.this.variableClass = oracle.getGlobalVariable( actionCallMethod.getVariable() );
} else {
ActionCallMethodWidget.this.fieldCompletionTexts = new String[ 0 ];
ActionCallMethodWidget.this.fieldCompletionValues = new String[ 0 ];
ActionCallMethodWidget.this.readOnly = true;
}
}
} );
} else {
final FactPattern pattern = mod.getModel().getLHSBoundFact( actionCallMethod.getVariable() );
if ( pattern != null ) {
oracle.getMethodInfos( pattern.getFactType(),
new Callback<List<MethodInfo>>() {
@Override
public void callback( final List<MethodInfo> methodInfos ) {
ActionCallMethodWidget.this.fieldCompletionTexts = new String[ methodInfos.size() ];
ActionCallMethodWidget.this.fieldCompletionValues = new String[ methodInfos.size() ];
int i = 0;
for ( MethodInfo methodInfo : methodInfos ) {
ActionCallMethodWidget.this.fieldCompletionTexts[ i ] = methodInfo.getName();
ActionCallMethodWidget.this.fieldCompletionValues[ i ] = methodInfo.getNameWithParameters();
i++;
}
ActionCallMethodWidget.this.variableClass = pattern.getFactType();
ActionCallMethodWidget.this.isBoundFact = true;
}
} );
} else {
/*
* if the call method is applied on a bound variable created in the rhs
*/
final ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact( actionCallMethod.getVariable() );
if ( patternRhs != null ) {
oracle.getMethodInfos( patternRhs.getFactType(),
new Callback<List<MethodInfo>>() {
@Override
public void callback( final List<MethodInfo> methodInfos ) {
ActionCallMethodWidget.this.fieldCompletionTexts = new String[ methodInfos.size() ];
ActionCallMethodWidget.this.fieldCompletionValues = new String[ methodInfos.size() ];
int i = 0;
for ( MethodInfo methodInfo : methodInfos ) {
ActionCallMethodWidget.this.fieldCompletionTexts[ i ] = methodInfo.getName();
ActionCallMethodWidget.this.fieldCompletionValues[ i ] = methodInfo.getNameWithParameters();
i++;
}
ActionCallMethodWidget.this.variableClass = patternRhs.getFactType();
ActionCallMethodWidget.this.isBoundFact = true;
}
} );
} else {
this.readOnly = true;
}
}
}
this.isFactTypeKnown = oracle.isFactTypeRecognized( this.variableClass );
if ( readOnly == null ) {
this.readOnly = !this.isFactTypeKnown;
} else {
this.readOnly = readOnly;
}