Search in sources :

Example 1 with GuiPlugin

use of org.apache.hop.core.gui.plugin.GuiPlugin in project hop by apache.

the class EnterOptionsDialog method addPluginTabs.

private void addPluginTabs() {
    // Add a new tab for every config plugin which is also a GuiPlugin
    // Then simply add the widgets on a separate tab
    // 
    HopGui hopGui = HopGui.getInstance();
    PluginRegistry pluginRegistry = PluginRegistry.getInstance();
    List<IPlugin> configPlugins = pluginRegistry.getPlugins(ConfigPluginType.class);
    for (IPlugin configPlugin : configPlugins) {
        try {
            Object emptySourceData = pluginRegistry.loadClass(configPlugin);
            GuiPlugin annotation = emptySourceData.getClass().getAnnotation(GuiPlugin.class);
            if (annotation != null) {
                // Load the instance
                // 
                Method method = emptySourceData.getClass().getMethod("getInstance");
                Object sourceData = method.invoke(null, (Object[]) null);
                // This config plugin is also a GUI plugin
                // Add a tab
                // 
                CTabItem wPluginTab = new CTabItem(wTabFolder, SWT.NONE);
                wPluginTab.setText(Const.NVL(TranslateUtil.translate(annotation.description(), emptySourceData.getClass()), ""));
                ScrolledComposite sOtherComp = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
                sOtherComp.setLayout(new FormLayout());
                Composite wPluginsComp = new Composite(sOtherComp, SWT.NONE);
                props.setLook(wPluginsComp);
                wPluginsComp.setLayout(new FormLayout());
                GuiCompositeWidgets compositeWidgets = new GuiCompositeWidgets(hopGui.getVariables());
                compositeWidgets.createCompositeWidgets(sourceData, null, wPluginsComp, GUI_WIDGETS_PARENT_ID, null);
                compositeWidgets.setWidgetsContents(sourceData, wPluginsComp, GUI_WIDGETS_PARENT_ID);
                if (sourceData instanceof IGuiPluginCompositeWidgetsListener) {
                    compositeWidgets.setWidgetsListener((IGuiPluginCompositeWidgetsListener) sourceData);
                }
                pluginWidgetContentsList.add(new PluginWidgetContents(compositeWidgets, sourceData));
                wPluginsComp.pack();
                Rectangle bounds = wPluginsComp.getBounds();
                sOtherComp.setContent(wPluginsComp);
                sOtherComp.setExpandHorizontal(true);
                sOtherComp.setExpandVertical(true);
                sOtherComp.setMinWidth(bounds.width);
                sOtherComp.setMinHeight(bounds.height);
                wPluginTab.setControl(sOtherComp);
            }
        } catch (Exception e) {
            new ErrorDialog(shell, "Error", "Error handling configuration options for config / GUI plugin " + configPlugin.getIds()[0], e);
        }
    // ///////////////////////////////////////////////////////////
    // / END OF PLUGINS TAB
    // ///////////////////////////////////////////////////////////
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) GuiCompositeWidgets(org.apache.hop.ui.core.gui.GuiCompositeWidgets) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Method(java.lang.reflect.Method) CTabItem(org.eclipse.swt.custom.CTabItem) IPlugin(org.apache.hop.core.plugins.IPlugin) GuiPlugin(org.apache.hop.core.gui.plugin.GuiPlugin) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IGuiPluginCompositeWidgetsListener(org.apache.hop.ui.core.gui.IGuiPluginCompositeWidgetsListener) HopGui(org.apache.hop.ui.hopgui.HopGui)

Aggregations

Method (java.lang.reflect.Method)1 GuiPlugin (org.apache.hop.core.gui.plugin.GuiPlugin)1 IPlugin (org.apache.hop.core.plugins.IPlugin)1 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)1 GuiCompositeWidgets (org.apache.hop.ui.core.gui.GuiCompositeWidgets)1 IGuiPluginCompositeWidgetsListener (org.apache.hop.ui.core.gui.IGuiPluginCompositeWidgetsListener)1 HopGui (org.apache.hop.ui.hopgui.HopGui)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FormLayout (org.eclipse.swt.layout.FormLayout)1