public static void updateDIEdge(Diagram diagram, Connection connection, Class clazz) { try { ModelHandler modelHandler = ModelHandlerLocator.getModelHandler( connection.getLink().getBusinessObjects().get(0).eResource()); EObject be = BusinessObjectUtil.getFirstElementOfType(connection, clazz); BPMNEdge edge = (BPMNEdge) modelHandler.findDIElement(diagram, (BaseElement) be); Point point = DcFactory.eINSTANCE.createPoint(); List<Point> waypoint = edge.getWaypoint(); waypoint.clear(); GraphicsAlgorithm graphicsAlgorithm = connection.getStart().getGraphicsAlgorithm(); // FIXME connections must create anchors!!! if (graphicsAlgorithm != null) { point.setX(graphicsAlgorithm.getX()); point.setY(graphicsAlgorithm.getY()); } else { point.setX(connection.getStart().getParent().getGraphicsAlgorithm().getX()); point.setY(connection.getStart().getParent().getGraphicsAlgorithm().getY()); } waypoint.add(point); if (connection instanceof FreeFormConnectionImpl) { FreeFormConnectionImpl freeForm = (FreeFormConnectionImpl) connection; EList<org.eclipse.graphiti.mm.algorithms.styles.Point> bendpoints = freeForm.getBendpoints(); for (org.eclipse.graphiti.mm.algorithms.styles.Point bp : bendpoints) { addBendPoint(freeForm, point); } } point = DcFactory.eINSTANCE.createPoint(); graphicsAlgorithm = connection.getEnd().getGraphicsAlgorithm(); if (graphicsAlgorithm != null) { point.setX(graphicsAlgorithm.getX()); point.setY(graphicsAlgorithm.getY()); } else { point.setX(connection.getEnd().getParent().getGraphicsAlgorithm().getX()); point.setY(connection.getEnd().getParent().getGraphicsAlgorithm().getY()); } waypoint.add(point); } catch (IOException e) { Activator.logError(e); } }
@Override public Object[] create(ICreateContext context) { String state = Selectstate(BPMNToolBehaviorProvider.id_v); if (state.compareTo("Working") == 0) { SubProcess element = createBusinessObject(context); // if (element instanceof Task) // System.out.println("selectTaskId()"+selectTaskId()); String id = selectTaskId(); element.setId("VA" + id + "-1"); UpdateTaskId(id); if (element != null) { changesDone = true; try { ModelHandler handler = ModelHandler.getInstance(getDiagram()); if (FeatureSupport.isTargetLane(context) && element instanceof FlowNode) { ((FlowNode) element) .getLanes() .add((Lane) getBusinessObjectForPictogramElement(context.getTargetContainer())); } handler.addFlowElement( getBusinessObjectForPictogramElement(context.getTargetContainer()), element); } catch (IOException e) { Activator.logError(e); } PictogramElement pe = null; pe = addGraphicalRepresentation(context, element); return new Object[] {element, pe}; } else changesDone = false; return new Object[] {null}; } else { System.out.println("01102015tttttttttttt"); JOptionPane.showMessageDialog( null, "Operation is not allowed because the version of process " + BPMNToolBehaviorProvider.id_v + " is Stable", "Error", JOptionPane.ERROR_MESSAGE); return new Object[] {null}; } }
private void modifyModelStructure(IMoveShapeContext context) { Lane movedLane = getMovedLane(context); Participant sourceParticipant = (Participant) getBusinessObjectForPictogramElement(context.getSourceContainer()); Participant internalParticipant = null; try { ModelHandler handler = ModelHandler.getInstance(getDiagram()); internalParticipant = handler.getInternalParticipant(); handler.moveLane(movedLane, internalParticipant); } catch (IOException e) { Activator.logError(e); } LaneSet laneSet = null; for (LaneSet set : sourceParticipant.getProcessRef().getLaneSets()) { if (set.getLanes().contains(movedLane)) { laneSet = set; break; } } if (laneSet != null) { laneSet.getLanes().remove(movedLane); if (laneSet.getLanes().isEmpty()) { sourceParticipant.getProcessRef().getLaneSets().remove(laneSet); } Process process = internalParticipant.getProcessRef(); if (process.getLaneSets().isEmpty()) { LaneSet createLaneSet = ModelHandler.FACTORY.createLaneSet(); // createLaneSet.setId(EcoreUtil.generateUUID()); process.getLaneSets().add(createLaneSet); ModelUtil.setID(createLaneSet); } process.getLaneSets().get(0).getLanes().add(movedLane); } }
@Override public Connection create(ICreateConnectionContext context) { try { A source = getSourceBo(context); B target = getTargetBo(context); ModelHandler mh = ModelHandler.getInstance(getDiagram()); AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor()); BaseElement flow = createFlow(mh, source, target); // flow.setId(EcoreUtil.generateUUID()); addContext.setNewObject(flow); Connection connection = (Connection) getFeatureProvider().addIfPossible(addContext); ModelUtil.setID(flow); return connection; } catch (IOException e) { Activator.logError(e); } return null; }