org.eclipse.gef.editparts.AbstractConnectionEditPart Java Examples
The following examples show how to use
org.eclipse.gef.editparts.AbstractConnectionEditPart.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CrossflowValidationDecoratorProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public void createDecorators(IDecoratorTarget decoratorTarget) { EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) { Object model = editPart.getModel(); if ((model instanceof View)) { View view = (View) model; if (!(view instanceof Edge) && !view.isSetElement()) { return; } } EditDomain ed = editPart.getViewer().getEditDomain(); if (!(ed instanceof DiagramEditDomain)) { return; } if (((DiagramEditDomain) ed).getEditorPart() instanceof CrossflowDiagramEditor) { decoratorTarget.installDecorator(KEY, new StatusDecorator(decoratorTarget)); } } }
Example #2
Source File: ERDiagramBendpointEditPolicy.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected Command getCreateBendpointCommand(final BendpointRequest bendpointrequest) { final AbstractConnectionEditPart connectionEditPart = (AbstractConnectionEditPart) getHost(); final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel(); if (connection.getSource() == connection.getTarget()) { return null; } final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final CreateBendpointCommand createBendpointCommand = new CreateBendpointCommand(connection, point.x, point.y, bendpointrequest.getIndex()); return createBendpointCommand; }
Example #3
Source File: ERDiagramBendpointEditPolicy.java From erflute with Apache License 2.0 | 6 votes |
@Override protected Command getCreateBendpointCommand(BendpointRequest bendpointrequest) { final AbstractConnectionEditPart connectionEditPart = (AbstractConnectionEditPart) getHost(); final WalkerConnection connection = (WalkerConnection) connectionEditPart.getModel(); if (connection.getSourceWalker() == connection.getTargetWalker()) { return null; } final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final CreateBendpointCommand createBendpointCommand = new CreateBendpointCommand(connection, point.x, point.y, bendpointrequest.getIndex()); return createBendpointCommand; }
Example #4
Source File: UpdateSizePoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private ShapeNodeEditPart findPoolEditPart(EditPart host) { EditPart result = host ; if(host instanceof SequenceFlowEditPart){ result = ((AbstractConnectionEditPart) host).getSource(); } if(host instanceof MessageFlowEditPart){ result = ((AbstractConnectionEditPart) host).getSource(); } /*first search for a CustomLaneEditPart*/ while(!(result instanceof CustomPoolEditPart) && result != null){ result = result.getParent() ; } if(result == null){ return null ; } return (ShapeNodeEditPart) result; }
Example #5
Source File: ProcessValidationDecoratorProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ public void createDecorators(IDecoratorTarget decoratorTarget) { EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) { Object model = editPart.getModel(); if ((model instanceof View)) { View view = (View) model; if (!(view instanceof Edge) && !view.isSetElement()) { return; } } EditDomain ed = editPart.getViewer().getEditDomain(); if (!(ed instanceof DiagramEditDomain)) { return; } if (((DiagramEditDomain) ed).getEditorPart() instanceof ProcessDiagramEditor) { decoratorTarget.installDecorator(KEY, new StatusDecorator(decoratorTarget)); } } }
Example #6
Source File: ERDiagramBendpointEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected Command getCreateBendpointCommand( BendpointRequest bendpointrequest) { AbstractConnectionEditPart connectionEditPart = (AbstractConnectionEditPart) this .getHost(); ConnectionElement connection = (ConnectionElement) connectionEditPart .getModel(); if (connection.getSource() == connection.getTarget()) { return null; } Point point = bendpointrequest.getLocation(); this.getConnection().translateToRelative(point); CreateBendpointCommand createBendpointCommand = new CreateBendpointCommand( connection, point.x, point.y, bendpointrequest.getIndex()); return createBendpointCommand; }
Example #7
Source File: ExternalXtextLabelEditPart.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void refreshBounds() { int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); int dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Rectangle bounds = new Rectangle(dx, dy, -1, -1); ((AbstractGraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new EdgeLabelLocator( ((AbstractConnectionEditPart) getParent()).getConnectionFigure(), bounds, getKeyPoint())); }
Example #8
Source File: StatechartValidationDecorationProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public void createDecorators(IDecoratorTarget decoratorTarget) { EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); if (editPart instanceof BorderItemEditPart) return; if (editPart instanceof IPrimaryEditPart && (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart)) { EditDomain ed = editPart.getViewer().getEditDomain(); if (!(ed instanceof DiagramEditDomain)) { return; } if (shouldInstall(((DiagramEditDomain) ed).getEditorPart())) { decoratorTarget.installDecorator(getDecoratorKey(), createStatusDecorator(decoratorTarget, issueStore)); } } }
Example #9
Source File: TransitionPriorityDecorationProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void createDecorators(IDecoratorTarget decoratorTarget) { EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) { EditDomain ed = editPart.getViewer().getEditDomain(); if (!(ed instanceof DiagramEditDomain)) { return; } if (shouldInstall(((DiagramEditDomain) ed).getEditorPart()) && editPart instanceof TransitionEditPart) { IDecorator decorator = createStatusDecorator(decoratorTarget); decorators.add(decorator); decoratorTarget.installDecorator(getDecoratorKey(), decorator); } } }
Example #10
Source File: RegionPriorityDecorationProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void createDecorators(IDecoratorTarget decoratorTarget) { EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) { EditDomain ed = editPart.getViewer().getEditDomain(); if (!(ed instanceof DiagramEditDomain)) { return; } if (shouldInstall(((DiagramEditDomain) ed).getEditorPart()) && editPart instanceof RegionEditPart) { IDecorator decorator = createStatusDecorator(decoratorTarget); decorators.add(decorator); decoratorTarget.installDecorator(getDecoratorKey(), decorator); } } }
Example #11
Source File: AbstractMarkerBasedDecorationProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public void createDecorators(IDecoratorTarget decoratorTarget) { EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) { EditDomain ed = editPart.getViewer().getEditDomain(); if (!(ed instanceof DiagramEditDomain)) { return; } if (shouldInstall(((DiagramEditDomain) ed).getEditorPart())) { decoratorTarget.installDecorator(getDecoratorKey(), createStatusDecorator(decoratorTarget)); } } }
Example #12
Source File: CustomPasteCommand.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Compute the relative location of each copied editparts */ private Rectangle computeRelativeLocation(Point newOrigin,IGraphicalEditPart srcPart, List<IGraphicalEditPart> toCopy) { int relativeToPoolY=0; Rectangle newLoc = new Rectangle(newOrigin, new Dimension()) ; newLoc.setY(newLoc.y()+relativeToPoolY); int minX = Integer.MAX_VALUE ; IGraphicalEditPart mostLeftEditPart = null ; for(IGraphicalEditPart parts : toCopy){ if(!(parts instanceof AbstractConnectionEditPart)){ int x =((Location)((Node)parts.getNotationView()).getLayoutConstraint()).getX() ; if(x < minX){ minX = x ; mostLeftEditPart = parts ; } } } if(mostLeftEditPart.equals(srcPart)){ return newLoc; }else{ int referenceX = minX ; int referenceY =((Location)((Node)mostLeftEditPart.getNotationView()).getLayoutConstraint()).getY() ; int toCopyX = ((Location)((Node)srcPart.getNotationView()).getLayoutConstraint()).getX() ; int toCopyY = ((Location)((Node)srcPart.getNotationView()).getLayoutConstraint()).getY() ; newLoc = newLoc.translate(toCopyX-referenceX, toCopyY-referenceY); newLoc.setY(newLoc.y()+relativeToPoolY); return newLoc; } }
Example #13
Source File: ERDiagramLayoutEditPolicy.java From ermasterr with Apache License 2.0 | 4 votes |
public static Command createChangeConstraintCommand(final ERDiagram diagram, final List selectedEditParts, final NodeElementEditPart editPart, final Rectangle rectangle) { try { final NodeElement nodeElement = (NodeElement) editPart.getModel(); final Rectangle currentRectangle = editPart.getFigure().getBounds(); boolean move = false; if (rectangle.width == currentRectangle.width && rectangle.height == currentRectangle.height) { move = true; } boolean nothingToDo = false; if (move && !(editPart instanceof CategoryEditPart)) { for (final Object selectedEditPart : selectedEditParts) { if (selectedEditPart instanceof CategoryEditPart) { final CategoryEditPart categoryEditPart = (CategoryEditPart) selectedEditPart; final Category category = (Category) categoryEditPart.getModel(); if (category.contains(nodeElement)) { nothingToDo = true; } } } } final List<Command> bendpointMoveCommandList = new ArrayList<Command>(); final int oldX = nodeElement.getX(); final int oldY = nodeElement.getY(); final int diffX = rectangle.x - oldX; final int diffY = rectangle.y - oldY; for (final Object obj : editPart.getSourceConnections()) { final AbstractConnectionEditPart connection = (AbstractConnectionEditPart) obj; if (selectedEditParts.contains(connection.getTarget())) { final ConnectionElement connectionElement = (ConnectionElement) connection.getModel(); final List<Bendpoint> bendpointList = connectionElement.getBendpoints(); for (int index = 0; index < bendpointList.size(); index++) { final Bendpoint bendPoint = bendpointList.get(index); if (bendPoint.isRelative()) { break; } final MoveBendpointCommand moveCommand = new MoveBendpointCommand(connection, bendPoint.getX() + diffX, bendPoint.getY() + diffY, index); bendpointMoveCommandList.add(moveCommand); } } } final CompoundCommand compoundCommand = new CompoundCommand(); if (!nothingToDo) { final Command changeConstraintCommand = createChangeConstraintCommandForNodeElement(diagram, selectedEditParts, editPart, rectangle); if (bendpointMoveCommandList.isEmpty()) { return changeConstraintCommand; } compoundCommand.add(changeConstraintCommand); } else { compoundCommand.add(new NothingToDoCommand()); } for (final Command command : bendpointMoveCommandList) { compoundCommand.add(command); } return compoundCommand; } catch (final Exception e) { ERDiagramActivator.log(e); return null; } }