Search in sources :

Example 71 with PluginInterface

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;
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 72 with PluginInterface

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);
            }
        }
    }
}
Also used : ImportRules(org.pentaho.di.imp.ImportRules) ImportRuleInterface(org.pentaho.di.imp.rule.ImportRuleInterface) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) KettleException(org.pentaho.di.core.exception.KettleException)

Example 73 with PluginInterface

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;
}
Also used : Button(org.eclipse.swt.widgets.Button) LogTablePluginInterface(org.pentaho.di.core.logging.LogTablePluginInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 74 with PluginInterface

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;
}
Also used : KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) WizardPage(org.eclipse.jface.wizard.WizardPage) Wizard(org.eclipse.jface.wizard.Wizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 75 with PluginInterface

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

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