Search in sources :

Example 1 with PluginTypeListener

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

the class ExtensionPointMap method reset.

public void reset() {
    lock.writeLock().lock();
    try {
        extensionPointPluginMap.clear();
        registry.addPluginListener(ExtensionPointPluginType.class, new PluginTypeListener() {

            @Override
            public void pluginAdded(Object serviceObject) {
                addExtensionPoint((PluginInterface) serviceObject);
            }

            @Override
            public void pluginRemoved(Object serviceObject) {
                removeExtensionPoint((PluginInterface) serviceObject);
            }

            @Override
            public void pluginChanged(Object serviceObject) {
                removeExtensionPoint((PluginInterface) serviceObject);
                addExtensionPoint((PluginInterface) serviceObject);
            }
        });
    } finally {
        lock.writeLock().unlock();
    }
}
Also used : PluginTypeListener(org.pentaho.di.core.plugins.PluginTypeListener) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 2 with PluginTypeListener

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

the class CarteServlet method init.

@Override
public void init(ServletConfig config) throws ServletException {
    cartePluginRegistry = new ConcurrentHashMap<String, CartePluginInterface>();
    detections = Collections.synchronizedList(new ArrayList<SlaveServerDetection>());
    PluginRegistry pluginRegistry = PluginRegistry.getInstance();
    List<PluginInterface> plugins = pluginRegistry.getPlugins(CartePluginType.class);
    // Initial Registry scan
    for (PluginInterface plugin : plugins) {
        try {
            registerServlet(loadServlet(plugin));
        } catch (KettlePluginException e) {
            log.logError("Unable to instantiate plugin for use with CarteServlet " + plugin.getName());
        }
    }
    // Servlets configured in web.xml take precedence to those discovered during plugin scan
    @SuppressWarnings("unchecked") Enumeration<String> initParameterNames = config.getInitParameterNames();
    while (initParameterNames.hasMoreElements()) {
        final String paramName = initParameterNames.nextElement();
        final String className = config.getInitParameter(paramName);
        final Class<?> clazz;
        try {
            clazz = Class.forName(className);
            registerServlet((CartePluginInterface) clazz.newInstance());
        } catch (ClassNotFoundException e) {
            log.logError("Unable to find configured " + paramName + " of " + className, e);
        } catch (InstantiationException e) {
            log.logError("Unable to instantiate configured " + paramName + " of " + className, e);
        } catch (IllegalAccessException e) {
            log.logError("Unable to access configured " + paramName + " of " + className, e);
        } catch (ClassCastException e) {
            log.logError("Unable to cast configured " + paramName + " of " + className + " to " + CartePluginInterface.class, e);
        }
    }
    // Catch servlets as they become available
    pluginRegistry.addPluginListener(CartePluginType.class, new PluginTypeListener() {

        @Override
        public void pluginAdded(Object serviceObject) {
            try {
                registerServlet(loadServlet((PluginInterface) serviceObject));
            } catch (KettlePluginException e) {
                log.logError(MessageFormat.format("Unable to load plugin: {0}", serviceObject), e);
            }
        }

        @Override
        public void pluginRemoved(Object serviceObject) {
            try {
                String key = getServletKey(loadServlet((PluginInterface) serviceObject));
                cartePluginRegistry.remove(key);
            } catch (KettlePluginException e) {
                log.logError(MessageFormat.format("Unable to load plugin: {0}", serviceObject), e);
            }
        }

        @Override
        public void pluginChanged(Object serviceObject) {
            pluginAdded(serviceObject);
        }
    });
}
Also used : KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ArrayList(java.util.ArrayList) PluginTypeListener(org.pentaho.di.core.plugins.PluginTypeListener) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

Example 3 with PluginTypeListener

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

the class Spoon method init.

public void init(TransMeta ti) {
    FormLayout layout = new FormLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    shell.setLayout(layout);
    addFileListener(new TransFileListener());
    addFileListener(new JobFileListener());
    // INIT Data structure
    if (ti != null) {
        delegates.trans.addTransformation(ti);
    }
    // Load settings in the props
    loadSettings();
    transExecutionConfiguration = new TransExecutionConfiguration();
    transExecutionConfiguration.setGatheringMetrics(true);
    transPreviewExecutionConfiguration = new TransExecutionConfiguration();
    transPreviewExecutionConfiguration.setGatheringMetrics(true);
    transDebugExecutionConfiguration = new TransExecutionConfiguration();
    transDebugExecutionConfiguration.setGatheringMetrics(true);
    jobExecutionConfiguration = new JobExecutionConfiguration();
    // Clean out every time we start, auto-loading etc, is not a good idea
    // If they are needed that often, set them in the kettle.properties file
    // 
    variables = new RowMetaAndData(new RowMeta());
    // props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    cursor_hourglass = new Cursor(display, SWT.CURSOR_WAIT);
    cursor_hand = new Cursor(display, SWT.CURSOR_HAND);
    Composite sashComposite = null;
    MainSpoonPerspective mainPerspective = null;
    try {
        KettleXulLoader xulLoader = new KettleXulLoader();
        xulLoader.setIconsSize(16, 16);
        xulLoader.setOuterContext(shell);
        xulLoader.setSettingsManager(XulSpoonSettingsManager.getInstance());
        ApplicationWindowLocal.setApplicationWindow(this);
        mainSpoonContainer = xulLoader.loadXul(XUL_FILE_MAIN, new XulSpoonResourceBundle());
        BindingFactory bf = new DefaultBindingFactory();
        bf.setDocument(mainSpoonContainer.getDocumentRoot());
        mainSpoonContainer.addEventHandler(this);
        /* menuBar = (XulMenubar) */
        mainSpoonContainer.getDocumentRoot().getElementById("spoon-menubar");
        mainToolbar = (XulToolbar) mainSpoonContainer.getDocumentRoot().getElementById("main-toolbar");
        props.setLook((Control) mainToolbar.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR);
        /* canvas = (XulVbox) */
        mainSpoonContainer.getDocumentRoot().getElementById("trans-job-canvas");
        deck = (SwtDeck) mainSpoonContainer.getDocumentRoot().getElementById("canvas-deck");
        final Composite tempSashComposite = new Composite(shell, SWT.None);
        sashComposite = tempSashComposite;
        mainPerspective = new MainSpoonPerspective(tempSashComposite, tabfolder);
        if (startupPerspective == null) {
            startupPerspective = mainPerspective.getId();
        }
        SpoonPerspectiveManager.getInstance().setStartupPerspective(startupPerspective);
        SpoonPerspectiveManager.getInstance().addPerspective(mainPerspective);
        SpoonPluginManager.getInstance().applyPluginsForContainer("spoon", mainSpoonContainer);
        SpoonPerspectiveManager.getInstance().setDeck(deck);
        SpoonPerspectiveManager.getInstance().setXulDoc(mainSpoonContainer);
        SpoonPerspectiveManager.getInstance().initialize();
    } catch (Exception e) {
        LogChannel.GENERAL.logError("Error initializing transformation", e);
    }
    // addBar();
    // Set the shell size, based upon previous time...
    WindowProperty windowProperty = props.getScreen(APP_TITLE);
    if (windowProperty != null) {
        windowProperty.setShell(shell);
    } else {
        shell.pack();
        // Default = maximized!
        shell.setMaximized(true);
    }
    layout = new FormLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    GridData data = new GridData();
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    data.verticalAlignment = SWT.FILL;
    data.horizontalAlignment = SWT.FILL;
    sashComposite.setLayoutData(data);
    sashComposite.setLayout(layout);
    sashform = new SashForm(sashComposite, SWT.HORIZONTAL);
    FormData fdSash = new FormData();
    fdSash.left = new FormAttachment(0, 0);
    // fdSash.top = new FormAttachment((org.eclipse.swt.widgets.ToolBar)
    // toolbar.getNativeObject(), 0);
    fdSash.top = new FormAttachment(0, 0);
    fdSash.bottom = new FormAttachment(100, 0);
    fdSash.right = new FormAttachment(100, 0);
    sashform.setLayoutData(fdSash);
    createPopupMenus();
    addTree();
    addTabs();
    mainPerspective.setTabset(this.tabfolder);
    ((Composite) deck.getManagedObject()).layout(true, true);
    SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifeCycleEvent.STARTUP);
    // Add a browser widget
    if (props.showWelcomePageOnStartup()) {
        showWelcomePage();
    }
    // Allow data to be copied or moved to the drop target
    int operations = DND.DROP_COPY | DND.DROP_DEFAULT;
    DropTarget target = new DropTarget(shell, operations);
    // Receive data in File format
    final FileTransfer fileTransfer = FileTransfer.getInstance();
    Transfer[] types = new Transfer[] { fileTransfer };
    target.setTransfer(types);
    target.addDropListener(new DropTargetListener() {

        @Override
        public void dragEnter(DropTargetEvent event) {
            if (event.detail == DND.DROP_DEFAULT) {
                if ((event.operations & DND.DROP_COPY) != 0) {
                    event.detail = DND.DROP_COPY;
                } else {
                    event.detail = DND.DROP_NONE;
                }
            }
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
        }

        @Override
        public void dragOperationChanged(DropTargetEvent event) {
            if (event.detail == DND.DROP_DEFAULT) {
                if ((event.operations & DND.DROP_COPY) != 0) {
                    event.detail = DND.DROP_COPY;
                } else {
                    event.detail = DND.DROP_NONE;
                }
            }
        }

        @Override
        public void dragLeave(DropTargetEvent event) {
        }

        @Override
        public void dropAccept(DropTargetEvent event) {
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (fileTransfer.isSupportedType(event.currentDataType)) {
                String[] files = (String[]) event.data;
                for (String file : files) {
                    openFile(file, false);
                }
            }
        }
    });
    // listen for steps being added or removed
    PluginRegistry.getInstance().addPluginListener(StepPluginType.class, new PluginTypeListener() {

        @Override
        public void pluginAdded(Object serviceObject) {
            // hack to get the tree to reload
            previousShowTrans = false;
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    refreshCoreObjects();
                }
            });
        }

        @Override
        public void pluginRemoved(Object serviceObject) {
            // hack to get the tree to reload
            previousShowTrans = false;
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    refreshCoreObjects();
                }
            });
        }

        @Override
        public void pluginChanged(Object serviceObject) {
        }
    });
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Cursor(org.eclipse.swt.graphics.Cursor) DefaultBindingFactory(org.pentaho.ui.xul.binding.DefaultBindingFactory) WindowProperty(org.pentaho.di.ui.core.gui.WindowProperty) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PluginTypeListener(org.pentaho.di.core.plugins.PluginTypeListener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) FileTransfer(org.eclipse.swt.dnd.FileTransfer) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) JobExecutionConfiguration(org.pentaho.di.job.JobExecutionConfiguration) 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) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) TransExecutionConfiguration(org.pentaho.di.trans.TransExecutionConfiguration) SashForm(org.eclipse.swt.custom.SashForm) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) GridData(org.eclipse.swt.layout.GridData) Transfer(org.eclipse.swt.dnd.Transfer) ImageTransfer(org.eclipse.swt.dnd.ImageTransfer) FileTransfer(org.eclipse.swt.dnd.FileTransfer) RepositoryObject(org.pentaho.di.repository.RepositoryObject) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FileObject(org.apache.commons.vfs2.FileObject) DropTarget(org.eclipse.swt.dnd.DropTarget) DefaultBindingFactory(org.pentaho.ui.xul.binding.DefaultBindingFactory) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Aggregations

PluginTypeListener (org.pentaho.di.core.plugins.PluginTypeListener)3 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 SWTException (org.eclipse.swt.SWTException)1 SashForm (org.eclipse.swt.custom.SashForm)1 DropTarget (org.eclipse.swt.dnd.DropTarget)1 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)1 DropTargetListener (org.eclipse.swt.dnd.DropTargetListener)1 FileTransfer (org.eclipse.swt.dnd.FileTransfer)1 ImageTransfer (org.eclipse.swt.dnd.ImageTransfer)1 Transfer (org.eclipse.swt.dnd.Transfer)1 Cursor (org.eclipse.swt.graphics.Cursor)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1