@Override public void selfStyleConnection(Object element, GraphConnection connection) { // Connections are not rendered in some cases when curved // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=373199 // Seems to be fixed connection.setLineWidth(0); connection.setTooltip(getTooltip(element)); connection.setLineColor(ColorConstants.black); PolylineConnection conn = (PolylineConnection) connection.getConnectionFigure(); if (element instanceof ISpecialisationRelationship) { conn.setTargetDecoration(SpecialisationConnectionFigure.createFigureTargetDecoration()); } else if (element instanceof ICompositionRelationship) { conn.setSourceDecoration(CompositionConnectionFigure.createFigureSourceDecoration()); } else if (element instanceof IAggregationRelationship) { conn.setSourceDecoration(AggregationConnectionFigure.createFigureSourceDecoration()); } else if (element instanceof IAssignmentRelationship) { conn.setSourceDecoration(AssignmentConnectionFigure.createFigureSourceDecoration()); conn.setTargetDecoration(AssignmentConnectionFigure.createFigureTargetDecoration()); } else if (element instanceof IRealisationRelationship) { conn.setTargetDecoration(RealisationConnectionFigure.createFigureTargetDecoration()); connection.setLineStyle(SWT.LINE_CUSTOM); conn.setLineDash(new float[] {4}); } else if (element instanceof ITriggeringRelationship) { conn.setTargetDecoration(TriggeringConnectionFigure.createFigureTargetDecoration()); } else if (element instanceof IFlowRelationship) { conn.setTargetDecoration(FlowConnectionFigure.createFigureTargetDecoration()); connection.setLineStyle(SWT.LINE_CUSTOM); conn.setLineDash(new float[] {6, 3}); } else if (element instanceof IUsedByRelationship) { conn.setTargetDecoration(UsedByConnectionFigure.createFigureTargetDecoration()); } else if (element instanceof IAccessRelationship) { conn.setTargetDecoration(AccessConnectionFigure.createFigureSourceDecoration()); conn.setTargetDecoration(AccessConnectionFigure.createFigureTargetDecoration()); connection.setLineStyle(SWT.LINE_CUSTOM); conn.setLineDash(new float[] {1.5f, 3}); } else if (element instanceof IInfluenceRelationship) { conn.setTargetDecoration(InfluenceConnectionFigure.createFigureTargetDecoration()); connection.setLineStyle(SWT.LINE_CUSTOM); conn.setLineDash(new float[] {6, 3}); } conn.setAntialias(SWT.ON); }
@Override protected Control createDialogArea(Composite parent) { // toolkit = new FormToolkit(parent.getDisplay()); // form = toolkit.createScrolledForm(parent); // form.setText("Dependency Graph UI Legend"); // form.getToolBarManager().add(new Action("Close Dialog", MavenEditorImages.CLEAR) { // public void run() { // close(); // } // }); // form.getToolBarManager().update(true); // form.getBody().setLayout(new TableWrapLayout()); // toolkit.decorateFormHeading(form.getForm()); Graph g = new Graph(parent, SWT.NONE) { public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed) { return new org.eclipse.swt.graphics.Point(260, 300); } }; g.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED); g.setEnabled(false); { GraphNode n1 = new GraphNode(g, SWT.NONE, " compile scope dependency "); n1.setLocation(10, 10); n1.setSize(240, 25); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " non-compile scope dependency "); n1.setLocation(10, 40); n1.setSize(240, 25); n1.setBackgroundColor(colorTestBackground); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " selected dependency "); n1.setLocation(10, 70); n1.setSize(240, 25); n1.setBackgroundColor(colorSelectedBackground); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " selected non-compile "); n1.setLocation(10, 100); n1.setSize(240, 25); n1.setBackgroundColor(colorSelectedTestBackground); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " "); GraphNode n2 = new GraphNode(g, SWT.NONE, " "); DependencyConnection c1 = new DependencyConnection(g, SWT.NONE, n1, n2); c1.setText("compile scope"); c1.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED | ZestStyles.CONNECTIONS_SOLID); n1.setLocation(10, 140); n2.setLocation(220, 140); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " "); GraphNode n2 = new GraphNode(g, SWT.NONE, " "); n2.setBackgroundColor(colorTestBackground); GraphConnection c1 = new DependencyConnection(g, SWT.NONE, n1, n2); c1.setText("non-compile scope"); c1.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED | ZestStyles.CONNECTIONS_DOT); c1.setLineColor(colorTestRel); n1.setLocation(10, 170); n2.setLocation(220, 170); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " "); GraphNode n2 = new GraphNode(g, SWT.NONE, " "); GraphConnection c1 = new DependencyConnection(g, SWT.NONE, n1, n2); c1.setText("resolved conflict"); c1.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED | ZestStyles.CONNECTIONS_SOLID); c1.setLineColor(colorRelResolved); n1.setLocation(10, 200); n2.setLocation(220, 200); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " "); GraphNode n2 = new GraphNode(g, SWT.NONE, " "); n2.setBackgroundColor(colorSelectedBackground); GraphConnection c1 = new DependencyConnection(g, SWT.NONE, n1, n2); c1.setText("referenced from selected"); c1.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED | ZestStyles.CONNECTIONS_SOLID); c1.setLineColor(highlighted); c1.setLineWidth(3); n1.setLocation(10, 230); n2.setLocation(220, 230); } { GraphNode n1 = new GraphNode(g, SWT.NONE, " "); GraphNode n2 = new GraphNode(g, SWT.NONE, " "); n2.setBackgroundColor(colorSelectedTestBackground); GraphConnection c1 = new DependencyConnection(g, SWT.NONE, n1, n2); c1.setText("referenced from non-compile"); c1.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED | ZestStyles.CONNECTIONS_DOT); c1.setLineColor(highlighted); c1.setLineWidth(3); n1.setLocation(10, 260); n2.setLocation(220, 260); } g.addFocusListener( new FocusAdapter() { public void focusLost(FocusEvent e) { close(); } }); return parent; }