Search in sources :

Example 51 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface 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 52 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class Spoon method helpJobEntry.

public void helpJobEntry() {
    final JobEntryCopy jobEntry = (JobEntryCopy) selectionObject;
    String jobName = jobEntry.getName();
    PluginInterface jobEntryPlugin = PluginRegistry.getInstance().findPluginWithName(JobEntryPluginType.class, jobName);
    HelpUtils.openHelpDialog(shell, jobEntryPlugin);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 53 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class Spoon method newStep.

/**
 * Allocate new step, optionally open and rename it.
 *
 * @param id
 *          Id of the new step
 * @param name
 *          Name of the new step
 * @param description
 *          Description of the type of step
 * @param openit
 *          Open the dialog for this step?
 * @param rename
 *          Rename this step?
 *
 * @return The newly created StepMeta object.
 */
public StepMeta newStep(TransMeta transMeta, String id, String name, String description, boolean openit, boolean rename) {
    StepMeta inf = null;
    // See if we need to rename the step to avoid doubles!
    if (rename && transMeta.findStep(name) != null) {
        int i = 2;
        String newName = name + " " + i;
        while (transMeta.findStep(newName) != null) {
            i++;
            newName = name + " " + i;
        }
        name = newName;
    }
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface stepPlugin = id != null ? registry.findPluginWithId(StepPluginType.class, id) : registry.findPluginWithName(StepPluginType.class, description);
    try {
        if (stepPlugin != null) {
            StepMetaInterface info = (StepMetaInterface) registry.loadClass(stepPlugin);
            info.setDefault();
            if (openit) {
                StepDialogInterface dialog = this.getStepEntryDialog(info, transMeta, name);
                if (dialog != null) {
                    name = dialog.open();
                }
            }
            inf = new StepMeta(stepPlugin.getIds()[0], name, info);
            if (name != null) {
                // OK pressed in the dialog: we have a step-name
                String newName = name;
                StepMeta stepMeta = transMeta.findStep(newName);
                int nr = 2;
                while (stepMeta != null) {
                    newName = name + " " + nr;
                    stepMeta = transMeta.findStep(newName);
                    nr++;
                }
                if (nr > 2) {
                    inf.setName(newName);
                    MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
                    // "This stepName already exists.  Spoon changed the stepName to ["+newName+"]"
                    mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.ChangeStepname.Message", newName));
                    mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.ChangeStepname.Title"));
                    mb.open();
                }
                // default location at (20,20)
                inf.setLocation(20, 20);
                transMeta.addStep(inf);
                addUndoNew(transMeta, new StepMeta[] { inf }, new int[] { transMeta.indexOfStep(inf) });
                // Also store it in the pluginHistory list...
                props.increasePluginHistory(stepPlugin.getIds()[0]);
                // stepHistoryChanged = true;
                refreshTree();
            } else {
                // Cancel pressed in dialog.
                return null;
            }
            setShellText();
        }
    } catch (KettleException e) {
        String filename = stepPlugin.getErrorHelpFile();
        if (!Utils.isEmpty(filename)) {
            // OK, in stead of a normal error message, we give back the
            // content of the error help file... (HTML)
            FileInputStream fis = null;
            try {
                StringBuilder content = new StringBuilder();
                fis = new FileInputStream(new File(filename));
                int ch = fis.read();
                while (ch >= 0) {
                    content.append((char) ch);
                    ch = fis.read();
                }
                ShowBrowserDialog sbd = new ShowBrowserDialog(// "Error help text"
                shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorHelpText.Title"), content.toString());
                sbd.open();
            } catch (Exception ex) {
                new ErrorDialog(shell, // "Error showing help text"
                BaseMessages.getString(PKG, "Spoon.Dialog.ErrorShowingHelpText.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorShowingHelpText.Message"), ex);
            } finally {
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (Exception ex) {
                        log.logError("Error closing plugin help file", ex);
                    }
                }
            }
        } else {
            new ErrorDialog(shell, // "I was unable to create a new step"
            BaseMessages.getString(PKG, "Spoon.Dialog.UnableCreateNewStep.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.UnableCreateNewStep.Message"), e);
        }
        return null;
    } catch (Throwable e) {
        if (!shell.isDisposed()) {
            new ErrorDialog(shell, // "Error creating step"
            BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingStep.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.UnableCreateNewStep.Message"), e);
        }
        return null;
    }
    return inf;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) StepDialogInterface(org.pentaho.di.trans.step.StepDialogInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) ShowBrowserDialog(org.pentaho.di.ui.core.dialog.ShowBrowserDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) FileInputStream(java.io.FileInputStream) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) MessageBox(org.eclipse.swt.widgets.MessageBox) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) LastUsedFile(org.pentaho.di.core.LastUsedFile) File(java.io.File)

Example 54 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class Spoon method refreshStepsSubtree.

private void refreshStepsSubtree(TreeItem tiRootName, TransMeta meta, GUIResource guiResource) {
    TreeItem tiStepTitle = createTreeItem(tiRootName, STRING_STEPS, guiResource.getImageFolder());
    // Put the steps below it.
    for (int i = 0; i < meta.nrSteps(); i++) {
        StepMeta stepMeta = meta.getStep(i);
        if (stepMeta.isMissing()) {
            continue;
        }
        PluginInterface stepPlugin = PluginRegistry.getInstance().findPluginWithId(StepPluginType.class, stepMeta.getStepID());
        if (!filterMatch(stepMeta.getName())) {
            continue;
        }
        Image stepIcon = guiResource.getImagesStepsSmall().get(stepPlugin.getIds()[0]);
        if (stepIcon == null) {
            stepIcon = guiResource.getImageFolder();
        }
        TreeItem tiStep = createTreeItem(tiStepTitle, stepMeta.getName(), stepIcon);
        if (stepMeta.isShared()) {
            tiStep.setFont(guiResource.getFontBold());
        }
        if (!stepMeta.isDrawn()) {
            tiStep.setForeground(guiResource.getColorDarkGray());
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Image(org.eclipse.swt.graphics.Image) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 55 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class ModPartitionerDialog method setShellImage.

private void setShellImage(Shell shell) {
    PluginInterface plugin = PluginRegistry.getInstance().getPlugin(PartitionerPluginType.class, partitioner.getId());
    if (!Utils.isEmpty(plugin.getDocumentationUrl())) {
        createHelpButton(shell, stepMeta, plugin);
    }
    shell.setImage(GUIResource.getInstance().getImageSpoon());
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Aggregations

PluginInterface (org.pentaho.di.core.plugins.PluginInterface)99 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)45 KettleException (org.pentaho.di.core.exception.KettleException)24 ArrayList (java.util.ArrayList)17 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)14 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)12 TransMeta (org.pentaho.di.trans.TransMeta)11 StepMeta (org.pentaho.di.trans.step.StepMeta)11 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)10 Test (org.junit.Test)9 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)9 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)8 Point (org.pentaho.di.core.gui.Point)8 JobMeta (org.pentaho.di.job.JobMeta)8 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)7 TransHopMeta (org.pentaho.di.trans.TransHopMeta)7 TreeItem (org.eclipse.swt.widgets.TreeItem)6 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)6 LongObjectId (org.pentaho.di.repository.LongObjectId)6 ObjectId (org.pentaho.di.repository.ObjectId)6