public class ToggleSLCommentAction
extends org.eclipse.ui.texteditor.TextEditorAction
| Modifier and Type | Class and Description |
|---|---|
static class |
ToggleSLCommentAction.Factory |
| Constructor and Description |
|---|
ToggleSLCommentAction(ResourceBundle bundle,
String prefix,
org.eclipse.ui.texteditor.ITextEditor editor)
Creates and initializes the action for the given text editor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
configure(org.eclipse.jface.text.source.ISourceViewer sourceViewer,
org.eclipse.jface.text.source.SourceViewerConfiguration configuration) |
protected String |
getDocumentPartitioning() |
protected int |
getFirstCompleteLineOfRegion(org.eclipse.jface.text.IRegion region,
org.eclipse.jface.text.IDocument document)
Returns the index of the first line whose start offset is in the given text range.
|
protected org.eclipse.jface.text.ITextOperationTarget |
getOperationTarget() |
protected Map<String,String[]> |
getPrefixesMap() |
protected org.eclipse.jface.text.IRegion |
getTextBlockFromSelection(org.eclipse.jface.text.ITextSelection selection,
org.eclipse.jface.text.IDocument document)
Creates a region describing the text block (something that starts at
the beginning of a line) completely containing the current selection.
|
protected boolean |
isBlockCommented(int startLine,
int endLine,
String[] prefixes,
org.eclipse.jface.text.IDocument document)
Determines whether each line is prefixed by one of the prefixes.
|
protected boolean |
isSelectionCommented(org.eclipse.jface.viewers.ISelection selection)
Is the given selection single-line commented?
|
void |
run()
Implementation of the
IAction prototype. |
void |
setEditor(org.eclipse.ui.texteditor.ITextEditor editor) |
void |
update()
Implementation of the
IUpdate prototype method discovers
the operation through the current editor's
ITextOperationTarget adapter, and sets the enabled state
accordingly. |
canModifyEditor, getTextEditor, validateEditorInputStategetString, initialize, setHelpContextIdconvertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipTextaddPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListenerpublic ToggleSLCommentAction(ResourceBundle bundle, String prefix, org.eclipse.ui.texteditor.ITextEditor editor)
bundle - the resource bundleprefix - a prefix to be prepended to the various resource keys
(described in ResourceAction constructor), or
null if noneeditor - the text editorResourceAction.ResourceAction(ResourceBundle, String, int)public void run()
IAction prototype. Checks if the selected
lines are all commented or not and uncomments/comments them respectively.run in interface org.eclipse.jface.action.IActionrun in class org.eclipse.jface.action.Actionprotected boolean isSelectionCommented(org.eclipse.jface.viewers.ISelection selection)
selection - Selection to checktrue iff all selected lines are commentedprotected org.eclipse.jface.text.IRegion getTextBlockFromSelection(org.eclipse.jface.text.ITextSelection selection,
org.eclipse.jface.text.IDocument document)
selection - The selection to usedocument - The documentprotected int getFirstCompleteLineOfRegion(org.eclipse.jface.text.IRegion region,
org.eclipse.jface.text.IDocument document)
region - the text range in characters where to find the linedocument - The documentprotected boolean isBlockCommented(int startLine,
int endLine,
String[] prefixes,
org.eclipse.jface.text.IDocument document)
startLine - Start line in documentendLine - End line in documentprefixes - Possible comment prefixesdocument - The documenttrue iff each line from startLine
to and including endLine is prepended by one
of the prefixes, ignoring whitespace at the
begin of linepublic void update()
IUpdate prototype method discovers
the operation through the current editor's
ITextOperationTarget adapter, and sets the enabled state
accordingly.update in interface org.eclipse.ui.texteditor.IUpdateupdate in class org.eclipse.ui.texteditor.TextEditorActionpublic void setEditor(org.eclipse.ui.texteditor.ITextEditor editor)
setEditor in class org.eclipse.ui.texteditor.TextEditorActionpublic void configure(org.eclipse.jface.text.source.ISourceViewer sourceViewer,
org.eclipse.jface.text.source.SourceViewerConfiguration configuration)
protected String getDocumentPartitioning()
protected org.eclipse.jface.text.ITextOperationTarget getOperationTarget()
Copyright © 2016. All Rights Reserved.