Search in sources :

Example 1 with PluginInterface

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

the class BaseStreamingDialog method getImage.

private Image getImage() {
    PluginInterface plugin = PluginRegistry.getInstance().getPlugin(StepPluginType.class, stepMeta.getStepMetaInterface());
    String id = plugin.getIds()[0];
    if (id != null) {
        return GUIResource.getInstance().getImagesSteps().get(id).getAsBitmapForSize(shell.getDisplay(), ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
    }
    return null;
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 2 with PluginInterface

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

the class CommonStepDialog method getImage.

protected Image getImage() {
    final PluginInterface plugin = PluginRegistry.getInstance().getPlugin(StepPluginType.class, stepMeta.getStepMetaInterface());
    final String id = plugin.getIds()[0];
    if (id != null) {
        return GUIResource.getInstance().getImagesSteps().get(id).getAsBitmapForSize(shell.getDisplay(), ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE);
    }
    return null;
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 3 with PluginInterface

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

the class SpoonTreeDelegateTest method getTreeObjects_getStepById.

@Test
public void getTreeObjects_getStepById() {
    SpoonTreeDelegate std = spy(new SpoonTreeDelegate(spoon));
    Tree selection = mock(Tree.class);
    Tree core = mock(Tree.class);
    TreeItem item = mock(TreeItem.class);
    PluginInterface step = mock(PluginInterface.class);
    PluginRegistry registry = mock(PluginRegistry.class);
    TreeItem[] items = new TreeItem[] { item };
    when(ConstUI.getTreeStrings(item)).thenReturn(new String[] { "Output", "Avro Output" });
    when(PluginRegistry.getInstance()).thenReturn(registry);
    doReturn(items).when(core).getSelection();
    doReturn("AvroOutputPlugin").when(item).getData(anyString());
    doReturn(step).when(registry).findPluginWithId(StepPluginType.class, "AvroOutputPlugin");
    spoon.showJob = false;
    spoon.showTrans = true;
    TreeSelection[] ts = std.getTreeObjects(core, selection, core);
    assertEquals(1, ts.length);
    assertEquals(step, ts[0].getSelection());
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) Tree(org.eclipse.swt.widgets.Tree) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with PluginInterface

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

the class SpoonJobDelegate method getJobEntryDialog.

public JobEntryDialogInterface getJobEntryDialog(JobEntryInterface jobEntryInterface, JobMeta jobMeta) {
    Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class };
    Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta };
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.getPlugin(JobEntryPluginType.class, jobEntryInterface);
    String dialogClassName = plugin.getClassMap().get(JobEntryDialogInterface.class);
    if (dialogClassName == null) {
        // try the deprecated way
        log.logDebug("Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead.");
        dialogClassName = jobEntryInterface.getDialogClassName();
    }
    try {
        Class<JobEntryDialogInterface> dialogClass = registry.getClass(plugin, dialogClassName);
        Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor(paramClasses);
        JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance(paramArgs);
        entryDialogInterface.setMetaStore(spoon.getMetaStore());
        return entryDialogInterface;
    } catch (Throwable t) {
        t.printStackTrace();
        String errorTitle = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title");
        String errorMsg = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName);
        spoon.getLog().logError(spoon.toString(), errorMsg);
        new ErrorDialog(spoon.getShell(), errorTitle, errorMsg, t);
        return null;
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryDialogInterface(org.pentaho.di.job.entry.JobEntryDialogInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Shell(org.eclipse.swt.widgets.Shell) Repository(org.pentaho.di.repository.Repository) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

Example 5 with PluginInterface

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

the class SpoonJobDelegate method newJobEntry.

public JobEntryCopy newJobEntry(JobMeta jobMeta, String type_desc, boolean openit) {
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface jobPlugin;
    try {
        jobPlugin = PluginRegistry.getInstance().findPluginWithName(JobEntryPluginType.class, type_desc);
        if (jobPlugin == null) {
            // Check if it's not START or DUMMY
            if (JobMeta.STRING_SPECIAL_START.equals(type_desc) || JobMeta.STRING_SPECIAL_DUMMY.equals(type_desc)) {
                jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, JobMeta.STRING_SPECIAL);
            }
        }
        if (jobPlugin != null) {
            // Determine name & number for this entry.
            // See if the name is already used...
            // 
            String entry_name = type_desc;
            int nr = 2;
            JobEntryCopy check = jobMeta.findJobEntry(entry_name, 0, true);
            while (check != null) {
                entry_name = type_desc + " " + nr++;
                check = jobMeta.findJobEntry(entry_name, 0, true);
            }
            // Generate the appropriate class...
            JobEntryInterface jei = (JobEntryInterface) registry.loadClass(jobPlugin);
            jei.setPluginId(jobPlugin.getIds()[0]);
            jei.setName(entry_name);
            if (jei.isSpecial()) {
                if (JobMeta.STRING_SPECIAL_START.equals(type_desc)) {
                    // Check if start is already on the canvas...
                    if (jobMeta.findStart() != null) {
                        JobGraph.showOnlyStartOnceMessage(spoon.getShell());
                        return null;
                    }
                    ((JobEntrySpecial) jei).setStart(true);
                    jei.setName(JobMeta.STRING_SPECIAL_START);
                }
                if (JobMeta.STRING_SPECIAL_DUMMY.equals(type_desc)) {
                    ((JobEntrySpecial) jei).setDummy(true);
                // jei.setName(JobMeta.STRING_SPECIAL_DUMMY); // Don't overwrite the name
                }
            }
            if (openit) {
                JobEntryDialogInterface d = getJobEntryDialog(jei, jobMeta);
                if (d != null && d.open() != null) {
                    JobEntryCopy jge = new JobEntryCopy();
                    jge.setEntry(jei);
                    jge.setLocation(50, 50);
                    jge.setNr(0);
                    jobMeta.addJobEntry(jge);
                    // Verify that the name is not already used in the job.
                    // 
                    jobMeta.renameJobEntryIfNameCollides(jge);
                    spoon.addUndoNew(jobMeta, new JobEntryCopy[] { jge }, new int[] { jobMeta.indexOfJobEntry(jge) });
                    spoon.refreshGraph();
                    spoon.refreshTree();
                    return jge;
                } else {
                    return null;
                }
            } else {
                JobEntryCopy jge = new JobEntryCopy();
                jge.setEntry(jei);
                jge.setLocation(50, 50);
                jge.setNr(0);
                jobMeta.addJobEntry(jge);
                spoon.addUndoNew(jobMeta, new JobEntryCopy[] { jge }, new int[] { jobMeta.indexOfJobEntry(jge) });
                spoon.refreshGraph();
                spoon.refreshTree();
                return jge;
            }
        } else {
            return null;
        }
    } catch (Throwable e) {
        new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.ErrorDialog.UnexpectedErrorCreatingNewJobGraphEntry.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.UnexpectedErrorCreatingNewJobGraphEntry.Message"), new Exception(e));
        return null;
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntrySpecial(org.pentaho.di.job.entries.special.JobEntrySpecial) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryDialogInterface(org.pentaho.di.job.entry.JobEntryDialogInterface) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) JobEntryPluginType(org.pentaho.di.core.plugins.JobEntryPluginType)

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