Search in sources :

Example 6 with XulMenuitem

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

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

the class Spoon method setMenu.

private synchronized void setMenu(Tree tree) {
    TreeSelection[] objects = getTreeObjects(tree);
    if (objects.length != 1) {
        // not yet supported, we can do this later when the OSX bug
        return;
    // goes away
    }
    TreeSelection object = objects[0];
    selectionObject = object.getSelection();
    Object selection = selectionObject;
    selectionObjectParent = object.getParent();
    // Not clicked on a real object: returns a class
    XulMenupopup spoonMenu = null;
    if (selection instanceof Class<?>) {
        if (selection.equals(TransMeta.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("trans-class");
        } else if (selection.equals(JobMeta.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("job-class");
        } else if (selection.equals(TransHopMeta.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("trans-hop-class");
        } else if (selection.equals(DatabaseMeta.class)) {
            spoonMenu = (XulMenupopup) menuMap.get("database-class");
        } else if (selection.equals(PartitionSchema.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("partition-schema-class");
        } else if (selection.equals(ClusterSchema.class)) {
            spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-class");
        } else if (selection.equals(SlaveServer.class)) {
            spoonMenu = (XulMenupopup) menuMap.get("slave-cluster-class");
        } else {
            spoonMenu = null;
        }
    } else {
        if (selection instanceof TransMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("trans-inst");
        } else if (selection instanceof JobMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("job-inst");
        } else if (selection instanceof PluginInterface) {
            spoonMenu = (XulMenupopup) menuMap.get("step-plugin");
        } else if (selection instanceof DatabaseMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("database-inst");
            // disable for now if the connection is an SAP ERP type of database...
            // 
            XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-explore");
            if (item != null) {
                final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
                item.setDisabled(!databaseMeta.isExplorable());
            }
            item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-clear-cache");
            if (item != null) {
                final DatabaseMeta databaseMeta = (DatabaseMeta) selectionObject;
                item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.ClearDBCache") + // Clear
                databaseMeta.getName());
            }
            item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-share");
            if (item != null) {
                final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
                if (databaseMeta.isShared()) {
                    item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.UnShare"));
                } else {
                    item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.Share"));
                }
            }
        } else if (selection instanceof StepMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("step-inst");
        } else if (selection instanceof JobEntryCopy) {
            spoonMenu = (XulMenupopup) menuMap.get("job-entry-copy-inst");
        } else if (selection instanceof TransHopMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("trans-hop-inst");
        } else if (selection instanceof PartitionSchema) {
            spoonMenu = (XulMenupopup) menuMap.get("partition-schema-inst");
        } else if (selection instanceof ClusterSchema) {
            spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-inst");
        } else if (selection instanceof SlaveServer) {
            spoonMenu = (XulMenupopup) menuMap.get("slave-server-inst");
        }
    }
    if (spoonMenu != null) {
        ConstUI.displayMenu(spoonMenu, tree);
    } else {
        tree.setMenu(null);
    }
    createPopUpMenuExtension();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) PartitionSchema(org.pentaho.di.partition.PartitionSchema) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) XulMenupopup(org.pentaho.ui.xul.containers.XulMenupopup) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) RepositoryObject(org.pentaho.di.repository.RepositoryObject) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FileObject(org.apache.commons.vfs2.FileObject) TransHopMeta(org.pentaho.di.trans.TransHopMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 8 with XulMenuitem

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

the class Spoon method disableMenuItem.

public void disableMenuItem(String itemId) {
    XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById(itemId);
    item.setDisabled(true);
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem)

Example 9 with XulMenuitem

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

the class Spoon method updateSettingsMenu.

/**
 * @param doc
 * @param disableJobMenu
 * @param disableTransMenu
 */
private void updateSettingsMenu(org.pentaho.ui.xul.dom.Document doc, boolean disableTransMenu, boolean disableJobMenu) {
    XulMenuitem settingsItem = (XulMenuitem) doc.getElementById("edit-settings");
    if (settingsItem != null) {
        if (disableTransMenu && !disableJobMenu) {
            settingsItem.setAcceltext("CTRL-J");
            settingsItem.setAccesskey("ctrl-j");
        } else if (!disableTransMenu && disableJobMenu) {
            settingsItem.setAcceltext("CTRL-T");
            settingsItem.setAccesskey("ctrl-t");
        } else {
            settingsItem.setAcceltext("");
            settingsItem.setAccesskey("");
        }
    }
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem)

Example 10 with XulMenuitem

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

the class Spoon method removeMenuItem.

public void removeMenuItem(String itemid, boolean removeTrailingSeparators) {
    XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById(itemid);
    if (item != null) {
        XulComponent menu = item.getParent();
        item.getParent().removeChild(item);
        if (removeTrailingSeparators) {
            List<XulComponent> children = menu.getChildNodes();
            if (children.size() > 0) {
                XulComponent lastMenuItem = children.get(children.size() - 1);
                if (lastMenuItem instanceof XulMenuseparator) {
                    menu.removeChild(lastMenuItem);
                    // the menu separators seem to not be modeled as individual objects in XUL
                    try {
                        Menu swtm = (Menu) menu.getManagedObject();
                        swtm.getItems()[swtm.getItemCount() - 1].dispose();
                    } catch (Throwable t) {
                        LogChannel.GENERAL.logError("Error removing XUL menu item", t);
                    }
                }
            }
        }
    } else {
        log.logError("Could not find menu item with id " + itemid + " to remove from Spoon menu");
    }
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Menu(org.eclipse.swt.widgets.Menu) XulComponent(org.pentaho.ui.xul.XulComponent) XulMenuseparator(org.pentaho.ui.xul.components.XulMenuseparator)

Aggregations

XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)20 KettleException (org.pentaho.di.core.exception.KettleException)6 XulException (org.pentaho.ui.xul.XulException)6 Spoon (org.pentaho.di.ui.spoon.Spoon)5 XulMenu (org.pentaho.ui.xul.containers.XulMenu)5 TransMeta (org.pentaho.di.trans.TransMeta)4 XulComponent (org.pentaho.ui.xul.XulComponent)4 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)3 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)3 Point (org.pentaho.di.core.gui.Point)3 JobMeta (org.pentaho.di.job.JobMeta)3 PurRepository (org.pentaho.di.repository.pur.PurRepository)3 StepMeta (org.pentaho.di.trans.step.StepMeta)3 Document (org.pentaho.ui.xul.dom.Document)3 Action (org.eclipse.jface.action.Action)2 Test (org.junit.Test)2 NotePadMeta (org.pentaho.di.core.NotePadMeta)2 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)2 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)2 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)2