Search in sources :

Example 1 with ObjectUsageCount

use of org.pentaho.di.core.ObjectUsageCount 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 2 with ObjectUsageCount

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

the class Spoon method refreshCoreObjects.

public void refreshCoreObjects() {
    if (shell.isDisposed()) {
        return;
    }
    if (!designSelected) {
        return;
    }
    if (coreObjectsTree == null || coreObjectsTree.isDisposed()) {
        addCoreObjectsTree();
    }
    showTrans = getActiveTransformation() != null;
    showJob = getActiveJob() != null;
    if (showTrans == previousShowTrans && showJob == previousShowJob) {
        return;
    }
    // First remove all the entries that where present...
    // 
    TreeItem[] expandItems = coreObjectsTree.getItems();
    for (TreeItem item : expandItems) {
        item.dispose();
    }
    if (showTrans) {
        // Fill the base components...
        // 
        // ////////////////////////////////////////////////////////////////////////////////////////////////
        // TRANSFORMATIONS
        // ////////////////////////////////////////////////////////////////////////////////////////////////
        PluginRegistry registry = PluginRegistry.getInstance();
        final List<PluginInterface> baseSteps = registry.getPlugins(StepPluginType.class);
        final List<String> baseCategories = registry.getCategories(StepPluginType.class);
        for (String baseCategory : baseCategories) {
            TreeItem item = new TreeItem(coreObjectsTree, SWT.NONE);
            item.setText(baseCategory);
            item.setImage(GUIResource.getInstance().getImageFolder());
            List<PluginInterface> sortedCat = baseSteps.stream().filter(baseStep -> baseStep.getCategory().equalsIgnoreCase(baseCategory)).sorted(Comparator.comparing(PluginInterface::getName)).collect(Collectors.toList());
            for (PluginInterface p : sortedCat) {
                final Image stepImage = GUIResource.getInstance().getImagesStepsSmall().get(p.getIds()[0]);
                String pluginName = p.getName();
                String pluginDescription = p.getDescription();
                if (!filterMatch(pluginName) && !filterMatch(pluginDescription)) {
                    continue;
                }
                createTreeItem(item, pluginName, stepImage, p.getIds()[0]);
                coreStepToolTipMap.put(pluginName, pluginDescription);
            }
        }
        // Add History Items...
        TreeItem item = new TreeItem(coreObjectsTree, SWT.NONE);
        item.setText(BaseMessages.getString(PKG, "Spoon.History"));
        item.setImage(GUIResource.getInstance().getImageFolder());
        List<ObjectUsageCount> pluginHistory = props.getPluginHistory();
        // 
        for (int i = 0; i < pluginHistory.size() && i < 10; i++) {
            ObjectUsageCount usage = pluginHistory.get(i);
            PluginInterface stepPlugin = PluginRegistry.getInstance().findPluginWithId(StepPluginType.class, usage.getObjectName());
            if (stepPlugin != null) {
                final Image stepImage = GUIResource.getInstance().getImagesSteps().get(stepPlugin.getIds()[0]).getAsBitmapForSize(display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE);
                String pluginName = Const.NVL(stepPlugin.getName(), "");
                String pluginDescription = Const.NVL(stepPlugin.getDescription(), "");
                if (!filterMatch(pluginName) && !filterMatch(pluginDescription)) {
                    continue;
                }
                TreeItem stepItem = createTreeItem(item, pluginName, stepImage);
                stepItem.addListener(SWT.Selection, new Listener() {

                    @Override
                    public void handleEvent(Event event) {
                        System.out.println("Tree item Listener fired");
                    }
                });
                coreStepToolTipMap.put(stepPlugin.getDescription(), pluginDescription + " (" + usage.getNrUses() + ")");
            }
        }
    }
    if (showJob) {
        // Fill the base components...
        // 
        // ////////////////////////////////////////////////////////////////////////////////////////////////
        // JOBS
        // ////////////////////////////////////////////////////////////////////////////////////////////////
        PluginRegistry registry = PluginRegistry.getInstance();
        List<PluginInterface> baseJobEntries = registry.getPlugins(JobEntryPluginType.class);
        List<String> baseCategories = registry.getCategories(JobEntryPluginType.class);
        TreeItem generalItem = null;
        for (String baseCategory : baseCategories) {
            TreeItem item = new TreeItem(coreObjectsTree, SWT.NONE);
            item.setText(baseCategory);
            item.setImage(GUIResource.getInstance().getImageFolder());
            if (baseCategory.equalsIgnoreCase(JobEntryPluginType.GENERAL_CATEGORY)) {
                generalItem = item;
            }
            for (int j = 0; j < baseJobEntries.size(); j++) {
                if (!baseJobEntries.get(j).getIds()[0].equals(JobMeta.STRING_SPECIAL)) {
                    if (baseJobEntries.get(j).getCategory().equalsIgnoreCase(baseCategory)) {
                        final Image jobEntryImage = GUIResource.getInstance().getImagesJobentriesSmall().get(baseJobEntries.get(j).getIds()[0]);
                        String pluginName = Const.NVL(baseJobEntries.get(j).getName(), "");
                        String pluginDescription = Const.NVL(baseJobEntries.get(j).getDescription(), "");
                        if (!filterMatch(pluginName) && !filterMatch(pluginDescription)) {
                            continue;
                        }
                        TreeItem stepItem = createTreeItem(item, pluginName, jobEntryImage);
                        stepItem.addListener(SWT.Selection, new Listener() {

                            @Override
                            public void handleEvent(Event arg0) {
                                System.out.println("Tree item Listener fired");
                            }
                        });
                        // if (isPlugin)
                        // stepItem.setFont(GUIResource.getInstance().getFontBold());
                        coreJobToolTipMap.put(pluginName, pluginDescription);
                    }
                }
            }
        }
        // First add a few "Special entries: Start, Dummy, OK, ERROR
        // We add these to the top of the base category, we don't care about
        // the sort order here.
        // 
        JobEntryCopy startEntry = JobMeta.createStartEntry();
        JobEntryCopy dummyEntry = JobMeta.createDummyEntry();
        String[] specialText = new String[] { startEntry.getName(), dummyEntry.getName() };
        String[] specialTooltip = new String[] { startEntry.getDescription(), dummyEntry.getDescription() };
        Image[] specialImage = new Image[] { GUIResource.getInstance().getImageStartMedium(), GUIResource.getInstance().getImageDummyMedium() };
        int pos = 0;
        for (int i = 0; i < specialText.length; i++) {
            if (!filterMatch(specialText[i]) && !filterMatch(specialTooltip[i])) {
                continue;
            }
            TreeItem specialItem = new TreeItem(generalItem, SWT.NONE, pos);
            specialItem.setImage(specialImage[i]);
            specialItem.setText(specialText[i]);
            specialItem.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event arg0) {
                    System.out.println("Tree item Listener fired");
                }
            });
            coreJobToolTipMap.put(specialText[i], specialTooltip[i]);
            pos++;
        }
    }
    variableComposite.layout(true, true);
    previousShowTrans = showTrans;
    previousShowJob = showJob;
}
Also used : ObjectUsageCount(org.pentaho.di.core.ObjectUsageCount) FileLoggingEventListener(org.pentaho.di.core.logging.FileLoggingEventListener) PluginTypeListener(org.pentaho.di.core.plugins.PluginTypeListener) ModifyListener(org.eclipse.swt.events.ModifyListener) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) PropertyChangeListener(java.beans.PropertyChangeListener) Listener(org.eclipse.swt.widgets.Listener) LocationListener(org.eclipse.swt.browser.LocationListener) TabListener(org.pentaho.xul.swt.tab.TabListener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) TreeItem(org.eclipse.swt.widgets.TreeItem) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Image(org.eclipse.swt.graphics.Image) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) LocationEvent(org.eclipse.swt.browser.LocationEvent) SpoonLifeCycleEvent(org.pentaho.di.ui.spoon.SpoonLifecycleListener.SpoonLifeCycleEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) Event(org.eclipse.swt.widgets.Event) TreeEvent(org.eclipse.swt.events.TreeEvent)

Aggregations

ObjectUsageCount (org.pentaho.di.core.ObjectUsageCount)2 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 LocationEvent (org.eclipse.swt.browser.LocationEvent)1 LocationListener (org.eclipse.swt.browser.LocationListener)1 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)1 DropTargetListener (org.eclipse.swt.dnd.DropTargetListener)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 MenuDetectEvent (org.eclipse.swt.events.MenuDetectEvent)1 MenuDetectListener (org.eclipse.swt.events.MenuDetectListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 TreeEvent (org.eclipse.swt.events.TreeEvent)1