put( constants.CheckinComment(),
new MetaDataQuery( "drools:checkinComment" ) ); //NON-NLS
}
};
FormStyleLayout fm = new FormStyleLayout();
for ( Iterator<String> iterator = atts.keySet().iterator(); iterator.hasNext(); ) {
String fieldName = (String) iterator.next();
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();
AssetItemGrid grid = new AssetItemGrid(editEvent,
"searchresults",
new AssetItemGridDataLoader() { //NON-NLS
public void loadData(int startRow,
int numberOfRows,
GenericCallback cb) {
MetaDataQuery[] mdq = new MetaDataQuery[atts.size()];
int i = 0;
for ( Iterator<String> iterator = atts.keySet().iterator(); iterator.hasNext(); ) {
String name = (String) iterator.next();
mdq[i] = (MetaDataQuery) atts.get( name );
i++;
}
try {
RepositoryServiceFactory.getService().queryMetaData( mdq,
getDate( createdAfter ),
getDate( createdBefore ),
getDate( lastModAfter ),
getDate( lastModBefore ),
false,
startRow,
numberOfRows,
cb );
} catch ( IllegalArgumentException e ) {
ErrorPopup.showMessage( Format.format( constants.BadDateFormatPleaseTryAgainTryTheFormatOf0(),
Preferences.getStringPref( "drools.dateformat" ) ) );
}
}
private Date getDate(final DatePickerTextBox datePicker) {
try {
return datePicker.getDate();
} catch ( IllegalArgumentException e ) {
datePicker.clear();
throw e;
}
}
} );
resultsP.add( grid );
}
} );
fm.addRow( resultsP );
advancedDisclosure.setContent( fm );
layout.add( advancedDisclosure );
}