Search in sources :

Example 1 with CompositeRevertAction

use of org.eclipse.ui.internal.editors.quickdiff.CompositeRevertAction in project eclipse.platform.text by eclipse.

the class AbstractDecoratedTextEditor method createActions.

@Override
protected void createActions() {
    super.createActions();
    // $NON-NLS-1$
    ResourceAction action = new AddMarkerAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.AddBookmark.", this, IMarker.BOOKMARK, true);
    action.setHelpContextId(ITextEditorHelpContextIds.BOOKMARK_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_BOOKMARK);
    setAction(IDEActionFactory.BOOKMARK.getId(), action);
    // $NON-NLS-1$
    action = new AddTaskAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.AddTask.", this);
    action.setHelpContextId(ITextEditorHelpContextIds.ADD_TASK_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_TASK);
    setAction(IDEActionFactory.ADD_TASK.getId(), action);
    // $NON-NLS-1$
    action = new ChangeEncodingAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ChangeEncodingAction.", this);
    action.setHelpContextId(ITextEditorHelpContextIds.CHANGE_ENCODING);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CHANGE_ENCODING);
    setAction(ITextEditorActionConstants.CHANGE_ENCODING, action);
    markAsPropertyDependentAction(ITextEditorActionConstants.CHANGE_ENCODING, true);
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.ToggleLineNumbersAction.", // $NON-NLS-1$
    IAction.AS_CHECK_BOX) {

        @Override
        public void run() {
            toggleLineNumberRuler();
        }
    };
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINENUMBER_TOGGLE);
    setAction(ITextEditorActionConstants.LINENUMBERS_TOGGLE, action);
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.ToggleQuickDiffAction.", // $NON-NLS-1$
    IAction.AS_CHECK_BOX) {

        @Override
        public void run() {
            toggleQuickDiffRuler();
        }
    };
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICKDIFF_TOGGLE);
    setAction(ITextEditorActionConstants.QUICKDIFF_TOGGLE, action);
    action = new RevertLineAction(this, false);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICKDIFF_REVERTLINE);
    setAction(ITextEditorActionConstants.QUICKDIFF_REVERTLINE, action);
    action = new RevertSelectionAction(this, false);
    setAction(ITextEditorActionConstants.QUICKDIFF_REVERTSELECTION, action);
    action = new RevertBlockAction(this, false);
    setAction(ITextEditorActionConstants.QUICKDIFF_REVERTBLOCK, action);
    action = new RestoreAction(this, false);
    setAction(ITextEditorActionConstants.QUICKDIFF_REVERTDELETION, action);
    IAction action2 = new CompositeRevertAction(this, new IAction[] { getAction(ITextEditorActionConstants.QUICKDIFF_REVERTSELECTION), getAction(ITextEditorActionConstants.QUICKDIFF_REVERTBLOCK), getAction(ITextEditorActionConstants.QUICKDIFF_REVERTDELETION), getAction(ITextEditorActionConstants.QUICKDIFF_REVERTLINE) });
    action2.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICKDIFF_REVERT);
    setAction(ITextEditorActionConstants.QUICKDIFF_REVERT, action2);
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.HideRevisionInformationAction.") {

        @Override
        public void run() {
            if (fLineColumn != null)
                fLineColumn.hideRevisionInformation();
        }
    };
    setAction(ITextEditorActionConstants.REVISION_HIDE_INFO, action);
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.CycleRevisionRenderingAction.") {

        @Override
        public void run() {
            final RenderingMode[] modes = { IRevisionRulerColumnExtension.AGE, IRevisionRulerColumnExtension.AUTHOR, IRevisionRulerColumnExtension.AUTHOR_SHADED_BY_AGE };
            IPreferenceStore store = EditorsUI.getPreferenceStore();
            String current = store.getString(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE);
            for (int i = 0; i < modes.length; i++) {
                String mode = modes[i].name();
                if (mode.equals(current)) {
                    int nextIndex = (i + 1) % modes.length;
                    RenderingMode nextMode = modes[nextIndex];
                    store.setValue(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE, nextMode.name());
                }
            }
        }
    };
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.REVISION_RENDERING_CYCLE);
    setAction(ITextEditorActionConstants.REVISION_RENDERING_CYCLE, action);
    // $NON-NLS-1$
    action = new BooleanPreferenceToggleAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ToggleRevisionAuthorAction.", IAction.AS_CHECK_BOX, EditorsUI.getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_AUTHOR);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.REVISION_AUTHOR_TOGGLE);
    setAction(ITextEditorActionConstants.REVISION_SHOW_AUTHOR_TOGGLE, action);
    // $NON-NLS-1$
    action = new BooleanPreferenceToggleAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ToggleRevisionIdAction.", IAction.AS_CHECK_BOX, EditorsUI.getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_REVISION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.REVISION_ID_TOGGLE);
    setAction(ITextEditorActionConstants.REVISION_SHOW_ID_TOGGLE, action);
    final Shell shell;
    if (getSourceViewer() != null)
        shell = getSourceViewer().getTextWidget().getShell();
    else
        shell = null;
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.RulerPreferencesAction.") {

        @Override
        public void run() {
            String[] preferencePages = collectRulerMenuPreferencePages();
            if (preferencePages.length > 0 && (shell == null || !shell.isDisposed()))
                PreferencesUtil.createPreferenceDialogOn(shell, preferencePages[0], preferencePages, null).open();
        }
    };
    setAction(ITextEditorActionConstants.RULER_PREFERENCES, action);
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.ContextPreferencesAction.") {

        @Override
        public void run() {
            String[] preferencePages = collectContextMenuPreferencePages();
            if (preferencePages.length > 0 && (shell == null || !shell.isDisposed()))
                PreferencesUtil.createPreferenceDialogOn(shell, preferencePages[0], preferencePages, null).open();
        }
    };
    setAction(ITextEditorActionConstants.CONTEXT_PREFERENCES, action);
    IAction showWhitespaceCharactersAction = getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
    if (showWhitespaceCharactersAction instanceof ShowWhitespaceCharactersAction)
        ((ShowWhitespaceCharactersAction) showWhitespaceCharactersAction).setPreferenceStore(EditorsUI.getPreferenceStore());
    setAction(ITextEditorActionConstants.REFRESH, new RefreshEditorAction(this));
    markAsPropertyDependentAction(ITextEditorActionConstants.REFRESH, true);
    // Override print action to provide additional options
    if (getAction(ITextEditorActionConstants.PRINT).isEnabled() && getSourceViewer() instanceof ITextViewerExtension8)
        createPrintAction();
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.ShowChangeRulerInformation.", // $NON-NLS-1$
    IAction.AS_PUSH_BUTTON) {

        @Override
        public void run() {
            showChangeRulerInformation();
        }
    };
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_CHANGE_RULER_INFORMATION_ID);
    setAction(ITextEditorActionConstants.SHOW_CHANGE_RULER_INFORMATION, action);
    action = new // $NON-NLS-1$
    ResourceAction(// $NON-NLS-1$
    TextEditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.ShowRulerAnnotationInformation.", // $NON-NLS-1$
    IAction.AS_PUSH_BUTTON) {

        @Override
        public void run() {
            showRulerAnnotationInformation();
        }
    };
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_RULER_ANNOTATION_INFORMATION_ID);
    setAction(ITextEditorActionConstants.SHOW_RULER_ANNOTATION_INFORMATION, action);
}
Also used : RevertSelectionAction(org.eclipse.ui.internal.editors.quickdiff.RevertSelectionAction) IAction(org.eclipse.jface.action.IAction) RestoreAction(org.eclipse.ui.internal.editors.quickdiff.RestoreAction) RevertBlockAction(org.eclipse.ui.internal.editors.quickdiff.RevertBlockAction) Shell(org.eclipse.swt.widgets.Shell) RevertLineAction(org.eclipse.ui.internal.editors.quickdiff.RevertLineAction) RenderingMode(org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode) BooleanPreferenceToggleAction(org.eclipse.ui.internal.texteditor.BooleanPreferenceToggleAction) RefreshEditorAction(org.eclipse.ui.internal.editors.text.RefreshEditorAction) ITextViewerExtension8(org.eclipse.jface.text.ITextViewerExtension8) CompositeRevertAction(org.eclipse.ui.internal.editors.quickdiff.CompositeRevertAction) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

IAction (org.eclipse.jface.action.IAction)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ITextViewerExtension8 (org.eclipse.jface.text.ITextViewerExtension8)1 RenderingMode (org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode)1 Shell (org.eclipse.swt.widgets.Shell)1 CompositeRevertAction (org.eclipse.ui.internal.editors.quickdiff.CompositeRevertAction)1 RestoreAction (org.eclipse.ui.internal.editors.quickdiff.RestoreAction)1 RevertBlockAction (org.eclipse.ui.internal.editors.quickdiff.RevertBlockAction)1 RevertLineAction (org.eclipse.ui.internal.editors.quickdiff.RevertLineAction)1 RevertSelectionAction (org.eclipse.ui.internal.editors.quickdiff.RevertSelectionAction)1 RefreshEditorAction (org.eclipse.ui.internal.editors.text.RefreshEditorAction)1 BooleanPreferenceToggleAction (org.eclipse.ui.internal.texteditor.BooleanPreferenceToggleAction)1