Search in sources :

Example 21 with XulComponent

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

the class SpoonPerspectiveManager method removePerspective.

public void removePerspective(SpoonPerspective per) {
    perspectives.remove(per);
    orderedPerspectives.remove(per);
    Document document = domContainer.getDocumentRoot();
    XulComponent comp = document.getElementById("perspective-" + per.getId());
    comp.getParent().removeChild(comp);
    comp = document.getElementById("perspective-btn-" + per.getId());
    comp.getParent().removeChild(comp);
    XulToolbar mainToolbar = (XulToolbar) domContainer.getDocumentRoot().getElementById("main-toolbar");
    ((Composite) mainToolbar.getManagedObject()).layout(true, true);
    deck.setSelectedIndex(0);
}
Also used : XulToolbar(org.pentaho.ui.xul.containers.XulToolbar) Composite(org.eclipse.swt.widgets.Composite) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 22 with XulComponent

use of org.pentaho.ui.xul.XulComponent 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 23 with XulComponent

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

the class AbstractPermissionsController method init.

protected void init(Repository rep) throws Exception {
    if (rep != null && rep.hasService(RepositorySecurityProvider.class)) {
        service = (RepositorySecurityProvider) rep.getService(RepositorySecurityProvider.class);
    } else {
        throw new ControllerInitializationException(BaseMessages.getString(PKG, "PermissionsController.ERROR_0001_UNABLE_TO_INITIAL_REPOSITORY_SERVICE", // $NON-NLS-1$
        RepositorySecurityManager.class));
    }
    // $NON-NLS-1$
    messageBox = (XulMessageBox) document.createElement("messagebox");
    viewAclsModel = new UIRepositoryObjectAcls();
    manageAclsModel = new UIRepositoryObjectAclModel(viewAclsModel);
    bf = new DefaultBindingFactory();
    bf.setDocument(this.getXulDomContainer().getDocumentRoot());
    mainController = (MainController) this.getXulDomContainer().getEventHandler("mainController");
    // $NON-NLS-1$
    confirmBox = (XulConfirmBox) document.createElement("confirmbox");
    // $NON-NLS-1$
    confirmBox.setTitle(BaseMessages.getString(PKG, "PermissionsController.RemoveAclWarning"));
    // $NON-NLS-1$
    confirmBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.RemoveAclWarningText"));
    // $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) {
                viewAclsModel.removeSelectedAcls();
            }
        }

        public void onError(XulComponent sender, Throwable t) {
        }
    });
}
Also used : UIRepositoryObjectAcls(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectAcls) RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) DefaultBindingFactory(org.pentaho.ui.xul.binding.DefaultBindingFactory) RepositorySecurityManager(org.pentaho.di.repository.RepositorySecurityManager) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) IAclObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject) XulComponent(org.pentaho.ui.xul.XulComponent) UIRepositoryObjectAclModel(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectAclModel)

Example 24 with XulComponent

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

Example 25 with XulComponent

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

the class RevisionController method restoreRevision.

public void restoreRevision() {
    try {
        final Collection<UIRepositoryContent> content = fileTable.getSelectedItems();
        final UIRepositoryContent contentToRestore = content.iterator().next();
        Collection<UIRepositoryObjectRevision> versions = revisionTable.getSelectedItems();
        final UIRepositoryObjectRevision versionToRestore = versions.iterator().next();
        SwtConfirmBox confirmbox = promptCommitComment(document);
        if (contentToRestore instanceof ILockObject && ((ILockObject) contentToRestore).isLocked()) {
            // Cannot restore revision of locked content
            // $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, "RevisionsController.RestoreLockedFileNotAllowed"));
            messageBox.open();
            return;
        }
        confirmbox.addDialogCallback(new XulDialogCallback<String>() {

            public void onClose(XulComponent component, Status status, String value) {
                if (!status.equals(Status.CANCEL)) {
                    try {
                        if (contentToRestore instanceof IRevisionObject) {
                            ((IRevisionObject) contentToRestore).restoreRevision(versionToRestore, value);
                            List<UIRepositoryObject> objects = new ArrayList<UIRepositoryObject>();
                            objects.add(contentToRestore);
                            browseController.setRepositoryObjects(objects);
                        } else {
                            throw new IllegalStateException(BaseMessages.getString(PKG, // $NON-NLS-1$
                            "RevisionsController.RevisionsNotSupported"));
                        }
                    } 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);
                }
            }
        });
        confirmbox.open();
    } catch (Exception e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            throw new RuntimeException(new KettleException(e));
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IRevisionObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) SwtConfirmBox(org.pentaho.ui.xul.swt.tags.SwtConfirmBox) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryObjectRevision(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision) ArrayList(java.util.ArrayList) List(java.util.List) 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