use of org.apache.hop.core.action.GuiContextActionFilter in project hop by apache.
the class AsyncGuiPlugin method filterAsyncActions.
/**
* We're filtering out the actions which are not a Pipeline action and which are already
* enabled/disabled.
*
* @param contextActionId
* @param context
* @return True if the action should be shown and false otherwise.
*/
@GuiContextActionFilter(parentId = HopGuiWorkflowActionContext.CONTEXT_ID)
public boolean filterAsyncActions(String contextActionId, HopGuiWorkflowActionContext context) {
ActionMeta actionMeta = context.getActionMeta();
boolean isPipeline = actionMeta.isPipeline();
Map<String, String> asyncMap = actionMeta.getAttributesMap().get(Defaults.ASYNC_STATUS_GROUP);
boolean enabled = false;
if (asyncMap != null) {
enabled = asyncMap.get(Defaults.ASYNC_ACTION_PIPELINE_SERVICE_NAME) != null;
}
//
if (contextActionId.equals(ACTION_ID_WORKFLOW_GRAPH_ENABLE_ASYNC_LOGGING)) {
return isPipeline && !enabled;
}
if (contextActionId.equals(ACTION_ID_WORKFLOW_GRAPH_DISABLE_ASYNC_LOGGING)) {
return isPipeline && enabled;
}
return true;
}
use of org.apache.hop.core.action.GuiContextActionFilter 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