lastEditDateItem.setDisabled(true);
lastEditDateItem.setUseTextField(true);
lastEditDateItem.setTitle(messages.searchFavouritesListWidgetLastChange());
form.setFields(nameItem, sharedItem, lastEditItem, lastEditDateItem);
HLayout buttonlayout = new HLayout(10);
buttonlayout.setHeight(20);
buttonlayout.setWidth100();
HLayout frmButtonlayout = new HLayout(10);
frmButtonlayout.setHeight(20);
frmButtonlayout.setWidth100();
final IButton saveButton = new IButton(messages.searchFavouritesListWidgetSave());
saveButton.setIcon(BTN_SAVE_IMG);
saveButton.setAutoFit(true);
saveButton.setShowDisabledIcon(false);
saveButton.setDisabled(true);
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
SearchFavourite oldFav = flr.getFavourite();
SearchFavourite newFav = (SearchFavourite) oldFav.clone();
newFav.setName(nameItem.getValueAsString());
newFav.setShared(sharedItem.getValueAsBoolean());
flr.setFavourite(newFav);
SearchWidgetRegistry.getFavouritesController().onChangeRequested(
new FavouriteEvent(oldFav, newFav, SearchFavouritesListPanel.this));
}
});
final IButton cancelButton = new IButton(messages.searchFavouritesListWidgetCancel());
cancelButton.setIcon(BTN_CANCEL_IMG);
cancelButton.setAutoFit(true);
cancelButton.setDisabled(true);
cancelButton.setShowDisabledIcon(false);
cancelButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
FavouritesListGrid.this.collapseRecord(record);
FavouritesListGrid.this.expandRecord(record);
}
});
form.addItemChangedHandler(new ItemChangedHandler() {
public void onItemChanged(ItemChangedEvent event) {
if (saveButton.isDisabled()) {
saveButton.setDisabled(false);
cancelButton.setDisabled(false);
}
}
});
IButton editCritButton = new IButton(messages.searchFavouritesListWidgetEditFilter());
editCritButton.setIcon(BTN_EDIT_IMG);
editCritButton.setAutoFit(true);
editCritButton.setShowDisabledIcon(false);
editCritButton.setTooltip(messages.searchFavouritesListWidgetEditFilterTooltip());
editCritButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
SearchWidget sw = null;
if (AttributeSearchPanel.canHandle(fav.getCriterion())) {
sw = SearchWidgetRegistry.getSearchWidgetInstance(AttributeSearchCreator.IDENTIFIER);
}
if (sw == null && CombinedSearchPanel.canHandle(fav.getCriterion())) {
sw = SearchWidgetRegistry.getSearchWidgetInstance(CombinedSearchCreator.IDENTIFIER);
}
if (sw == null) {
SC.say(messages.searchFavouritesListWidgetSearchWindowNotFound());
return;
}
sw.showForSave(new SaveRequestHandler() {
public void onSaveRequested(SaveRequestEvent event) {
SearchFavourite oldFav = flr.getFavourite();
SearchFavourite newFav = (SearchFavourite) oldFav.clone();
newFav.setCriterion(event.getCriterion());
flr.setFavourite(newFav);
SearchWidgetRegistry.getFavouritesController().onChangeRequested(
new FavouriteEvent(oldFav, newFav, SearchFavouritesListPanel.this));
}
});
sw.initialize(fav.getCriterion());
}
});
IButton deleteButton = new IButton(messages.searchFavouritesListWidgetDelete());
deleteButton.setIcon(BTN_DELETE_IMG);
deleteButton.setAutoFit(true);
deleteButton.setShowDisabledIcon(false);
deleteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
SC.ask(messages.searchFavouritesListWidgetDelete(),
messages.searchFavouritesListWidgetDeleteMessage(), new BooleanCallback() {
public void execute(Boolean value) {
if (value) {
favouriteItems.collapseRecord(record);
SearchWidgetRegistry.getFavouritesController().onDeleteRequested(
new FavouriteEvent(flr.getFavourite(), null,
SearchFavouritesListPanel.this));
}
}
});
}
});
LayoutSpacer lsrFrm = new LayoutSpacer();
lsrFrm.setWidth("*");
// ----------------------------------------------------------
frmButtonlayout.addMember(lsrFrm);
frmButtonlayout.addMember(saveButton);
frmButtonlayout.addMember(cancelButton);
group.addMember(form);
group.addMember(frmButtonlayout);
buttonlayout.addMember(editCritButton);
buttonlayout.addMember(deleteButton);