Search in sources :

Example 1 with GuiAction

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

the class HopGuiPipelineHopContext method getSupportedActions.

/**
 * Create a list of supported actions on a pipeline. These are picked up from the annotations,
 * mostly in PipelineGraph. Plugins can add actions as well.
 *
 * @return The list of supported actions
 */
@Override
public List<GuiAction> getSupportedActions() {
    List<GuiAction> actions = new ArrayList<>();
    // Get the actions from the plugins...
    // 
    List<GuiAction> pluginActions = getPluginActions(true);
    if (pluginActions != null) {
        for (GuiAction pluginAction : pluginActions) {
            // See if the action is applicable to the hop.
            // 
            actions.add(lambdaBuilder.createLambda(pluginAction, this, pipelineGraph));
        }
    }
    return actions;
}
Also used : GuiAction(org.apache.hop.core.gui.plugin.action.GuiAction) ArrayList(java.util.ArrayList)

Example 2 with GuiAction

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

the class HopGuiPipelineTransformContext method getSupportedActions.

/**
 * Create a list of supported actions on a pipeline. We'll add the creation of every possible
 * transform as well as the modification of the pipeline itself.
 *
 * @return The list of supported actions
 */
@Override
public List<GuiAction> getSupportedActions() {
    List<GuiAction> actions = new ArrayList<>();
    // Put references at the start since we use those things a lot
    // 
    ITransformMeta iTransformMeta = transformMeta.getTransform();
    String[] objectDescriptions = iTransformMeta.getReferencedObjectDescriptions();
    for (int i = 0; objectDescriptions != null && i < objectDescriptions.length; i++) {
        final String objectDescription = objectDescriptions[i];
        if (iTransformMeta.isReferencedObjectEnabled()[i]) {
            final int index = i;
            GuiAction openReferencedAction = new GuiAction("transform-open-referenced-" + objectDescription, GuiActionType.Info, BaseMessages.getString(PKG, "HopGuiPipelineTransformContext.OpenReferencedAction.Name", objectDescription), BaseMessages.getString(PKG, "HopGuiPipelineTransformContext.OpenReferencedAction.Tooltip"), "ui/images/open.svg", (shiftAction, controlAction, t) -> openReferencedObject(pipelineMeta, pipelineGraph.getVariables(), iTransformMeta, objectDescription, index));
            openReferencedAction.setCategory("Basic");
            openReferencedAction.setCategoryOrder("1");
            actions.add(openReferencedAction);
        }
    }
    // Get the actions from the plugins, sorted by ID...
    // 
    List<GuiAction> pluginActions = getPluginActions(true);
    if (pluginActions != null) {
        for (GuiAction pluginAction : pluginActions) {
            actions.add(lambdaBuilder.createLambda(pluginAction, this, pipelineGraph));
        }
    }
    return actions;
}
Also used : GuiAction(org.apache.hop.core.gui.plugin.action.GuiAction) ArrayList(java.util.ArrayList) ITransformMeta(org.apache.hop.pipeline.transform.ITransformMeta) Point(org.apache.hop.core.gui.Point)

Example 3 with GuiAction

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

the class HopPipelineFileType method getContextHandlers.

@Override
public List<IGuiContextHandler> getContextHandlers() {
    HopGui hopGui = HopGui.getInstance();
    List<IGuiContextHandler> handlers = new ArrayList<>();
    GuiAction newAction = new GuiAction(ACTION_ID_NEW_PIPELINE, GuiActionType.Create, BaseMessages.getString(PKG, "HopPipelineFileType.GuiAction.Pipeline.Name"), BaseMessages.getString(PKG, "HopPipelineFileType.GuiAction.Pipeline.Tooltip"), "ui/images/pipeline.svg", (shiftClicked, controlClicked, parameters) -> {
        try {
            HopPipelineFileType.this.newFile(hopGui, hopGui.getVariables());
        } catch (Exception e) {
            new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "HopPipelineFileType.ErrorDialog.PipelineDrawing.Header"), BaseMessages.getString(PKG, "HopPipelineFileType.ErrorDialog.PipelineDrawing.Message"), e);
        }
    });
    newAction.setCategory("File");
    newAction.setCategoryOrder("1");
    handlers.add(new GuiContextHandler(ACTION_ID_NEW_PIPELINE, Arrays.asList(newAction)));
    return handlers;
}
Also used : GuiAction(org.apache.hop.core.gui.plugin.action.GuiAction) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) GuiContextHandler(org.apache.hop.ui.hopgui.context.GuiContextHandler) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) ArrayList(java.util.ArrayList) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) HopGui(org.apache.hop.ui.hopgui.HopGui)

Example 4 with GuiAction

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

the class HopGuiWorkflowActionContext method getSupportedActions.

/**
 * Create a list of supported actions on a action.
 *
 * @return The list of supported actions
 */
@Override
public List<GuiAction> getSupportedActions() {
    List<GuiAction> actions = new ArrayList<>();
    // Put references at the start since we use those things a lot
    // 
    IAction action = actionMeta.getAction();
    String[] objectDescriptions = action.getReferencedObjectDescriptions();
    for (int i = 0; objectDescriptions != null && i < objectDescriptions.length; i++) {
        final String objectDescription = objectDescriptions[i];
        if (action.isReferencedObjectEnabled()[i]) {
            final int index = i;
            GuiAction openReferencedAction = new GuiAction("action-open-referenced-" + objectDescription, GuiActionType.Info, BaseMessages.getString(PKG, "HopGuiWorkflowTransformContext.OpenReferencedAction.Name", objectDescription), BaseMessages.getString(PKG, "HopGuiWorkflowTransformContext.OpenReferencedAction.Tooltip"), "ui/images/open.svg", (shiftAction, controlAction, t) -> openReferencedObject(workflowMeta, workflowGraph.getVariables(), action, objectDescription, index));
            openReferencedAction.setCategory("Basic");
            openReferencedAction.setCategoryOrder("1");
            actions.add(openReferencedAction);
        }
    }
    // Get the actions from the plugins, sorted by ID...
    // 
    List<GuiAction> pluginActions = getPluginActions(true);
    if (pluginActions != null) {
        for (GuiAction pluginAction : pluginActions) {
            actions.add(lambdaBuilder.createLambda(pluginAction, this, workflowGraph));
        }
    }
    return actions;
}
Also used : IAction(org.apache.hop.workflow.action.IAction) GuiAction(org.apache.hop.core.gui.plugin.action.GuiAction) ArrayList(java.util.ArrayList) Point(org.apache.hop.core.gui.Point)

Example 5 with GuiAction

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

the class HopGuiWorkflowContext method getSupportedActions.

/**
 * Create a list of supported actions on a workflow. We'll add the creation of every possible
 * action as well as the modification of the workflow itself from the annotations.
 *
 * @return The list of supported actions
 */
@Override
public List<GuiAction> getSupportedActions() {
    List<GuiAction> guiActions = new ArrayList<>();
    // Get the actions from the plugins...
    // 
    List<GuiAction> pluginActions = getPluginActions(true);
    if (pluginActions != null) {
        for (GuiAction pluginAction : pluginActions) {
            guiActions.add(lambdaBuilder.createLambda(pluginAction, this, workflowGraph));
        }
    }
    // Also add all the entry creation actions...
    // 
    PluginRegistry registry = PluginRegistry.getInstance();
    List<IPlugin> actionPlugins = registry.getPlugins(ActionPluginType.class);
    for (IPlugin actionPlugin : actionPlugins) {
        GuiAction createActionGuiAction = new GuiAction("workflow-graph-create-workflow-action-" + actionPlugin.getIds()[0], GuiActionType.Create, actionPlugin.getName(), actionPlugin.getDescription(), actionPlugin.getImageFile(), (shiftClicked, controlClicked, t) -> workflowGraph.workflowActionDelegate.newAction(workflowMeta, actionPlugin.getIds()[0], actionPlugin.getName(), controlClicked, click));
        createActionGuiAction.getKeywords().addAll(Arrays.asList(actionPlugin.getKeywords()));
        createActionGuiAction.setCategory(actionPlugin.getCategory());
        createActionGuiAction.setCategoryOrder(// sort alphabetically
        "9999_" + actionPlugin.getCategory());
        try {
            createActionGuiAction.setClassLoader(registry.getClassLoader(actionPlugin));
        } catch (HopPluginException e) {
            LogChannel.UI.logError("Unable to get classloader for action plugin " + actionPlugin.getIds()[0], e);
        }
        createActionGuiAction.getKeywords().add(actionPlugin.getCategory());
        guiActions.add(createActionGuiAction);
    }
    return guiActions;
}
Also used : GuiAction(org.apache.hop.core.gui.plugin.action.GuiAction) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) ArrayList(java.util.ArrayList) HopPluginException(org.apache.hop.core.exception.HopPluginException) IPlugin(org.apache.hop.core.plugins.IPlugin)

Aggregations

GuiAction (org.apache.hop.core.gui.plugin.action.GuiAction)19 ArrayList (java.util.ArrayList)14 HopException (org.apache.hop.core.exception.HopException)5 Point (org.apache.hop.core.gui.Point)5 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)5 HopGui (org.apache.hop.ui.hopgui.HopGui)4 GuiContextHandler (org.apache.hop.ui.hopgui.context.GuiContextHandler)4 HopMetadata (org.apache.hop.metadata.api.HopMetadata)3 IHopMetadata (org.apache.hop.metadata.api.IHopMetadata)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HopPluginException (org.apache.hop.core.exception.HopPluginException)2 AreaOwner (org.apache.hop.core.gui.AreaOwner)2 IPlugin (org.apache.hop.core.plugins.IPlugin)2 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)2 IGuiContextHandler (org.apache.hop.ui.hopgui.context.IGuiContextHandler)2 GC (org.eclipse.swt.graphics.GC)2 java.util (java.util)1 List (java.util.List)1 StringUtils (org.apache.commons.lang.StringUtils)1 Const (org.apache.hop.core.Const)1