예제 #1
0
  private void hookContextMenu() {
    activeTaskSelectionProvider = new SelectionProviderAdapter();

    actionGroup = new RepositoryElementActionGroup();
    actionGroup.setSelectionProvider(activeTaskSelectionProvider);

    menuManager = new MenuManager("#PopupMenu"); // $NON-NLS-1$
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(
        new IMenuListener() {
          public void menuAboutToShow(IMenuManager manager) {
            actionGroup.fillContextMenu(manager);
            // trims do not have a workbench part so there is no simple way of registering the
            // context menu
            ObjectActionContributorManager.getManager()
                .contributeObjectActions(null, manager, activeTaskSelectionProvider);
          }
        });
  }
예제 #2
0
  @Override
  public void dispose() {
    if (composite != null && !composite.isDisposed()) {
      composite.dispose();
    }
    composite = null;

    if (menuManager != null) {
      menuManager.removeAll();
      menuManager.dispose();
    }
    menuManager = null;

    if (menu != null && !menu.isDisposed()) {
      menu.dispose();
    }
    menu = null;

    actionGroup.setSelectionProvider(null);

    TasksUi.getTaskActivityManager().removeActivationListener(taskActivationListener);
    TasksUiPlugin.getTaskList().removeChangeListener(taskListListener);
  }