public SourceFilesLabelProvider(SourceFilesViewer viewer) {
    super(new CElementLabelProvider());
    this.viewer = viewer;

    // brute-force clear the cache when executables change
    ExecutablesManager.getExecutablesManager().addExecutablesChangeListener(this);
    viewer
        .getControl()
        .addDisposeListener(
            new DisposeListener() {
              @Override
              public void widgetDisposed(DisposeEvent e) {
                ExecutablesManager.getExecutablesManager()
                    .removeExecutablesChangeListener(SourceFilesLabelProvider.this);
              }
            });
  }
Exemple #2
0
  public ExecutablesViewer(ExecutablesView executablesView, Composite parent, int style) {
    super(executablesView, parent, style);

    // Setup D&D support
    int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT;
    Transfer[] transfers = new Transfer[] {FileTransfer.getInstance()};
    ExecutablesDropAdapter adapter = new ExecutablesDropAdapter(this);
    adapter.setFeedbackEnabled(false);
    addDropSupport(ops | DND.DROP_DEFAULT, transfers, adapter);

    // Setup content provider
    ExecutablesContentProvider exeContentProvider = new ExecutablesContentProvider(this);
    setContentProvider(exeContentProvider);
    setLabelProvider(exeContentProvider);

    getTree().setHeaderVisible(true);
    getTree().setLinesVisible(true);
    executablesView.getSite().setSelectionProvider(this);
    getTree().setData(".uid", "ExecutablesViewerTree"); // $NON-NLS-1$ //$NON-NLS-2$

    createColumns();

    setInput(ExecutablesManager.getExecutablesManager());

    MenuManager popupMenuManager = new MenuManager("#PopupMenu"); // $NON-NLS-1$
    IMenuListener listener =
        new IMenuListener() {
          @Override
          public void menuAboutToShow(IMenuManager manager) {
            manager.add(ExecutablesViewer.this.getExecutablesView().refreshAction);
            manager.add(ExecutablesViewer.this.getExecutablesView().importAction);
            manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
          }
        };
    popupMenuManager.addMenuListener(listener);
    popupMenuManager.setRemoveAllWhenShown(true);
    getExecutablesView()
        .getSite()
        .registerContextMenu(
            popupMenuManager, this.getExecutablesView().getSite().getSelectionProvider());
    Menu menu = popupMenuManager.createContextMenu(getTree());
    getTree().setMenu(menu);
  }