public PictogramElement add(IAddContext context) { IAddConnectionContext addConContext = (IAddConnectionContext) context; EActionLink addedEReference = (EActionLink) context.getNewObject(); IPeCreateService peCreateService = Graphiti.getPeCreateService(); // CONNECTION WITH POLYLINE Connection connection = peCreateService.createFreeFormConnection(getDiagram()); connection.setStart(addConContext.getSourceAnchor()); connection.setEnd(addConContext.getTargetAnchor()); IGaService gaService = Graphiti.getGaService(); Polyline polyline = gaService.createPolyline(connection); polyline.setLineWidth(3); polyline.setForeground(manageColor(IColorConstant.LIGHT_ORANGE)); // create link and wire it link(connection, addedEReference); // add dynamic text decorator for the association name ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true); Text text = gaService.createText(textDecorator); // createDefaultText(textDecorator); text.setForeground(manageColor(IColorConstant.BLACK)); gaService.setLocation(text, 10, 0); text.setValue("has the action"); return connection; }
@Override public PictogramElement add(IAddContext context) { IAddConnectionContext addConContext = (IAddConnectionContext) context; IPeCreateService peCreateService = Graphiti.getPeCreateService(); IGaService gaService = Graphiti.getGaService(); Connection connection = peCreateService.createFreeFormConnection(getDiagram()); connection.setStart(addConContext.getSourceAnchor()); connection.setEnd(addConContext.getTargetAnchor()); Polyline polyline = gaService.createPlainPolyline(connection); polyline.setForeground(manageColor(IColorConstant.BLACK)); // TODO: enable the link to the domain object // Object addedDomainObjectConnection = context.getNewObject(); // link(connection, addedDomainObjectConnection); return connection; }
@Override public PictogramElement add(IAddContext context) { // TODO Auto-generated method stub IAddConnectionContext addConContext = (IAddConnectionContext) context; AdviceEdge edge = (AdviceEdge) context.getNewObject(); IPeCreateService peCreateService = Graphiti.getPeCreateService(); Connection connection = peCreateService.createFreeFormConnection(getDiagram()); connection.setStart(addConContext.getSourceAnchor()); connection.setEnd(addConContext.getTargetAnchor()); IGaService gaService = Graphiti.getGaService(); Polyline polyline = gaService.createPlainPolyline(connection); polyline.setStyle(StyleUtil.getStyleForElement(getDiagram())); polyline.setLineStyle(LineStyle.DOT); link(connection, edge); // add dynamic text decorator for the reference name ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true); Text text = gaService.createPlainText(textDecorator); text.setStyle(StyleUtil.getStyleForTextDecorator((getDiagram()))); gaService.setLocation(text, 10, 0); text.setValue(edge.getAdvicetype().toString()); ConnectionDecorator cd; cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true); int[] xy = {getPointCutR() * 2, 0, 0, -getPointCutR() * 2, 0, 0, 0, getPointCutR() * 2}; Polygon polygon = Graphiti.getGaCreateService().createPolygon(cd, xy); polygon.setStyle(StyleUtil.getStyleForElement(getDiagram())); polygon.setLineStyle(LineStyle.DOT); return connection; }