Search in sources :

Example 26 with XulDomContainer

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

the class TransPreviewDelegate method addToolBar.

private void addToolBar() {
    try {
        XulLoader loader = new KettleXulLoader();
        loader.setSettingsManager(XulSpoonSettingsManager.getInstance());
        ResourceBundle bundle = GlobalMessages.getBundle("org/pentaho/di/ui/spoon/messages/messages");
        XulDomContainer xulDomContainer = loader.loadXul(XUL_FILE_TRANS_PREVIEW_TOOLBAR, bundle);
        xulDomContainer.addEventHandler(this);
        toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById("nav-toolbar");
        ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
        spoon.props.setLook(swtToolBar, Props.WIDGET_STYLE_TOOLBAR);
        swtToolBar.layout(true, true);
        swtToolBar.pack();
        firstRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById("preview-first");
        lastRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById("preview-last");
        offRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById("preview-off");
        PropsUI.getInstance().setLook((Control) firstRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR);
        PropsUI.getInstance().setLook((Control) lastRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR);
        PropsUI.getInstance().setLook((Control) offRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR);
    } catch (Throwable t) {
        log.logError(toString(), Const.getStackTracker(t));
        new ErrorDialog(transPreviewComposite.getShell(), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_PREVIEW_TOOLBAR), new Exception(t));
    }
}
Also used : XulLoader(org.pentaho.ui.xul.XulLoader) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) ToolBar(org.eclipse.swt.widgets.ToolBar) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ResourceBundle(java.util.ResourceBundle) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 27 with XulDomContainer

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

the class JobHistoryDelegate method addToolBar.

private void addToolBar() {
    try {
        XulLoader loader = new KettleXulLoader();
        loader.setSettingsManager(XulSpoonSettingsManager.getInstance());
        ResourceBundle bundle = new XulSpoonResourceBundle(Spoon.class);
        XulDomContainer xulDomContainer = loader.loadXul(XUL_FILE_TRANS_GRID_TOOLBAR, bundle);
        xulDomContainer.addEventHandler(this);
        toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById("nav-toolbar");
        refreshButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById("refresh-history");
        fetchNextBatchButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById("fetch-next-batch-history");
        fetchAllButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById("fetch-all-history");
        ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
        spoon.props.setLook(swtToolBar, Props.WIDGET_STYLE_TOOLBAR);
        swtToolBar.layout(true, true);
    } catch (Throwable t) {
        log.logError(Const.getStackTracker(t));
        new ErrorDialog(jobHistoryComposite.getShell(), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_GRID_TOOLBAR), new Exception(t));
    }
}
Also used : XulSpoonResourceBundle(org.pentaho.di.ui.spoon.XulSpoonResourceBundle) XulLoader(org.pentaho.ui.xul.XulLoader) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) ToolBar(org.eclipse.swt.widgets.ToolBar) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) XulSpoonResourceBundle(org.pentaho.di.ui.spoon.XulSpoonResourceBundle) ResourceBundle(java.util.ResourceBundle) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) KettleValueException(org.pentaho.di.core.exception.KettleValueException)

Example 28 with XulDomContainer

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

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

the class DataServiceTestDialog method initXul.

private Document initXul(Composite parent) throws KettleException {
    try {
        SwtXulLoader swtLoader = new KettleXulLoader();
        swtLoader.setOuterContext(parent);
        swtLoader.registerClassLoader(getClass().getClassLoader());
        XulDomContainer container = swtLoader.loadXul(XUL_PATH, resourceBundle);
        container.addEventHandler(dataServiceTestController);
        final XulRunner runner = new SwtXulRunner();
        runner.addContainer(container);
        runner.initialize();
        return container.getDocumentRoot();
    } catch (XulException xulException) {
        throw new KettleException("Failed to initialize DataServicesTestDialog.", xulException);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) SwtXulLoader(org.pentaho.ui.xul.swt.SwtXulLoader) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 30 with XulDomContainer

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

the class DriverDetailsDialog method initXul.

Document initXul(Composite parent, AbstractXulLoader xulLoader, XulRunner xulRunner) throws KettleException {
    try {
        xulLoader.setOuterContext(parent);
        xulLoader.registerClassLoader(getClass().getClassLoader());
        XulDomContainer container = xulLoader.loadXul(XUL_DIALOG_PATH, resourceBundle);
        container.addEventHandler(controller);
        xulRunner.addContainer(container);
        xulRunner.initialize();
        return container.getDocumentRoot();
    } catch (XulException xulException) {
        throw new KettleException("Failed to initialize DriverDetailsDialog.", xulException);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) XulDomContainer(org.pentaho.ui.xul.XulDomContainer)

Aggregations

XulDomContainer (org.pentaho.ui.xul.XulDomContainer)33 ResourceBundle (java.util.ResourceBundle)14 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)12 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)11 XulLoader (org.pentaho.ui.xul.XulLoader)11 ToolBar (org.eclipse.swt.widgets.ToolBar)8 Test (org.junit.Test)8 KettleException (org.pentaho.di.core.exception.KettleException)8 XulException (org.pentaho.ui.xul.XulException)8 XulRunner (org.pentaho.ui.xul.XulRunner)7 Shell (org.eclipse.swt.widgets.Shell)6 XulComponent (org.pentaho.ui.xul.XulComponent)6 XulSpoonResourceBundle (org.pentaho.di.ui.spoon.XulSpoonResourceBundle)5 Document (org.pentaho.ui.xul.dom.Document)5 Before (org.junit.Before)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 TransMeta (org.pentaho.di.trans.TransMeta)2 Spoon (org.pentaho.di.ui.spoon.Spoon)2 DatabaseConnectionDialog (org.pentaho.ui.database.DatabaseConnectionDialog)2 XulDialog (org.pentaho.ui.xul.containers.XulDialog)2