Search in sources :

Example 1 with AnchorListener

use of org.eclipse.draw2d.AnchorListener in project tdi-studio-se by Talend.

the class NodeFigure method setBounds.

@Override
public void setBounds(final Rectangle rect) {
    super.setBounds(rect);
    Point location = (new Point(rect.getCenter())).translate(new Point(-fig.getSize().width / 2, -(fig.getSize().height / 2)));
    Rectangle figBounds = new Rectangle(location, fig.getSize());
    this.fig.setBounds(figBounds);
    if (dummy) {
        if (sourceDummyMap != null) {
            if (targetConnection != null && sourceDummyMap.keySet().size() != 0) {
                for (final ConnectionFigure curConn : newSourceConnections) {
                    AnchorListener sourceListener = new AnchorListener() {

                        @Override
                        public void anchorMoved(ConnectionAnchor anchor) {
                            if (curConn != null) {
                                updateSource(curConn);
                            }
                        }
                    };
                    if (curConn.getTargetAnchor() != null && curConn.getTargetAnchor().getOwner() != null) {
                        sourceListeners.put(curConn, sourceListener);
                        curConn.getTargetAnchor().addAnchorListener(sourceListener);
                    }
                }
                newSourceConnections.clear();
                updateTarget();
                List<ConnectionFigure> toRemove = new ArrayList<ConnectionFigure>();
                for (ConnectionFigure curConn : sourceDummyMap.keySet()) {
                    ConnectionFigure connToRemove = updateSource(curConn);
                    if (connToRemove != null) {
                        toRemove.add(connToRemove);
                    }
                }
                sourceDummyMap.keySet().removeAll(toRemove);
            } else {
                INodeConnector mainNodeConnector = node.getConnectorFromType(EConnectionType.FLOW_MAIN);
                ConnectionFigure connection = new ConnectionFigure(mainNodeConnector.getConnectionProperty(EConnectionType.FLOW_MAIN), node);
                connection.setTargetDecoration(null);
                connection.setStart(new Point(figBounds.x, figBounds.y + figBounds.height / 2));
                connection.setEnd(new Point(figBounds.x + figBounds.width, figBounds.y + figBounds.height / 2));
            }
        }
    }
    if (!rect.getSize().equals(fig.getSize())) {
        lineBorder.setUseRectangle(true);
    } else {
        lineBorder.setUseRectangle(false);
    }
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) DummyConnectionFigure(org.talend.designer.core.ui.editor.connections.DummyConnectionFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AnchorListener(org.eclipse.draw2d.AnchorListener) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point) INodeConnector(org.talend.core.model.process.INodeConnector)

Aggregations

ArrayList (java.util.ArrayList)1 AnchorListener (org.eclipse.draw2d.AnchorListener)1 ConnectionAnchor (org.eclipse.draw2d.ConnectionAnchor)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 INodeConnector (org.talend.core.model.process.INodeConnector)1 ConnectionFigure (org.talend.designer.core.ui.editor.connections.ConnectionFigure)1 DummyConnectionFigure (org.talend.designer.core.ui.editor.connections.DummyConnectionFigure)1