/**
   * Sets the active editor to this contributor. This updates the actions to reflect the editor.
   *
   * @see EditorActionBarContributor#editorChanged
   */
  @Override
  public void setActiveEditor(IEditorPart part) {

    super.setActiveEditor(part);

    ITextEditor editor = null;
    if (part instanceof ITextEditor) editor = (ITextEditor) part;

    contentAssistProposal.setAction(
        getAction(editor, IChameleonEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS));
    formatProposal.setAction(getAction(editor, IChameleonEditorActionDefinitionIds.FORMAT));
    contentAssistContextInformation.setAction(
        getAction(editor, IChameleonEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION));
  }
  public BasicJavaEditorActionContributor() {
    super();

    ResourceBundle b = JavaEditorMessages.getBundleForConstructedKeys();

    fRetargetShowInformationAction =
        new RetargetTextEditorAction(b, "Editor.ShowInformation."); // $NON-NLS-1$
    fRetargetShowInformationAction.setActionDefinitionId(
        ITextEditorActionDefinitionIds.SHOW_INFORMATION);

    // actions that are "contributed" to editors, they are considered belonging to the active editor
    fTogglePresentation = new TogglePresentationAction();

    fToggleMarkOccurrencesAction = new ToggleMarkOccurrencesAction();

    fGotoMatchingBracket = new RetargetTextEditorAction(b, "GotoMatchingBracket."); // $NON-NLS-1$
    fGotoMatchingBracket.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);

    fShowOutline =
        new RetargetTextEditorAction(
            JavaEditorMessages.getBundleForConstructedKeys(), "ShowOutline."); // $NON-NLS-1$
    fShowOutline.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_OUTLINE);

    fOpenHierarchy =
        new RetargetTextEditorAction(
            JavaEditorMessages.getBundleForConstructedKeys(), "OpenHierarchy."); // $NON-NLS-1$
    fOpenHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY);

    fOpenStructure =
        new RetargetTextEditorAction(
            JavaEditorMessages.getBundleForConstructedKeys(), "OpenStructure."); // $NON-NLS-1$
    fOpenStructure.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE);

    fStructureSelectEnclosingAction =
        new RetargetTextEditorAction(b, "StructureSelectEnclosing."); // $NON-NLS-1$
    fStructureSelectEnclosingAction.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.SELECT_ENCLOSING);
    fStructureSelectNextAction =
        new RetargetTextEditorAction(b, "StructureSelectNext."); // $NON-NLS-1$
    fStructureSelectNextAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_NEXT);
    fStructureSelectPreviousAction =
        new RetargetTextEditorAction(b, "StructureSelectPrevious."); // $NON-NLS-1$
    fStructureSelectPreviousAction.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.SELECT_PREVIOUS);
    fStructureSelectHistoryAction =
        new RetargetTextEditorAction(b, "StructureSelectHistory."); // $NON-NLS-1$
    fStructureSelectHistoryAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_LAST);

    fGotoNextMemberAction = new RetargetTextEditorAction(b, "GotoNextMember."); // $NON-NLS-1$
    fGotoNextMemberAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
    fGotoPreviousMemberAction =
        new RetargetTextEditorAction(b, "GotoPreviousMember."); // $NON-NLS-1$
    fGotoPreviousMemberAction.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);

    fRemoveOccurrenceAnnotationsAction =
        new RetargetTextEditorAction(b, "RemoveOccurrenceAnnotations."); // $NON-NLS-1$
    fRemoveOccurrenceAnnotationsAction.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
  }
  /*
   * @see EditorActionBarContributor#setActiveEditor(IEditorPart)
   */
  @Override
  public void setActiveEditor(IEditorPart part) {

    super.setActiveEditor(part);

    ITextEditor textEditor = null;
    if (part instanceof ITextEditor) textEditor = (ITextEditor) part;

    fTogglePresentation.setEditor(textEditor);
    fToggleMarkOccurrencesAction.setEditor(textEditor);

    fGotoMatchingBracket.setAction(
        getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
    fShowOutline.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.SHOW_OUTLINE));
    fOpenHierarchy.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_HIERARCHY));
    fOpenStructure.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_STRUCTURE));

    fStructureSelectEnclosingAction.setAction(
        getAction(textEditor, StructureSelectionAction.ENCLOSING));
    fStructureSelectNextAction.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
    fStructureSelectPreviousAction.setAction(
        getAction(textEditor, StructureSelectionAction.PREVIOUS));
    fStructureSelectHistoryAction.setAction(
        getAction(textEditor, StructureSelectionAction.HISTORY));

    fGotoNextMemberAction.setAction(
        getAction(textEditor, GoToNextPreviousMemberAction.NEXT_MEMBER));
    fGotoPreviousMemberAction.setAction(
        getAction(textEditor, GoToNextPreviousMemberAction.PREVIOUS_MEMBER));

    fRemoveOccurrenceAnnotationsAction.setAction(
        getAction(textEditor, "RemoveOccurrenceAnnotations")); // $NON-NLS-1$
    fRetargetShowInformationAction.setAction(
        getAction(textEditor, ITextEditorActionConstants.SHOW_INFORMATION));

    if (part instanceof JavaEditor) {
      JavaEditor javaEditor = (JavaEditor) part;
      javaEditor.getActionGroup().fillActionBars(getActionBars());
      FoldingActionGroup foldingActions = javaEditor.getFoldingActionGroup();
      if (foldingActions != null) foldingActions.updateActionBars();
    }

    IActionBars actionBars = getActionBars();
    IStatusLineManager manager = actionBars.getStatusLineManager();
    manager.setMessage(null);
    manager.setErrorMessage(null);

    /** The global actions to be connected with editor actions */
    IAction action = getAction(textEditor, ITextEditorActionConstants.NEXT);
    actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, action);
    action = getAction(textEditor, ITextEditorActionConstants.PREVIOUS);
    actionBars.setGlobalActionHandler(
        ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action);
    action = getAction(textEditor, IJavaEditorActionConstants.COPY_QUALIFIED_NAME);
    actionBars.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, action);

    actionBars.setGlobalActionHandler(
        IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB,
        getAction(textEditor, IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB));
    actionBars.setGlobalActionHandler(
        "org.eclipse.jdt.internal.ui.actions.OpenHyperlink",
        getAction(textEditor, ITextEditorActionConstants.OPEN_HYPERLINK)); // $NON-NLS-1$
  }