setWidth( "100%" );
}
private void doMetaSearch() {
Panel p = new Panel();
p.setCollapsible( true );
p.setTitle( constants.AttributeSearch() );
final Map<String, MetaDataQuery> atts = new HashMap<String, MetaDataQuery>() {
{
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 ( Iterator 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.addChangeListener( new ChangeListener() {
public void onChange(Widget w) {
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.addClickListener( new ClickListener() {
public void onClick(Widget w) {
resultsP.clear();
AssetItemGrid grid = new AssetItemGrid( openItem,
"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 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 );
p.add( fm );
p.setCollapsed( true );
layout.add( p );
}