Search in sources :

Example 6 with AbstractJobletContainer

use of org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer in project tdi-studio-se by Talend.

the class NodeContainer method prepareStatus.

private Rectangle prepareStatus(Point nodeLocation, Dimension nodeSize) {
    Rectangle statusRectangle = null;
    Rectangle breakpointRectangle, warningRectangle, infoRectangle, parallelLocationRectangle, windowLocationRectangle, validationRuleRectangle, collapseRectangle;
    int status = node.getStatus();
    if ((status & Process.BREAKPOINT_STATUS) != 0) {
        breakpointLocation.x = nodeLocation.x - breakpointSize.width;
        breakpointLocation.y = nodeLocation.y - breakpointSize.height;
        breakpointRectangle = new Rectangle(breakpointLocation, breakpointSize);
        statusRectangle = breakpointRectangle;
    }
    if ((status & Process.ERROR_STATUS) != 0) {
        errorLocation.x = nodeLocation.x + nodeSize.width;
        errorLocation.y = nodeLocation.y - errorSize.height;
        errorRectangle = new Rectangle(errorLocation, errorSize);
        if (statusRectangle == null) {
            statusRectangle = errorRectangle;
        } else {
            statusRectangle.union(errorRectangle);
        }
    }
    if ((status & Process.WARNING_STATUS) != 0) {
        warningLocation.x = nodeLocation.x + nodeSize.width;
        warningLocation.y = nodeLocation.y - warningSize.height;
        warningRectangle = new Rectangle(warningLocation, warningSize);
        if (statusRectangle == null) {
            statusRectangle = warningRectangle;
        } else {
            statusRectangle.union(warningRectangle);
        }
    }
    if (this instanceof AbstractJobletContainer) {
        Dimension collapseSize = new Dimension(20, 20);
        collapseLocation.x = nodeLocation.x - 20;
        collapseLocation.y = nodeLocation.y - collapseSize.height;
        collapseRectangle = new Rectangle(collapseLocation, collapseSize);
        if (statusRectangle == null) {
            Point extendPoint = new Point();
            extendPoint.x = nodeLocation.x + nodeSize.width;
            extendPoint.y = nodeLocation.y - warningSize.height;
            Rectangle extendRectangle = new Rectangle(extendPoint, warningSize);
            statusRectangle = extendRectangle;
        }
        statusRectangle.union(collapseRectangle);
    }
    if ((status & Process.INFO_STATUS) != 0) {
        infoLocation.x = nodeLocation.x + nodeSize.width;
        infoLocation.y = nodeLocation.y - infoSize.height;
        infoRectangle = new Rectangle(infoLocation, infoSize);
        if (statusRectangle == null) {
            statusRectangle = infoRectangle;
        } else {
            statusRectangle.union(infoRectangle);
        }
    }
    if ((status & Process.VALIDATION_RULE_STATUS) != 0) {
        validationRuleLocation.x = nodeLocation.x + nodeSize.width / 2 + nodeSize.width / 4;
        validationRuleLocation.y = nodeLocation.y - validationRuleSize.height / 2;
        validationRuleRectangle = new Rectangle(validationRuleLocation, validationRuleSize);
        if (statusRectangle == null) {
            statusRectangle = validationRuleRectangle;
        } else {
            statusRectangle.union(validationRuleRectangle);
        }
    }
    if (node.isErrorFlag()) {
        markLocation.x = nodeLocation.x - nodeSize.width / 2;
        markLocation.y = nodeLocation.y;
        errorMarkLocation.x = nodeLocation.x - (errorMarkSize.width - nodeSize.width) / 2;
        errorMarkLocation.y = markLocation.y - errorMarkSize.height;
        errorMarkRectangle = new Rectangle(errorMarkLocation, errorMarkSize);
        if (statusRectangle == null) {
            statusRectangle = errorMarkRectangle;
        } else {
            statusRectangle.union(errorMarkRectangle);
        }
    }
    boolean parallelize = false;
    IElementParameter enableParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE.getName());
    if (enableParallelizeParameter != null) {
        parallelize = (Boolean) enableParallelizeParameter.getValue();
    }
    if (parallelize) {
        parallelLocation.x = nodeLocation.x - parallelSize.width;
        parallelLocation.y = nodeLocation.y - parallelSize.height;
        parallelLocationRectangle = new Rectangle(parallelLocation, parallelSize);
        if (statusRectangle == null) {
            statusRectangle = parallelLocationRectangle;
        } else {
            statusRectangle.union(parallelLocationRectangle);
        }
    }
    IElementParameter window = node.getElementParameter(EParameterName.WINDOW_DURATION.getName());
    String windowDuration = null;
    if (window != null) {
        windowDuration = (String) window.getValue();
    }
    if (windowDuration != null) {
        windowLocation.x = nodeLocation.x - ((nodeLocation.x + (windowSize.width / 2)) - (nodeLocation.x + (nodeSize.width / 2)));
        windowLocation.y = nodeLocation.y - windowSize.height;
        windowLocationRectangle = new Rectangle(windowLocation, windowSize);
        if (statusRectangle == null) {
            statusRectangle = windowLocationRectangle;
        } else {
            statusRectangle.union(windowLocationRectangle);
        }
    }
    return statusRectangle;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) IElementParameter(org.talend.core.model.process.IElementParameter) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 7 with AbstractJobletContainer

use of org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer in project tdi-studio-se by Talend.

the class NodeContainer method prepareCleanStatus.

private Rectangle prepareCleanStatus(Point nodeLocation, Dimension nodeSize) {
    Rectangle statusRectangle = null;
    Rectangle breakpointRectangle, warningRectangle, infoRectangle, validationRuleRectangle, collapseRectangle;
    int status = node.getStatus();
    if ((status & Process.BREAKPOINT_STATUS) != 0) {
        breakpointLocation.x = nodeLocation.x - breakpointSize.width;
        breakpointLocation.y = nodeLocation.y - breakpointSize.height;
        breakpointRectangle = new Rectangle(breakpointLocation, breakpointSize);
        statusRectangle = breakpointRectangle;
    }
    if ((status & Process.ERROR_STATUS) != 0) {
        errorLocation.x = nodeLocation.x + nodeSize.width;
        errorLocation.y = nodeLocation.y - errorSize.height;
        errorRectangle = new Rectangle(errorLocation, errorSize);
        if (statusRectangle == null) {
            statusRectangle = errorRectangle;
        } else {
            statusRectangle.union(errorRectangle);
        }
    }
    if ((status & Process.WARNING_STATUS) != 0) {
        warningLocation.x = nodeLocation.x + nodeSize.width;
        warningLocation.y = nodeLocation.y - warningSize.height;
        warningRectangle = new Rectangle(warningLocation, warningSize);
        if (statusRectangle == null) {
            statusRectangle = warningRectangle;
        } else {
            statusRectangle.union(warningRectangle);
        }
    }
    if (this instanceof AbstractJobletContainer) {
        Dimension collapseSize = new Dimension(20, 20);
        collapseLocation.x = nodeLocation.x - 20;
        collapseLocation.y = nodeLocation.y - collapseSize.height;
        collapseRectangle = new Rectangle(collapseLocation, collapseSize);
        if (statusRectangle == null) {
            Point extendPoint = new Point();
            extendPoint.x = nodeLocation.x + nodeSize.width;
            extendPoint.y = nodeLocation.y - warningSize.height;
            Rectangle extendRectangle = new Rectangle(extendPoint, warningSize);
            statusRectangle = extendRectangle;
        }
        statusRectangle.union(collapseRectangle);
    }
    if ((status & Process.INFO_STATUS) != 0) {
        infoLocation.x = nodeLocation.x + nodeSize.width;
        infoLocation.y = nodeLocation.y - infoSize.height;
        infoRectangle = new Rectangle(infoLocation, infoSize);
        if (statusRectangle == null) {
            statusRectangle = infoRectangle;
        } else {
            statusRectangle.union(infoRectangle);
        }
    }
    if ((status & Process.VALIDATION_RULE_STATUS) != 0) {
        validationRuleLocation.x = nodeLocation.x + nodeSize.width / 2 + nodeSize.width / 4;
        validationRuleLocation.y = nodeLocation.y - validationRuleSize.height / 2;
        validationRuleRectangle = new Rectangle(validationRuleLocation, validationRuleSize);
        if (statusRectangle == null) {
            statusRectangle = validationRuleRectangle;
        } else {
            statusRectangle.union(validationRuleRectangle);
        }
    }
    if (node.isErrorFlag()) {
        markLocation.x = nodeLocation.x - nodeSize.width / 2;
        markLocation.y = nodeLocation.y;
        errorMarkLocation.x = nodeLocation.x - (errorMarkSize.width - nodeSize.width) / 2;
        errorMarkLocation.y = markLocation.y - errorMarkSize.height;
        errorMarkRectangle = new Rectangle(errorMarkLocation, errorMarkSize);
        if (statusRectangle == null) {
            statusRectangle = errorMarkRectangle;
        } else {
            statusRectangle.union(errorMarkRectangle);
        }
    }
    return statusRectangle;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 8 with AbstractJobletContainer

use of org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer in project tdi-studio-se by Talend.

the class SubjobContainer method getSubjobContainerRectangle.

/**
     * DOC nrousseau Comment method "getSubjobContainerRectangle".
     * 
     * @return
     */
public Rectangle getSubjobContainerRectangle() {
    Rectangle totalRectangle = null;
    boolean collapsed = isCollapsed();
    boolean isTestContainer = false;
    ITestContainerGEFService testContainerService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
        testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
        if (testContainerService != null) {
            isTestContainer = testContainerService.isTestContainer(this.process);
        }
    }
    // boolean hasJoblet = false;
    for (NodeContainer container : nodeContainers) {
        Rectangle curRect = null;
        if (container instanceof AbstractJobletContainer) {
            curRect = ((AbstractJobletContainer) container).getJobletContainerRectangle();
        } else if (isTestContainer && testContainerService != null) {
            curRect = testContainerService.getJunitContainerRectangle(container);
        } else {
            curRect = container.getNodeContainerRectangle();
        }
        if ((curRect.x + curRect.width) == (container.getNode().getPosX() + container.getNode().getSize().width)) {
            curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE, curRect.getSize().height);
        }
        if ((curRect.y + curRect.height) == (container.getNode().getPosY() + container.getNode().getSize().height)) {
            curRect.setSize(curRect.getSize().width, curRect.getSize().height + TalendEditor.GRID_SIZE);
        }
        if (curRect.y == container.getNode().getPosY()) {
            // means have totally no other status or such on the top of the node in the NodeContainerFigure, then we
            // add one more space on the top of the subjob
            // this could be done only once, but to simplify the calculation, just do for every node
            curRect.setLocation(curRect.getLocation().x, curRect.getLocation().y - TalendEditor.GRID_SIZE);
            curRect.setSize(curRect.getSize().width, curRect.getSize().height + TalendEditor.GRID_SIZE);
        }
        if (curRect.x == container.getNode().getPosX()) {
            // means if the node container figure is just at the border of the size of the component
            // then we add one more space on the left of the component, just to avoid have one subjob background
            // "too small" (too close to component)
            // this could be done only once, but to simplify the calculation, just do for every node
            curRect.setLocation(curRect.getLocation().x - TalendEditor.GRID_SIZE, curRect.getLocation().y);
            curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE, curRect.getSize().height);
        }
        if (collapsed && totalRectangle == null) {
            totalRectangle = curRect.getCopy();
        } else if (!collapsed) {
            if (totalRectangle == null) {
                totalRectangle = curRect.getCopy();
            } else {
                totalRectangle = totalRectangle.getUnion(curRect);
            }
        } else if (collapsed && testContainerService != null && testContainerService.isJunitContainer(container)) {
            INode startNode = this.getSubjobStartNode().getJunitNode();
            INode containerNode = container.getNode().getJunitNode();
            if (startNode != null && containerNode != null && startNode == containerNode) {
                totalRectangle = testContainerService.getJunitContainerRectangle(container).getCopy();
            }
        }
        if (isTestContainer && !collapsed) {
            if (curRect.x == totalRectangle.x) {
                totalRectangle.setLocation(totalRectangle.getLocation().x - TalendEditor.GRID_SIZE, totalRectangle.getLocation().y);
                totalRectangle.setSize(totalRectangle.getSize().width + TalendEditor.GRID_SIZE, totalRectangle.getSize().height);
            }
            if (curRect.y == totalRectangle.y) {
                totalRectangle.setLocation(totalRectangle.getLocation().x, totalRectangle.getLocation().y - TalendEditor.GRID_SIZE);
                totalRectangle.setSize(totalRectangle.getSize().width, totalRectangle.getSize().height + TalendEditor.GRID_SIZE);
            }
        }
    }
    if (totalRectangle == null) {
        return null;
    }
    Point location = totalRectangle.getLocation();
    Point newLocation = new Point();
    newLocation.x = (location.x / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    newLocation.y = (location.y / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    // bug 5158
    if (newLocation.y <= 0 && location.y < 0) {
        newLocation.y = newLocation.y - TalendEditor.GRID_SIZE;
    }
    if (newLocation.x <= 0 && location.x < 0) {
        newLocation.x = newLocation.x - TalendEditor.GRID_SIZE;
    }
    totalRectangle.setLocation(newLocation);
    Dimension diff = location.getDifference(newLocation);
    Dimension size = totalRectangle.getSize().expand(diff);
    if ((size.height % TalendEditor.GRID_SIZE) == 0) {
        size.height = (size.height / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    } else {
        size.height = ((size.height / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
    }
    if ((size.width % TalendEditor.GRID_SIZE) == 0) {
        size.width = (size.width / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    } else {
        size.width = ((size.width / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
    }
    // if (hasJoblet) {
    // size.width = size.width + TalendEditor.GRID_SIZE;
    // }
    totalRectangle.setSize(size);
    return totalRectangle;
}
Also used : INode(org.talend.core.model.process.INode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ITestContainerGEFService(org.talend.designer.core.ITestContainerGEFService) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

AbstractJobletContainer (org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer)8 INode (org.talend.core.model.process.INode)5 Node (org.talend.designer.core.ui.editor.nodes.Node)5 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)4 Dimension (org.eclipse.draw2d.geometry.Dimension)3 Point (org.eclipse.draw2d.geometry.Point)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 Process (org.talend.designer.core.ui.editor.process.Process)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 IComponent (org.talend.core.model.components.IComponent)1 AbstractNode (org.talend.core.model.process.AbstractNode)1 IConnection (org.talend.core.model.process.IConnection)1 IExternalNode (org.talend.core.model.process.IExternalNode)1 IProcess (org.talend.core.model.process.IProcess)1 Item (org.talend.core.model.properties.Item)1