Search in sources :

Example 16 with XulMessageBox

use of org.pentaho.ui.xul.components.XulMessageBox 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 17 with XulMessageBox

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

the class SpoonLockController method viewLockNote.

public void viewLockNote() throws Exception {
    if (workingMeta != null && supportsLocking(Spoon.getInstance().getRepository())) {
        try {
            RepositoryLock repoLock = fetchRepositoryLock(workingMeta);
            if (repoLock != null) {
                // $NON-NLS-1$
                XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
                // $NON-NLS-1$
                msgBox.setTitle(BaseMessages.getString(PKG, "PurRepository.LockNote.Title"));
                msgBox.setMessage(repoLock.getMessage());
                msgBox.setModalParent(shell);
                msgBox.open();
            }
        } catch (Throwable th) {
            // $NON-NLS-1$
            log.error(BaseMessages.getString(PKG, "LockController.NoLockingSupport"), th);
            new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "LockController.NoLockingSupport"), // $NON-NLS-1$ //$NON-NLS-2$
            th);
        }
    } else {
        // $NON-NLS-1$
        XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
        // $NON-NLS-1$
        msgBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
        // $NON-NLS-1$
        msgBox.setMessage(BaseMessages.getString(PKG, "LockController.NoLockingSupport"));
        msgBox.setModalParent(shell);
        msgBox.open();
    }
}
Also used : XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) Spoon(org.pentaho.di.ui.spoon.Spoon) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock)

Example 18 with XulMessageBox

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

the class SpoonLockController method lockContent.

public void lockContent() throws Exception {
    try {
        if (workingMeta != null && workingMeta.getObjectId() != null && supportsLocking(Spoon.getInstance().getRepository())) {
            // Look in the SpoonTransformationDelegate for details on the TabItem creation
            if (!tabBound) {
                bindingFactory.createBinding(this, "activeMetaUnlocked", Spoon.getInstance().delegates.tabs.findTabMapEntry(workingMeta).getTabItem(), "image", new // $NON-NLS-1$ //$NON-NLS-2$
                BindingConvertor<Boolean, Image>() {

                    @Override
                    public Image sourceToTarget(Boolean activeMetaUnlocked) {
                        if (activeMetaUnlocked) {
                            if (workingMeta instanceof TransMeta) {
                                return GUIResource.getInstance().getImageTransGraph();
                            } else if (workingMeta instanceof JobMeta) {
                                return GUIResource.getInstance().getImageJobGraph();
                            }
                        } else {
                            return GUIResource.getInstance().getImageLocked();
                        }
                        return null;
                    }

                    @Override
                    public Boolean targetToSource(Image arg0) {
                        return false;
                    }
                });
                tabBound = true;
            }
            // Decide whether to lock or unlock the object
            if (fetchRepositoryLock(workingMeta) == null) {
                // Lock the object (it currently is NOT locked)
                XulPromptBox lockNotePrompt = promptLockMessage(document, messages, null);
                lockNotePrompt.addDialogCallback(new XulDialogCallback<String>() {

                    public void onClose(XulComponent component, Status status, String value) {
                        if (!status.equals(Status.CANCEL)) {
                            try {
                                if (workingMeta instanceof TransMeta) {
                                    getService(Spoon.getInstance().getRepository()).lockTransformation(workingMeta.getObjectId(), value);
                                } else if (workingMeta instanceof JobMeta) {
                                    getService(Spoon.getInstance().getRepository()).lockJob(workingMeta.getObjectId(), value);
                                }
                                // Execute binding. Notify listeners that the object is now locked
                                // $NON-NLS-1$ //$NON-NLS-2$
                                firePropertyChange("activeMetaUnlocked", true, false);
                                // this keeps the menu item and the state in sync
                                // could a binding be used instead?
                                XulDomContainer container = getXulDomContainer();
                                XulMenuitem lockMenuItem = // $NON-NLS-1$
                                (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
                                lockMenuItem.setSelected(true);
                            } catch (Exception e) {
                                // convert to runtime exception so it bubbles up through the UI
                                throw new RuntimeException(e);
                            }
                        } else {
                            // this keeps the menu item and the state in sync
                            // could a binding be used instead?
                            XulDomContainer container = getXulDomContainer();
                            XulMenuitem lockMenuItem = // $NON-NLS-1$
                            (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
                            lockMenuItem.setSelected(false);
                        }
                    }

                    public void onError(XulComponent component, Throwable err) {
                        throw new RuntimeException(err);
                    }
                });
                lockNotePrompt.open();
            } else {
                // Unlock the object (it currently IS locked)
                if (workingMeta instanceof TransMeta) {
                    getService(Spoon.getInstance().getRepository()).unlockTransformation(workingMeta.getObjectId());
                } else if (workingMeta instanceof JobMeta) {
                    getService(Spoon.getInstance().getRepository()).unlockJob(workingMeta.getObjectId());
                }
                // Execute binding. Notify listeners that the object is now unlocked
                // $NON-NLS-1$ //$NON-NLS-2$
                firePropertyChange("activeMetaUnlocked", false, true);
            }
        } else if (workingMeta != null && workingMeta.getObjectId() == null && supportsLocking(Spoon.getInstance().getRepository())) {
            XulDomContainer container = getXulDomContainer();
            // $NON-NLS-1$
            XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
            lockMenuItem.setSelected(false);
            // $NON-NLS-1$
            XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
            // $NON-NLS-1$
            msgBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
            // $NON-NLS-1$
            msgBox.setMessage(BaseMessages.getString(PKG, "LockController.SaveBeforeLock"));
            msgBox.setModalParent(shell);
            msgBox.open();
        } else {
            XulDomContainer container = getXulDomContainer();
            // $NON-NLS-1$
            XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
            lockMenuItem.setSelected(false);
            // $NON-NLS-1$
            XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
            // $NON-NLS-1$
            msgBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
            // $NON-NLS-1$
            msgBox.setMessage(BaseMessages.getString(PKG, "LockController.NoLockingSupport"));
            msgBox.setModalParent(shell);
            msgBox.open();
        }
    } catch (Throwable th) {
        // $NON-NLS-1$
        log.error(BaseMessages.getString(PKG, "LockController.NoLockingSupport"), th);
        new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "LockController.NoLockingSupport"), // $NON-NLS-1$ //$NON-NLS-2$
        th);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Image(org.eclipse.swt.graphics.Image) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) Spoon(org.pentaho.di.ui.spoon.Spoon) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 19 with XulMessageBox

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

the class AbsController method applyRoleActionPermission.

/**
 * Save the permission for the selected role
 */
public void applyRoleActionPermission() {
    XulMessageBox messageBox = this.getMessageBox();
    IUIRole role = null;
    IUIAbsRole absRole = null;
    try {
        role = absSecurity.getSelectedRole();
        if (role instanceof IUIAbsRole) {
            absRole = (IUIAbsRole) role;
        } else {
            throw new IllegalStateException();
        }
        ((IAbsSecurityManager) service).setLogicalRoles(absRole.getName(), absRole.getLogicalRoles());
        // $NON-NLS-1$
        messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Success"));
        // $NON-NLS-1$
        messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
        // $NON-NLS-1$
        messageBox.setMessage(BaseMessages.getString(PKG, "AbsController.RoleActionPermission.Success"));
        messageBox.open();
        // Refresh permissions in open tabs
        SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifecycleListener.SpoonLifeCycleEvent.REPOSITORY_CHANGED);
    } catch (KettleException e) {
        // $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, "AbsController.RoleActionPermission.UnableToApplyPermissions", role.getName(), // $NON-NLS-1$
        e.getLocalizedMessage()));
        messageBox.open();
    }
}
Also used : IUIAbsRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.IUIAbsRole) KettleException(org.pentaho.di.core.exception.KettleException) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) IAbsSecurityManager(org.pentaho.di.ui.repository.pur.services.IAbsSecurityManager) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)

Example 20 with XulMessageBox

use of org.pentaho.ui.xul.components.XulMessageBox in project pdi-dataservice-server-plugin by pentaho.

the class AbstractController method error.

protected void error(String title, String message) throws XulException {
    XulMessageBox messageBox = createMessageBox();
    messageBox.setTitle(title);
    messageBox.setMessage(message);
    messageBox.setIcon(SWT.ICON_WARNING);
    messageBox.setButtons(new Object[] { SWT.OK });
    messageBox.open();
}
Also used : XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox)

Aggregations

XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)22 XulException (org.pentaho.ui.xul.XulException)12 KettleException (org.pentaho.di.core.exception.KettleException)4 Spoon (org.pentaho.di.ui.spoon.Spoon)3 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)2 IUIAbsRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.IUIAbsRole)2 IAbsSecurityManager (org.pentaho.di.ui.repository.pur.services.IAbsSecurityManager)2 Image (org.eclipse.swt.graphics.Image)1 Test (org.junit.Test)1 BaseMessages.getString (org.pentaho.di.i18n.BaseMessages.getString)1 JobMeta (org.pentaho.di.job.JobMeta)1 RepositoryLock (org.pentaho.di.repository.pur.model.RepositoryLock)1 TransMeta (org.pentaho.di.trans.TransMeta)1 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)1 ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)1 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)1 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)1