Search in sources :

Example 21 with GuiContextAction

use of org.apache.hop.core.action.GuiContextAction in project hop by apache.

the class HopGuiWorkflowGraph method detachAction.

@GuiContextAction(id = "workflow-graph-action-10100-action-detach", parentId = HopGuiWorkflowActionContext.CONTEXT_ID, type = GuiActionType.Modify, name = "i18n::HopGuiWorkflowGraph.ContextualAction.DetachAction.Text", tooltip = "i18n::HopGuiWorkflowGraph.ContextualAction.DetachAction.Tooltip", image = "ui/images/HOP_delete.svg", category = "i18n::HopGuiWorkflowGraph.ContextualAction.Category.Basic.Text", categoryOrder = "1")
public void detachAction(HopGuiWorkflowActionContext context) {
    ActionMeta actionMeta = context.getActionMeta();
    WorkflowHopMeta fromHop = workflowMeta.findWorkflowHopTo(actionMeta);
    WorkflowHopMeta toHop = workflowMeta.findWorkflowHopFrom(actionMeta);
    for (int i = workflowMeta.nrWorkflowHops() - 1; i >= 0; i--) {
        WorkflowHopMeta hop = workflowMeta.getWorkflowHop(i);
        if (actionMeta.equals(hop.getFromAction()) || actionMeta.equals(hop.getToAction())) {
            // Action is connected with a hop, remove this hop.
            // 
            hopGui.undoDelegate.addUndoNew(workflowMeta, new WorkflowHopMeta[] { hop }, new int[] { i });
            workflowMeta.removeWorkflowHop(i);
        }
    }
    // 
    if (fromHop != null && toHop != null) {
        workflowHopDelegate.newHop(workflowMeta, new WorkflowHopMeta(fromHop.getFromAction(), toHop.getToAction()));
    }
    updateGui();
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 22 with GuiContextAction

use of org.apache.hop.core.action.GuiContextAction in project hop by apache.

the class HopGuiWorkflowGraph method deleteNote.

@GuiContextAction(id = "workflow-graph-20-delete-note", parentId = HopGuiWorkflowNoteContext.CONTEXT_ID, type = GuiActionType.Delete, name = "i18n::HopGuiWorkflowGraph.ContextualAction.DeleteNote.Text", tooltip = "HopGuiWorkflowGraph.ContextualAction.DeleteNote.Tooltip", image = "ui/images/delete.svg", category = "i18n::HopGuiWorkflowGraph.ContextualAction.Category.Basic.Text", categoryOrder = "1")
public void deleteNote(HopGuiWorkflowNoteContext context) {
    selectionRegion = null;
    NotePadMeta note = context.getNotePadMeta();
    int idx = workflowMeta.indexOfNote(note);
    if (idx >= 0) {
        workflowMeta.removeNote(idx);
        hopGui.undoDelegate.addUndoDelete(workflowMeta, new NotePadMeta[] { note }, new int[] { idx });
    }
    adjustScrolling();
    redraw();
}
Also used : HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 23 with GuiContextAction

use of org.apache.hop.core.action.GuiContextAction in project hop by apache.

the class HopGuiWorkflowGraph method newNote.

@GuiContextAction(id = "workflow-graph-new-note", parentId = HopGuiWorkflowContext.CONTEXT_ID, type = GuiActionType.Create, name = "i18n::HopGuiWorkflowGraph.ContextualAction.CreateNote.Text", tooltip = "i18n::HopGuiWorkflowGraph.ContextualAction.CreateNote.Tooltip", image = "ui/images/note-add.svg", category = "i18n::HopGuiWorkflowGraph.ContextualAction.Category.Basic.Text", categoryOrder = "1")
public void newNote(HopGuiWorkflowContext context) {
    String title = BaseMessages.getString(PKG, "WorkflowGraph.Dialog.EditNote.Title");
    NotePadDialog dd = new NotePadDialog(variables, hopShell(), title);
    NotePadMeta n = dd.open();
    if (n != null) {
        NotePadMeta npi = new NotePadMeta(n.getNote(), context.getClick().x, context.getClick().y, ConstUi.NOTE_MIN_SIZE, ConstUi.NOTE_MIN_SIZE, n.getFontName(), n.getFontSize(), n.isFontBold(), n.isFontItalic(), n.getFontColorRed(), n.getFontColorGreen(), n.getFontColorBlue(), n.getBackGroundColorRed(), n.getBackGroundColorGreen(), n.getBackGroundColorBlue(), n.getBorderColorRed(), n.getBorderColorGreen(), n.getBorderColorBlue());
        workflowMeta.addNote(npi);
        hopGui.undoDelegate.addUndoNew(workflowMeta, new NotePadMeta[] { npi }, new int[] { workflowMeta.indexOfNote(npi) });
        adjustScrolling();
        redraw();
    }
}
Also used : NotePadDialog(org.apache.hop.ui.hopgui.dialog.NotePadDialog) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 24 with GuiContextAction

use of org.apache.hop.core.action.GuiContextAction in project hop by apache.

the class TestingGuiPlugin method writeTransformDataToDataSet.

/**
 * Ask which data set to write to Ask for the mapping between the output row and the data set
 * field Start the pipeline and capture the output of the transform, write to the database table
 * backing the data set.
 */
@GuiContextAction(id = "pipeline-graph-transform-20500-write-transform-data-to-set", parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Create, name = "i18n::TestingGuiPlugin.ContextAction.Run.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.Run.Tooltip", image = "write-to-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void writeTransformDataToDataSet(HopGuiPipelineTransformContext context) {
    HopGui hopGui = HopGui.getInstance();
    IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
    IVariables variables = context.getPipelineGraph().getVariables();
    TransformMeta transformMeta = context.getTransformMeta();
    PipelineMeta pipelineMeta = context.getPipelineMeta();
    if (pipelineMeta.hasChanged()) {
        MessageBox box = new MessageBox(hopGui.getShell(), SWT.OK | SWT.ICON_INFORMATION);
        box.setText(BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.Run.SavePipelineDialog.Header"));
        box.setMessage(BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.Run.SavePipelineDialog.Message"));
        box.open();
        return;
    }
    try {
        IHopMetadataSerializer<DataSet> setSerializer = metadataProvider.getSerializer(DataSet.class);
        // Ask which data set to write to
        // 
        List<String> setNames = setSerializer.listObjectNames();
        Collections.sort(setNames);
        EnterSelectionDialog esd = new EnterSelectionDialog(hopGui.getShell(), setNames.toArray(new String[setNames.size()]), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.Run.ActionList.Item1"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.Run.ActionList.Item2"));
        String setName = esd.open();
        if (setName == null) {
            return;
        }
        DataSet dataSet = setSerializer.load(setName);
        String[] setFields = new String[dataSet.getFields().size()];
        for (int i = 0; i < setFields.length; i++) {
            setFields[i] = dataSet.getFields().get(i).getFieldName();
        }
        IRowMeta rowMeta = pipelineMeta.getTransformFields(variables, transformMeta);
        String[] transformFields = new String[rowMeta.size()];
        for (int i = 0; i < rowMeta.size(); i++) {
            IValueMeta valueMeta = rowMeta.getValueMeta(i);
            transformFields[i] = valueMeta.getName();
        }
        // Ask for the mapping between the output row and the data set field
        // 
        EnterMappingDialog mappingDialog = new EnterMappingDialog(hopGui.getShell(), transformFields, setFields);
        List<SourceToTargetMapping> mapping = mappingDialog.open();
        if (mapping == null) {
            return;
        }
        // Run the pipeline.  We want to use the standard HopGui runFile() method
        // So we need to leave the source to target mapping list somewhere so it can be picked up
        // later.
        // For now we'll leave it where we need it.
        // 
        WriteToDataSetExtensionPoint.transformsMap.put(pipelineMeta.getName(), transformMeta);
        WriteToDataSetExtensionPoint.mappingsMap.put(pipelineMeta.getName(), mapping);
        WriteToDataSetExtensionPoint.setsMap.put(pipelineMeta.getName(), dataSet);
        // Signal to the pipeline xp plugin to inject data into some data set
        // 
        variables.setVariable(DataSetConst.VAR_WRITE_TO_DATASET, "Y");
        // Start the pipeline
        // 
        context.getPipelineGraph().start();
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.Run.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.Run.Error.Message"), e);
    }
}
Also used : IRowMeta(org.apache.hop.core.row.IRowMeta) EnterMappingDialog(org.apache.hop.ui.core.dialog.EnterMappingDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) WriteToDataSetExtensionPoint(org.apache.hop.testing.xp.WriteToDataSetExtensionPoint) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) MessageBox(org.eclipse.swt.widgets.MessageBox) IValueMeta(org.apache.hop.core.row.IValueMeta) IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) SourceToTargetMapping(org.apache.hop.core.SourceToTargetMapping) EnterSelectionDialog(org.apache.hop.ui.core.dialog.EnterSelectionDialog) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 25 with GuiContextAction

use of org.apache.hop.core.action.GuiContextAction in project hop by apache.

the class TestingGuiPlugin method enableTweakRemoveTransformInUnitTest.

@GuiContextAction(id = ACTION_ID_PIPELINE_GRAPH_TRANSFORM_ENABLE_TWEAK_REMOVE_TRANSFORM, parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Modify, name = "i18n::TestingGuiPlugin.ContextAction.RemoveFromTest.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.RemoveFromTest.Tooltip", image = "Test_tube_icon.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void enableTweakRemoveTransformInUnitTest(HopGuiPipelineTransformContext context) {
    IVariables variables = context.getPipelineGraph().getVariables();
    tweakRemoveTransformInUnitTest(variables, context.getPipelineMeta(), context.getTransformMeta(), true);
}
Also used : IVariables(org.apache.hop.core.variables.IVariables) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Aggregations

GuiContextAction (org.apache.hop.core.action.GuiContextAction)27 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)13 HopGui (org.apache.hop.ui.hopgui.HopGui)12 IVariables (org.apache.hop.core.variables.IVariables)11 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)11 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)10 HopException (org.apache.hop.core.exception.HopException)9 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)9 ActionMeta (org.apache.hop.workflow.action.ActionMeta)9 EnterSelectionDialog (org.apache.hop.ui.core.dialog.EnterSelectionDialog)8 HopPluginException (org.apache.hop.core.exception.HopPluginException)7 HopTransformException (org.apache.hop.core.exception.HopTransformException)7 HopValueException (org.apache.hop.core.exception.HopValueException)7 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)5 IRowMeta (org.apache.hop.core.row.IRowMeta)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)4 MessageBox (org.eclipse.swt.widgets.MessageBox)4 MetadataManager (org.apache.hop.ui.core.metadata.MetadataManager)3