Search in sources :

Example 1 with GwtPromptBox

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

the class MetadataImportDialogController method promptImportMetadata.

/**
 * Shows a promt dialog
 *
 * @param title
 * @param message
 * @param radioDSWLabel
 * @param radioMetaLabel
 * @param onResulthandler
 */
private void promptImportMetadata(final String title, final String message, final String radioDSWLabel, final String radioMetaLabel, final AsyncCallback<Boolean> onResulthandler) {
    final VerticalPanel panel = new VerticalPanel();
    // $NON-NLS-1$
    panel.add(new Label(message));
    VerticalPanel vp = new VerticalPanel();
    HorizontalPanel hp = new HorizontalPanel();
    hp.getElement().getStyle().setMarginBottom(10, Style.Unit.PX);
    hp.getElement().getStyle().setMarginTop(10, Style.Unit.PX);
    final RadioButton dswRadio = new RadioButton("importMetadata");
    RadioButton metadataRadio = new RadioButton("importMetadata");
    dswRadio.setEnabled(true);
    dswRadio.setValue(true);
    hp.add(dswRadio);
    hp.add(new Label(radioDSWLabel));
    vp.add(hp);
    HorizontalPanel hp2 = new HorizontalPanel();
    hp2.add(metadataRadio);
    hp2.add(new Label(radioMetaLabel));
    vp.add(hp2);
    panel.add(vp);
    XulPromptBox promptBox = new GwtPromptBox() {

        @Override
        public Panel getDialogContents() {
            return panel;
        }

        @Override
        public int open() {
            super.show();
            dswRadio.setFocus(true);
            return 0;
        }

        @Override
        public Panel getButtonPanel() {
            Panel button = super.getButtonPanel();
            return button;
        }
    };
    promptBox.setTitle(title);
    promptBox.setAcceptLabel(resBundle.getString("importDialog.DIALOG_OK", "OK"));
    promptBox.setCancelLabel(resBundle.getString("importDialog.DIALOG_Cancel", "Cancel"));
    promptBox.addDialogCallback(new XulDialogCallback<String>() {

        @Override
        public void onClose(XulComponent component, Status status, String value) {
            if (status == Status.CANCEL) {
                onImportCancel();
                reShowDialog();
                return;
            }
            if (onResulthandler != null) {
                onResulthandler.onSuccess(dswRadio.getValue());
            }
        }

        @Override
        public void onError(XulComponent xulComponent, Throwable throwable) {
            onResulthandler.onFailure(throwable);
        }
    });
    promptBox.setWidth(460);
    promptBox.setHeight(140);
    promptBox.open();
}
Also used : HttpStatus(org.apache.http.HttpStatus) Label(com.google.gwt.user.client.ui.Label) XulLabel(org.pentaho.ui.xul.components.XulLabel) RadioButton(com.google.gwt.user.client.ui.RadioButton) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) RootPanel(com.google.gwt.user.client.ui.RootPanel) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) FormPanel(com.google.gwt.user.client.ui.FormPanel) Panel(com.google.gwt.user.client.ui.Panel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) GwtPromptBox(org.pentaho.ui.xul.gwt.tags.GwtPromptBox) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) XulComponent(org.pentaho.ui.xul.XulComponent)

Aggregations

FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 FormPanel (com.google.gwt.user.client.ui.FormPanel)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Label (com.google.gwt.user.client.ui.Label)1 Panel (com.google.gwt.user.client.ui.Panel)1 RadioButton (com.google.gwt.user.client.ui.RadioButton)1 RootPanel (com.google.gwt.user.client.ui.RootPanel)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 HttpStatus (org.apache.http.HttpStatus)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 XulLabel (org.pentaho.ui.xul.components.XulLabel)1 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)1 GwtPromptBox (org.pentaho.ui.xul.gwt.tags.GwtPromptBox)1