use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement in project hop by apache.
the class HopVfsFileDialog method addBookmark.
@GuiToolbarElement(root = BOOKMARKS_TOOLBAR_PARENT_ID, id = BOOKMARKS_ITEM_ID_BOOKMARK_ADD, toolTip = "i18n::HopVfsFileDialog.AddBookmark.Tooltip.Message", image = "ui/images/bookmark-add.svg")
public void addBookmark() {
FileObject selectedFile = getSelectedFileObject();
if (selectedFile != null) {
String name = selectedFile.getName().getBaseName();
EnterStringDialog dialog = new EnterStringDialog(shell, name, BaseMessages.getString(PKG, "HopVfsFileDialog.NameBookmark.Header"), BaseMessages.getString(PKG, "HopVfsFileDialog.NameBookmark.Message"));
name = dialog.open();
if (name != null) {
String path = HopVfs.getFilename(selectedFile);
bookmarks.put(name, path);
saveBookmarks();
refreshBookmarks();
}
}
refreshStates();
}
use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement in project hop by apache.
the class TestingGuiPlugin method editUnitTest.
@GuiToolbarElement(root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID, id = ID_TOOLBAR_ITEM_UNIT_TEST_EDIT, toolTip = "i18n::TestingGuiPlugin.ToolbarElement.UnitTest.Edit.Tooltip", image = "Test_tube_icon_edit.svg", separator = true)
public void editUnitTest() {
HopGui hopGui = HopGui.getInstance();
PipelineMeta pipelineMeta = getActivePipelineMeta();
if (pipelineMeta == null) {
return;
}
PipelineUnitTest unitTest = getCurrentUnitTest(pipelineMeta);
MetadataManager<PipelineUnitTest> manager = new MetadataManager<>(hopGui.getVariables(), hopGui.getMetadataProvider(), PipelineUnitTest.class);
if (manager.editMetadata(unitTest.getName())) {
// Activate the test
refreshUnitTestsList();
selectUnitTest(pipelineMeta, unitTest);
}
}
use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement in project hop by apache.
the class TestingGuiPlugin method detachUnitTest.
/**
* Clear the current unit test from the active pipeline...
*/
@GuiToolbarElement(root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID, id = ID_TOOLBAR_ITEM_UNIT_TEST_DETACH, toolTip = "i18n::TestingGuiPlugin.ToolbarElement.UnitTest.Detach.Tooltip", image = "Test_tube_icon_detach.svg")
public void detachUnitTest() {
HopGui hopGui = HopGui.getInstance();
HopGuiPipelineGraph pipelineGraph = HopGui.getActivePipelineGraph();
if (pipelineGraph == null) {
return;
}
try {
PipelineMeta pipelineMeta = getActivePipelineMeta();
if (pipelineMeta == null) {
return;
}
// Remove
//
Map<String, Object> stateMap = getStateMap(pipelineMeta);
if (stateMap != null) {
stateMap.remove(DataSetConst.STATE_KEY_ACTIVE_UNIT_TEST);
}
// Clear the combo box
//
Combo combo = getUnitTestsCombo();
if (combo != null) {
combo.setText("");
}
// Update the GUI
//
pipelineGraph.updateGui();
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.Detach.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ToolbarElement.Detach.Error.Message"), e);
}
}
use of org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement in project hop by apache.
the class HopGuiEnvironment method initGuiPlugins.
/**
* Look for GuiWidgetElement annotated fields in all the GuiPlugins. Put them in the Gui registry
*
* @throws HopException
*/
public static void initGuiPlugins() throws HopException {
try {
GuiRegistry guiRegistry = GuiRegistry.getInstance();
PluginRegistry pluginRegistry = PluginRegistry.getInstance();
List<IPlugin> guiPlugins = pluginRegistry.getPlugins(GuiPluginType.class);
for (IPlugin guiPlugin : guiPlugins) {
ClassLoader classLoader = pluginRegistry.getClassLoader(guiPlugin);
Class<?>[] typeClasses = guiPlugin.getClassMap().keySet().toArray(new Class<?>[0]);
String guiPluginClassName = guiPlugin.getClassMap().get(typeClasses[0]);
Class<?> guiPluginClass = classLoader.loadClass(guiPluginClassName);
// Component widgets are defined on fields
//
List<Field> fields = findDeclaredFields(guiPluginClass);
for (Field field : fields) {
GuiWidgetElement guiElement = field.getAnnotation(GuiWidgetElement.class);
if (guiElement != null) {
// Add the GUI Element to the registry...
//
guiRegistry.addGuiWidgetElement(guiPluginClassName, guiElement, field);
}
}
// Menu and toolbar items are defined on methods
//
List<Method> methods = findDeclaredMethods(guiPluginClass);
for (Method method : methods) {
GuiMenuElement menuElement = method.getAnnotation(GuiMenuElement.class);
if (menuElement != null) {
guiRegistry.addGuiWidgetElement(guiPluginClassName, menuElement, method, classLoader);
}
GuiToolbarElement toolbarElement = method.getAnnotation(GuiToolbarElement.class);
if (toolbarElement != null) {
guiRegistry.addGuiToolbarElement(guiPluginClassName, toolbarElement, method, classLoader);
}
GuiKeyboardShortcut shortcut = method.getAnnotation(GuiKeyboardShortcut.class);
if (shortcut != null) {
// RAP does not support ESC as a shortcut key.
if (EnvironmentUtils.getInstance().isWeb() && shortcut.key() == SWT.ESC) {
continue;
}
guiRegistry.addKeyboardShortcut(guiPluginClassName, method, shortcut);
}
GuiOsxKeyboardShortcut osxShortcut = method.getAnnotation(GuiOsxKeyboardShortcut.class);
if (osxShortcut != null) {
// RAP does not support ESC as a shortcut key.
if (EnvironmentUtils.getInstance().isWeb() && osxShortcut.key() == SWT.ESC) {
continue;
}
guiRegistry.addKeyboardShortcut(guiPluginClassName, method, osxShortcut);
}
GuiContextAction contextAction = method.getAnnotation(GuiContextAction.class);
if (contextAction != null) {
guiRegistry.addGuiContextAction(guiPluginClassName, method, contextAction, classLoader);
}
GuiContextActionFilter actionFilter = method.getAnnotation(GuiContextActionFilter.class);
if (actionFilter != null) {
guiRegistry.addGuiActionFilter(guiPluginClassName, method, actionFilter, classLoader);
}
GuiCallback guiCallback = method.getAnnotation(GuiCallback.class);
if (guiCallback != null) {
guiRegistry.registerGuiCallback(guiPluginClass, method, guiCallback);
}
}
}
// Sort all GUI elements once.
//
guiRegistry.sortAllElements();
// Now populate the HopFileTypeRegistry
//
// Get all the file handler plugins
//
PluginRegistry registry = PluginRegistry.getInstance();
List<IPlugin> plugins = registry.getPlugins(HopFileTypePluginType.class);
for (IPlugin plugin : plugins) {
try {
IHopFileType hopFileTypeInterface = registry.loadClass(plugin, IHopFileType.class);
HopFileTypeRegistry.getInstance().registerHopFile(hopFileTypeInterface);
} catch (HopPluginException e) {
throw new HopException("Unable to load plugin with ID '" + plugin.getIds()[0] + "' and type : " + plugin.getPluginType().getName(), e);
}
}
} catch (Exception e) {
throw new HopException("Error looking for Elements in GUI Plugins ", e);
}
}
Aggregations