Search in sources :

Example 6 with XulComponent

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

the class DataHandler method traverseDomSetReadOnly.

private void traverseDomSetReadOnly(XulComponent component, boolean readonly) {
    component.setDisabled(readonly);
    List<XulComponent> children = component.getChildNodes();
    if (children != null && children.size() > 0) {
        for (XulComponent child : children) {
            child.setDisabled(readonly);
            traverseDomSetReadOnly(child, readonly);
        }
    }
}
Also used : XulComponent(org.pentaho.ui.xul.XulComponent)

Example 7 with XulComponent

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

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

the class RepositoryLockController method lockContent.

public void lockContent() throws Exception {
    List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
    if (selectedRepoObjects.size() > 0 && selectedRepoObjects.get(0) instanceof UIRepositoryContent) {
        final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get(0);
        if (((ILockObject) contentToLock).isLocked()) {
            // Unlock the item
            ((ILockObject) contentToLock).unlock();
            browseController.getSelectedItemsBinding().fireSourceChanged();
        } else {
            // Lock the item
            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 {
                            ((ILockObject) contentToLock).lock(value);
                            browseController.getSelectedItemsBinding().fireSourceChanged();
                        } catch (Exception e) {
                            // convert to runtime exception so it bubbles up through the UI
                            throw new RuntimeException(e);
                        }
                    } else {
                        // $NON-NLS-1$
                        XulMenuitem lockMenuItem = (XulMenuitem) document.getElementById("lock-context-lock");
                        lockMenuItem.setSelected(false);
                        // $NON-NLS-1$
                        lockMenuItem = (XulMenuitem) document.getElementById("file-context-lock");
                        lockMenuItem.setSelected(false);
                    }
                }

                public void onError(XulComponent component, Throwable err) {
                    throw new RuntimeException(err);
                }
            });
            lockNotePrompt.open();
        }
    }
}
Also used : UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) 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) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 9 with XulComponent

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

the class StarModelerPerspective method setNameForTab.

public void setNameForTab(XulTab tab, String name) {
    String tabName = name;
    List<String> usedNames = new ArrayList<String>();
    for (XulComponent c : tabs.getChildNodes()) {
        if (c != tab) {
            usedNames.add(((SwtTab) c).getLabel());
        }
    }
    if (usedNames.contains(name)) {
        int num = 2;
        while (true) {
            tabName = name + " (" + num + ")";
            if (usedNames.contains(tabName) == false) {
                break;
            }
            num++;
        }
    }
    tab.setLabel(tabName);
}
Also used : ArrayList(java.util.ArrayList) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 10 with XulComponent

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

the class BrowseController method createFolder.

public void createFolder() throws Exception {
    try {
        Collection<UIRepositoryDirectory> directories = folderTree.getSelectedItems();
        if (directories == null || directories.size() == 0) {
            return;
        }
        UIRepositoryDirectory selectedFolder = directories.iterator().next();
        // First, ask for a name for the folder
        XulPromptBox prompt = promptForName(null);
        prompt.addDialogCallback(new XulDialogCallback<String>() {

            public void onClose(XulComponent component, Status status, String value) {
                if (status == Status.ACCEPT) {
                    newName = value;
                } else {
                    newName = null;
                }
            }

            public void onError(XulComponent component, Throwable err) {
                throw new RuntimeException(err);
            }
        });
        prompt.open();
        if (newName != null) {
            if (selectedFolder == null) {
                selectedFolder = repositoryDirectory;
            }
            // Do an explicit check here to see if the folder already exists in the ui
            // This is to prevent a double message being sent in case the folder does
            // not exist in the ui but does exist in the repo (PDI-5202)
            boolean folderExistsInUI = selectedFolder.contains(newName);
            if (folderExistsInUI) {
                throw new Exception(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInUI", newName));
            }
            // PDI-5202
            String newNameInRepo = selectedFolder.checkDirNameExistsInRepo(newName);
            if (newNameInRepo != null) {
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Warning"));
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                messageBox.setMessage(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInRepository", newNameInRepo));
                messageBox.open();
                newName = newNameInRepo;
            }
            UIRepositoryDirectory newDir = selectedFolder.createFolder(newName);
            dirMap.put(newDir.getObjectId(), newDir);
            directoryBinding.fireSourceChanged();
            selectedItemsBinding.fireSourceChanged();
            this.folderTree.setSelectedItems(Collections.singletonList(selectedFolder));
        }
        newName = null;
    } catch (Exception e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            confirm(BaseMessages.getString(PKG, "Dialog.Error"), e.getLocalizedMessage());
        }
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent) XulException(org.pentaho.ui.xul.XulException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException) KettleException(org.pentaho.di.core.exception.KettleException)

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