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
// ///////////////////////////////////////////////////////////
}
}
Aggregations