@Override protected boolean calculateEnabled() { final GraphicalViewer viewer = getGraphicalViewer(); for (final Object object : viewer.getSelectedEditParts()) { if (object instanceof ConnectionEditPart) { return true; } else if (object instanceof NodeElementEditPart) { final NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object; if (!nodeElementEditPart.getSourceConnections().isEmpty()) { return true; } } } return false; }
/** * {@inheritDoc} */ @Override protected boolean calculateEnabled() { final GraphicalViewer viewer = getGraphicalViewer(); for (final Object object : viewer.getSelectedEditParts()) { if (object instanceof ConnectionEditPart) { return true; } else if (object instanceof NodeElementEditPart) { final NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object; if (!nodeElementEditPart.getSourceConnections().isEmpty()) { return true; } } } return false; }
private List<NormalColumn> getSelectedForeignKeyColulmnList() { final List<NormalColumn> foreignKeyColulmnList = new ArrayList<NormalColumn>(); final TableViewEditPart parent = (TableViewEditPart) getParent(); for (final Object object : parent.getTargetConnections()) { final ConnectionEditPart connectionEditPart = (ConnectionEditPart) object; final int selected = connectionEditPart.getSelected(); if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) { final ConnectionElement connectionElement = (ConnectionElement) connectionEditPart.getModel(); if (connectionElement instanceof Relation) { final Relation relation = (Relation) connectionElement; foreignKeyColulmnList.addAll(relation.getForeignKeyColumns()); } } } return foreignKeyColulmnList; }
/** * {@inheritDoc} */ @Override public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart editPart) { // if (!(editPart instanceof RelationEditPart)) { // return super.getSourceConnectionAnchor(editPart); // } final ConnectionElement connection = (ConnectionElement) editPart.getModel(); final Rectangle bounds = getFigure().getBounds(); final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure()); if (connection.getSourceXp() != -1 && connection.getSourceYp() != -1) { anchor.setLocation(new Point(bounds.x + (bounds.width * connection.getSourceXp() / 100), bounds.y + (bounds.height * connection.getSourceYp() / 100))); } return anchor; }
/** * {@inheritDoc} */ @Override public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart editPart) { // if (!(editPart instanceof RelationEditPart)) { // return new ChopboxAnchor(this.getFigure()); // } final ConnectionElement connection = (ConnectionElement) editPart.getModel(); final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure()); final Rectangle bounds = getFigure().getBounds(); if (connection.getTargetXp() != -1 && connection.getTargetYp() != -1) { anchor.setLocation(new Point(bounds.x + (bounds.width * connection.getTargetXp() / 100), bounds.y + (bounds.height * connection.getTargetYp() / 100))); } return anchor; }
@Override protected boolean calculateEnabled() { GraphicalViewer viewer = this.getGraphicalViewer(); for (Object object : viewer.getSelectedEditParts()) { if (object instanceof ConnectionEditPart) { return true; } else if (object instanceof NodeElementEditPart) { NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object; if (!nodeElementEditPart.getSourceConnections().isEmpty()) { return true; } } } return false; }
/** * {@inheritDoc} */ @Override protected boolean calculateEnabled() { GraphicalViewer viewer = this.getGraphicalViewer(); for (Object object : viewer.getSelectedEditParts()) { if (object instanceof ConnectionEditPart) { return true; } else if (object instanceof NodeElementEditPart) { NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) object; if (!nodeElementEditPart.getSourceConnections().isEmpty()) { return true; } } } return false; }
private List<NormalColumn> getSelectedForeignKeyColulmnList() { List<NormalColumn> foreignKeyColulmnList = new ArrayList<NormalColumn>(); TableViewEditPart parent = (TableViewEditPart) this.getParent(); for (Object object : parent.getTargetConnections()) { ConnectionEditPart connectionEditPart = (ConnectionEditPart) object; int selected = connectionEditPart.getSelected(); if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) { ConnectionElement connectionElement = (ConnectionElement) connectionEditPart .getModel(); if (connectionElement instanceof Relation) { Relation relation = (Relation) connectionElement; foreignKeyColulmnList.addAll(relation .getForeignKeyColumns()); } } } return foreignKeyColulmnList; }
/** * {@inheritDoc} */ public ConnectionAnchor getSourceConnectionAnchor( ConnectionEditPart editPart) { // if (!(editPart instanceof RelationEditPart)) { // return super.getSourceConnectionAnchor(editPart); // } Category currentCategory = getDiagram().getCurrentCategory(); ConnectionElement connection = (ConnectionElement) editPart.getModel(); Rectangle bounds = this.getFigure().getBounds(); XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure()); if (connection.getSourceXp(currentCategory) != -1 && connection.getSourceYp(currentCategory) != -1) { anchor.setLocation(new Point( bounds.x + (bounds.width * connection.getSourceXp(currentCategory) / 100), bounds.y + (bounds.height * connection.getSourceYp(currentCategory) / 100))); } return anchor; }
/** * {@inheritDoc} */ public ConnectionAnchor getTargetConnectionAnchor( ConnectionEditPart editPart) { // if (!(editPart instanceof RelationEditPart)) { // return new ChopboxAnchor(this.getFigure()); // } Category currentCategory = getDiagram().getCurrentCategory(); ConnectionElement connection = (ConnectionElement) editPart.getModel(); XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure()); Rectangle bounds = this.getFigure().getBounds(); if (connection.getTargetXp(currentCategory) != -1 && connection.getTargetYp(currentCategory) != -1) { anchor.setLocation(new Point( bounds.x + (bounds.width * connection.getTargetXp(currentCategory) / 100), bounds.y + (bounds.height * connection.getTargetYp(currentCategory) / 100))); } return anchor; }
/** * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart) */ public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) { if (connection instanceof AttachementEditPart) { return new ChopboxAnchor(getFigure()); } if (connection.getTarget() != null && connection.getSource() != null) { LifeLineNode sourceNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getSource().getModel()); LifeLineNode targetNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getTarget().getModel()); if (sourceNode.equals(targetNode)) { Point point = new Point(sourceNode.getX() + sourceNode.getWidth() / 2, ((AbstractView) connection.getModel()).getY()); connection.getFigure().translateToAbsolute(point); return new XYAnchor(point); } else { return new MessageOutgoingConnectionAnchor(getFigure(), connection); } } else { return new MessageOutgoingConnectionAnchor(getFigure(), connection); } }
/** * @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart) */ public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) { if (connection instanceof AttachementEditPart) { return new ChopboxAnchor(getFigure()); } if (connection.getTarget() != null && connection.getSource() != null) { LifeLineNode sourceNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getSource().getModel()); LifeLineNode targetNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getTarget().getModel()); if (sourceNode.equals(targetNode)) { Point point = new Point(targetNode.getX() + targetNode.getWidth() / 2, ((AbstractView) connection.getModel()).getY() + 10); connection.getFigure().translateToAbsolute(point); return new XYAnchor(point); } else { return new MessageIncommingConnectionAnchor(getFigure(), connection); } } else { return new MessageIncommingConnectionAnchor(getFigure(), connection); } }
@Override protected boolean calculateEnabled() { final GraphicalViewer viewer = getGraphicalViewer(); for (final Object object : viewer.getSelectedEditParts()) { if (object instanceof ConnectionEditPart) { return true; } else if (object instanceof DiagramWalkerEditPart) { final DiagramWalkerEditPart nodeElementEditPart = (DiagramWalkerEditPart) object; if (!nodeElementEditPart.getSourceConnections().isEmpty()) { return true; } } } return false; }
@Override public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart editPart) { if (!(editPart instanceof RelationEditPart)) { return super.getSourceConnectionAnchor(editPart); } final Relationship relation = (Relationship) editPart.getModel(); final Rectangle bounds = getFigure().getBounds(); final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure()); if (relation.getSourceXp() != -1 && relation.getSourceYp() != -1) { anchor.setLocation(new Point(bounds.x + (bounds.width * relation.getSourceXp() / 100), bounds.y + (bounds.height * relation.getSourceYp() / 100))); } return anchor; }
@Override public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart editPart) { if (!(editPart instanceof RelationEditPart)) { return super.getTargetConnectionAnchor(editPart); } final Relationship relation = (Relationship) editPart.getModel(); final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure()); final Rectangle bounds = getFigure().getBounds(); if (relation.getTargetXp() != -1 && relation.getTargetYp() != -1) { anchor.setLocation(new Point(bounds.x + (bounds.width * relation.getTargetXp() / 100), bounds.y + (bounds.height * relation.getTargetYp() / 100))); } return anchor; }
private List<NormalColumn> getSelectedForeignKeyColulmnList() { final List<NormalColumn> foreignKeyColulmnList = new ArrayList<>(); final TableViewEditPart parent = (TableViewEditPart) getParent(); for (final Object object : parent.getTargetConnections()) { final ConnectionEditPart connectionEditPart = (ConnectionEditPart) object; final int selected = connectionEditPart.getSelected(); if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) { final WalkerConnection connectionElement = (WalkerConnection) connectionEditPart.getModel(); if (connectionElement instanceof Relationship) { final Relationship relation = (Relationship) connectionElement; foreignKeyColulmnList.addAll(relation.getForeignKeyColumns()); } } } return foreignKeyColulmnList; }
@Override protected List<?> createSelectionHandles() { final Relationship relation = (Relationship) getHost().getModel(); if (relation.getSourceWalker() == relation.getTargetWalker()) { showSelectedLine(); if (getHost().getRoot().getContents() instanceof ERDiagramEditPart) { // TODO ymd ここを通るケースを確認できず。消すかもしれない。 final ERDiagramEditPart diagramEditPart = (ERDiagramEditPart) getHost().getRoot().getContents(); diagramEditPart.refreshVisuals(); } final List<BendpointMoveHandle> list = new ArrayList<>(); list.add(new BendpointMoveHandle((ConnectionEditPart) getHost(), 1, 2)); return list; } return super.createSelectionHandles(); }
@Override public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) { Object model = connection.getModel(); if (model instanceof BinaryTemporalConstraint) { BinaryTemporalConstraint r = (BinaryTemporalConstraint) model; return new TimepointConnectionAnchor(r.getPointA().getEndpoint(), getFigure()); } else if (model instanceof TemporalChainLink) { return new TimepointConnectionAnchor(Timepoint.END, getFigure()); } else if (model instanceof TemporalBoundLink) { PeriodicTemporalConstraint b = ((TemporalBoundLink)model).getTarget(); return new TimepointConnectionAnchor(b.getPoint().getEndpoint(), getFigure()); } return null; }
/** * {@inheritDoc} */ public ConnectionAnchor getSourceConnectionAnchor( ConnectionEditPart editPart) { // if (!(editPart instanceof RelationEditPart)) { // return super.getSourceConnectionAnchor(editPart); // } ConnectionElement connection = (ConnectionElement) editPart.getModel(); Rectangle bounds = this.getFigure().getBounds(); XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure()); if (connection.getSourceXp() != -1 && connection.getSourceYp() != -1) { anchor.setLocation(new Point(bounds.x + (bounds.width * connection.getSourceXp() / 100), bounds.y + (bounds.height * connection.getSourceYp() / 100))); } return anchor; }
/** * {@inheritDoc} */ public ConnectionAnchor getTargetConnectionAnchor( ConnectionEditPart editPart) { // if (!(editPart instanceof RelationEditPart)) { // return new ChopboxAnchor(this.getFigure()); // } ConnectionElement connection = (ConnectionElement) editPart.getModel(); XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure()); Rectangle bounds = this.getFigure().getBounds(); if (connection.getTargetXp() != -1 && connection.getTargetYp() != -1) { anchor.setLocation(new Point(bounds.x + (bounds.width * connection.getTargetXp() / 100), bounds.y + (bounds.height * connection.getTargetYp() / 100))); } return anchor; }
/** * Given a connection on a node, this method finds the next (or the * previous) connection of that node. * * @param node * The EditPart whose connections are being traversed * @param current * The connection relative to which the next connection has to be * found * @param forward * <code>true</code> if the next connection has to be found; * false otherwise */ ConnectionEditPart findConnection(GraphicalEditPart node, ConnectionEditPart current, boolean forward) { List connections = new ArrayList(node.getSourceConnections()); connections.addAll(node.getTargetConnections()); connections = getValidNavigationTargets(connections); if (connections.isEmpty()) return null; if (forward) counter++; else counter--; while (counter < 0) counter += connections.size(); counter %= connections.size(); return (ConnectionEditPart) connections.get(counter % connections.size()); }
@Override public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection) { // source for a found message if (connection instanceof InitiatorMessageEditPart) { return new ChopboxAnchor(getFigure()) { @Override public Point getLocation(final Point reference) { final Rectangle bounds = Rectangle.SINGLETON; bounds.setBounds(getBox()); getOwner().translateToAbsolute(bounds); final Point result = bounds.getTopLeft(); result.y = reference.y; return result; } }; } throw new IllegalArgumentException("Unsupported connection: " + connection); }
@Override public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection) { // target for a lost message if (connection instanceof TerminatorMessageEditPart) { return new ChopboxAnchor(getFigure()) { @Override public Point getLocation(final Point reference) { final Rectangle bounds = Rectangle.SINGLETON; bounds.setBounds(getBox()); getOwner().translateToAbsolute(bounds); final Point result = bounds.getBottomLeft(); // bounds.getTopRight(); result.y = reference.y; return result; } }; } throw new IllegalArgumentException("Unsupported connection: " + connection); }
@Override public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection) { final Message message = (Message) connection.getModel(); // this execution can be the source for multiple initiators if (connection instanceof InitiatorMessageEditPart) { return new MethodCallSourceConnectionAnchor(); } // this execution can be the source for at most one terminator else if (connection instanceof TerminatorMessageEditPart) { if (message.kind() == MessageKind.MK_LOST_BROKEN) { return new MethodBrokenReturnConnectionAnchor(message); } return new MethodReturnSourceConnectionAnchor(); } throw new IllegalArgumentException("Unsupported connection: " + connection); }
@Override public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection) { final Message message = (Message) connection.getModel(); // this execution can be the target for one initiator if (connection instanceof InitiatorMessageEditPart) { if (message.kind() == MessageKind.MK_FOUND_BROKEN) { return new MethodBrokenCallTargetConnectionAnchor(message); } return new MethodCallTargetConnectionAnchor(); } // this execution can be the target for multiple terminators else if (connection instanceof TerminatorMessageEditPart) { return new MethodReturnTargetConnectionAnchor(); } throw new IllegalArgumentException("Unsupported connection: " + connection); }
/** * Given a connection on a node, this method finds the next (or the * previous) connection of that node. * * @param node * The EditPart whose connections are being traversed * @param current * The connection relative to which the next connection has to be * found * @param forward * <code>true</code> if the next connection has to be found; * false otherwise */ ConnectionEditPart findConnection( GraphicalEditPart node, ConnectionEditPart current, boolean forward ) { List connections = new ArrayList( node.getSourceConnections( ) ); connections.addAll( node.getTargetConnections( ) ); if ( connections.isEmpty( ) ) return null; if ( forward ) counter++; else counter--; while ( counter < 0 ) counter += connections.size( ); counter %= connections.size( ); return (ConnectionEditPart) connections.get( counter % connections.size( ) ); }
public Class mapType(Object object) { if (object instanceof LabelEditPart) { LabelEditPart labelEditPart = (LabelEditPart) object; if (labelEditPart instanceof ConditionEditPart) return mapType(labelEditPart.getModelObj()); if(labelEditPart instanceof ConnectionEditPart) return mapType(labelEditPart.getModelObj()); if (labelEditPart.getModelObj().eContainer() != null) return labelEditPart.getModelObj().eContainer().getClass(); } if (object instanceof LinkRefEditPart) { LinkRefEditPart linkRefEditPart = (LinkRefEditPart) object; return linkRefEditPart.getLinkRef().getLink().getClass(); } else if (object instanceof EditPart) { if (((EditPart)object).getModel() == null) return object.getClass(); // bug 818 - rare but just to avoid errors - deleted items for which properties are shown else return ((EditPart) object).getModel().getClass(); } else if (object instanceof EObject) { return ((EObject) object).getClass(); } return super.mapType(object); }
@Override public ConnectionAnchor getSourceConnectionAnchor( ConnectionEditPart connection) { Link wire = (Link) connection.getModel(); return getComponentFigure().getConnectionAnchor( wire.getSourceTerminal()); }
@Override public ConnectionAnchor getTargetConnectionAnchor( ConnectionEditPart connection) { Link wire = (Link) connection.getModel(); return getComponentFigure().getConnectionAnchor( wire.getTargetTerminal()); }
@Override protected List<Object> createSelectionHandles(){ List<Object> list = new ArrayList<Object>(); list.add(new ConnectionEndpointHandle((ConnectionEditPart) getHost(), ConnectionLocator.SOURCE)); return list; }
@Override public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) { if(!figure.isVisible()){ return null; } return ((DwParentChildConnectionFigure)getFigure()).getAnchor(); }
@Override public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) { if(!figure.isVisible()){ return null; } return ((DwParentChildConnectionFigure)getFigure()).getAnchor(); }
private List<NormalColumn> getSelectedReferencedColulmnList() { final List<NormalColumn> referencedColulmnList = new ArrayList<NormalColumn>(); final TableViewEditPart parent = (TableViewEditPart) getParent(); final TableView tableView = (TableView) parent.getModel(); for (final Object object : parent.getSourceConnections()) { final ConnectionEditPart connectionEditPart = (ConnectionEditPart) object; final int selected = connectionEditPart.getSelected(); if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) { final ConnectionElement connectionElement = (ConnectionElement) connectionEditPart.getModel(); if (connectionElement instanceof Relation) { final Relation relation = (Relation) connectionElement; if (relation.isReferenceForPK()) { referencedColulmnList.addAll(((ERTable) tableView).getPrimaryKeys()); } else if (relation.getReferencedComplexUniqueKey() != null) { referencedColulmnList.addAll(relation.getReferencedComplexUniqueKey().getColumnList()); } else { referencedColulmnList.add(relation.getReferencedColumn()); } } } } return referencedColulmnList; }
/** * {@inheritDoc} */ @Override protected Command getMoveBendpointCommand(final BendpointRequest bendpointrequest) { final ConnectionEditPart editPart = (ConnectionEditPart) getHost(); final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final MoveBendpointCommand command = new MoveBendpointCommand(editPart, point.x, point.y, bendpointrequest.getIndex()); return command; }
private List<NormalColumn> getSelectedReferencedColulmnList() { List<NormalColumn> referencedColulmnList = new ArrayList<NormalColumn>(); TableViewEditPart parent = (TableViewEditPart) this.getParent(); TableView tableView = (TableView) parent.getModel(); for (Object object : parent.getSourceConnections()) { ConnectionEditPart connectionEditPart = (ConnectionEditPart) object; int selected = connectionEditPart.getSelected(); if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) { ConnectionElement connectionElement = (ConnectionElement) connectionEditPart .getModel(); if (connectionElement instanceof Relation) { Relation relation = (Relation) connectionElement; if (relation.isReferenceForPK()) { referencedColulmnList.addAll(((ERTable) tableView) .getPrimaryKeys()); } else if (relation.getReferencedComplexUniqueKey() != null) { referencedColulmnList.addAll(relation .getReferencedComplexUniqueKey() .getColumnList()); } else { referencedColulmnList.add(relation .getReferencedColumn()); } } } } return referencedColulmnList; }
public MoveBendpointCommand(ERDiagram diagram, ConnectionEditPart editPart, int x, int y, int index) { this.targetCategory = diagram.getCurrentCategory(); this.editPart = editPart; this.bendPoint = new Bendpoint(x, y); this.index = index; }
/** * {@inheritDoc} */ @Override protected Command getMoveBendpointCommand(BendpointRequest bendpointrequest) { ConnectionEditPart editPart = (ConnectionEditPart) this.getHost(); Point point = bendpointrequest.getLocation(); this.getConnection().translateToRelative(point); MoveBendpointCommand command = new MoveBendpointCommand( diagram, editPart, point.x, point.y, bendpointrequest.getIndex()); return command; }