private ListBox boundVariable(final FieldNature c) {
/*
* If there is a bound variable that is the same type of the current
* variable type, then propose a list
*/
ListBox listVariable = new ListBox();
List<String> vars = model.getModel().getLHSBoundFacts();
for ( String v : vars ) {
FactPattern factPattern = model.getModel().getLHSBoundFact( v );
if ( factPattern.getFactType().equals( this.methodParameter.type ) ) {
// First selection is empty
if ( listVariable.getItemCount() == 0 ) {
listVariable.addItem( "..." );
}
listVariable.addItem( v );
}
}
/*
* add the bound variable of the rhs
*/
List<String> vars2 = model.getModel().getRHSBoundFacts();
for ( String v : vars2 ) {
ActionInsertFact factPattern = model.getModel().getRHSBoundFact( v );
if ( factPattern.factType.equals( this.methodParameter.type ) ) {
// First selection is empty
if ( listVariable.getItemCount() == 0 ) {
listVariable.addItem( "..." );
}
listVariable.addItem( v );
}
}
if ( methodParameter.value.equals( "=" ) ) {
listVariable.setSelectedIndex( 0 );
} else {
for ( int i = 0; i < listVariable.getItemCount(); i++ ) {
if ( listVariable.getItemText( i ).equals( methodParameter.value ) ) {
listVariable.setSelectedIndex( i );
}
}
}
if ( listVariable.getItemCount() > 0 ) {
listVariable.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent event) {
ListBox w = (ListBox) event.getSource();
methodParameter.value = w.getValue( w.getSelectedIndex() );
if ( onValueChangeCommand != null ) {
onValueChangeCommand.execute();
}
makeDirty();
refresh();