private void init(IMemento memento) {

    updateActionBars = new UpdateActionBarsJob(commonNavigator.getTitle());

    CommonViewer commonViewer = commonNavigator.getCommonViewer();
    commonViewer.addSelectionChangedListener(this);
    commonViewer.addPostSelectionChangedListener(statusBarListener);
    updateStatusBar(commonViewer.getSelection());

    ICommonViewerSite commonViewerSite =
        CommonViewerSiteFactory.createCommonViewerSite(commonNavigator.getViewSite());
    actionService =
        new NavigatorActionService(
            commonViewerSite, commonViewer, commonViewer.getNavigatorContentService());

    final RetargetAction openAction =
        new RetargetAction(ICommonActionConstants.OPEN, CommonNavigatorMessages.Open_action_label);
    commonNavigator.getViewSite().getPage().addPartListener(openAction);
    openAction.setActionDefinitionId(ICommonActionConstants.OPEN);
    //		RAP [bmichalik]: help system
    //		new OpenAndLinkWithEditorHelper(commonNavigator.getCommonViewer()) {
    //			protected void activate(ISelection selection) {
    //				final int currentMode = OpenStrategy.getOpenMethod();
    //				try {
    //					/*
    //					 * XXX:
    //					 * Currently the only way to activate the editor because there is no API to
    //					 * get an editor input for a given object.
    //					 */
    //					OpenStrategy.setOpenMethod(OpenStrategy.DOUBLE_CLICK);
    //					actionService.setContext(new
    // ActionContext(commonNavigator.getCommonViewer().getSelection()));
    //					actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());
    //					openAction.run();
    //				} finally {
    //					OpenStrategy.setOpenMethod(currentMode);
    //				}
    //			}
    //
    //			protected void linkToEditor(ISelection selection) {
    //				// do nothing: this is handled by
    // org.eclipse.ui.internal.navigator.actions.LinkEditorAction
    //			}
    //
    //			protected void open(ISelection selection, boolean activate) {
    //				actionService.setContext(new
    // ActionContext(commonNavigator.getCommonViewer().getSelection()));
    //				actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());
    //				openAction.run();
    //			}
    //
    //		};

    if (memento != null) restoreState(memento);

    initContextMenu();
    initViewMenu();
  }
  /**
   * Adds listeners to aNavigator to listen for selection changes and respond to mouse events.
   *
   * @param aNavigator The CommonNavigator managed by this class. Requires a non-null value.
   * @param aMemento a memento for restoring state, or <code>null</code>
   */
  public CommonNavigatorManager(CommonNavigator aNavigator, IMemento aMemento) {
    super();
    commonNavigator = aNavigator;
    contentService = commonNavigator.getNavigatorContentService();
    statusLineManager = commonNavigator.getViewSite().getActionBars().getStatusLineManager();
    commonDescriptionProvider = contentService.createCommonDescriptionProvider();
    labelProvider = (ILabelProvider) commonNavigator.getCommonViewer().getLabelProvider();

    init(aMemento);
  }
  protected void initViewMenu() {
    IMenuManager viewMenu = commonNavigator.getViewSite().getActionBars().getMenuManager();
    viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); // $NON-NLS-1$

    updateActionBars.schedule(NavigatorPlugin.ACTION_BAR_DELAY);
  }
 /**
  * @param anEvent An event indicating the current selection of the {@link CommonViewer}
  * @see
  *     org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
  */
 public void selectionChanged(SelectionChangedEvent anEvent) {
   if (anEvent.getSelection() instanceof IStructuredSelection) {
     IStructuredSelection structuredSelection = (IStructuredSelection) anEvent.getSelection();
     actionService.setContext(new ActionContext(structuredSelection));
     actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());
   }
 }
  /** Initializes and registers the context menu. */
  protected void initContextMenu() {
    MenuManager menuMgr = new MenuManager(contentService.getViewerDescriptor().getPopupMenuId());
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(
        new IMenuListener() {

          public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
          }
        });
    TreeViewer commonViewer = commonNavigator.getCommonViewer();
    Menu menu = menuMgr.createContextMenu(commonViewer.getTree());

    commonViewer.getTree().setMenu(menu);

    actionService.prepareMenuForPlatformContributions(menuMgr, commonViewer, false);
  }
 /**
  * Fills aMenuManager with menu contributions from the {@link NavigatorActionService}.
  *
  * @param aMenuManager A popup menu
  * @see NavigatorActionService#fillContextMenu(IMenuManager)
  */
 protected void fillContextMenu(IMenuManager aMenuManager) {
   ISelection selection = commonNavigator.getCommonViewer().getSelection();
   actionService.setContext(new ActionContext(selection));
   actionService.fillContextMenu(aMenuManager);
 }
 /** Called by {@link CommonNavigator} when the View Part is disposed. */
 public void dispose() {
   commonNavigator.getCommonViewer().removeSelectionChangedListener(this);
   commonNavigator.getCommonViewer().removeSelectionChangedListener(statusBarListener);
   actionService.dispose();
 }