use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class DefaultEncodingSupport method createStatusEncodingChangeControl.
/**
* Creates the control which allows to change the encoding.
* In case of encoding errors this control will be placed below
* the status of the status editor.
*
* @param parent the parent control
* @param status the status
* @since 3.1
*/
public void createStatusEncodingChangeControl(Composite parent, final IStatus status) {
final IAction action = fTextEditor.getAction(ITextEditorActionConstants.CHANGE_ENCODING);
if (action instanceof TextEditorAction)
((TextEditorAction) action).update();
if (action == null || !action.isEnabled())
return;
Shell shell = parent.getShell();
Display display = shell.getDisplay();
Color bgColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
Button button = new Button(parent, SWT.PUSH | SWT.FLAT);
button.setText(action.getText());
button.addSelectionListener(new SelectionAdapter() {
/*
* @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
action.run();
}
});
button.setFocus();
Label filler = new Label(parent, SWT.NONE);
filler.setLayoutData(new GridData(GridData.FILL_BOTH));
filler.setBackground(bgColor);
}
use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class TextEditor method handlePreferenceStoreChanged.
@Override
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
if (event.getProperty().equals(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
ISourceViewer viewer = getSourceViewer();
if (!(viewer instanceof ISourceViewerExtension2))
// cannot unconfigure - do nothing
return;
// XXX: this is pretty heavy-weight
((ISourceViewerExtension2) viewer).unconfigure();
viewer.configure(getSourceViewerConfiguration());
if (Boolean.FALSE.equals(event.getNewValue()))
SpellingProblem.removeAll(getSourceViewer(), null);
IAction quickAssistAction = getAction(ITextEditorActionConstants.QUICK_ASSIST);
if (quickAssistAction instanceof IUpdate)
((IUpdate) quickAssistAction).update();
return;
}
super.handlePreferenceStoreChanged(event);
}
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;
}
Aggregations