Search in sources :

Example 1 with IGuiContextHandler

use of org.apache.hop.ui.hopgui.context.IGuiContextHandler in project hop by apache.

the class HopGuiPipelineGraph method showActionDialog.

private void showActionDialog(MouseEvent e, Point real, boolean fSingleClick, SingleClickType fSingleClickType, TransformMeta fSingleClickTransform, NotePadMeta fSingleClickNote, PipelineHopMeta fSingleClickHop) {
    // In any case clear the selection region...
    // 
    selectionRegion = null;
    // 
    if (fSingleClickType == SingleClickType.Pipeline) {
        if (pipelineMeta.getSelectedTransforms().size() > 0 || pipelineMeta.getSelectedNotes().size() > 0) {
            pipelineMeta.unselectAll();
            selectionRegion = null;
            updateGui();
            // Show a short tooltip
            // 
            toolTip.setVisible(false);
            toolTip.setAutoHide(true);
            toolTip.setText(Const.CR + "  Selection cleared " + Const.CR);
            showToolTip(new org.eclipse.swt.graphics.Point(e.x, e.y));
            return;
        }
    }
    if (!doubleClick) {
        // 
        if (fSingleClick && fSingleClickType != null) {
            IGuiContextHandler contextHandler = null;
            String message = null;
            switch(fSingleClickType) {
                case Pipeline:
                    message = BaseMessages.getString(PKG, "PipelineGraph.ContextualActionDialog.Pipeline.Header");
                    contextHandler = new HopGuiPipelineContext(pipelineMeta, this, real);
                    break;
                case Transform:
                    message = BaseMessages.getString(PKG, "PipelineGraph.ContextualActionDialog.Transform.Header", fSingleClickTransform.getName());
                    contextHandler = new HopGuiPipelineTransformContext(pipelineMeta, fSingleClickTransform, this, real);
                    break;
                case Note:
                    message = BaseMessages.getString(PKG, "PipelineGraph.ContextualActionDialog.Note.Header");
                    contextHandler = new HopGuiPipelineNoteContext(pipelineMeta, fSingleClickNote, this, real);
                    break;
                case Hop:
                    message = BaseMessages.getString(PKG, "PipelineGraph.ContextualActionDialog.Hop.Header");
                    contextHandler = new HopGuiPipelineHopContext(pipelineMeta, fSingleClickHop, this, real);
                    break;
                default:
                    break;
            }
            if (contextHandler != null) {
                Shell parent = hopShell();
                org.eclipse.swt.graphics.Point p = parent.getDisplay().map(canvas, null, e.x, e.y);
                // Show the context dialog
                // 
                avoidContextDialog = GuiContextUtil.getInstance().handleActionSelection(parent, message, new Point(p.x, p.y), contextHandler);
            }
        }
    }
}
Also used : HopGuiPipelineTransformContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineTransformContext) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) HopGuiPipelineHopContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineHopContext) HopGuiPipelineContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineContext) HopGuiPipelineNoteContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineNoteContext) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint)

Example 2 with IGuiContextHandler

use of org.apache.hop.ui.hopgui.context.IGuiContextHandler 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 3 with IGuiContextHandler

use of org.apache.hop.ui.hopgui.context.IGuiContextHandler in project hop by apache.

the class HopGuiWorkflowGraph method showContextDialog.

private void showContextDialog(MouseEvent e, Point real, boolean fSingleClick, SingleClickType fSingleClickType, ActionMeta fSingleClickAction, NotePadMeta fSingleClickNote, WorkflowHopMeta fSingleClickHop) {
    // In any case clear the selection region...
    // 
    selectionRegion = null;
    // 
    if (fSingleClickType == SingleClickType.Workflow) {
        if (workflowMeta.getSelectedActions().size() > 0 || workflowMeta.getSelectedNotes().size() > 0) {
            workflowMeta.unselectAll();
            selectionRegion = null;
            updateGui();
            // Show a short tooltip
            // 
            toolTip.setVisible(false);
            toolTip.setText(Const.CR + "  Selection cleared " + Const.CR);
            showToolTip(new org.eclipse.swt.graphics.Point(e.x, e.y));
            return;
        }
    }
    if (!doubleClick) {
        // 
        if (fSingleClick && fSingleClickType != null) {
            IGuiContextHandler contextHandler = null;
            String message = null;
            switch(fSingleClickType) {
                case Workflow:
                    message = BaseMessages.getString(PKG, "HopGuiWorkflowGraph.ContextualActionDialog.Workflow.Header");
                    contextHandler = new HopGuiWorkflowContext(workflowMeta, this, real);
                    break;
                case Action:
                    message = BaseMessages.getString(PKG, "HopGuiWorkflowGraph.ContextualActionDialog.Action.Header", fSingleClickAction.getName());
                    contextHandler = new HopGuiWorkflowActionContext(workflowMeta, fSingleClickAction, this, real);
                    break;
                case Note:
                    message = BaseMessages.getString(PKG, "HopGuiWorkflowGraph.ContextualActionDialog.Note.Header");
                    contextHandler = new HopGuiWorkflowNoteContext(workflowMeta, fSingleClickNote, this, real);
                    break;
                case Hop:
                    message = BaseMessages.getString(PKG, "HopGuiWorkflowGraph.ContextualActionDialog.Hop.Header");
                    contextHandler = new HopGuiWorkflowHopContext(workflowMeta, fSingleClickHop, this, real);
                    break;
                default:
                    break;
            }
            if (contextHandler != null) {
                Shell parent = hopShell();
                org.eclipse.swt.graphics.Point p = parent.getDisplay().map(canvas, null, e.x, e.y);
                // Show the context dialog
                // 
                ignoreNextClick = GuiContextUtil.getInstance().handleActionSelection(parent, message, new Point(p.x, p.y), contextHandler);
            }
        }
    }
}
Also used : HopGuiWorkflowContext(org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowContext) HopGuiWorkflowNoteContext(org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowNoteContext) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) HopGuiWorkflowHopContext(org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowHopContext) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) HopGuiWorkflowActionContext(org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowActionContext)

Example 4 with IGuiContextHandler

use of org.apache.hop.ui.hopgui.context.IGuiContextHandler in project hop by apache.

the class HopWorkflowFileType method getContextHandlers.

@Override
public List<IGuiContextHandler> getContextHandlers() {
    HopGui hopGui = HopGui.getInstance();
    List<IGuiContextHandler> handlers = new ArrayList<>();
    GuiAction newAction = new GuiAction(ACTION_ID_NEW_WORKFLOW, GuiActionType.Create, BaseMessages.getString(PKG, "HopWorkflowFileType.GuiAction.Workflow.Name"), BaseMessages.getString(PKG, "HopWorkflowFileType.GuiAction.Workflow.Tooltip"), "ui/images/workflow.svg", (shiftClicked, controlClicked, parameters) -> {
        try {
            HopWorkflowFileType.this.newFile(hopGui, hopGui.getVariables());
        } catch (Exception e) {
            new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "HopWorkflowFileType.ErrorDialog.NewWorkflowCreation.Header"), BaseMessages.getString(PKG, "HopWorkflowFileType.ErrorDialog.NewWorkflowCreation.Message"), e);
        }
    });
    newAction.setCategory("File");
    newAction.setCategoryOrder("1");
    handlers.add(new GuiContextHandler(ACTION_ID_NEW_WORKFLOW, 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 5 with IGuiContextHandler

use of org.apache.hop.ui.hopgui.context.IGuiContextHandler in project hop by apache.

the class HopGui method getContextHandlers.

/**
 * What are the contexts to consider: - the file types registered - the available metadata types
 *
 * @return The list of context handlers
 */
@Override
public List<IGuiContextHandler> getContextHandlers() {
    List<IGuiContextHandler> contextHandlers = new ArrayList<>();
    // Get all the file context handlers
    // 
    HopFileTypeRegistry registry = HopFileTypeRegistry.getInstance();
    List<IHopFileType> hopFileTypes = registry.getFileTypes();
    for (IHopFileType hopFileType : hopFileTypes) {
        contextHandlers.addAll(hopFileType.getContextHandlers());
    }
    // Get all the metadata context handlers...
    // 
    contextHandlers.addAll(new MetadataContext(this, metadataProvider).getContextHandlers());
    return contextHandlers;
}
Also used : HopFileTypeRegistry(org.apache.hop.ui.hopgui.file.HopFileTypeRegistry) IHopFileType(org.apache.hop.ui.hopgui.file.IHopFileType) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) MetadataContext(org.apache.hop.ui.hopgui.context.metadata.MetadataContext)

Aggregations

IGuiContextHandler (org.apache.hop.ui.hopgui.context.IGuiContextHandler)5 ArrayList (java.util.ArrayList)2 HopException (org.apache.hop.core.exception.HopException)2 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)2 GuiAction (org.apache.hop.core.gui.plugin.action.GuiAction)2 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)2 HopGui (org.apache.hop.ui.hopgui.HopGui)2 GuiContextHandler (org.apache.hop.ui.hopgui.context.GuiContextHandler)2 MetadataContext (org.apache.hop.ui.hopgui.context.metadata.MetadataContext)1 HopFileTypeRegistry (org.apache.hop.ui.hopgui.file.HopFileTypeRegistry)1 IHopFileType (org.apache.hop.ui.hopgui.file.IHopFileType)1 HopGuiPipelineContext (org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineContext)1 HopGuiPipelineHopContext (org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineHopContext)1 HopGuiPipelineNoteContext (org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineNoteContext)1 HopGuiPipelineTransformContext (org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineTransformContext)1 HopGuiWorkflowActionContext (org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowActionContext)1 HopGuiWorkflowContext (org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowContext)1 HopGuiWorkflowHopContext (org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowHopContext)1 HopGuiWorkflowNoteContext (org.apache.hop.ui.hopgui.file.workflow.context.HopGuiWorkflowNoteContext)1