Search in sources :

Example 81 with PluginInterface

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

the class Spoon method editPartitioning.

public void editPartitioning(TransMeta transMeta, StepMeta stepMeta) {
    String[] schemaNames;
    try {
        schemaNames = pickupPartitionSchemaNames(transMeta);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.ErrorDialog.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorFetchingFromRepo.PartitioningSchemas"), e);
        return;
    }
    try {
        /*Check if Partition schema has already defined*/
        if (isDefinedSchemaExist(schemaNames)) {
            /*Prepare settings for Method selection*/
            PluginRegistry registry = PluginRegistry.getInstance();
            List<PluginInterface> plugins = registry.getPlugins(PartitionerPluginType.class);
            int exactSize = StepPartitioningMeta.methodDescriptions.length + plugins.size();
            PartitionSettings settings = new PartitionSettings(exactSize, transMeta, stepMeta, this);
            settings.fillOptionsAndCodesByPlugins(plugins);
            /*Method selection*/
            PartitionMethodSelector methodSelector = new PartitionMethodSelector();
            String partitionMethodDescription = methodSelector.askForPartitionMethod(shell, settings);
            if (!StringUtil.isEmpty(partitionMethodDescription)) {
                String method = settings.getMethodByMethodDescription(partitionMethodDescription);
                int methodType = StepPartitioningMeta.getMethodType(method);
                settings.updateMethodType(methodType);
                settings.updateMethod(method);
                /*Schema selection*/
                MethodProcessor methodProcessor = MethodProcessorFactory.create(methodType);
                methodProcessor.schemaSelection(settings, shell, delegates);
            }
            addUndoChange(settings.getTransMeta(), new StepMeta[] { settings.getBefore() }, new StepMeta[] { settings.getAfter() }, new int[] { settings.getTransMeta().indexOfStep(settings.getStepMeta()) });
            refreshGraph();
        }
    } catch (Exception e) {
        new ErrorDialog(shell, "Error", "There was an unexpected error while editing the partitioning method specifics:", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) MethodProcessor(org.pentaho.di.ui.spoon.partition.processor.MethodProcessor) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) PartitionSettings(org.pentaho.di.ui.spoon.partition.PartitionSettings) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PartitionMethodSelector(org.pentaho.di.ui.spoon.partition.PartitionMethodSelector) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException)

Example 82 with PluginInterface

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

the class SpoonUiExtenderPluginType method getRelevantExtenders.

public List<SpoonUiExtenderPluginInterface> getRelevantExtenders(Class<?> clazz, String uiEvent) {
    PluginRegistry instance = PluginRegistry.getInstance();
    List<PluginInterface> pluginInterfaces = instance.getPlugins(SpoonUiExtenderPluginType.class);
    List<SpoonUiExtenderPluginInterface> relevantPluginInterfaces = new ArrayList<SpoonUiExtenderPluginInterface>();
    if (pluginInterfaces != null) {
        for (PluginInterface pluginInterface : pluginInterfaces) {
            try {
                Object loadClass = instance.loadClass(pluginInterface);
                SpoonUiExtenderPluginInterface spoonUiExtenderPluginInterface = (SpoonUiExtenderPluginInterface) loadClass;
                Set<String> events = spoonUiExtenderPluginInterface.respondsTo().get(clazz);
                if (events != null && events.contains(uiEvent)) {
                    relevantPluginInterfaces.add(spoonUiExtenderPluginInterface);
                }
            } catch (KettlePluginException e) {
                e.printStackTrace();
            }
        }
    }
    return relevantPluginInterfaces;
}
Also used : KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ArrayList(java.util.ArrayList)

Example 83 with PluginInterface

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

the class TransDialog method open.

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

        public void modifyText(ModifyEvent e) {
            changed = true;
        }
    };
    lsModSel = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent 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, "TransDialog.Shell.Title"));
    middle = props.getMiddlePct();
    margin = Const.MARGIN;
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    wTabFolder.setSimple(false);
    addTransTab();
    addParamTab();
    addLogTab();
    addDateTab();
    addDepTab();
    addMiscTab();
    addMonitoringTab();
    // See if there are any other tabs to be added...
    extraTabs = new ArrayList<TransDialogPluginInterface>();
    java.util.List<PluginInterface> transDialogPlugins = PluginRegistry.getInstance().getPlugins(TransDialogPluginType.class);
    for (PluginInterface transDialogPlugin : transDialogPlugins) {
        try {
            TransDialogPluginInterface extraTab = (TransDialogPluginInterface) PluginRegistry.getInstance().loadClass(transDialogPlugin);
            extraTab.addTab(transMeta, parent, wTabFolder);
            extraTabs.add(extraTab);
        } catch (Exception e) {
            KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
            if (krle != null) {
                throw krle;
            }
            new ErrorDialog(shell, "Error", "Error loading transformation dialog plugin with id " + transDialogPlugin.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"));
    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 }, Const.MARGIN, null);
    // Add listeners
    lsOK = new Listener() {

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

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

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

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

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wTransname.addSelectionListener(lsDef);
    wTransdescription.addSelectionListener(lsDef);
    wTransversion.addSelectionListener(lsDef);
    wMaxdatetable.addSelectionListener(lsDef);
    wMaxdatefield.addSelectionListener(lsDef);
    wMaxdateoffset.addSelectionListener(lsDef);
    wMaxdatediff.addSelectionListener(lsDef);
    wSizeRowset.addSelectionListener(lsDef);
    wUniqueConnections.addSelectionListener(lsDef);
    wFeedbackSize.addSelectionListener(lsDef);
    wStepPerfInterval.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    if (currentTab != null) {
        setCurrentTab(currentTab);
    } else {
        wTabFolder.setSelection(0);
    }
    getData();
    BaseStepDialog.setSize(shell);
    changed = false;
    sharedObjectsFileChanged = false;
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return transMeta;
}
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) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) 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) 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 84 with PluginInterface

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

the class BaseStepDialog method setShellImage.

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

Example 85 with PluginInterface

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

the class SpoonStepsDelegate method getStepDialog.

public StepDialogInterface getStepDialog(StepMetaInterface stepMeta, TransMeta transMeta, String stepName) throws KettleException {
    Class<?>[] paramClasses = new Class<?>[] { Shell.class, Object.class, TransMeta.class, String.class };
    Object[] paramArgs = new Object[] { spoon.getShell(), stepMeta, transMeta, stepName };
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.getPlugin(StepPluginType.class, stepMeta);
    String dialogClassName = plugin.getClassMap().get(StepDialogInterface.class);
    if (dialogClassName == null) {
        // try the deprecated way
        log.logDebug("Use of StepMetaInterface#getDialogClassName is deprecated, use PluginDialog annotation instead.");
        dialogClassName = stepMeta.getDialogClassName();
    }
    try {
        Class<StepDialogInterface> dialogClass = registry.getClass(plugin, dialogClassName);
        Constructor<StepDialogInterface> dialogConstructor = dialogClass.getConstructor(paramClasses);
        return dialogConstructor.newInstance(paramArgs);
    } catch (Exception e) {
        // try the old way for compatibility
        try {
            Class<?>[] sig = new Class<?>[] { Shell.class, StepMetaInterface.class, TransMeta.class, String.class };
            Method method = stepMeta.getClass().getDeclaredMethod("getDialog", sig);
            if (method != null) {
                log.logDebug("Use of StepMetaInterface#getDialog is deprecated, use PluginDialog annotation instead.");
                return (StepDialogInterface) method.invoke(stepMeta, paramArgs);
            }
        } catch (Throwable ignored) {
        }
        String errorTitle = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingStepDialog.Title");
        String errorMsg = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingStepDialog.Message", dialogClassName);
        new ErrorDialog(spoon.getShell(), errorTitle, errorMsg, e);
        throw new KettleException(e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) StepDialogInterface(org.pentaho.di.trans.step.StepDialogInterface) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Method(java.lang.reflect.Method) KettleException(org.pentaho.di.core.exception.KettleException) Shell(org.eclipse.swt.widgets.Shell) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

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