Search in sources :

Example 1 with XulDialogCallback

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
            }
        });
    }
}
Also used : IFilePickItem(org.pentaho.mantle.client.solutionbrowser.filepicklist.IFilePickItem) SwitchThemeCommand(org.pentaho.mantle.client.commands.SwitchThemeCommand) Command(com.google.gwt.user.client.Command) SwitchLocaleCommand(org.pentaho.mantle.client.commands.SwitchLocaleCommand) ShowBrowserCommand(org.pentaho.mantle.client.commands.ShowBrowserCommand) XulDialogCallback(org.pentaho.ui.xul.util.XulDialogCallback) MenuBar(com.google.gwt.user.client.ui.MenuBar) GwtConfirmBox(org.pentaho.ui.xul.gwt.tags.GwtConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Aggregations

Command (com.google.gwt.user.client.Command)1 MenuBar (com.google.gwt.user.client.ui.MenuBar)1 ShowBrowserCommand (org.pentaho.mantle.client.commands.ShowBrowserCommand)1 SwitchLocaleCommand (org.pentaho.mantle.client.commands.SwitchLocaleCommand)1 SwitchThemeCommand (org.pentaho.mantle.client.commands.SwitchThemeCommand)1 IFilePickItem (org.pentaho.mantle.client.solutionbrowser.filepicklist.IFilePickItem)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 GwtConfirmBox (org.pentaho.ui.xul.gwt.tags.GwtConfirmBox)1 XulDialogCallback (org.pentaho.ui.xul.util.XulDialogCallback)1