use of org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method rulerContextMenuAboutToShow.
@Override
protected void rulerContextMenuAboutToShow(IMenuManager menu) {
/*
* XXX: workaround for reliable menu item ordering.
* This can be changed once the action contribution story converges,
* see http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-ui-home/R3_1/dynamic_teams/dynamic_teams.html#actionContributions
*/
// pre-install menus for contributions and call super
// $NON-NLS-1$
menu.add(new Separator("debug"));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_RESTORE));
// $NON-NLS-1$
menu.add(new Separator("add"));
menu.add(new Separator(ITextEditorActionConstants.GROUP_RULERS));
menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
super.rulerContextMenuAboutToShow(menu);
addRulerContributionActions(menu);
/* quick diff */
if (isEditorInputModifiable()) {
IAction quickdiffAction = getAction(ITextEditorActionConstants.QUICKDIFF_TOGGLE);
quickdiffAction.setChecked(isChangeInformationShowing());
menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, quickdiffAction);
if (isChangeInformationShowing()) {
TextEditorAction revertLine = new RevertLineAction(this, true);
TextEditorAction revertSelection = new RevertSelectionAction(this, true);
TextEditorAction revertBlock = new RevertBlockAction(this, true);
TextEditorAction revertDeletion = new RestoreAction(this, true);
revertSelection.update();
revertBlock.update();
revertLine.update();
revertDeletion.update();
// only add block action if selection action is not enabled
if (revertSelection.isEnabled())
menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertSelection);
else if (revertBlock.isEnabled())
menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertBlock);
if (revertLine.isEnabled())
menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertLine);
if (revertDeletion.isEnabled())
menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertDeletion);
}
}
// revision info
if (fLineColumn != null && fLineColumn.isShowingRevisionInformation()) {
IMenuManager revisionMenu = new MenuManager(TextEditorMessages.AbstractDecoratedTextEditor_revisions_menu);
menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, revisionMenu);
IAction hideRevisionInfoAction = getAction(ITextEditorActionConstants.REVISION_HIDE_INFO);
revisionMenu.add(hideRevisionInfoAction);
revisionMenu.add(new Separator());
String[] labels = { TextEditorMessages.AbstractDecoratedTextEditor_revision_colors_option_by_date, TextEditorMessages.AbstractDecoratedTextEditor_revision_colors_option_by_author, TextEditorMessages.AbstractDecoratedTextEditor_revision_colors_option_by_author_and_date };
final RenderingMode[] modes = { IRevisionRulerColumnExtension.AGE, IRevisionRulerColumnExtension.AUTHOR, IRevisionRulerColumnExtension.AUTHOR_SHADED_BY_AGE };
final IPreferenceStore uiStore = EditorsUI.getPreferenceStore();
String current = uiStore.getString(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE);
for (int i = 0; i < modes.length; i++) {
final String mode = modes[i].name();
IAction action = new Action(labels[i], IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
// set preference globally, LineNumberColumn reacts on preference change
uiStore.setValue(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE, mode);
}
};
action.setChecked(mode.equals(current));
revisionMenu.add(action);
}
revisionMenu.add(new Separator());
IAction action = getAction(ITextEditorActionConstants.REVISION_SHOW_AUTHOR_TOGGLE);
if (action instanceof IUpdate)
((IUpdate) action).update();
revisionMenu.add(action);
action = getAction(ITextEditorActionConstants.REVISION_SHOW_ID_TOGGLE);
if (action instanceof IUpdate)
((IUpdate) action).update();
revisionMenu.add(action);
}
IAction lineNumberAction = getAction(ITextEditorActionConstants.LINENUMBERS_TOGGLE);
lineNumberAction.setChecked(fLineColumn != null && fLineColumn.isShowingLineNumbers());
menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, lineNumberAction);
IAction preferencesAction = getAction(ITextEditorActionConstants.RULER_PREFERENCES);
menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, new Separator(ITextEditorActionConstants.GROUP_SETTINGS));
menu.appendToGroup(ITextEditorActionConstants.GROUP_SETTINGS, preferencesAction);
}
use of org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode 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);
}
Aggregations