/**
* This shows a popup for adding fields to a composite
*/
public void showPatternPopupForComposite(Widget w,
final CompositeFieldConstraint composite) {
final FormStylePopup popup = new FormStylePopup( images.newexWiz(),
constants.AddFieldsToThisConstraint() );
final ListBox box = new ListBox();
box.addItem( "..." );
String[] fields = this.completions.getFieldCompletions( this.pattern.getFactType() );
for ( int i = 0; i < fields.length; i++ ) {
box.addItem( fields[i] );
}
box.setSelectedIndex( 0 );
box.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent event) {
composite.addConstraint( new SingleFieldConstraint( box.getItemText( box.getSelectedIndex() ) ) );
modeller.refreshWidget();
popup.hide();
}
} );
popup.addAttribute( constants.AddARestrictionOnAField(),
box );
final ListBox composites = new ListBox();
composites.addItem( "..." ); //NON-NLS
composites.addItem( constants.AllOfAnd(),
CompositeFieldConstraint.COMPOSITE_TYPE_AND );
composites.addItem( constants.AnyOfOr(),
CompositeFieldConstraint.COMPOSITE_TYPE_OR );
composites.setSelectedIndex( 0 );
composites.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent event) {
CompositeFieldConstraint comp = new CompositeFieldConstraint();
comp.compositeJunctionType = composites.getValue( composites.getSelectedIndex() );
composite.addConstraint( comp );
modeller.refreshWidget();
popup.hide();
}
} );
InfoPopup infoComp = new InfoPopup( constants.MultipleFieldConstraints(),
constants.MultipleConstraintsTip() );
HorizontalPanel horiz = new HorizontalPanel();
horiz.add( composites );
horiz.add( infoComp );
popup.addAttribute( constants.MultipleFieldConstraint(),
horiz );
popup.show();
}