Пример #1
0
  @Override
  public void selfStyleNode(Object element, GraphNode node) {
    if (element == focusObject) {
      node.setBackgroundColor(FOCUS_COLOR);
    }

    node.setHighlightColor(getNodeHighlightColor(element));
    node.setTooltip(getTooltip(element));
  }
  @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;
  }