use of org.pentaho.ui.xul.util.XulDialogCallback in project pentaho-platform by pentaho.
the class MantleController method refreshPickListMenu.
/**
* Loads an arbitrary <code>FilePickList</code> into a menu
*
* @param pickMenu
* The XulMenuBar to host the menu entries
* @param filePickList
* The files to list in natural order
*/
private void refreshPickListMenu(XulMenubar pickMenu, final AbstractFilePickList<? extends IFilePickItem> filePickList, PickListType type) {
final MenuBar menuBar = (MenuBar) pickMenu.getManagedObject();
menuBar.clearItems();
final String menuClearMessage = Messages.getString(type.getMenuItemKey());
final String clearMessage = Messages.getString(type.getMessageKey());
if (filePickList.size() > 0) {
for (IFilePickItem filePickItem : filePickList.getFilePickList()) {
final String text = filePickItem.getFullPath();
menuBar.addItem(filePickItem.getTitle(), new Command() {
public void execute() {
SolutionBrowserPanel.getInstance().openFile(text, COMMAND.RUN);
}
});
}
menuBar.addSeparator();
menuBar.addItem(menuClearMessage, new Command() {
public void execute() {
// confirm the clear
GwtConfirmBox warning = new GwtConfirmBox();
warning.setHeight(117);
warning.setMessage(clearMessage);
warning.setTitle(menuClearMessage);
warning.setAcceptLabel(Messages.getString("clearRecentAcceptButtonLabel"));
warning.setCancelLabel(Messages.getString("clearRecentCancelButtonLabel"));
warning.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent sender, Status returnCode, String retVal) {
if (returnCode == Status.ACCEPT) {
filePickList.clear();
}
}
public void onError(XulComponent sender, Throwable t) {
}
});
warning.show();
}
});
} else {
menuBar.addItem(Messages.getString("empty"), new // $NON-NLS-1$
Command() {
public void execute() {
// Do nothing
}
});
}
}
Aggregations