Search in sources :

Example 1 with AreaType

use of org.apache.hop.core.gui.AreaOwner.AreaType 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)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 FileObject (org.apache.commons.vfs2.FileObject)1 HopException (org.apache.hop.core.exception.HopException)1 HopTransformException (org.apache.hop.core.exception.HopTransformException)1 HopValueException (org.apache.hop.core.exception.HopValueException)1 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)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 HopGuiTooltipExtension (org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension)1 Image (org.eclipse.swt.graphics.Image)1