use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class AbstractTextSearchViewPage method removeFilterActionsFromViewMenu.
private void removeFilterActionsFromViewMenu(IAction[] filterActions) {
IActionBars bars = getSite().getActionBars();
IMenuManager menu = bars.getMenuManager();
if (filterActions != null) {
for (IAction filterAction : filterActions) {
menu.remove(filterAction.getId());
}
}
menu.remove(MatchFilterSelectionAction.ACTION_ID);
}
use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method editorContextMenuAboutToShow.
/**
* Sets up this editor's context menu before it is made visible.
* <p>
* Subclasses may extend to add other actions.</p>
*
* @param menu the menu
*/
protected void editorContextMenuAboutToShow(IMenuManager menu) {
menu.add(new Separator(ITextEditorActionConstants.GROUP_UNDO));
menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_SAVE));
menu.add(new Separator(ITextEditorActionConstants.GROUP_COPY));
menu.add(new Separator(ITextEditorActionConstants.GROUP_PRINT));
menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
menu.add(new Separator(ITextEditorActionConstants.GROUP_FIND));
menu.add(new Separator(IWorkbenchActionConstants.GROUP_ADD));
menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
if (isEditable()) {
addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.UNDO);
addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.REVERT_TO_SAVED);
addAction(menu, ITextEditorActionConstants.GROUP_SAVE, ITextEditorActionConstants.SAVE);
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.CUT);
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.PASTE);
IAction action = getAction(ITextEditorActionConstants.QUICK_ASSIST);
if (action != null && action.isEnabled())
addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.QUICK_ASSIST);
} else {
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
}
}
use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method getAction.
@Override
public IAction getAction(String actionID) {
Assert.isNotNull(actionID);
IAction action = fActions.get(actionID);
if (action == null) {
action = findContributedAction(actionID);
if (action != null)
setAction(actionID, action);
}
return action;
}
use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method updateInsertModeAction.
private void updateInsertModeAction() {
// drop out in this case.
if (getSite() == null)
return;
IAction action = getAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE);
if (action != null) {
action.setEnabled(!fIsOverwriting);
action.setChecked(fInsertMode == SMART_INSERT);
}
}
use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method handlePreferenceStoreChanged.
/**
* Handles a property change event describing a change of the editor's
* preference store and updates the preference related editor properties.
* <p>
* Subclasses may extend.
* </p>
*
* @param event the property change event
*/
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
if (fSourceViewer == null)
return;
String property = event.getProperty();
if (getFontPropertyPreferenceKey().equals(property))
// There is a separate handler for font preference changes
return;
if (PREFERENCE_COLOR_FOREGROUND.equals(property) || PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_BACKGROUND.equals(property) || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT.equals(property)) {
initializeViewerColors(fSourceViewer);
} else if (PREFERENCE_COLOR_FIND_SCOPE.equals(property)) {
initializeFindScopeColor(fSourceViewer);
} else if (PREFERENCE_USE_CUSTOM_CARETS.equals(property)) {
updateCaret();
} else if (PREFERENCE_WIDE_CARET.equals(property)) {
updateCaret();
}
if (affectsTextPresentation(event))
fSourceViewer.invalidateTextPresentation();
if (PREFERENCE_HYPERLINKS_ENABLED.equals(property)) {
if (fSourceViewer instanceof ITextViewerExtension6) {
IHyperlinkDetector[] detectors = getSourceViewerConfiguration().getHyperlinkDetectors(fSourceViewer);
int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(fSourceViewer);
ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) fSourceViewer;
textViewer6.setHyperlinkDetectors(detectors, stateMask);
}
return;
}
if (PREFERENCE_HYPERLINK_KEY_MODIFIER.equals(property)) {
if (fSourceViewer instanceof ITextViewerExtension6) {
ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) fSourceViewer;
IHyperlinkDetector[] detectors = getSourceViewerConfiguration().getHyperlinkDetectors(fSourceViewer);
int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(fSourceViewer);
textViewer6.setHyperlinkDetectors(detectors, stateMask);
}
return;
}
if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) {
String[] difference = StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue());
IColumnSupport support = getAdapter(IColumnSupport.class);
for (int i = 0; i < difference.length; i++) {
RulerColumnDescriptor desc = RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]);
if (desc != null && support.isColumnSupported(desc)) {
boolean newState = !support.isColumnVisible(desc);
support.setColumnVisible(desc, newState);
}
}
return;
}
if (PREFERENCE_SHOW_WHITESPACE_CHARACTERS.equals(property) || PREFERENCE_SHOW_LEADING_SPACES.equals(property) || PREFERENCE_SHOW_ENCLOSED_SPACES.equals(property) || PREFERENCE_SHOW_TRAILING_SPACES.equals(property) || PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_LEADING_TABS.equals(property) || PREFERENCE_SHOW_ENCLOSED_TABS.equals(property) || PREFERENCE_SHOW_TRAILING_TABS.equals(property) || PREFERENCE_SHOW_CARRIAGE_RETURN.equals(property) || PREFERENCE_SHOW_LINE_FEED.equals(property) || PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE.equals(property)) {
IAction action = getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
if (action instanceof IUpdate)
((IUpdate) action).update();
return;
}
if (PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED.equals(property)) {
IPreferenceStore store = getPreferenceStore();
if (store != null && store.getBoolean(PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED))
installTextDragAndDrop(getSourceViewer());
else
uninstallTextDragAndDrop(getSourceViewer());
return;
}
if (PREFERENCE_HOVER_ENRICH_MODE.equals(property)) {
if (fSourceViewer instanceof ITextViewerExtension8) {
IPreferenceStore store = getPreferenceStore();
if (store != null) {
((ITextViewerExtension8) fSourceViewer).setHoverEnrichMode(convertEnrichModePreference(store.getInt(PREFERENCE_HOVER_ENRICH_MODE)));
}
}
return;
}
}
Aggregations