Exemplo n.º 1
0
  public void save_Event() {
    FileDialog fd = new FileDialog(ZestDebuggerView.this.getSite().getShell(), SWT.SAVE);
    fd.setText("Save");
    fd.setFilterPath("C:/");
    String[] filterExt = {"*.jpg"};
    fd.setFilterExtensions(filterExt);
    String selected = fd.open();
    System.out.println(selected);

    if (selected != null) {
      GC gc = new GC(viewer.getControl());
      org.eclipse.swt.graphics.Rectangle bounds = viewer.getControl().getBounds();

      Image image = new Image(viewer.getControl().getDisplay(), bounds);
      try {
        gc.copyArea(image, 0, 0);
        ImageLoader imageLoader = new ImageLoader();
        imageLoader.data = new ImageData[] {image.getImageData()};
        imageLoader.save(selected, SWT.IMAGE_JPEG);
        MessageDialog.openInformation(
            ZestDebuggerView.this.getSite().getShell(),
            "Success",
            "The image has been saved successfully");
      } catch (Exception e) {
        e.printStackTrace();
        MessageDialog.openError(
            ZestDebuggerView.this.getSite().getShell(), "Failure", "The image can't be saved");
      } finally {
        image.dispose();
        gc.dispose();
      }
    }
  }
Exemplo n.º 2
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;
                }
              }
            }
          }
        });
  }
Exemplo n.º 3
0
  @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");
  }
Exemplo n.º 4
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);
 }
 @SuppressWarnings("restriction")
 private void updateViewer(ModelManagerEvent event) {
   // Use the setRedraw method to reduce flicker
   // when adding or removing multiple items in a table.
   viewer.getGraphControl().setRedraw(false);
   try {
     for (IChange change : event.getNewChanges()) {
       viewer.addNode((Change) change);
     }
   } finally {
     viewer.getGraphControl().setRedraw(true);
     viewer.refresh();
     viewer.applyLayout();
   }
 }
 public void updateAndRefresh() {
   viewer.refresh();
   viewer.applyLayout();
 }
 @Override
 public void refresh() {
   viewer.refresh();
 }
Exemplo n.º 8
0
 @Override
 public void setFocus() {
   viewer.getControl().setFocus();
 }