Search in sources :

Example 1 with ILinkState

use of org.talend.designer.abstractmap.ui.visualmap.link.ILinkState in project tdi-studio-se by Talend.

the class StyleLinkFactory method getStyleLink.

// public static DrawableLinkFactory getInstance() {
// if (instance == null) {
// instance = new DrawableLinkFactory();
// }
// return instance;
// }
//
// public IDrawableLink getDrawableLink(IMapperLink link) {
// IDrawableLink drawableLink = null;
// PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptorSource();
// PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptorTarget();
// if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
// drawableLink = new HorizontalBezierLink();
// } else if (pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
// drawableLink = new VerticalRoundedCornerLink();
// }
// return drawableLink;
// }
//
public IStyleLink getStyleLink(IMapperLink link) {
    ILinkState linkState = link.getState();
    PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptor1();
    PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptor2();
    ITableEntry targetTableEntry = pointLinkDescriptorTarget.getTableEntry();
    boolean targetIsConstraint = false;
    if (targetTableEntry instanceof FilterTableEntry) {
        targetIsConstraint = true;
    }
    IStyleLink style = null;
    if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
        if (linkState == LinkState.SELECTED) {
            if (targetIsConstraint) {
                style = selectedFilterStyle;
            } else {
                style = selectedZoneToZoneStyle;
            }
        } else if (linkState == LinkState.UNSELECTED) {
            if (targetIsConstraint) {
                style = unselectedFilterStyle;
            } else {
                style = unselectedZoneToZoneStyle;
            }
        }
    } else if ((pointLinkDescriptorSource.getZone() == Zone.INPUTS || pointLinkDescriptorSource.getZone() == Zone.OUTPUTS) && pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
        if (linkState == LinkState.SELECTED) {
            style = selectedSameInputZoneStyle;
        } else if (linkState == LinkState.UNSELECTED) {
            style = unselectedSameZoneStyle;
        }
    }
    return style;
}
Also used : PointLinkDescriptor(org.talend.designer.abstractmap.ui.visualmap.link.PointLinkDescriptor) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ILinkState(org.talend.designer.abstractmap.ui.visualmap.link.ILinkState) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink)

Example 2 with ILinkState

use of org.talend.designer.abstractmap.ui.visualmap.link.ILinkState in project tdi-studio-se by Talend.

the class StyleLinkFactory method getStyleLink.

// public static DrawableLinkFactory getInstance() {
// if (instance == null) {
// instance = new DrawableLinkFactory();
// }
// return instance;
// }
//
// public IDrawableLink getDrawableLink(IMapperLink link) {
// IDrawableLink drawableLink = null;
// PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptorSource();
// PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptorTarget();
// if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
// drawableLink = new HorizontalBezierLink();
// } else if (pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
// drawableLink = new VerticalRoundedCornerLink();
// }
// return drawableLink;
// }
//
public IStyleLink getStyleLink(IMapperLink link) {
    ILinkState linkState = link.getState();
    PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptor1();
    PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptor2();
    ITableEntry targetTableEntry = pointLinkDescriptorTarget.getTableEntry();
    boolean targetIsConstraint = false;
    if (targetTableEntry instanceof FilterTableEntry || targetTableEntry instanceof ExpressionFilterEntry) {
        targetIsConstraint = true;
    }
    boolean targetIsGlobalMap = false;
    if (targetTableEntry instanceof GlobalMapEntry) {
        targetIsGlobalMap = true;
    }
    IStyleLink style = null;
    if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
        if (linkState == LinkState.SELECTED) {
            if (targetIsConstraint) {
                style = selectedZoneToZoneFilterStyle;
            } else {
                style = selectedZoneToZoneStyle;
            }
        } else if (linkState == LinkState.UNSELECTED) {
            if (targetIsConstraint) {
                style = unselectedZoneToZoneFilterStyle;
            } else {
                style = unselectedZoneToZoneStyle;
            }
        }
    } else if (pointLinkDescriptorSource.getZone() == Zone.INPUTS && pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
        if (linkState == LinkState.SELECTED) {
            if (pointLinkDescriptorTarget.getTableEntry() instanceof ExpressionFilterEntry) {
                style = selectedSameZoneFilterStyle;
            } else if (pointLinkDescriptorTarget.getTableEntry() instanceof GlobalMapEntry) {
                style = selectedSameZoneGlobalMapStyle;
            } else {
                style = selectedSameInputZoneStyle;
            }
        } else if (linkState == LinkState.UNSELECTED) {
            if (pointLinkDescriptorTarget.getTableEntry() instanceof ExpressionFilterEntry) {
                style = unselectedSameZoneFilterStyle;
            } else if (pointLinkDescriptorTarget.getTableEntry() instanceof GlobalMapEntry) {
                style = unselectedSameZoneGlobalMapStyle;
            } else {
                style = unselectedSameInputZoneStyle;
            }
        }
    } else if (pointLinkDescriptorSource.getZone() == Zone.VARS && pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
        if (linkState == LinkState.SELECTED) {
            style = selectedSameVarsZoneStyle;
        } else if (linkState == LinkState.UNSELECTED) {
            style = unselectedSameVarsZoneStyle;
        }
    }
    return style;
}
Also used : PointLinkDescriptor(org.talend.designer.abstractmap.ui.visualmap.link.PointLinkDescriptor) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ILinkState(org.talend.designer.abstractmap.ui.visualmap.link.ILinkState) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Aggregations

IStyleLink (org.talend.commons.ui.swt.drawing.link.IStyleLink)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 ILinkState (org.talend.designer.abstractmap.ui.visualmap.link.ILinkState)2 PointLinkDescriptor (org.talend.designer.abstractmap.ui.visualmap.link.PointLinkDescriptor)2 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)1 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)1 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)1 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)1