Search in sources :

Example 1 with XulConfirmBox

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

the class AbstractPermissionsController method onContextChange.

public TYPE onContextChange() {
    try {
        if (viewAclsModel.isModelDirty()) {
            if (!hasManageAclAccess()) {
                // if the user does not have permission to modify the acls,
                // ignore any changes, although this code shouldn't be executed
                // because all buttons should be disabled.
                viewAclsModel.clear();
                // Clear the ACL from the backing repo object
                clearSelectedObjAcl();
                viewAclsModel.setModelDirty(false);
                return TYPE.OK;
            }
            XulConfirmBox confirmBox = null;
            try {
                // $NON-NLS-1$
                confirmBox = (XulConfirmBox) document.createElement("confirmbox");
            } catch (Exception e) {
                // convert to runtime exception so it bubbles up through the UI
                throw new RuntimeException(e);
            }
            // $NON-NLS-1$
            confirmBox.setTitle(BaseMessages.getString(PKG, "PermissionsController.ContextChangeWarning"));
            // $NON-NLS-1$
            confirmBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.ContextChangeWarningText"));
            // $NON-NLS-1$
            confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Yes"));
            // $NON-NLS-1$
            confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.No"));
            confirmBox.addDialogCallback(new XulDialogCallback<Object>() {

                public void onClose(XulComponent sender, Status returnCode, Object retVal) {
                    if (returnCode == Status.ACCEPT) {
                        returnType = TYPE.OK;
                        viewAclsModel.clear();
                        // Clear the ACL from the backing repo object
                        clearSelectedObjAcl();
                        viewAclsModel.setModelDirty(false);
                    } else {
                        returnType = TYPE.CANCEL;
                    }
                }

                public void onError(XulComponent sender, Throwable t) {
                    returnType = TYPE.NO_OP;
                }
            });
            confirmBox.open();
        } else {
            returnType = TYPE.NO_OP;
        }
        return returnType;
    } catch (Exception e) {
        if (KettleRepositoryLostException.lookupStackStrace(e) != null) {
            return TYPE.NO_OP;
        } else {
            throw new RuntimeException(e);
        }
    }
}
Also used : XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) IAclObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject) XulComponent(org.pentaho.ui.xul.XulComponent) KettleException(org.pentaho.di.core.exception.KettleException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)

Example 2 with XulConfirmBox

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

the class StarModelerPerspective method onTabClose.

public boolean onTabClose(final int pos) throws XulException {
    if (models.get(pos).hasChanged()) {
        XulConfirmBox confirm = (XulConfirmBox) document.createElement("confirmbox");
        confirm.setTitle(BaseMessages.getString(this.getClass(), "StarModelerPerspective.unsavedChangesTitle"));
        confirm.setMessage(BaseMessages.getString(this.getClass(), "StarModelerPerspective.unsavedChangesMessage"));
        CloseConfirmXulDialogCallback callback = new CloseConfirmXulDialogCallback();
        confirm.addDialogCallback(callback);
        confirm.open();
        if (callback.closeIt) {
            models.remove(pos);
            metas.remove(tabbox.getTabs().getChildNodes().get(pos));
            return true;
        } else {
            return false;
        }
    } else {
        models.remove(pos);
        metas.remove(pos);
    }
    return true;
}
Also used : XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox)

Example 3 with XulConfirmBox

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

the class SecurityController method removeUser.

/**
 * removeUser method is called when user has click on a remove button in a user deck. It first displays a confirmation
 * message to the user and once the user selects ok, it remove the user
 *
 * @throws Exception
 */
public void removeUser() throws Exception {
    XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
    confirmBox.setTitle(BaseMessages.getString(PKG, "ConfirmDialog.Title"));
    confirmBox.setMessage(BaseMessages.getString(PKG, "RemoveUserConfirmDialog.Message"));
    confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
    confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
    confirmBox.addDialogCallback(new XulDialogCallback<Object>() {

        public void onClose(XulComponent sender, Status returnCode, Object retVal) {
            if (returnCode == Status.ACCEPT) {
                if (service != null) {
                    if (security != null && security.getSelectedUser() != null) {
                        try {
                            service.delUser(security.getSelectedUser().getName());
                            security.removeUser(security.getSelectedUser().getName());
                        } catch (Throwable th) {
                            if (mainController == null || !mainController.handleLostRepository(th)) {
                                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                                messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.UnableToRemoveUser", th.getLocalizedMessage()));
                                messageBox.open();
                            }
                        }
                    } else {
                        messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                        messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                        messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.NoUserSelected"));
                        messageBox.open();
                    }
                }
            }
        }

        public void onError(XulComponent sender, Throwable t) {
            if (mainController == null || !mainController.handleLostRepository(t)) {
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.UnableToRemoveUser", t.getLocalizedMessage()));
                messageBox.open();
            }
        }
    });
    confirmBox.open();
}
Also used : XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 4 with XulConfirmBox

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

the class RepositoriesHelper method deleteRepository.

public void deleteRepository() {
    try {
        XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
        final RepositoryMeta repositoryMeta = input.searchRepository(model.getSelectedRepository().getName());
        if (repositoryMeta != null) {
            confirmBox.setTitle(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Title"));
            confirmBox.setMessage(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Message"));
            confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
            confirmBox.addDialogCallback(new XulDialogCallback<Object>() {

                public void onClose(XulComponent sender, Status returnCode, Object retVal) {
                    if (returnCode == Status.ACCEPT) {
                        int idx = input.indexOfRepository(repositoryMeta);
                        input.removeRepository(idx);
                        fillRepositories();
                        writeData();
                    }
                }

                public void onError(XulComponent sender, Throwable t) {
                    log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()));
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()), t);
                }
            });
            confirmBox.open();
        }
    } catch (Exception e) {
        log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()));
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()), e);
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) XulComponent(org.pentaho.ui.xul.XulComponent) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 5 with XulConfirmBox

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

the class EESecurityController method removeRole.

/**
 * removeRole method is called when user has click on a remove button in a role deck. It first displays a confirmation
 * message to the user and once the user selects ok, it remove the role
 *
 * @throws Exception
 */
public void removeRole() throws Exception {
    // $NON-NLS-1$
    XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
    // $NON-NLS-1$
    confirmBox.setTitle(BaseMessages.getString(PKG, "ConfirmDialog.Title"));
    // $NON-NLS-1$
    confirmBox.setMessage(BaseMessages.getString(PKG, "RemoveRoleConfirmDialog.Message"));
    // $NON-NLS-1$
    confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
    // $NON-NLS-1$
    confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
    confirmBox.addDialogCallback(new XulDialogCallback<Object>() {

        public void onClose(XulComponent sender, Status returnCode, Object retVal) {
            if (returnCode == Status.ACCEPT) {
                if (service != null) {
                    if (eeSecurity != null && eeSecurity.getSelectedRole() != null) {
                        try {
                            ((IRoleSupportSecurityManager) service).deleteRole(eeSecurity.getSelectedRole().getName());
                            eeSecurity.removeRole(eeSecurity.getSelectedRole().getName());
                        } catch (Throwable th) {
                            // $NON-NLS-1$
                            messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                            // $NON-NLS-1$
                            messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                            messageBox.setMessage(BaseMessages.getString(PKG, "RemoveRole.UnableToRemoveRole", // $NON-NLS-1$
                            th.getLocalizedMessage()));
                            messageBox.open();
                        }
                    } else {
                        // $NON-NLS-1$
                        messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                        // $NON-NLS-1$
                        messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                        // $NON-NLS-1$
                        messageBox.setMessage(BaseMessages.getString(PKG, "RemoveRole.NoRoleSelected"));
                        messageBox.open();
                    }
                }
            }
        }

        public void onError(XulComponent sender, Throwable t) {
            if (mainController == null || !mainController.handleLostRepository(t)) {
                // $NON-NLS-1$
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                // $NON-NLS-1$
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                messageBox.setMessage(// $NON-NLS-1$
                BaseMessages.getString(PKG, "RemoveRole.UnableToRemoveRole", t.getLocalizedMessage()));
                messageBox.open();
            }
        }
    });
    confirmBox.open();
}
Also used : XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Aggregations

XulConfirmBox (org.pentaho.ui.xul.components.XulConfirmBox)9 XulComponent (org.pentaho.ui.xul.XulComponent)8 KettleException (org.pentaho.di.core.exception.KettleException)2 XulException (org.pentaho.ui.xul.XulException)2 Label (com.google.gwt.user.client.ui.Label)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 HttpStatus (org.apache.http.HttpStatus)1 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 IAclObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)1 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)1 XulLabel (org.pentaho.ui.xul.components.XulLabel)1 GwtConfirmBox (org.pentaho.ui.xul.gwt.tags.GwtConfirmBox)1 Bindable (org.pentaho.ui.xul.stereotype.Bindable)1