advancedDisclosure.setContent( container );
layout.add( advancedDisclosure );
}
private void doMetaSearch() {
DecoratedDisclosurePanel advancedDisclosure = new DecoratedDisclosurePanel( constants.AttributeSearch() );
advancedDisclosure.setWidth( "100%" );
advancedDisclosure.setOpen( true );
VerticalPanel container = new VerticalPanel();
VerticalPanel criteria = new VerticalPanel();
final Map<String, MetaDataQuery> atts = new HashMap<String, MetaDataQuery>() {
private static final long serialVersionUID = 510l;
{
put( constants.CreatedBy(),
new MetaDataQuery( "drools:creator" ) ); // NON-NLS
put( constants.Format1(),
new MetaDataQuery( "drools:format" ) ); // NON-NLS
put( constants.Subject(),
new MetaDataQuery( "drools:subject" ) ); // NON-NLS
put( constants.Type1(),
new MetaDataQuery( "drools:type" ) ); // NON-NLS
put( constants.ExternalLink(),
new MetaDataQuery( "drools:relation" ) ); // NON-NLS
put( constants.Source(),
new MetaDataQuery( "drools:source" ) ); // NON-NLS
put( constants.Description1(),
new MetaDataQuery( "drools:description" ) ); // NON-NLS
put( constants.LastModifiedBy(),
new MetaDataQuery( "drools:lastContributor" ) ); // NON-NLS
put( constants.CheckinComment(),
new MetaDataQuery( "drools:checkinComment" ) ); // NON-NLS
}
};
FormStyleLayout fm = new FormStyleLayout();
for ( String fieldName : atts.keySet() ) {
final MetaDataQuery q = (MetaDataQuery) atts.get( fieldName );
final TextBox box = new TextBox();
box.setTitle( constants.WildCardsSearchTip() );
fm.addAttribute( fieldName
+ ":",
box );
box.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent arg0) {
q.valueList = box.getText();
}
} );
}
HorizontalPanel created = new HorizontalPanel();
created.add( new SmallLabel( constants.AfterColon() ) );
final DatePickerTextBox createdAfter = new DatePickerTextBox( "" );
created.add( createdAfter );
created.add( new SmallLabel( " " ) ); // NON-NLS
created.add( new SmallLabel( constants.BeforeColon() ) );
final DatePickerTextBox createdBefore = new DatePickerTextBox( "" );
created.add( createdBefore );
fm.addAttribute( constants.DateCreated1(),
created );
HorizontalPanel lastMod = new HorizontalPanel();
lastMod.add( new SmallLabel( constants.AfterColon() ) );
final DatePickerTextBox lastModAfter = new DatePickerTextBox( "" );
lastMod.add( lastModAfter );
lastMod.add( new SmallLabel( " " ) ); // NON-NLS
lastMod.add( new SmallLabel( constants.BeforeColon() ) );
final DatePickerTextBox lastModBefore = new DatePickerTextBox( "" );
lastMod.add( lastModBefore );
fm.addAttribute( constants.LastModified1(),
lastMod );
final SimplePanel resultsP = new SimplePanel();
Button search = new Button( constants.Search() );
fm.addAttribute( "",
search );
search.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent arg0) {
resultsP.clear();
try {
List<MetaDataQuery> metadata = new ArrayList<MetaDataQuery>();
metadata.addAll( atts.values() );
QueryPagedTable table = new QueryPagedTable( metadata,
getDate( createdAfter ),
getDate( createdBefore ),
getDate( lastModAfter ),
getDate( lastModBefore ),
false,
clientFactory );
resultsP.add( table );
} catch ( IllegalArgumentException e ) {
ErrorPopup.showMessage( constants.BadDateFormatPleaseTryAgainTryTheFormatOf0(
ApplicationPreferences.getDroolsDateFormat() ) );
}
}
private Date getDate(final DatePickerTextBox datePicker) {
try {
return datePicker.getDate();
} catch ( IllegalArgumentException e ) {
datePicker.clear();
throw e;
}
}
} );
criteria.add( fm );
container.add( criteria );
container.add( resultsP );
advancedDisclosure.setContent( container );
layout.add( advancedDisclosure );
}