/**
   * Returns the tool tip text for the given element.
   *
   * @param element the element
   * @return the tooltip for the element
   */
  String getToolTipText(Object element) {
    String result;
    if (!(element instanceof IResource)) {
      result =
          ScriptElementLabels.getDefault()
              .getTextLabel(element, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
    } else {
      IPath path = ((IResource) element).getFullPath();
      if (path.isRoot()) {
        result = getConfigurationElement().getAttribute("name"); // $NON-NLS-1$
      } else {
        result = path.makeRelative().toString();
      }
    }

    if (fWorkingSetFilterActionGroup == null
        || fWorkingSetFilterActionGroup.getWorkingSet() == null) return result;

    IWorkingSet ws = fWorkingSetFilterActionGroup.getWorkingSet();
    String wsstr =
        Messages.format(
            ScriptBrowsingMessages.JavaBrowsingPart_toolTip, new String[] {ws.getLabel()});
    if (result.length() == 0) return wsstr;
    return Messages.format(
        ScriptBrowsingMessages.JavaBrowsingPart_toolTip2, new String[] {result, ws.getLabel()});
  }
  protected void createActions() {
    fActionGroups =
        new CompositeActionGroup(
            new ActionGroup[] {
              new NewWizardsActionGroup(this.getSite()),
              fOpenEditorGroup = new OpenEditorActionGroup(this),
              new OpenViewActionGroup(this),
              fCCPActionGroup = new CCPActionGroup(this),
              // new GenerateActionGroup(this),
              new RefactorActionGroup(this),
              new ImportActionGroup(this),
              fBuildActionGroup = new BuildActionGroup(this),
              new SearchActionGroup(this, this.getToolkit())
            });

    if (fHasWorkingSetFilter) {
      String viewId = getConfigurationElement().getAttribute("id"); // $NON-NLS-1$
      Assert.isNotNull(viewId);
      IPropertyChangeListener workingSetListener =
          new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
              doWorkingSetChanged(event);
            }
          };
      fWorkingSetFilterActionGroup = new WorkingSetFilterActionGroup(getSite(), workingSetListener);
      fViewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
    }

    // Custom filter group
    if (fHasCustomFilter) fCustomFiltersActionGroup = new CustomFiltersActionGroup(this, fViewer);

    fToggleLinkingAction = new ToggleLinkingAction(this);
  }
  protected void restoreState(IMemento memento) {
    if (fHasWorkingSetFilter) fWorkingSetFilterActionGroup.restoreState(memento);
    if (fHasCustomFilter) fCustomFiltersActionGroup.restoreState(memento);

    if (fHasCustomFilter || fHasWorkingSetFilter) {
      fViewer.getControl().setRedraw(false);
      fViewer.refresh();
      fViewer.getControl().setRedraw(true);
    }
  }
 /*
  * Implements method from IViewPart.
  */
 public void saveState(IMemento memento) {
   if (fViewer == null) {
     // part has not been created
     if (fMemento != null) // Keep the old state;
     memento.putMemento(fMemento);
     return;
   }
   if (fHasWorkingSetFilter) fWorkingSetFilterActionGroup.saveState(memento);
   if (fHasCustomFilter) fCustomFiltersActionGroup.saveState(memento);
   saveSelectionState(memento);
   saveLinkingEnabled(memento);
 }
  protected void fillActionBars(IActionBars actionBars) {
    IToolBarManager toolBar = actionBars.getToolBarManager();
    fillToolBar(toolBar);

    if (fHasWorkingSetFilter)
      fWorkingSetFilterActionGroup.fillActionBars(getViewSite().getActionBars());

    actionBars.updateActionBars();

    fActionGroups.fillActionBars(actionBars);

    if (fHasCustomFilter) fCustomFiltersActionGroup.fillActionBars(actionBars);

    IMenuManager menu = actionBars.getMenuManager();
    menu.add(fToggleLinkingAction);
  }
  public void dispose() {
    if (fContextActivation != null) {
      IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
      if (ctxService != null) {
        ctxService.deactivateContext(fContextActivation);
      }
    }
    if (fViewer != null) {
      getViewSite().getPage().removePostSelectionListener(this);
      getViewSite().getPage().removePartListener(fPartListener);
      fViewer = null;
    }
    if (fActionGroups != null) fActionGroups.dispose();

    if (fWorkingSetFilterActionGroup != null) {
      fWorkingSetFilterActionGroup.dispose();
    }

    super.dispose();
  }