Search in sources :

Example 11 with PluginInterface

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

the class PropsUI method init.

@SuppressWarnings("unchecked")
protected synchronized void init() {
    super.createLogChannel();
    properties = new Properties();
    pluginHistory = new ArrayList<ObjectUsageCount>();
    setDefault();
    loadProps();
    addDefaultEntries();
    loadPluginHistory();
    loadScreens();
    loadLastUsedFiles();
    loadLastUsedRepoFiles();
    loadOpenTabFiles();
    resetRecentSearches();
    PluginRegistry registry = PluginRegistry.getInstance();
    List<PluginInterface> plugins = registry.getPlugins(LifecyclePluginType.class);
    List<GUIOption<Object>> leditables = new ArrayList<GUIOption<Object>>();
    for (PluginInterface plugin : plugins) {
        if (!plugin.getClassMap().keySet().contains(GUIOption.class)) {
            continue;
        }
        try {
            GUIOption<Object> loaded = registry.loadClass(plugin, GUIOption.class);
            if (loaded != null) {
                leditables.add(loaded);
            }
        } catch (ClassCastException cce) {
            // Not all Lifecycle plugins implement GUIOption, keep calm and carry on
            LogChannel.GENERAL.logDebug("Plugin " + plugin.getIds()[0] + " does not implement GUIOption, it will not be editable");
        } catch (Exception e) {
            LogChannel.GENERAL.logError("Unexpected error loading class for plugin " + plugin.getName(), e);
        }
    }
    editables = Collections.unmodifiableList(leditables);
}
Also used : ObjectUsageCount(org.pentaho.di.core.ObjectUsageCount) GUIOption(org.pentaho.di.core.gui.GUIOption) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ArrayList(java.util.ArrayList) Properties(java.util.Properties) ParseException(java.text.ParseException) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

Example 12 with PluginInterface

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

the class CreateDatabaseWizardPage1 method createControl.

public void createControl(Composite parent) {
    int margin = Const.MARGIN;
    int middle = props.getMiddlePct();
    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);
    FormLayout compLayout = new FormLayout();
    compLayout.marginHeight = Const.FORM_MARGIN;
    compLayout.marginWidth = Const.FORM_MARGIN;
    composite.setLayout(compLayout);
    wlName = new Label(composite, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "CreateDatabaseWizardPage1.DBName.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.top = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    wlName.setLayoutData(fdlName);
    wName = new Text(composite, SWT.SINGLE | SWT.BORDER);
    props.setLook(wName);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    wName.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setPageComplete(false);
        }
    });
    wlDBType = new Label(composite, SWT.RIGHT);
    wlDBType.setText(BaseMessages.getString(PKG, "CreateDatabaseWizardPage1.DBType.Label"));
    props.setLook(wlDBType);
    fdlDBType = new FormData();
    fdlDBType.left = new FormAttachment(0, 0);
    fdlDBType.top = new FormAttachment(wName, margin);
    fdlDBType.right = new FormAttachment(middle, 0);
    wlDBType.setLayoutData(fdlDBType);
    wDBType = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wDBType);
    PluginRegistry registry = PluginRegistry.getInstance();
    java.util.List<PluginInterface> plugins = registry.getPlugins(DatabasePluginType.class);
    Collections.sort(plugins, new Comparator<PluginInterface>() {

        @Override
        public int compare(PluginInterface o1, PluginInterface o2) {
            return o1.getName().toUpperCase().compareTo(o2.getName().toUpperCase());
        }
    });
    for (PluginInterface plugin : plugins) {
        try {
            wDBType.add(plugin.getName());
            wDBIDtoNameMap.put(plugin.getIds()[0], plugin.getName());
        } catch (Exception e) {
            throw new RuntimeException("Error creating class for: " + plugin, e);
        }
    }
    // Select a default: the first
    /*
     * if (databaseMeta.getDatabaseType() <= 0) { wDBType.select(0); } else {
     */
    int idx = wDBType.indexOf(wDBIDtoNameMap.get(databaseMeta.getPluginId()));
    if (idx >= 0) {
        wDBType.select(idx);
    } else {
        wDBType.select(0);
    }
    // }
    fdDBType = new FormData();
    fdDBType.top = new FormAttachment(wName, margin);
    fdDBType.left = new FormAttachment(middle, margin);
    fdDBType.bottom = new FormAttachment(80, 0);
    fdDBType.right = new FormAttachment(100, 0);
    wDBType.setLayoutData(fdDBType);
    wDBType.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            setAccessTypes();
            setPageComplete(false);
        }
    });
    wlAccType = new Label(composite, SWT.RIGHT);
    wlAccType.setText(BaseMessages.getString(PKG, "CreateDatabaseWizardPage1.DBAccessType.Label"));
    props.setLook(wlAccType);
    fdlAccType = new FormData();
    fdlAccType.left = new FormAttachment(0, 0);
    fdlAccType.top = new FormAttachment(wDBType, margin);
    fdlAccType.right = new FormAttachment(middle, 0);
    wlAccType.setLayoutData(fdlAccType);
    wAccType = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wAccType);
    fdAccType = new FormData();
    fdAccType.top = new FormAttachment(wDBType, margin);
    fdAccType.left = new FormAttachment(middle, margin);
    fdAccType.bottom = new FormAttachment(100, 0);
    fdAccType.right = new FormAttachment(100, 0);
    wAccType.setLayoutData(fdAccType);
    wAccType.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            setPageComplete(false);
        }
    });
    setAccessTypes();
    // set the composite as the control for this page
    setControl(composite);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) ModifyEvent(org.eclipse.swt.events.ModifyEvent) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 13 with PluginInterface

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

the class GUIResource method loadJobEntryImages.

/**
 * Load all step images from files.
 */
private void loadJobEntryImages() {
    imagesJobentries = new Hashtable<String, SwtUniversalImage>();
    imagesJobentriesSmall = new Hashtable<String, Image>();
    // //
    // // JOB ENTRY IMAGES TO LOAD
    // //
    PluginRegistry registry = PluginRegistry.getInstance();
    List<PluginInterface> plugins = registry.getPlugins(JobEntryPluginType.class);
    for (int i = 0; i < plugins.size(); i++) {
        PluginInterface plugin = plugins.get(i);
        if ("SPECIAL".equals(plugin.getIds()[0])) {
            continue;
        }
        SwtUniversalImage image = null;
        Image small_image = null;
        String filename = plugin.getImageFile();
        try {
            ClassLoader classLoader = registry.getClassLoader(plugin);
            image = SwtSvgImageUtil.getUniversalImage(display, classLoader, filename);
        } catch (Throwable t) {
            log.logError("Error occurred loading image [" + filename + "] for plugin " + plugin.getIds()[0], t);
        } finally {
            if (image == null) {
                log.logError("Unable to load image [" + filename + "] for plugin " + plugin.getIds()[0]);
                image = SwtSvgImageUtil.getMissingImage(display);
            }
        }
        // 
        if (image != null) {
            small_image = image.getAsBitmapForSize(display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE);
        }
        imagesJobentries.put(plugin.getIds()[0], image);
        imagesJobentriesSmall.put(plugin.getIds()[0], small_image);
    }
}
Also used : PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Image(org.eclipse.swt.graphics.Image) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) Point(org.eclipse.swt.graphics.Point) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage)

Example 14 with PluginInterface

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

the class GUIResource method loadStepImages.

/**
 * Load all step images from files.
 */
private void loadStepImages() {
    // imagesSteps.clear();
    // imagesStepsSmall.clear();
    // 
    // STEP IMAGES TO LOAD
    // 
    PluginRegistry registry = PluginRegistry.getInstance();
    List<PluginInterface> steps = registry.getPlugins(StepPluginType.class);
    for (PluginInterface step : steps) {
        if (imagesSteps.get(step.getIds()[0]) != null) {
            continue;
        }
        SwtUniversalImage image = null;
        Image small_image = null;
        String filename = step.getImageFile();
        try {
            ClassLoader classLoader = registry.getClassLoader(step);
            image = SwtSvgImageUtil.getUniversalImage(display, classLoader, filename);
        } catch (Throwable t) {
            log.logError("Error occurred loading image [" + filename + "] for plugin " + step, t);
        } finally {
            if (image == null) {
                log.logError("Unable to load image file [" + filename + "] for plugin " + step);
                image = SwtSvgImageUtil.getMissingImage(display);
            }
        }
        // Calculate the smaller version of the image @ 16x16...
        // Perhaps we should make this configurable?
        // 
        small_image = image.getAsBitmapForSize(display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE);
        imagesSteps.put(step.getIds()[0], image);
        imagesStepsSmall.put(step.getIds()[0], small_image);
    }
}
Also used : PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Image(org.eclipse.swt.graphics.Image) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage)

Example 15 with PluginInterface

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

the class ImportRulesDialog method getCompositesData.

protected void getCompositesData() {
    for (TableItem item : table.getItems()) {
        item.dispose();
    }
    table.clearAll();
    // Fill the table items in the table with data from importRules:
    // 
    compositesList = new ArrayList<ImportRuleCompositeInterface>();
    for (ImportRuleInterface rule : importRules.getRules()) {
        try {
            TableItem item = new TableItem(table, SWT.NONE);
            item.setChecked(rule.isEnabled());
            PluginRegistry registry = PluginRegistry.getInstance();
            PluginInterface plugin = registry.getPlugin(ImportRulePluginType.class, rule);
            item.setText(1, Const.NVL(plugin.getName(), rule.getClass().getName()));
            // Put a composite in the 3rd column...
            // 
            // First get the composite generating class...
            // 
            ImportRuleCompositeInterface importRuleComposite = getImportRuleComposite(rule);
            compositesList.add(importRuleComposite);
            final Composite composite = importRuleComposite.getComposite(table, rule);
            composite.layout(true, true);
            final TableEditor editor = new TableEditor(table);
            editor.grabHorizontal = true;
            editor.grabVertical = true;
            editor.setEditor(composite, item, 2);
            // Put actual data onto the composite
            // 
            importRuleComposite.setCompositeData(rule);
            item.addDisposeListener(new DisposeListener() {

                public void widgetDisposed(DisposeEvent event) {
                    composite.dispose();
                }
            });
        } catch (Exception e) {
            new ErrorDialog(shell, "Error", "Error displaying rule options for rule: " + rule.toString(), e);
            compositesList.add(null);
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ImportRuleCompositeInterface(org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface) Composite(org.eclipse.swt.widgets.Composite) ImportRuleInterface(org.pentaho.di.imp.rule.ImportRuleInterface) TableItem(org.eclipse.swt.widgets.TableItem) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DisposeEvent(org.eclipse.swt.events.DisposeEvent) TableEditor(org.eclipse.swt.custom.TableEditor) KettleException(org.pentaho.di.core.exception.KettleException)

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