Search in sources :

Example 26 with XulComponent

use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.

the class TrashBrowseController method renameRepositoryObject.

@Override
protected void renameRepositoryObject(final UIRepositoryObject repoObject) throws XulException {
    // final Document doc = document;
    XulPromptBox prompt = promptForName(repoObject);
    prompt.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == Status.ACCEPT) {
                final String newName = value;
                try {
                    repoObject.setName(newName);
                } catch (KettleException ke) {
                    if (ke.getCause() instanceof RepositoryObjectAccessException) {
                        moveDeletePrompt(ke, repoObject, new XulDialogCallback<Object>() {

                            public void onClose(XulComponent sender, Status returnCode, Object retVal) {
                                if (returnCode == Status.ACCEPT) {
                                    try {
                                        ((UIEERepositoryDirectory) repoObject).setName(newName, true);
                                    } catch (Exception e) {
                                        if (mainController == null || !mainController.handleLostRepository(e)) {
                                            displayExceptionMessage(BaseMessages.getString(PKG, e.getLocalizedMessage()));
                                        }
                                    }
                                }
                            }

                            public void onError(XulComponent sender, Throwable t) {
                                if (mainController == null || !mainController.handleLostRepository(t)) {
                                    throw new RuntimeException(t);
                                }
                            }
                        });
                    } else {
                        if (mainController == null || !mainController.handleLostRepository(ke)) {
                            throw new RuntimeException(ke);
                        }
                    }
                } catch (Exception e) {
                    if (mainController == null || !mainController.handleLostRepository(e)) {
                        // convert to runtime exception so it bubbles up through the UI
                        throw new RuntimeException(e);
                    }
                }
            }
        }

        public void onError(XulComponent component, Throwable err) {
            if (mainController == null || !mainController.handleLostRepository(err)) {
                throw new RuntimeException(err);
            }
        }
    });
    prompt.open();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObjectAccessException(org.pentaho.di.repository.pur.RepositoryObjectAccessException) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) IDeletedObject(org.pentaho.di.ui.repository.pur.services.ITrashService.IDeletedObject) XulComponent(org.pentaho.ui.xul.XulComponent) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObjectAccessException(org.pentaho.di.repository.pur.RepositoryObjectAccessException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)

Example 27 with XulComponent

use of org.pentaho.ui.xul.XulComponent in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method showConfirm.

public void showConfirm(final JavaScriptObject callback, String message, String title, String okText, String cancelText) throws XulException {
    XulConfirmBox confirm = (XulConfirmBox) wizard.getMainWizardContainer().getDocumentRoot().createElement("confirmbox");
    confirm.setTitle(title);
    confirm.setMessage(message);
    confirm.setAcceptLabel(okText);
    confirm.setCancelLabel(cancelText);
    confirm.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == XulDialogCallback.Status.ACCEPT) {
                notifyDialogCallbackSuccess(callback, value);
            }
        }

        public void onError(XulComponent component, Throwable err) {
            notifyDialogCallbackError(callback, err.getMessage());
        }
    });
    confirm.open();
}
Also used : XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 28 with XulComponent

use of org.pentaho.ui.xul.XulComponent in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method overwriteFileDialog.

/**
 * used to handle the overwrite in repository message
 *
 * @param parentFormPanel
 * @param message
 * @param controller
 */
public void overwriteFileDialog(final FormPanel parentFormPanel, String message, final IOverwritableController controller) {
    // Experiment
    XulConfirmBox confirm = null;
    try {
        confirm = (XulConfirmBox) wizard.getMainWizardContainer().getDocumentRoot().createElement("confirmbox");
    } catch (XulException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    confirm.setTitle("Confirmation");
    confirm.setMessage(message);
    confirm.setAcceptLabel("Ok");
    confirm.setCancelLabel("Cancel");
    confirm.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == XulDialogCallback.Status.ACCEPT) {
                controller.setOverwrite(true);
                controller.removeHiddenPanels();
                controller.buildAndSetParameters();
                parentFormPanel.submit();
            }
        }

        public void onError(XulComponent component, Throwable err) {
            return;
        }
    });
    confirm.open();
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 29 with XulComponent

use of org.pentaho.ui.xul.XulComponent in project data-access by pentaho.

the class AnalysisImportDialogController method overwriteFileDialog.

@Bindable
public void overwriteFileDialog(int code) {
    if (code != PUBLISH_SCHEMA_CATALOG_EXISTS_ERROR && code != PUBLISH_SCHEMA_EXISTS_ERROR) {
        return;
    }
    String msg = messages.getString("Mondrian.OVERWRITE_EXISTING_SCHEMA");
    if (PUBLISH_SCHEMA_CATALOG_EXISTS_ERROR == code) {
        msg = messages.getString("Mondrian.OVERWRITE_EXISTING_CATALOG");
    }
    XulConfirmBox confirm = null;
    try {
        confirm = (XulConfirmBox) document.createElement("confirmbox");
    } catch (XulException e) {
        Window.alert(e.getMessage());
    }
    confirm.setTitle("Confirmation");
    confirm.setMessage(msg);
    confirm.setAcceptLabel("Ok");
    confirm.setCancelLabel("Cancel");
    confirm.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == XulDialogCallback.Status.ACCEPT) {
                overwrite = true;
                removeHiddenPanels();
                buildAndSetParameters();
                formPanel.submit();
            }
        }

        public void onError(XulComponent component, Throwable err) {
            return;
        }
    });
    confirm.open();
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 30 with XulComponent

use of org.pentaho.ui.xul.XulComponent 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)33 XulException (org.pentaho.ui.xul.XulException)13 KettleException (org.pentaho.di.core.exception.KettleException)8 XulConfirmBox (org.pentaho.ui.xul.components.XulConfirmBox)8 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)6 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)6 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)4 Document (org.pentaho.ui.xul.dom.Document)4 Test (org.junit.Test)3 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)3 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)3 Bindable (org.pentaho.ui.xul.stereotype.Bindable)3 Label (com.google.gwt.user.client.ui.Label)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 ArrayList (java.util.ArrayList)2 HttpStatus (org.apache.http.HttpStatus)2 IAclObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)2 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)2 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)2