org.eclipse.ui.texteditor.TextEditorAction Java Examples

The following examples show how to use org.eclipse.ui.texteditor.TextEditorAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditorUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static void initializeHighlightRange(IEditorPart editorPart) {
	if (editorPart instanceof ITextEditor) {
		IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
		boolean enable= toggleAction != null;
		if (enable && editorPart instanceof JavaEditor)
			enable= JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
		else
			enable= enable && toggleAction.isEnabled() && toggleAction.isChecked();
		if (enable) {
			if (toggleAction instanceof TextEditorAction) {
				// Reset the action
				((TextEditorAction)toggleAction).setEditor(null);
				// Restore the action
				((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart);
			} else {
				// Uncheck
				toggleAction.run();
				// Check
				toggleAction.run();
			}
		}
	}
}
 
Example #2
Source File: XbaseFoldingActionContributor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void contributeActions(XtextEditor xtextEditor) {
	foldingActionGroup = new FoldingActionGroup(xtextEditor, xtextEditor.getInternalSourceViewer()) {
		@Override
		protected TextEditorAction createToggleFoldingAction(ITextEditor editor) {
			TextEditorAction toggle = new ResourceActionExtension(FoldingMessages.getResourceBundle(),
					"Projection.Toggle.", editor, ProjectionViewer.TOGGLE);
			toggle.setChecked(true);
			toggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE);
			return toggle;
		}
	};
}
 
Example #3
Source File: XbaseEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * replace default cut/copy/paste actions with a version that provided by the factory, if one is injected
 */
protected void createClipboardActions() {
	IClipboardActionFactory actionsFactory = getClipboardActionFactory();
	if (actionsFactory != null) {
		ResourceBundle bundle = XbaseEditorMessages.getBundleForConstructedKeys();
		TextEditorAction action = actionsFactory.create(bundle, "Editor.Cut.", this, ITextOperationTarget.CUT); //$NON-NLS-1$
		setAction(ITextEditorActionConstants.CUT, action);
		action = actionsFactory.create(bundle, "Editor.Copy.", this, ITextOperationTarget.COPY); //$NON-NLS-1$
		setAction(ITextEditorActionConstants.COPY, action);
		action = actionsFactory.create(bundle, "Editor.Paste.", this, ITextOperationTarget.PASTE); //$NON-NLS-1$
		setAction(ITextEditorActionConstants.PASTE, action);
	}
}
 
Example #4
Source File: MacroModeStateHandler.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void restore(ITextEditor textEditor, String actionId) {
    Boolean b = fMemento.get(actionId);
    if (b != null && b) {
        Control control = textEditor.getAdapter(Control.class);
        if (control != null && !control.isDisposed()) {
            // Do nothing if already disposed.
            IAction action = textEditor.getAction(actionId);
            if (action instanceof TextEditorAction) {
                TextEditorAction textEditorAction = (TextEditorAction) action;
                textEditorAction.setEditor(textEditor);
                textEditorAction.update();
            }
        }
    }
}
 
Example #5
Source File: MacroModeStateHandler.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void disable(ITextEditor textEditor, String actionId) {
    IAction action = textEditor.getAction(actionId);
    if (action != null && action instanceof TextEditorAction) {
        TextEditorAction textEditorAction = (TextEditorAction) action;
        fMemento.put(actionId, true);
        textEditorAction.setEditor(null);
        textEditorAction.update();
    }
}
 
Example #6
Source File: FoldingActionGroup.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.8
 */
protected TextEditorAction createToggleFoldingAction(ITextEditor editor) {
	return new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor,
			ProjectionViewer.TOGGLE, true);
}
 
Example #7
Source File: ImportsAwareClipboardAction.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public TextEditorAction create(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode) {
	ImportsAwareClipboardAction action = new ImportsAwareClipboardAction(bundle, prefix, editor, operationCode);
	injector.injectMembers(action);
	return action;
}
 
Example #8
Source File: IClipboardActionFactory.java    From xtext-eclipse with Eclipse Public License 2.0 votes vote down vote up
public TextEditorAction create(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode);