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;
}
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;
}
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());
}
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;
}
}
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;
}
}
Aggregations