use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class CompressionProviderFactory method createCompressionProviderInstance.
@Override
public CompressionProvider createCompressionProviderInstance(String name) {
CompressionProvider provider = null;
List<PluginInterface> providers = getPlugins();
if (providers != null) {
for (PluginInterface plugin : providers) {
if (name != null && name.equalsIgnoreCase(plugin.getName())) {
try {
return PluginRegistry.getInstance().loadClass(plugin, CompressionProvider.class);
} catch (Exception e) {
provider = null;
}
}
}
}
return provider;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ImportRulesDialog method addRule.
public void addRule() {
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> plugins = registry.getPlugins(ImportRulePluginType.class);
//
for (ImportRuleInterface rule : importRules.getRules()) {
if (rule.isUnique()) {
int removeIndex = -1;
for (int i = 0; i < plugins.size(); i++) {
PluginInterface plugin = plugins.get(i);
if (Const.indexOfString(rule.getId(), plugin.getIds()) >= 0) {
removeIndex = i;
break;
}
}
if (removeIndex >= 0) {
plugins.remove(removeIndex);
}
}
}
//
if (plugins.size() > 0) {
String[] names = new String[plugins.size()];
for (int i = 0; i < plugins.size(); i++) {
names[i] = plugins.get(i).getName() + " : " + plugins.get(i).getDescription();
}
EnterSelectionDialog esd = new EnterSelectionDialog(shell, names, "Select a rule", "Select a new rule to add to the list:");
String name = esd.open();
if (name != null) {
try {
int index = Const.indexOfString(name, names);
PluginInterface plugin = plugins.get(index);
ImportRuleInterface rule = (ImportRuleInterface) registry.loadClass(plugin);
rule.setEnabled(true);
rule.setId(plugin.getIds()[0]);
ImportRules newRules = new ImportRules();
getInfo(newRules);
newRules.getRules().add(rule);
importRules = newRules;
// Refresh the whole list..
//
getCompositesData();
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error loading rule class", e);
}
}
}
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class JobDialog method setShellImage.
public static final Button setShellImage(Shell shell, JobEntryInterface jobEntryInterface) {
Button helpButton = null;
try {
final PluginInterface plugin = getPlugin(jobEntryInterface);
helpButton = HelpUtils.createHelpButton(shell, HelpUtils.getHelpDialogTitle(plugin), plugin);
shell.setImage(getImage(shell, plugin));
} catch (Throwable e) {
// Ignore unexpected errors, not worth it
}
return helpButton;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class CreateDatabaseWizard method createAndRunDatabaseWizard.
/**
* Shows a wizard that creates a new database connection...
*
* @param shell
* @param props
* @param databases
* @return DatabaseMeta when finished or null when canceled
*/
public DatabaseMeta createAndRunDatabaseWizard(Shell shell, PropsUI props, List<DatabaseMeta> databases) {
DatabaseMeta newDBInfo = new DatabaseMeta();
final CreateDatabaseWizardPage1 page1 = new CreateDatabaseWizardPage1("1", props, newDBInfo, databases);
final CreateDatabaseWizardPageInformix pageifx = new CreateDatabaseWizardPageInformix("ifx", props, newDBInfo);
final CreateDatabaseWizardPageJDBC pagejdbc = new CreateDatabaseWizardPageJDBC("jdbc", props, newDBInfo);
final CreateDatabaseWizardPageOCI pageoci = new CreateDatabaseWizardPageOCI("oci", props, newDBInfo);
final CreateDatabaseWizardPageODBC pageodbc = new CreateDatabaseWizardPageODBC("odbc", props, newDBInfo);
final CreateDatabaseWizardPageOracle pageoracle = new CreateDatabaseWizardPageOracle("oracle", props, newDBInfo);
final CreateDatabaseWizardPageGeneric pageGeneric = new CreateDatabaseWizardPageGeneric("generic", props, newDBInfo);
final CreateDatabaseWizardPage2 page2 = new CreateDatabaseWizardPage2("2", props, newDBInfo);
for (PluginInterface pluginInterface : PluginRegistry.getInstance().getPlugins(DatabasePluginType.class)) {
try {
Object plugin = PluginRegistry.getInstance().loadClass(pluginInterface);
if (plugin instanceof WizardPageFactory) {
WizardPageFactory factory = (WizardPageFactory) plugin;
additionalPages.add(factory.createWizardPage(props, newDBInfo));
}
} catch (KettlePluginException kpe) {
// Don't do anything
}
}
// set to false for safety only
wizardFinished = false;
Wizard wizard = new Wizard() {
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
wizardFinished = true;
return true;
}
/**
* @see org.eclipse.jface.wizard.Wizard#canFinish()
*/
public boolean canFinish() {
return page2.canFinish();
}
};
wizard.addPage(page1);
wizard.addPage(pageoci);
wizard.addPage(pageodbc);
wizard.addPage(pagejdbc);
wizard.addPage(pageoracle);
wizard.addPage(pageifx);
wizard.addPage(pageGeneric);
for (WizardPage page : additionalPages) {
wizard.addPage(page);
}
wizard.addPage(page2);
WizardDialog wd = new WizardDialog(shell, wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 400);
wd.updateSize();
wd.open();
if (!wizardFinished) {
newDBInfo = null;
}
return newDBInfo;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class SpoonTreeDelegateTest method getTreeObjects_getStepByName.
@Test
public void getTreeObjects_getStepByName() {
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", "Delete" });
when(PluginRegistry.getInstance()).thenReturn(registry);
doReturn(items).when(core).getSelection();
doReturn(null).when(item).getData(anyString());
doReturn(step).when(registry).findPluginWithName(StepPluginType.class, "Delete");
spoon.showJob = false;
spoon.showTrans = true;
TreeSelection[] ts = std.getTreeObjects(core, selection, core);
assertEquals(1, ts.length);
assertEquals(step, ts[0].getSelection());
}
Aggregations