/** * This method creates and returns the figure for {@link Relation}s from type cyclic, total, acyclic, reflexive and * irreflexive, which differs from relationshipConstraint to relationshipConstraint only in the * text of the {@link Label}. A cyclic, total, acyclic, reflexive or irreflexive figure is dashed line with a * {@link Label}. * * @return conn org.eclipse.draw2d.PolylineConnection * */ private static Figure createRelationshipConstraintFigure(Relation relation, EditPart editpart) { ORMRelationshipConstraintEditPart editP = (ORMRelationshipConstraintEditPart) editpart; editP.getLabel().setText(relation.getName()); editP.setTextInitial(relation.getName()); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setConnectionRouter(new BendpointConnectionRouter()); // add label to the connection ConnectionLocator loc = new ConnectionLocator(conn, ConnectionLocator.MIDDLE); loc.setRelativePosition(PositionConstants.SOUTH); loc.setGap(5); // this is needed, because when the label would be just added the label text could be seen in // the rootModel if (editP.getRoot().getContents() instanceof ORMCompartmentEditPart) { conn.add(editP.getLabel(), loc); } return conn; }
/** * {@inheritDoc} In case the figures of targetLabel and sourceLabel which are {@link NamedElement} * s. */ @Override protected void addChildVisual(final EditPart childEditPart, final int index) { if (childEditPart instanceof ORMNamedElementEditPart) { ORMNamedElementEditPart labelEditPart = (ORMNamedElementEditPart) childEditPart; if (labelEditPart.getModel().equals(getRelationship().getSourceLabel())) { getRelationFigure().getLayoutManager().setConstraint(labelEditPart.getFigure(), getConnectionLocator(getRelationFigure(), false)); } else { getRelationFigure().getLayoutManager().setConstraint(labelEditPart.getFigure(), getConnectionLocator(getRelationFigure(), true)); } } if (childEditPart instanceof ORMSuperShapeEditPart) { ConnectionLocator loc = new ConnectionLocator(getRelationFigure(), ConnectionLocator.MIDDLE); getRelationFigure().getLayoutManager().setConstraint( ((ORMSuperShapeEditPart) childEditPart).getFigure(), loc); } super.addChildVisual(childEditPart, index); }
@Override protected List<Object> createSelectionHandles(){ List<Object> list = new ArrayList<Object>(); list.add(new ConnectionEndpointHandle((ConnectionEditPart) getHost(), ConnectionLocator.SOURCE)); return list; }
/** * Creates and returns a new {@link ConnectionEndpointTracker}. * * @return the new ConnectionEndpointTracker */ protected DragTracker createDragTracker() { if (isFixed()) return null; ConnectionEndpointTracker tracker; tracker = new ConnectionEndpointTracker((ConnectionEditPart) getOwner()); if (endPoint == ConnectionLocator.SOURCE) { tracker.setCommandName(RequestConstants.REQ_RECONNECT_SOURCE); } else { tracker.setCommandName(RequestConstants.REQ_RECONNECT_TARGET); } tracker.setDefaultCursor(getCursor()); return tracker; }
/** * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#createSelectionHandles() */ protected List createSelectionHandles() { List list = new ArrayList(); list.add(new ConnectionEndpointHandle((ConnectionEditPart) getHost(), ConnectionLocator.SOURCE)); list.add(new ConnectionEndpointHandle((ConnectionEditPart) getHost(), ConnectionLocator.TARGET)); return list; }
/** * {@link Relation}s from type relationship have as figure a drawn through line with two * {@link Label}s at both ends and Label in the middle for it's name. The {@link Label} are added * through child model elements( {@link NamedElements}). * * @return conn org.eclipse.draw2d.PolylineConnection */ private static Figure createRelationshipFigure(ORMRelationshipEditPart editPart) { //PolylineConnection connection = new PolylineConnection(); ORMConnectionMultiplePolyline connection = new ORMConnectionMultiplePolyline(); connection.setHasConstraint(true); connection.setConnectionRouter(new BendpointConnectionRouter()); // add label to the connection ConnectionLocator locNameLabel = new ConnectionLocator(connection, ConnectionLocator.MIDDLE); locNameLabel.setRelativePosition(PositionConstants.NORTH); locNameLabel.setGap(5); ConnectionLocator locConstraintLabel = new ConnectionLocator(connection, ConnectionLocator.MIDDLE); locConstraintLabel.setRelativePosition(PositionConstants.SOUTH); locConstraintLabel.setGap(5); // this is needed, because when the label would be just added the label text could be seen in // the rootModel if (editPart.getRoot().getContents() instanceof ORMCompartmentEditPart) { editPart.getNameLabel().setText(editPart.getRelationship().getName()); connection.add(editPart.getNameLabel(), locNameLabel); editPart.getConstraintLabel().setText(editPart.getRelationship().getName()); connection.add(editPart.getConstraintLabel(), locConstraintLabel); } return connection; }
/** * Given a connection, draw the TimeoutPathFigure on the node connection. * * @param connection */ private void addTimeout(SplineConnection connection) { if (timeout != null) getFigure().remove(timeout); int index = getLink().getSource().getSucc().indexOf(getLink()); if (index == 1) { NodeConnectionLocator constraint = new NodeConnectionLocator(connection, ConnectionLocator.MIDDLE); constraint.setRelativePosition(PositionConstants.CENTER); timeout = new TimeoutPathFigure(); connection.add(timeout, constraint); } }
/** * Sets the decoration to be used at the middle of the {@link Connection}. * * @param dec * the new decoration */ public void setMiddleDecoration(RotatableDecoration dec) { if (middleDec == dec) return; if (middleDec != null) remove(middleDec); middleDec = dec; if (middleDec != null) { add(middleDec, new NodeConnectionLocator(this, ConnectionLocator.MIDDLE)); } }
/** * Creates a new ConnectionEndHandle. */ public ConnectionEndHandle() { super(ConnectionLocator.TARGET); }
/** * Creates a new ConnectionStartHandle. */ public ConnectionStartHandle() { super(ConnectionLocator.TARGET); }
/** * @generated */ public int getKeyPoint() { return ConnectionLocator.MIDDLE; }
/** * @generated */ public int getKeyPoint() { return ConnectionLocator.SOURCE; }
/** * @generated */ public int getKeyPoint() { return ConnectionLocator.TARGET; }