Example #1
0
  public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout());
    parent.addControlListener(
        new ControlListener() {
          public void controlResized(ControlEvent e) {
            viewer.applyLayout();
          }

          public void controlMoved(ControlEvent e) {}
        });
    viewer = new GraphViewer(parent, SWT.NONE);
    viewer.setContentProvider(new XLogFlowContentProvider());
    viewer.setLabelProvider(new XLogFlowLabelProvider());
    viewer.setLayoutAlgorithm(
        new HorizontalTreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            if (sel.getFirstElement() instanceof XLogConnection) {
              XLogData d = ((XLogConnection) sel.getFirstElement()).destXlog;
              String date = DateUtil.yyyymmdd(d.p.endTime);
              ArrayList<AgentObject> objList = agentProxy.getObjectList(date, d.serverId);
              for (AgentObject obj : objList) {
                if (obj.getObjHash() == d.p.objHash) {
                  new OpenXLogProfileJob(
                          XLogCallView.this.getViewSite().getShell().getDisplay(), d, d.serverId)
                      .schedule();
                  break;
                }
              }
            }
          }
        });
  }
  @Override
  public void createPartControl(Composite parent) {
    viewer = new GraphViewer(parent, SWT.NONE);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setInput(getViewSite());
    viewer.setLayoutAlgorithm(new TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
    ResourcesPlugin.getWorkspace()
        .addResourceChangeListener(
            new IResourceChangeListener() {
              public void resourceChanged(IResourceChangeEvent event) {
                Display.getDefault()
                    .asyncExec(
                        new Runnable() {
                          public void run() {
                            viewer.refresh();
                            viewer.applyLayout();
                          }
                        });
              }
            });
    getSite().setSelectionProvider(viewer);

    // Create the help context id for the viewer's control
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(viewer.getControl(), "com.javadude.dependencies2.viewer");
  }
Example #3
0
 private void testWith(IGraphContentProvider contentProvider) {
   viewer.setContentProvider(contentProvider);
   viewer.setLabelProvider(new CustomLabelProvider());
   viewer.setInput(new Object());
   StringBuffer buffer = new StringBuffer();
   for (int i = 0; i < viewer.getGraphControl().getNodes().size(); i++) {
     CGraphNode n = (CGraphNode) viewer.getGraphControl().getNodes().get(i);
     buffer.append(((Label) n.getNodeFigure().getChildren().get(0)).getText());
   }
   String string = buffer.toString();
   assertTrue("Label 1 should be in figure labels", string.indexOf("1") >= 0);
   assertTrue("Label 2 should be in figure labels", string.indexOf("2") >= 0);
   assertTrue("Label 3 should be in figure labels", string.indexOf("3") >= 0);
 }