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; }
/** Navigates to the source or target of the currently focused ConnectionEditPart. */ void navigateOutOfConnection(KeyEvent event) { GraphicalEditPart cached = getCachedNode(); ConnectionEditPart conn = (ConnectionEditPart) getFocusEntityPart(); if (cached != null && (cached == conn.getSource() || cached == conn.getTarget())) navigateTo(cached, event); else navigateTo(conn.getSource(), event); }
private Collection<Shape> getConnectionFigures() { EditPart host = getHost(); Collection<Shape> shapes = new ArrayList<Shape>(); if (host instanceof CompositeConnectionEditPart) { Collection<ConnectionEditPart> editParts = ((CompositeConnectionEditPart) host).getEditParts(); for (ConnectionEditPart editPart : editParts) { shapes.add((Shape) editPart.getFigure()); } } else { shapes.add((Shape) ((GraphicalEditPart) getHost()).getFigure()); } return shapes; }
/** * Figure out if a cyclic dependency will arise if target connection edit part is connected to the * source connection edit part. * * @param targetCEP the target connection edit part * @param sourceCEP the source connection edit part * @param checkSourceAndTargetEditParts check both the source and taret edit parts for cyclic * dependencies * @param doNotCheckSourceEditPart (if checkSourceAndTargetEditParts is false) check only the * target edit part if true, otherwise check only the source edit part * @return true if a cyclic dependency would be create when targetCEP and sourceCEP were to be * connected, false otherwise. */ private boolean isCyclicConnectionRequest( org.eclipse.gef.ConnectionEditPart targetCEP, org.eclipse.gef.ConnectionEditPart sourceCEP, boolean checkSourceAndTargetEditParts, boolean doNotCheckSourceEditPart) { if (targetCEP == null || sourceCEP == null) return false; if (sourceCEP == targetCEP) return true; // first, do a cyclic check on source and target connections // of the source connection itself. // (as every connection is also a node). HashSet set = new HashSet(); getSourceAndTargetConnections(set, sourceCEP); if (set.contains(targetCEP.getFigure())) return true; // now do the cyclic check on the source and target of the source connection... EditPart sourceEP = sourceCEP.getSource(), targetEP = sourceCEP.getTarget(); if ((sourceEP == targetCEP) || (targetEP == targetCEP)) { return true; } else { if (!checkSourceAndTargetEditParts && doNotCheckSourceEditPart) { // . } else if (sourceEP instanceof org.eclipse.gef.ConnectionEditPart && isCyclicConnectionRequest( targetCEP, (org.eclipse.gef.ConnectionEditPart) sourceEP, true, doNotCheckSourceEditPart)) return true; if (!checkSourceAndTargetEditParts && !doNotCheckSourceEditPart) { // . } else if (targetEP instanceof org.eclipse.gef.ConnectionEditPart && isCyclicConnectionRequest( targetCEP, (org.eclipse.gef.ConnectionEditPart) targetEP, true, doNotCheckSourceEditPart)) return true; } return false; }
/** This method navigates through connections based on the keys pressed. */ void navigateConnections(KeyEvent event) { GraphicalEditPart focus = (GraphicalEditPart) getFocusEntityPart(); ConnectionEditPart current = null; GraphicalEditPart node = getCachedNode(); if (focus instanceof ConnectionEditPart) { current = (ConnectionEditPart) focus; if (node == null || (node != current.getSource() && node != current.getTarget())) { node = (GraphicalEditPart) current.getSource(); counter = 0; } } else { node = focus; } setCachedNode(node); boolean forward = event.character == '/' || event.character == '?'; ConnectionEditPart next = findConnection(node, current, forward); navigateTo(next, event); }
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; }
@Override public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) { // handle reconnections if (connection != null) { if (connection.getSource() != null && connection.getTarget() != null) { if (connection.getSource().equals(connection.getTarget())) { return new ReconnectionTargetAnchor(getFigure()); } } } if (((WorkflowNode) getModel()) .getComponentDescription() .getComponentInstallation() .getComponentRevision() .getComponentInterface() .getShape() == ComponentShape.CIRCLE) { return new EllipseAnchor(getFigure()); } else { return new ChopboxAnchor(getFigure()); } }
/** @generated */ protected Command getReconnectSourceCommand(ReconnectRequest request) { ConnectionEditPart connection = request.getConnectionEditPart(); if (connection.getModel() instanceof Edge == false) { return null; } Edge edge = (Edge) connection.getModel(); String modelID = ImaginDataVisualIDRegistry.getModelID(edge); if (!DiagramEditPart.MODEL_ID.equals(modelID)) { return null; } org.eclipse.emf.common.command.Command result = null; int visualID = ImaginDataVisualIDRegistry.getVisualID(edge); switch (visualID) { case TransitionEditPart.VISUAL_ID: result = new ReconnectTransition4001SourceCommand(request); break; } if (result == null || !result.canExecute()) { return null; } return new WrappingCommand( TransactionUtil.getEditingDomain(((Node) getHost().getModel()).getDiagram().getElement()), result); }
/** * Retrieve the list of all source and target connections for the connection. * * @param set HashSet to add the connections to. * @param connectionEditPart the connection edit part. */ private void getSourceAndTargetConnections( HashSet set, org.eclipse.gef.ConnectionEditPart connectionEditPart) { if (connectionEditPart == null || set == null) return; for (Iterator i = connectionEditPart.getSourceConnections().iterator(); i.hasNext(); ) { org.eclipse.gef.ConnectionEditPart next = (org.eclipse.gef.ConnectionEditPart) i.next(); Connection sourceConnection = (Connection) next.getFigure(); set.add(sourceConnection); getSourceAndTargetConnections(set, next); } for (Iterator i = connectionEditPart.getTargetConnections().iterator(); i.hasNext(); ) { org.eclipse.gef.ConnectionEditPart next = (org.eclipse.gef.ConnectionEditPart) i.next(); Connection targetConnection = (Connection) next.getFigure(); set.add(targetConnection); getSourceAndTargetConnections(set, next); } }
@Override public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) { if (anchorMap == null) fillAnchorMap(); ConnectionModel conn = (ConnectionModel) connection.getModel(); return anchorMap.get(conn.getTargetTerminal()); }
/** Gets the remote figure. */ private void updateRemoteFig() { // CreateConnectionRequest needs to refresh fRemoteFig each time switch (fAnchorType) { case CRCONREQ_SRC: fRemoteFig = (((CreateConnectionRequest) fRequest).getTargetEditPart() != null) ? ((GraphicalEditPart) ((CreateConnectionRequest) fRequest).getTargetEditPart()) .getFigure() : null; break; case CRCONREQ_TGT: fRemoteFig = (((CreateConnectionRequest) fRequest).getSourceEditPart() != null) ? ((GraphicalEditPart) ((CreateConnectionRequest) fRequest).getSourceEditPart()) .getFigure() : null; break; } // The other cases can be cached if (fRemoteFig != null) { return; } switch (fAnchorType) { case CONNECTION_SRC: fRemoteFig = ((GraphicalEditPart) fAnchorConnection.getTarget()).getFigure(); break; case CONNECTION_TGT: fRemoteFig = ((GraphicalEditPart) fAnchorConnection.getSource()).getFigure(); break; case RECONREQ_SRC: fRemoteFig = (((ReconnectRequest) fRequest).getConnectionEditPart().getTarget() != null) ? ((GraphicalEditPart) ((ReconnectRequest) fRequest).getConnectionEditPart().getTarget()) .getFigure() : null; if (((Connection) ((ReconnectRequest) fRequest).getConnectionEditPart().getFigure()) .getTargetAnchor() instanceof OrthogonalAnchor) ((OrthogonalAnchor) ((Connection) ((ReconnectRequest) fRequest).getConnectionEditPart().getFigure()) .getTargetAnchor()) .setAlternateRemoteFig(getOwner()); break; case RECONREQ_TGT: fRemoteFig = (((ReconnectRequest) fRequest).getConnectionEditPart().getSource() != null) ? ((GraphicalEditPart) ((ReconnectRequest) fRequest).getConnectionEditPart().getSource()) .getFigure() : null; if (((Connection) ((ReconnectRequest) fRequest).getConnectionEditPart().getFigure()) .getSourceAnchor() instanceof OrthogonalAnchor) ((OrthogonalAnchor) ((Connection) ((ReconnectRequest) fRequest).getConnectionEditPart().getFigure()) .getSourceAnchor()) .setAlternateRemoteFig(getOwner()); break; } }