Search in sources :

Example 1 with GwtConfirmBox

use of org.pentaho.ui.xul.gwt.tags.GwtConfirmBox 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)

Example 2 with GwtConfirmBox

use of org.pentaho.ui.xul.gwt.tags.GwtConfirmBox in project data-access by pentaho.

the class MetadataImportDialogController method confirm.

/**
 * Shows a confirmation dialog
 *
 * @param title
 * @param message
 * @param okButtonLabel
 * @param cancelButtonLabel
 * @param onResulthandler
 */
private void confirm(final String title, final String message, final String okButtonLabel, final String cancelButtonLabel, final AsyncCallback<Boolean> onResulthandler) {
    XulConfirmBox confirm = new GwtConfirmBox() {

        @Override
        public Panel getDialogContents() {
            VerticalPanel vp = new VerticalPanel();
            Label lbl = new Label(this.getMessage());
            vp.add(lbl);
            vp.setCellHorizontalAlignment(lbl, VerticalPanel.ALIGN_LEFT);
            vp.setCellVerticalAlignment(lbl, VerticalPanel.ALIGN_MIDDLE);
            return vp;
        }
    };
    confirm.setTitle(title);
    confirm.setMessage(message);
    confirm.setAcceptLabel(okButtonLabel);
    confirm.setCancelLabel(cancelButtonLabel);
    confirm.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (onResulthandler != null) {
                onResulthandler.onSuccess(status == XulDialogCallback.Status.ACCEPT);
            }
        }

        public void onError(XulComponent component, Throwable err) {
            onResulthandler.onFailure(err);
            return;
        }
    });
    confirm.open();
}
Also used : HttpStatus(org.apache.http.HttpStatus) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) Label(com.google.gwt.user.client.ui.Label) XulLabel(org.pentaho.ui.xul.components.XulLabel) GwtConfirmBox(org.pentaho.ui.xul.gwt.tags.GwtConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Aggregations

XulComponent (org.pentaho.ui.xul.XulComponent)2 GwtConfirmBox (org.pentaho.ui.xul.gwt.tags.GwtConfirmBox)2 Command (com.google.gwt.user.client.Command)1 Label (com.google.gwt.user.client.ui.Label)1 MenuBar (com.google.gwt.user.client.ui.MenuBar)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 HttpStatus (org.apache.http.HttpStatus)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 XulConfirmBox (org.pentaho.ui.xul.components.XulConfirmBox)1 XulLabel (org.pentaho.ui.xul.components.XulLabel)1 XulDialogCallback (org.pentaho.ui.xul.util.XulDialogCallback)1