Search in sources :

Example 1 with HopGuiWorkflowClipboardDelegate

use of org.apache.hop.ui.hopgui.file.workflow.delegates.HopGuiWorkflowClipboardDelegate in project hop by apache.

the class HopGuiWorkflowHplFilenamePastedExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, HopGuiWorkflowClipboardExtension wce) throws HopException {
    HopGuiWorkflowClipboardDelegate clipboardDelegate = wce.workflowGraph.workflowClipboardDelegate;
    WorkflowMeta workflowMeta = wce.workflowMeta;
    HopGui hopGui = wce.workflowGraph.getHopGui();
    // Pipeline?
    // 
    HopPipelineFileType pipelineFileType = new HopPipelineFileType();
    if (wce.filename.endsWith(pipelineFileType.getDefaultFileExtension())) {
        // Add a new Pipeline action...
        // 
        String name = clipboardDelegate.getUniqueName(workflowMeta, wce.file.getName());
        ActionPipeline actionPipeline = new ActionPipeline(name);
        actionPipeline.setFileName(wce.filename);
        // Pick the first run configuration available...
        // 
        List<String> names = hopGui.getMetadataProvider().getSerializer(PipelineRunConfiguration.class).listObjectNames();
        if (!names.isEmpty()) {
            actionPipeline.setRunConfiguration(names.get(0));
        }
        ActionMeta actionMeta = new ActionMeta(actionPipeline);
        actionMeta.setLocation(new Point(wce.location));
        workflowMeta.addAction(actionMeta);
        hopGui.undoDelegate.addUndoNew(workflowMeta, new ActionMeta[] { actionMeta }, new int[] { workflowMeta.indexOfAction(actionMeta) });
        // Shift the location for the next action
        // 
        clipboardDelegate.shiftLocation(wce.location);
    }
}
Also used : HopGuiWorkflowClipboardDelegate(org.apache.hop.ui.hopgui.file.workflow.delegates.HopGuiWorkflowClipboardDelegate) ActionMeta(org.apache.hop.workflow.action.ActionMeta) PipelineRunConfiguration(org.apache.hop.pipeline.config.PipelineRunConfiguration) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) HopPipelineFileType(org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) HopGui(org.apache.hop.ui.hopgui.HopGui)

Example 2 with HopGuiWorkflowClipboardDelegate

use of org.apache.hop.ui.hopgui.file.workflow.delegates.HopGuiWorkflowClipboardDelegate in project hop by apache.

the class HopGuiWorkflowHwfFilenamePastedExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, HopGuiWorkflowClipboardExtension wce) throws HopException {
    HopGuiWorkflowClipboardDelegate clipboardDelegate = wce.workflowGraph.workflowClipboardDelegate;
    WorkflowMeta workflowMeta = wce.workflowMeta;
    HopGui hopGui = wce.workflowGraph.getHopGui();
    // Workflow?
    // 
    HopWorkflowFileType workflowFileType = new HopWorkflowFileType<>();
    if (wce.filename.endsWith(workflowFileType.getDefaultFileExtension())) {
        // Add a new Workflow action...
        // 
        String name = clipboardDelegate.getUniqueName(workflowMeta, wce.file.getName());
        ActionWorkflow actionWorkflow = new ActionWorkflow(name);
        actionWorkflow.setFileName(wce.filename);
        // Pick the first run configuration available...
        // 
        List<String> names = hopGui.getMetadataProvider().getSerializer(WorkflowRunConfiguration.class).listObjectNames();
        if (!names.isEmpty()) {
            actionWorkflow.setRunConfiguration(names.get(0));
        }
        ActionMeta actionMeta = new ActionMeta(actionWorkflow);
        actionMeta.setLocation(new Point(wce.location));
        workflowMeta.addAction(actionMeta);
        hopGui.undoDelegate.addUndoNew(workflowMeta, new ActionMeta[] { actionMeta }, new int[] { workflowMeta.indexOfAction(actionMeta) });
        // Shift the location for the next action
        // 
        clipboardDelegate.shiftLocation(wce.location);
    }
}
Also used : HopGuiWorkflowClipboardDelegate(org.apache.hop.ui.hopgui.file.workflow.delegates.HopGuiWorkflowClipboardDelegate) WorkflowRunConfiguration(org.apache.hop.workflow.config.WorkflowRunConfiguration) ActionMeta(org.apache.hop.workflow.action.ActionMeta) HopWorkflowFileType(org.apache.hop.ui.hopgui.file.workflow.HopWorkflowFileType) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) HopGui(org.apache.hop.ui.hopgui.HopGui)

Aggregations

ExtensionPoint (org.apache.hop.core.extension.ExtensionPoint)2 IExtensionPoint (org.apache.hop.core.extension.IExtensionPoint)2 Point (org.apache.hop.core.gui.Point)2 HopGui (org.apache.hop.ui.hopgui.HopGui)2 HopGuiWorkflowClipboardDelegate (org.apache.hop.ui.hopgui.file.workflow.delegates.HopGuiWorkflowClipboardDelegate)2 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)2 ActionMeta (org.apache.hop.workflow.action.ActionMeta)2 PipelineRunConfiguration (org.apache.hop.pipeline.config.PipelineRunConfiguration)1 HopPipelineFileType (org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType)1 HopWorkflowFileType (org.apache.hop.ui.hopgui.file.workflow.HopWorkflowFileType)1 WorkflowRunConfiguration (org.apache.hop.workflow.config.WorkflowRunConfiguration)1