@Override public void attachDefaultHandlers() { this.connector.addMouseMoveHandler(new MouseMoveHandler() { this.connector.addMouseDownHandler(new MouseDownHandler() { this.connector.addDoubleClickHandler(new DoubleClickHandler() {
if (incomingC.getTarget().equals(connectable)) incomingC.setTarget(null); for(IConnectorPoint m:incomingC.getAllConnectorPoints()){ if (outgoingC.getSource().equals(connectable)) outgoingC.setSource(null); for(IConnectorPoint m:outgoingC.getAllConnectorPoints()){ if (connector.getSource()!=null) connector.getSource().getOutgoingConnectors().remove(connector); if (connector.getTarget()!=null) connector.getTarget().getIncommingConnectors().remove(connector);
IConnectorPoint previousPoint = connector.getConnectorStartPoint(); IConnectorPoint nextPoint = connector.getConnectorEndPoint(); IConnectorPoint pointToAdd = connector.createConnectorPoint((int)actualWayPoint.getX(), (int)actualWayPoint.getY()); connector.addIntermediateConnectorPoint(pointToAdd, previousPoint, nextPoint); connector.connect(connectableSourceElement, connectableTargetElement);
@Override public void onStart(IDragStartEvent event) { this.getConnector().refresh(); //if current point is already attached => detach it if (this.getConnectedToMagnet()!=null){ this.getConnectedToMagnet().removeConnectorPoint(this); //remove incoming or outgoing connector this.getConnectedToMagnet().getConnectableElement().getIncommingConnectors().remove(this.getConnector()); this.getConnectedToMagnet().getConnectableElement().getOutgoingConnectors().remove(this.getConnector()); this.setConnectedToMagnet(null); if (this instanceof IConnectorStart){ this.getConnector().setSource(null); }else if (this instanceof IConnectorEnd){ this.getConnector().setTarget(null); } } }
@Override public void onMove(IDragMoveEvent event) { this.getConnector().refresh(); }
for(IConnectorPoint p : (HashSet<IConnectorPoint>)connector.getAllConnectorPoints()){ connector.refresh();
@Override public boolean isConform(IDiagramElementView diagramElementView) { Participant connectable = (Participant) diagramElementView; int nb = 0; for(IConnector connector : connectable.getOutgoingConnectors()){ if (connector instanceof Association && connector.getTarget() instanceof Message){ nb++; } } if (nb>1){ return false; } return true; }
IDiagramElementView source = (IDiagramElementView) connector.getSource();
public ClosestPoints getClosestPoints(Point point) { IConnectorPoint minPoint = this.connector.getConnectorStartPoint(); IConnectorPoint currentPoint = minPoint; while (currentPoint.getNextPoint() != null) { Point previousPoint = new Point(currentPoint.getAbsoluteLeft(),currentPoint.getAbsoluteTop()); Point nextPoint = new Point(currentPoint.getNextPoint().getAbsoluteLeft(),currentPoint.getNextPoint().getAbsoluteTop()); Region r = new Region(previousPoint,nextPoint); if (r.contains(point)){ minPoint = currentPoint; break; } currentPoint = currentPoint.getNextPoint(); } IConnectorPoint maxPoint = minPoint.getNextPoint(); ClosestPoints closesPoints = new ClosestPoints(minPoint, maxPoint); return closesPoints; }
@Override public void execute() { IDiagramElementView connector = (IDiagramElementView) diagramView.getElementFactory().getElement(new FakeDragProxy(connectorClazz)); assert connector!=null; assert (source.getDiagramElement() instanceof IConnectable); assert (target.getDiagramElement() instanceof IConnectable); if (connector instanceof IConnector){ ((IConnector) connector).connect((IConnectable)source.getDiagramElement(),(IConnectable)target.getDiagramElement()); }else{ throw new IllegalStateException(connector + " is not instance of "+IConnector.class); } } });
@Override public void onStop(IDragStopEvent event) { this.getConnector().refresh(); }
@Override public boolean isConform(IDiagramElementView diagramElementView) { Participant connectable = (Participant) diagramElementView; if (connectable.getOutgoingConnectors().size()>0){ IConnector connector = connectable.getOutgoingConnectors().iterator().next(); if (connector instanceof Association){ IConnectableElement target = connector.getTarget(); if (target instanceof Message){ Message message = (Message) target; if (connectable.isInitiating()!=message.isInitiating()){ return false; } } } } return true; }
@Override public boolean isConform(IDiagramElementView diagramElementView) { IConnector connector = (IConnector) diagramElementView; IDiagramElementView source = (IDiagramElementView) connector.getSource(); IDiagramElementView target = (IDiagramElementView) connector.getTarget(); if (source==target){ return false; } return true; }
p.getConnector().refresh();
p.getConnector().refresh();