Search in sources :

Example 1 with HopGuiTooltipExtension

use of org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension in project hop by apache.

the class HopGuiPipelineGraph method setToolTip.

private AreaOwner setToolTip(int x, int y, int screenX, int screenY) {
    AreaOwner subject = null;
    if (!hopGui.getProps().showToolTips()) {
        return subject;
    }
    canvas.setToolTipText(null);
    String newTip = null;
    Image tipImage = null;
    final PipelineHopMeta hi = findPipelineHop(x, y);
    // check the area owner list...
    // 
    StringBuilder tip = new StringBuilder();
    AreaOwner areaOwner = getVisibleAreaOwner(x, y);
    if (areaOwner != null && areaOwner.getAreaType() != null) {
        AreaType areaType = areaOwner.getAreaType();
        switch(areaType) {
            case TRANSFORM_PARTITIONING:
                TransformMeta transform = (TransformMeta) areaOwner.getParent();
                tip.append("Transform partitioning:").append(Const.CR).append("-----------------------").append(Const.CR);
                tip.append(transform.getTransformPartitioningMeta().toString()).append(Const.CR);
                if (transform.getTargetTransformPartitioningMeta() != null) {
                    tip.append(Const.CR).append(Const.CR).append("TARGET: " + transform.getTargetTransformPartitioningMeta().toString()).append(Const.CR);
                }
                break;
            case TRANSFORM_FAILURE_ICON:
                String log = (String) areaOwner.getParent();
                tip.append(log);
                tipImage = GuiResource.getInstance().getImageFailure();
                break;
            case HOP_COPY_ICON:
                transform = (TransformMeta) areaOwner.getParent();
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.Hop.Tooltip.HopTypeCopy", transform.getName(), Const.CR));
                tipImage = GuiResource.getInstance().getImageCopyHop();
                break;
            case ROW_DISTRIBUTION_ICON:
                transform = (TransformMeta) areaOwner.getParent();
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.Hop.Tooltip.RowDistribution", transform.getName(), transform.getRowDistribution() == null ? "" : transform.getRowDistribution().getDescription()));
                tip.append(Const.CR);
                tipImage = GuiResource.getInstance().getImageBalance();
                break;
            case HOP_INFO_ICON:
                TransformMeta from = (TransformMeta) areaOwner.getParent();
                TransformMeta to = (TransformMeta) areaOwner.getOwner();
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.Hop.Tooltip.HopTypeInfo", to.getName(), from.getName(), Const.CR));
                tipImage = GuiResource.getInstance().getImageInfo();
                break;
            case HOP_ERROR_ICON:
                from = (TransformMeta) areaOwner.getParent();
                to = (TransformMeta) areaOwner.getOwner();
                areaOwner.getOwner();
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.Hop.Tooltip.HopTypeError", from.getName(), to.getName(), Const.CR));
                tipImage = GuiResource.getInstance().getImageError();
                break;
            case HOP_INFO_TRANSFORM_COPIES_ERROR:
                from = (TransformMeta) areaOwner.getParent();
                to = (TransformMeta) areaOwner.getOwner();
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.Hop.Tooltip.InfoTransformCopies", from.getName(), to.getName(), Const.CR));
                tipImage = GuiResource.getInstance().getImageError();
                break;
            case HOP_INFO_TRANSFORMS_PARTITIONED:
                from = (TransformMeta) areaOwner.getParent();
                to = (TransformMeta) areaOwner.getOwner();
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.Hop.Tooltip.InfoTransformsPartitioned", from.getName(), to.getName(), Const.CR));
                tipImage = GuiResource.getInstance().getImageError();
                break;
            case TRANSFORM_INPUT_HOP_ICON:
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.TransformInputConnector.Tooltip"));
                tipImage = GuiResource.getInstance().getImageInput();
                break;
            case TRANSFORM_OUTPUT_HOP_ICON:
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.TransformOutputConnector.Tooltip"));
                tipImage = GuiResource.getInstance().getImageOutput();
                break;
            case TRANSFORM_INFO_HOP_ICON:
                ITransformIOMeta ioMeta = (ITransformIOMeta) areaOwner.getOwner();
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.TransformMetaConnector.Tooltip") + Const.CR + ioMeta.toString());
                tipImage = GuiResource.getInstance().getImageInfo();
                break;
            case TRANSFORM_TARGET_HOP_ICON:
                IStream stream = (IStream) areaOwner.getOwner();
                tip.append(stream.getDescription());
                if (stream.getStreamIcon() == StreamIcon.TRUE) {
                    tipImage = GuiResource.getInstance().getImageTrue();
                } else if (stream.getStreamIcon() == StreamIcon.FALSE) {
                    tipImage = GuiResource.getInstance().getImageFalse();
                } else {
                    tipImage = GuiResource.getInstance().getImageTarget();
                }
                break;
            case TRANSFORM_ERROR_HOP_ICON:
                TransformMeta transformMeta = (TransformMeta) areaOwner.getParent();
                if (transformMeta.supportsErrorHandling()) {
                    tip.append(BaseMessages.getString(PKG, "PipelineGraph.TransformSupportsErrorHandling.Tooltip"));
                } else {
                    tip.append(BaseMessages.getString(PKG, "PipelineGraph.TransformDoesNotSupportsErrorHandling.Tooltip"));
                }
                tipImage = GuiResource.getInstance().getImageError();
                break;
            case TRANSFORM_EDIT_ICON:
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.EditTransform.Tooltip"));
                tipImage = GuiResource.getInstance().getImageEdit();
                break;
            case TRANSFORM_INJECT_ICON:
                Object injection = areaOwner.getOwner();
                if (injection != null) {
                    tip.append(BaseMessages.getString(PKG, "PipelineGraph.TransformInjectionSupported.Tooltip"));
                } else {
                    tip.append(BaseMessages.getString(PKG, "PipelineGraph.TransformInjectionNotSupported.Tooltip"));
                }
                tipImage = GuiResource.getInstance().getImageInject();
                break;
            case TRANSFORM_MENU_ICON:
                tip.append(BaseMessages.getString(PKG, "PipelineGraph.ShowMenu.Tooltip"));
                tipImage = GuiResource.getInstance().getImageContextMenu();
                break;
            case TRANSFORM_ICON:
                TransformMeta iconTransformMeta = (TransformMeta) areaOwner.getOwner();
                if (iconTransformMeta.isDeprecated()) {
                    // only need tooltip if transform is deprecated
                    tip.append(BaseMessages.getString(PKG, "PipelineGraph.DeprecatedTransform.Tooltip.Title")).append(Const.CR);
                    String tipNext = BaseMessages.getString(PKG, "PipelineGraph.DeprecatedTransform.Tooltip.Message1", iconTransformMeta.getName());
                    int length = tipNext.length() + 5;
                    for (int i = 0; i < length; i++) {
                        tip.append("-");
                    }
                    tip.append(Const.CR).append(tipNext).append(Const.CR);
                    tip.append(BaseMessages.getString(PKG, "PipelineGraph.DeprecatedTransform.Tooltip.Message2"));
                    if (!Utils.isEmpty(iconTransformMeta.getSuggestion()) && !(iconTransformMeta.getSuggestion().startsWith("!") && iconTransformMeta.getSuggestion().endsWith("!"))) {
                        tip.append(" ");
                        tip.append(BaseMessages.getString(PKG, "PipelineGraph.DeprecatedTransform.Tooltip.Message3", iconTransformMeta.getSuggestion()));
                    }
                    tipImage = GuiResource.getInstance().getImageDeprecated();
                }
                break;
            case TRANSFORM_OUTPUT_DATA:
                RowBuffer rowBuffer = (RowBuffer) areaOwner.getOwner();
                if (rowBuffer != null && !rowBuffer.isEmpty()) {
                    tip.append("Available output rows: " + rowBuffer.size());
                    tipImage = GuiResource.getInstance().getImageData();
                }
                break;
            default:
                // 
                try {
                    HopGuiTooltipExtension tooltipExt = new HopGuiTooltipExtension(x, y, screenX, screenY, areaOwner, tip);
                    ExtensionPointHandler.callExtensionPoint(hopGui.getLog(), variables, HopExtensionPoint.HopGuiPipelineGraphAreaHover.name(), tooltipExt);
                    tipImage = tooltipExt.tooltipImage;
                } catch (Exception ex) {
                    hopGui.getLog().logError("Error calling extension point " + HopExtensionPoint.HopGuiPipelineGraphAreaHover.name(), ex);
                }
                break;
        }
    }
    if (hi != null && tip.length() == 0) {
        // We clicked on a HOP!
        // Set the tooltip for the hop:
        tip.append(Const.CR).append(BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo")).append(newTip = hi.toString()).append(Const.CR);
    }
    if (tip.length() == 0) {
        newTip = null;
    } else {
        newTip = tip.toString();
    }
    if (newTip == null) {
        toolTip.setVisible(false);
        if (hi != null) {
            // We clicked on a HOP!
            // Set the tooltip for the hop:
            newTip = BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo") + Const.CR + BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo.SourceTransform") + " " + hi.getFromTransform().getName() + Const.CR + BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo.TargetTransform") + " " + hi.getToTransform().getName() + Const.CR + BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo.Status") + " " + (hi.isEnabled() ? BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo.Enable") : BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo.Disable"));
            toolTip.setText(newTip);
            showToolTip(new org.eclipse.swt.graphics.Point(screenX, screenY));
        }
    } else if (!newTip.equalsIgnoreCase(getToolTipText())) {
        Image tooltipImage = null;
        if (tipImage != null) {
            tooltipImage = tipImage;
        } else {
            tooltipImage = GuiResource.getInstance().getImageHopUi();
        }
        showTooltip(newTip, tooltipImage, screenX, screenY);
    }
    return subject;
}
Also used : IStream(org.apache.hop.pipeline.transform.stream.IStream) HopGuiTooltipExtension(org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension) Image(org.eclipse.swt.graphics.Image) AreaType(org.apache.hop.core.gui.AreaOwner.AreaType) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) RowBuffer(org.apache.hop.core.row.RowBuffer) HopException(org.apache.hop.core.exception.HopException) InvocationTargetException(java.lang.reflect.InvocationTargetException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) FileObject(org.apache.commons.vfs2.FileObject)

Example 2 with HopGuiTooltipExtension

use of org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension in project hop by apache.

the class HopGuiWorkflowGraph method setToolTip.

protected void setToolTip(int x, int y, int screenX, int screenY) {
    if (!hopGui.getProps().showToolTips()) {
        return;
    }
    canvas.setToolTipText(null);
    Image tipImage = null;
    WorkflowHopMeta hi = findWorkflowHop(x, y);
    // check the area owner list...
    // 
    StringBuilder tip = new StringBuilder();
    AreaOwner areaOwner = getVisibleAreaOwner(x, y);
    if (areaOwner != null && areaOwner.getAreaType() != null) {
        ActionMeta actionCopy;
        switch(areaOwner.getAreaType()) {
            case WORKFLOW_HOP_ICON:
                hi = (WorkflowHopMeta) areaOwner.getOwner();
                if (hi.isUnconditional()) {
                    tipImage = GuiResource.getInstance().getImageUnconditionalHop();
                    tip.append(BaseMessages.getString(PKG, "WorkflowGraph.Hop.Tooltip.Unconditional", hi.getFromAction().getName(), Const.CR));
                } else {
                    if (hi.getEvaluation()) {
                        tip.append(BaseMessages.getString(PKG, "WorkflowGraph.Hop.Tooltip.EvaluatingTrue", hi.getFromAction().getName(), Const.CR));
                        tipImage = GuiResource.getInstance().getImageTrue();
                    } else {
                        tip.append(BaseMessages.getString(PKG, "WorkflowGraph.Hop.Tooltip.EvaluatingFalse", hi.getFromAction().getName(), Const.CR));
                        tipImage = GuiResource.getInstance().getImageFalse();
                    }
                }
                break;
            case WORKFLOW_HOP_PARALLEL_ICON:
                hi = (WorkflowHopMeta) areaOwner.getOwner();
                tip.append(BaseMessages.getString(PKG, "WorkflowGraph.Hop.Tooltip.Parallel", hi.getFromAction().getName(), Const.CR));
                tipImage = GuiResource.getInstance().getImageParallelHop();
                break;
            case CUSTOM:
                String message = (String) areaOwner.getOwner();
                tip.append(message);
                tipImage = null;
                GuiResource.getInstance().getImagePipeline();
                break;
            case ACTION_RESULT_FAILURE:
            case ACTION_RESULT_SUCCESS:
                ActionResult actionResult = (ActionResult) areaOwner.getOwner();
                actionCopy = (ActionMeta) areaOwner.getParent();
                Result result = actionResult.getResult();
                tip.append("'").append(actionCopy.getName()).append("' ");
                if (result.getResult()) {
                    tipImage = GuiResource.getInstance().getImageSuccess();
                    tip.append("finished successfully.");
                } else {
                    tipImage = GuiResource.getInstance().getImageFailure();
                    tip.append("failed.");
                }
                tip.append(Const.CR).append("------------------------").append(Const.CR).append(Const.CR);
                tip.append("Result         : ").append(result.getResult()).append(Const.CR);
                tip.append("Errors         : ").append(result.getNrErrors()).append(Const.CR);
                if (result.getNrLinesRead() > 0) {
                    tip.append("Lines read     : ").append(result.getNrLinesRead()).append(Const.CR);
                }
                if (result.getNrLinesWritten() > 0) {
                    tip.append("Lines written  : ").append(result.getNrLinesWritten()).append(Const.CR);
                }
                if (result.getNrLinesInput() > 0) {
                    tip.append("Lines input    : ").append(result.getNrLinesInput()).append(Const.CR);
                }
                if (result.getNrLinesOutput() > 0) {
                    tip.append("Lines output   : ").append(result.getNrLinesOutput()).append(Const.CR);
                }
                if (result.getNrLinesUpdated() > 0) {
                    tip.append("Lines updated  : ").append(result.getNrLinesUpdated()).append(Const.CR);
                }
                if (result.getNrLinesDeleted() > 0) {
                    tip.append("Lines deleted  : ").append(result.getNrLinesDeleted()).append(Const.CR);
                }
                if (result.getNrLinesRejected() > 0) {
                    tip.append("Lines rejected : ").append(result.getNrLinesRejected()).append(Const.CR);
                }
                if (result.getResultFiles() != null && !result.getResultFiles().isEmpty()) {
                    tip.append(Const.CR).append("Result files:").append(Const.CR);
                    if (result.getResultFiles().size() > 10) {
                        tip.append(" (10 files of ").append(result.getResultFiles().size()).append(" shown");
                    }
                    List<ResultFile> files = new ArrayList<>(result.getResultFiles().values());
                    for (int i = 0; i < files.size(); i++) {
                        ResultFile file = files.get(i);
                        tip.append("  - ").append(file.toString()).append(Const.CR);
                    }
                }
                if (result.getRows() != null && !result.getRows().isEmpty()) {
                    tip.append(Const.CR).append("Result rows: ");
                    if (result.getRows().size() > 10) {
                        tip.append(" (10 rows of ").append(result.getRows().size()).append(" shown");
                    }
                    tip.append(Const.CR);
                    for (int i = 0; i < result.getRows().size() && i < 10; i++) {
                        RowMetaAndData row = result.getRows().get(i);
                        tip.append("  - ").append(row.toString()).append(Const.CR);
                    }
                }
                break;
            case ACTION_RESULT_CHECKPOINT:
                tip.append("The workflow started here since this is the furthest checkpoint " + "that was reached last time the pipeline was executed.");
                tipImage = GuiResource.getInstance().getImageCheckpoint();
                break;
            case ACTION_ICON:
                ActionMeta jec = (ActionMeta) areaOwner.getOwner();
                if (jec.isDeprecated()) {
                    // only need tooltip if action is deprecated
                    tip.append(BaseMessages.getString(PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Title")).append(Const.CR);
                    String tipNext = BaseMessages.getString(PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Message1", jec.getName());
                    int length = tipNext.length() + 5;
                    for (int i = 0; i < length; i++) {
                        tip.append("-");
                    }
                    tip.append(Const.CR).append(tipNext).append(Const.CR);
                    tip.append(BaseMessages.getString(PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Message2"));
                    if (!Utils.isEmpty(jec.getSuggestion()) && !(jec.getSuggestion().startsWith("!") && jec.getSuggestion().endsWith("!"))) {
                        tip.append(" ");
                        tip.append(BaseMessages.getString(PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Message3", jec.getSuggestion()));
                    }
                    tipImage = GuiResource.getInstance().getImageDeprecated();
                }
                break;
            default:
                // 
                try {
                    HopGuiTooltipExtension tooltipExt = new HopGuiTooltipExtension(x, y, screenX, screenY, areaOwner, tip);
                    ExtensionPointHandler.callExtensionPoint(hopGui.getLog(), variables, HopExtensionPoint.HopGuiWorkflowGraphAreaHover.name(), tooltipExt);
                    tipImage = tooltipExt.tooltipImage;
                } catch (Exception ex) {
                    hopGui.getLog().logError("Error calling extension point " + HopExtensionPoint.HopGuiWorkflowGraphAreaHover.name(), ex);
                }
                break;
        }
    }
    if (hi != null && tip.length() == 0) {
        // Set the tooltip for the hop:
        tip.append(BaseMessages.getString(PKG, "WorkflowGraph.Dialog.HopInfo")).append(Const.CR);
        tip.append(BaseMessages.getString(PKG, "WorkflowGraph.Dialog.HopInfo.SourceEntry")).append(" ").append(hi.getFromAction().getName()).append(Const.CR);
        tip.append(BaseMessages.getString(PKG, "WorkflowGraph.Dialog.HopInfo.TargetEntry")).append(" ").append(hi.getToAction().getName()).append(Const.CR);
        tip.append(BaseMessages.getString(PKG, "PipelineGraph.Dialog.HopInfo.Status")).append(" ");
        tip.append((hi.isEnabled() ? BaseMessages.getString(PKG, "WorkflowGraph.Dialog.HopInfo.Enable") : BaseMessages.getString(PKG, "WorkflowGraph.Dialog.HopInfo.Disable")));
        if (hi.isUnconditional()) {
            tipImage = GuiResource.getInstance().getImageUnconditionalHop();
        } else {
            if (hi.getEvaluation()) {
                tipImage = GuiResource.getInstance().getImageTrue();
            } else {
                tipImage = GuiResource.getInstance().getImageFalse();
            }
        }
    }
    if (tip == null || tip.length() == 0) {
        toolTip.setVisible(false);
    } else {
        if (!tip.toString().equalsIgnoreCase(getToolTipText())) {
            toolTip.setText(tip.toString());
            toolTip.setVisible(false);
            showToolTip(new org.eclipse.swt.graphics.Point(screenX, screenY));
        }
    }
}
Also used : HopGuiTooltipExtension(org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension) Image(org.eclipse.swt.graphics.Image) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) HopException(org.apache.hop.core.exception.HopException) ActionMeta(org.apache.hop.workflow.action.ActionMeta)

Aggregations

HopException (org.apache.hop.core.exception.HopException)2 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)2 HopGuiTooltipExtension (org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension)2 Image (org.eclipse.swt.graphics.Image)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 FileObject (org.apache.commons.vfs2.FileObject)1 HopTransformException (org.apache.hop.core.exception.HopTransformException)1 HopValueException (org.apache.hop.core.exception.HopValueException)1 AreaType (org.apache.hop.core.gui.AreaOwner.AreaType)1 RowBuffer (org.apache.hop.core.row.RowBuffer)1 IStream (org.apache.hop.pipeline.transform.stream.IStream)1 ActionMeta (org.apache.hop.workflow.action.ActionMeta)1