Search in sources :

Example 16 with PluginInterface

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

the class JobDialog method open.

public JobMeta open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.APPLICATION_MODAL);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageJobGraph());
    lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            changed = true;
        }
    };
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobDialog.JobProperties.ShellText"));
    middle = props.getMiddlePct();
    margin = Const.MARGIN;
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    // 
    for (LogTableInterface logTable : logTables) {
        // can be null
        logTableUserInterfaces.add(getLogTableUserInterface(logTable, jobMeta, lsMod));
    }
    addJobTab();
    addParamTab();
    addSettingsTab();
    addLogTab();
    // See if there are any other tabs to be added...
    extraTabs = new ArrayList<JobDialogPluginInterface>();
    java.util.List<PluginInterface> jobDialogPlugins = PluginRegistry.getInstance().getPlugins(JobDialogPluginType.class);
    for (PluginInterface jobDialogPlugin : jobDialogPlugins) {
        try {
            JobDialogPluginInterface extraTab = (JobDialogPluginInterface) PluginRegistry.getInstance().loadClass(jobDialogPlugin);
            extraTab.addTab(jobMeta, parent, wTabFolder);
            extraTabs.add(extraTab);
        } catch (Exception e) {
            KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
            if (krle != null) {
                throw krle;
            }
            new ErrorDialog(shell, "Error", "Error loading job dialog plugin with id " + jobDialogPlugin.getIds()[0], e);
        }
    }
    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(0, 0);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);
    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wSQL = new Button(shell, SWT.PUSH);
    wSQL.setText(BaseMessages.getString(PKG, "System.Button.SQL"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    // BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, margin, wSharedObjectsFile);
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, Const.MARGIN, null);
    // Add listeners
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    lsSQL = new Listener() {

        public void handleEvent(Event e) {
            sql();
        }
    };
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wSQL.addListener(SWT.Selection, lsSQL);
    wCancel.addListener(SWT.Selection, lsCancel);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wJobname.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    wTabFolder.setSelection(0);
    getData();
    BaseStepDialog.setSize(shell);
    changed = false;
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobMeta;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) CTabFolder(org.eclipse.swt.custom.CTabFolder) FieldDisabledListener(org.pentaho.di.ui.core.widget.FieldDisabledListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) LogTablePluginInterface(org.pentaho.di.core.logging.LogTablePluginInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ShellEvent(org.eclipse.swt.events.ShellEvent) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleException(org.pentaho.di.core.exception.KettleException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 17 with PluginInterface

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

the class DataHandlerTest method testDatabaseTypeListener.

@Test
public void testDatabaseTypeListener() throws Exception {
    DataHandler.DatabaseTypeListener listener = spy(new DataHandler.DatabaseTypeListener(PluginRegistry.getInstance()) {

        @Override
        public void databaseTypeAdded(String pluginName, DatabaseInterface databaseInterface) {
        }

        @Override
        public void databaseTypeRemoved(String pluginName) {
        }
    });
    assertNotNull(listener);
    PluginInterface pluginInterface = mock(PluginInterface.class);
    when(pluginInterface.getName()).thenReturn("Oracle");
    doReturn(DatabaseInterface.class).when(pluginInterface).getMainType();
    when(pluginInterface.getIds()).thenReturn(new String[] { "oracle" });
    doReturn(DatabasePluginType.class).when(pluginInterface).getPluginType();
    listener.pluginAdded(pluginInterface);
    // The test can't load the plugin, so databaseTypeAdded never gets called. Perhaps register a mock plugin
    verify(listener, never()).databaseTypeAdded(eq("Oracle"), any(DatabaseInterface.class));
    listener.pluginRemoved(pluginInterface);
    verify(listener, times(1)).databaseTypeRemoved("Oracle");
    // Changed calls removed then added
    listener.pluginChanged(pluginInterface);
    verify(listener, times(2)).databaseTypeRemoved("Oracle");
    verify(listener, never()).databaseTypeAdded(eq("Oracle"), any(DatabaseInterface.class));
}
Also used : DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Test(org.junit.Test)

Example 18 with PluginInterface

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

the class ImportRules method getXML.

public String getXML() {
    StringBuilder xml = new StringBuilder();
    xml.append(XMLHandler.openTag(XML_TAG)).append(Const.CR).append(Const.CR);
    for (ImportRuleInterface rule : getRules()) {
        PluginInterface plugin = PluginRegistry.getInstance().getPlugin(ImportRulePluginType.class, rule.getId());
        xml.append("<!-- ").append(plugin.getName()).append(" : ").append(plugin.getDescription()).append(Const.CR).append(" -->").append(Const.CR);
        xml.append(rule.getXML());
        xml.append(Const.CR).append(Const.CR);
    }
    xml.append(XMLHandler.closeTag(XML_TAG));
    return xml.toString();
}
Also used : ImportRuleInterface(org.pentaho.di.imp.rule.ImportRuleInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 19 with PluginInterface

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

the class BaseImportRule method toString.

@Override
public String toString() {
    // The rule name with an indication of whether or not this rule is enabled should do for now.
    // 
    String pluginId = PluginRegistry.getInstance().getPluginId(this);
    PluginInterface plugin = PluginRegistry.getInstance().findPluginWithId(ImportRulePluginType.class, pluginId);
    return plugin.getName() + " (" + (enabled ? "enabled" : "disabled") + ").";
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 20 with PluginInterface

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

the class ValueMetaFactory method getAllValueMetaNames.

public static String[] getAllValueMetaNames() {
    List<String> strings = new ArrayList<String>();
    List<PluginInterface> plugins = pluginRegistry.getPlugins(ValueMetaPluginType.class);
    for (PluginInterface plugin : plugins) {
        String id = plugin.getIds()[0];
        if (!("0".equals(id))) {
            strings.add(plugin.getName());
        }
    }
    return strings.toArray(new String[strings.size()]);
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ArrayList(java.util.ArrayList)

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