Search in sources :

Example 36 with XulException

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

the class BaseStepGenericXulDialog method showMessage.

public void showMessage(final String message, final String title) {
    try {
        final XulMessageBox msg = (XulMessageBox) document.createElement("messagebox");
        msg.setModalParent(modalParent);
        msg.setTitle(title);
        msg.setMessage(message);
        msg.open();
    } catch (XulException e) {
        log.logError("Error displaying message: {0}", message);
    }
}
Also used : XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) XulException(org.pentaho.ui.xul.XulException)

Example 37 with XulException

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

the class BaseStepGenericXulDialog method showPromptMessage.

public int showPromptMessage(final String message, final String title, Object[] buttons) {
    try {
        final XulMessageBox msg = (XulMessageBox) document.createElement("messagebox");
        msg.setModalParent(modalParent);
        msg.setTitle(title);
        msg.setMessage(message);
        msg.setButtons(buttons);
        return msg.open();
    } catch (XulException e) {
        log.logError("Error displaying message: {0}", message);
    }
    return -1;
}
Also used : XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) XulException(org.pentaho.ui.xul.XulException)

Example 38 with XulException

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

the class PurRepositoryDialog method open.

public RepositoryMeta open(final MODE mode) {
    try {
        SwtXulLoader swtLoader = new SwtXulLoader();
        swtLoader.setOuterContext(parent);
        swtLoader.registerClassLoader(getClass().getClassLoader());
        container = // $NON-NLS-1$
        swtLoader.loadXul("org/pentaho/di/ui/repository/pur/xul/pur-repository-config-dialog.xul", resourceBundle);
        final XulRunner runner = new SwtXulRunner();
        runner.addContainer(container);
        parent.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent arg0) {
                hide();
            }
        });
        repositoryConfigController.setMessages(resourceBundle);
        repositoryConfigController.setRepositoryMeta(repositoryMeta);
        repositoryConfigController.setCallback(new IRepositoryConfigDialogCallback() {

            public void onSuccess(PurRepositoryMeta meta) {
                // If repository does not have a name then send back a null repository meta
                if (meta.getName() != null) {
                    // already exist
                    if (mode == MODE.ADD) {
                        if (masterRepositoriesMeta.searchRepository(meta.getName()) == null) {
                            repositoryMeta = meta;
                            hide();
                        } else {
                            displayRepositoryAlreadyExistMessage(meta.getName());
                        }
                    } else {
                        if (masterRepositoryName.equals(meta.getName())) {
                            repositoryMeta = meta;
                            hide();
                        } else if (masterRepositoriesMeta.searchRepository(meta.getName()) == null) {
                            repositoryMeta = meta;
                            hide();
                        } else {
                            displayRepositoryAlreadyExistMessage(meta.getName());
                        }
                    }
                }
            }

            public void onError(Throwable t) {
                SpoonFactory.getInstance().messageBox(t.getLocalizedMessage(), resourceBundle.getString("RepositoryConfigDialog.InitializationFailed"), false, // $NON-NLS-1$
                Const.ERROR);
                // $NON-NLS-1$
                log.error(resourceBundle.getString("RepositoryConfigDialog.ErrorStartingXulApplication"), t);
            }

            public void onCancel() {
                repositoryMeta = null;
                hide();
            }
        });
        container.addEventHandler(repositoryConfigController);
        try {
            runner.initialize();
            show();
        } catch (XulException e) {
            SpoonFactory.getInstance().messageBox(e.getLocalizedMessage(), resourceBundle.getString("RepositoryConfigDialog.InitializationFailed"), false, // $NON-NLS-1$
            Const.ERROR);
            // $NON-NLS-1$
            log.error(resourceBundle.getString("RepositoryConfigDialog.ErrorStartingXulApplication"), e);
        }
    } catch (XulException e) {
        // $NON-NLS-1$
        log.error(resourceBundle.getString("RepositoryConfigDialog.ErrorStartingXulApplication"), e);
    }
    return repositoryMeta;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) XulException(org.pentaho.ui.xul.XulException) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) SwtXulLoader(org.pentaho.ui.xul.swt.SwtXulLoader) DisposeEvent(org.eclipse.swt.events.DisposeEvent) XulRunner(org.pentaho.ui.xul.XulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 39 with XulException

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

the class AbsController method initializeLogicalRolesUI.

/**
 * Initialized the ActionPermissions UI with all the possible values from LogicalRoles enum
 */
private void initializeLogicalRolesUI() {
    try {
        Map<String, String> logicalRoles = ((IAbsSecurityManager) service).getAllLogicalRoles(GlobalMessages.getLocale().getDisplayName());
        for (Entry<String, String> logicalRole : logicalRoles.entrySet()) {
            XulCheckbox logicalRoleCheckbox;
            // $NON-NLS-1$
            logicalRoleCheckbox = (XulCheckbox) document.createElement("checkbox");
            logicalRoleCheckbox.setLabel(logicalRole.getValue());
            logicalRoleCheckbox.setId(logicalRole.getValue());
            // $NON-NLS-1$
            logicalRoleCheckbox.setCommand("iSecurityController.updateRoleActionPermission()");
            logicalRoleCheckbox.setFlex(1);
            logicalRoleCheckbox.setDisabled(true);
            logicalRolesBox.addChild(logicalRoleCheckbox);
            logicalRoleChecboxMap.put(logicalRoleCheckbox, logicalRole.getKey());
            bf.setBindingType(Binding.Type.ONE_WAY);
            // $NON-NLS-1$ //$NON-NLS-2$
            bf.createBinding(roleListBox, "selectedIndex", logicalRoleCheckbox, "disabled", buttonConverter);
        }
    } catch (XulException xe) {
    } catch (KettleException xe) {
    }
}
Also used : XulCheckbox(org.pentaho.ui.xul.components.XulCheckbox) KettleException(org.pentaho.di.core.exception.KettleException) IAbsSecurityManager(org.pentaho.di.ui.repository.pur.services.IAbsSecurityManager) XulException(org.pentaho.ui.xul.XulException)

Example 40 with XulException

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

Aggregations

XulException (org.pentaho.ui.xul.XulException)60 KettleException (org.pentaho.di.core.exception.KettleException)20 Test (org.junit.Test)11 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)10 XulComponent (org.pentaho.ui.xul.XulComponent)9 Shell (org.eclipse.swt.widgets.Shell)7 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)7 SwtXulRunner (org.pentaho.ui.xul.swt.SwtXulRunner)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)6 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)6 XulRunner (org.pentaho.ui.xul.XulRunner)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Document (org.pentaho.ui.xul.dom.Document)4 ResourceBundle (java.util.ResourceBundle)3 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 XulLoader (org.pentaho.ui.xul.XulLoader)3 SwtBindingFactory (org.pentaho.ui.xul.swt.SwtBindingFactory)3