use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class JavaEditor method createActions.
/**
* The <code>JavaEditor</code> implementation of this
* <code>AbstractTextEditor</code> method extend the
* actions to add those specific to the receiver
*/
@Override
protected void createActions() {
super.createActions();
// $NON-NLS-1$
IAction a = new DefineFoldingRegionAction(JavaEditorMessages.getResourceBundle(), "DefineFoldingRegion.", this);
// $NON-NLS-1$
setAction("DefineFoldingRegion", a);
}
use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method addRulerContributionActions.
/**
* Adds "show" actions for all contributed rulers that support it.
*
* @param menu the ruler context menu
* @since 3.3
*/
private void addRulerContributionActions(IMenuManager menu) {
// store directly in generic editor preferences
final IColumnSupport support = getAdapter(IColumnSupport.class);
IPreferenceStore store = EditorsUI.getPreferenceStore();
final RulerColumnPreferenceAdapter adapter = new RulerColumnPreferenceAdapter(store, AbstractTextEditor.PREFERENCE_RULER_CONTRIBUTIONS);
List<RulerColumnDescriptor> descriptors = RulerColumnRegistry.getDefault().getColumnDescriptors();
for (Iterator<RulerColumnDescriptor> t = descriptors.iterator(); t.hasNext(); ) {
final RulerColumnDescriptor descriptor = t.next();
if (!descriptor.isIncludedInMenu() || !support.isColumnSupported(descriptor))
continue;
final boolean isVisible = support.isColumnVisible(descriptor);
IAction action = new Action(MessageFormat.format(TextEditorMessages.AbstractDecoratedTextEditor_show_ruler_label, new Object[] { descriptor.getName() }), IAction.AS_CHECK_BOX) {
@Override
public void run() {
if (descriptor.isGlobal())
// column state is modified via preference listener of AbstractTextEditor
adapter.setEnabled(descriptor, !isVisible);
else
// directly modify column for this editor instance
support.setColumnVisible(descriptor, !isVisible);
}
};
action.setChecked(isVisible);
action.setImageDescriptor(descriptor.getIcon());
menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, action);
}
}
use of org.eclipse.jface.action.IAction in project xtext-xtend by eclipse.
the class ShowWhitespaceCharactersActionContributor method contributeActions.
@Override
public void contributeActions(XtextEditor editor) {
IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
IAction action = editor.getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
action.setImageDescriptor(imageHelper.getImageDescriptor("full/etool16/show_whitespace_chars.gif"));
action.setDisabledImageDescriptor(imageHelper.getImageDescriptor("full/dtool16/show_whitespace_chars.gif"));
if (toolBarManager.find(action.getId()) == null) {
toolBarManager.add(new ActionContributionItemExtension(action));
// toolBarManager.add(action);
}
}
use of org.eclipse.jface.action.IAction in project xtext-xtend by eclipse.
the class ShowWhitespaceCharactersActionContributor method editorDisposed.
@Override
public void editorDisposed(XtextEditor editor) {
IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
IContributionItem i = toolBarManager.remove(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
if (i instanceof ActionContributionItem) {
IAction action = ((ActionContributionItem) i).getAction();
if (action instanceof ShowWhitespaceCharactersAction) {
((ShowWhitespaceCharactersAction) action).setEditor(null);
}
}
}
use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.
the class ContentAssistTests method getResults.
protected ICompletionProposal[] getResults(IFile file, int offset) throws Exception {
disableContributions();
// call the ContentAssistProcessor
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
FileEditorInput editorInput = new FileEditorInput(file);
IEditorPart editorPart = page.openEditor(editorInput, "org.eclipse.cdt.ui.editor.CEditor");
CEditor editor = (CEditor) editorPart;
@SuppressWarnings("unused") IAction completionAction = editor.getAction("ContentAssistProposal");
String contentType = editor.getViewer().getDocument().getContentType(offset);
ContentAssistant assistant = new ContentAssistant();
CContentAssistProcessor processor = new CContentAssistProcessor(editor, assistant, contentType);
return processor.computeCompletionProposals(editor.getViewer(), offset);
}
Aggregations