Search in sources :

Example 11 with XulPromptBox

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

the class SpoonLockController method promptLockMessage.

private XulPromptBox promptLockMessage(org.pentaho.ui.xul.dom.Document document, ResourceBundle messages, String defaultMessage) throws XulException {
    // $NON-NLS-1$
    XulPromptBox prompt = (XulPromptBox) document.createElement("promptbox");
    prompt.setModalParent(shell);
    // $NON-NLS-1$
    prompt.setTitle(BaseMessages.getString(PKG, "RepositoryExplorer.LockMessage.Title"));
    prompt.setButtons(new DialogConstant[] { DialogConstant.OK, DialogConstant.CANCEL });
    // $NON-NLS-1$
    prompt.setMessage(BaseMessages.getString(PKG, "RepositoryExplorer.LockMessage.Label"));
    prompt.setValue(defaultMessage == null ? BaseMessages.getString(PKG, "RepositoryExplorer.DefaultLockMessage") : // $NON-NLS-1$
    defaultMessage);
    return prompt;
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox)

Example 12 with XulPromptBox

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

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

the class RepositoryLockController method promptLockMessage.

private XulPromptBox promptLockMessage(org.pentaho.ui.xul.dom.Document document, ResourceBundle messages, String defaultMessage) throws XulException {
    // $NON-NLS-1$
    XulPromptBox prompt = (XulPromptBox) document.createElement("promptbox");
    // $NON-NLS-1$
    prompt.setTitle(BaseMessages.getString(PKG, "RepositoryExplorer.LockMessage.Title"));
    prompt.setButtons(new DialogConstant[] { DialogConstant.OK, DialogConstant.CANCEL });
    // $NON-NLS-1$
    prompt.setMessage(BaseMessages.getString(PKG, "RepositoryExplorer.LockMessage.Label"));
    prompt.setValue(defaultMessage == null ? BaseMessages.getString(PKG, "RepositoryExplorer.DefaultLockMessage") : // $NON-NLS-1$
    defaultMessage);
    return prompt;
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox)

Example 14 with XulPromptBox

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

Example 15 with XulPromptBox

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

the class BrowseController method promptForName.

protected XulPromptBox promptForName(final UIRepositoryObject object) throws XulException {
    XulPromptBox prompt = (XulPromptBox) document.createElement("promptbox");
    String currentName = (object == null) ? BaseMessages.getString(PKG, "BrowserController.NewFolder") : object.getName();
    prompt.setTitle(BaseMessages.getString(PKG, "BrowserController.Name").concat(currentName));
    prompt.setButtons(new DialogConstant[] { DialogConstant.OK, DialogConstant.CANCEL });
    prompt.setMessage(BaseMessages.getString(PKG, "BrowserController.NameLabel").concat(currentName));
    prompt.setValue(currentName);
    return prompt;
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox)

Aggregations

XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)15 XulComponent (org.pentaho.ui.xul.XulComponent)6 XulException (org.pentaho.ui.xul.XulException)6 KettleException (org.pentaho.di.core.exception.KettleException)5 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)4 Test (org.junit.Test)2 ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)2 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)2 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)2 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)2 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 FormPanel (com.google.gwt.user.client.ui.FormPanel)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Label (com.google.gwt.user.client.ui.Label)1 Panel (com.google.gwt.user.client.ui.Panel)1 RadioButton (com.google.gwt.user.client.ui.RadioButton)1 RootPanel (com.google.gwt.user.client.ui.RootPanel)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 HttpStatus (org.apache.http.HttpStatus)1