|
LPEX 4.4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Viewer com.ibm.lpex.alef.LpexTextViewer
public class LpexTextViewer
A line-oriented, LPEX-based partial implementation of
org.eclipse.jface.text.ITextViewer
.
This viewer supports a split window of several views on the document.
Its main control is an LpexMultiWindow
.
The first LpexWindow opened is the primary window, and its associated LpexView
is the primary view. Additional windows opened in this viewer are secondary
windows, and their associated LpexViews are secondary views. The focus window
is the one which currently has the input focus. The active window is that which
has the input focus, or otherwise had it lately and will be given the input focus
when this viewer regains focus. Views on the same document external to this
viewer are not managed in here.
Like TextViewer, once this viewer and its text widget have been created,
the viewer can only indirectly be disposed by disposing its primary SWT
control (the LpexMultiWindow).
Clients are supposed to instantiate a text viewer and subsequently to
communicate with it exclusively using the ITextViewer
interface
or any of the implemented extension interfaces.
A text viewer serves as text operation target. It only partially supports the external control of the enable state of its text operations.
A text viewer is also a widget token owner. Anything that wants to
display an overlay window on top of a text viewer should implement the
IWidgetTokenKeeper
interface, and participate in the widget
token negotiation between the text viewer and all its potential widget token
keepers.
This class is not intended to be subclassed outside the LPEX component.
Several TextViewer classes, methods, and fields are not available in LpexTextViewer. Most programming of the underlying LPEX widget should be done directly via its LpexView and LpexWindow.
Always use LpexView to set the text of the edited document. For example:
IEditorPart editor = IWorkbenchPage.getActiveEditor(); // (a) Using LPEX if (editor instanceof LpexTextEditor) { LpexTextEditor lpexEditor = (LpexTextEditor)editor; LpexView lpexView = lpexEditor.getLpexView(); if (lpexView != null) { lpexView.doDefaultCommand("insertText " + text); // insert text at cursor LpexView.doGlobalCommand("screenShow"); // refresh display } } // (b) Using the Eclipse editor else { // . . . get DocumentProvider, get IDocument, do replace() } |
TextViewer classes, methods, and fields which are not available, not implemented, or whose function differs significantly in LpexTextViewer are listed below, along with explanations and any LPEX alternatives. While the list is rather long, it should be noted that several (such as those geared towards specific Eclipse solutions, like the shift-string operations, or those specific to the underlying StyledText) are indicated for completeness, even if their visibility is package or private.
null
: use getLpexWindow() and
getLpexView() instead
IUndoManager
ITextDoubleClickStrategy
. Token/word selection and bracket
matching can be customized via new LpexActions
IAutoIndentStrategy
is not supported
getLpexView()
,
getFirstLpexView()
,
getLpexWindow()
,
getFirstLpexWindow()
Nested Class Summary | |
---|---|
protected static class |
LpexTextViewer.TextHoverKey
Value object used as a key in the text hover configuration table. |
Field Summary | |
---|---|
protected IInformationControlCreator |
fHoverControlCreator
The creator of the text hover control |
protected IHyperlinkDetector[] |
fHyperlinkDetectors
The text viewer's hyperlink detectors. |
protected LpexHyperlinkManager |
fHyperlinkManager
The text viewer's hyperlink manager. |
protected IHyperlinkPresenter |
fHyperlinkPresenter
The text viewer's hyperlink presenter. |
protected int |
fHyperlinkStateMask
The SWT key modifier mask which in combination with the left mouse button triggers the hyperlink mode. |
protected IDocumentInformationMapping |
fInformationMapping
The mapping between model and visible document. |
protected String |
fPartitioning
The viewers partitioning, i.e., the partitioning name the viewer uses to access partitioning information of its input document. |
protected Map<LpexTextViewer.TextHoverKey,ITextHover> |
fTextHovers
The text viewer's text hovers. |
protected List<ITextInputListener> |
fTextInputListeners
All registered text input listeners. |
protected static int |
INTERNAL
Id for originator of a viewport change. |
protected static int |
KEY
Id for originator of a viewport change. |
protected static int |
MOUSE
Id for originator of a viewport change. |
protected static int |
MOUSE_END
Id for originator of a viewport change. |
protected static int |
RESIZE
Id for originator of a viewport change. |
protected static int |
SCROLLER
Id for originator of a viewport change. |
static boolean |
TRACE_ERRORS
|
Constructor Summary | |
---|---|
protected |
LpexTextViewer()
Internal-use constructor. |
|
LpexTextViewer(Composite parent,
int styles)
Creates an LpexTextViewer with the given SWT style bits. |
Method Summary | |
---|---|
protected int |
_getVisibleRegionOffset()
This method always returns 0. |
protected IRegion |
_internalGetVisibleRegion()
This method returns null . |
void |
activatePlugins()
Activates the installed TextViewer 'plugins'. |
void |
addPostSelectionChangedListener(ISelectionChangedListener listener)
|
void |
addTextInputListener(ITextInputListener listener)
Adds a text input listener to the ITextViewer . |
void |
addTextListener(ITextListener listener)
The implementation of this method does nothing. |
void |
addTextPresentationListener(ITextPresentationListener listener)
|
void |
addViewportListener(IViewportListener listener)
This method does nothing. |
void |
appendVerifyKeyListener(VerifyKeyListener listener)
The LpexTextViewer implementation of this method does nothing. |
boolean |
canDoOperation(int operation)
Returns whether the action specified by the operation id can be performed. |
void |
changeTextPresentation(TextPresentation presentation,
boolean controlRedraw)
This method does nothing. |
protected void |
createControl(Composite parent,
int styles)
Creates the viewer's SWT control. |
protected com.ibm.lpex.alef.DocumentAdapter |
createDocumentAdapter()
Factory method to create the document adapter to be used by this viewer. |
protected IDocument |
createSlaveDocument(IDocument document)
Creates a slave document for the given document if there is a slave document manager associated with this viewer. |
protected ISlaveDocumentManager |
createSlaveDocumentManager()
Creates a new slave document manager. |
void |
doOperation(int operation)
Performs the action specified by the operation id. |
void |
enableOperation(int operation,
boolean enable)
|
protected void |
fireInputDocumentAboutToBeChanged(IDocument oldInput,
IDocument newInput)
Informs all registered text input listeners about the forthcoming input change. |
protected void |
fireInputDocumentChanged(IDocument oldInput,
IDocument newInput)
Informs all registered text input listeners about the successful input change. |
protected void |
fireSelectionChanged(int offset,
int len)
Sends out a text selection changed event to all registered listeners. |
protected void |
freeSlaveDocument(IDocument slave)
Frees the given document if it is a slave document. |
LpexView |
getActiveLpexView()
Returns the active view of the underlying LPEX text widget. |
LpexWindow |
getActiveLpexWindow()
Returns the active window of the underlying LPEX text widget. |
protected int |
getAverageCharWidth(LpexWindow lpexWindow)
Returns the average character width in the specified text window of this viewer's widget. |
int |
getBottomIndex()
Return the ZERO-based index of the visible document-section line with the highest line number. |
int |
getBottomIndexEndOffset()
Returns the character position which is at the lower-right corner of the widget's viewport, i.e., the visible character with the highest character position. |
protected int |
getClosestWidgetLineForModelLine(int modelLine)
Returns the line of the widget whose corresponding line in the viewer's document is closest to the given line in the viewer's document or -1 . |
Control |
getControl()
Returns the primary SWT Control (an LpexMultiWindow) associated with this viewer. |
int |
getCurrentOffset()
Returns the cursor offset in the active document view, in coordinates of this viewer's document. |
ITextHover |
getCurrentTextHover()
|
int |
getDocOffset(LpexDocumentLocation documentLocation)
Returns the offset in IDocument for the given location defined inside the document section currently loaded in LPEX. |
IDocument |
getDocument()
Returns this text viewer's stream-oriented IDocument. |
protected String |
getDocumentPartitioning()
Returns the document partitioning for this viewer. |
IFindReplaceTarget |
getFindReplaceTarget()
This method returns null . |
LpexView |
getFirstLpexView()
Returns the primary view of the underlying LPEX text widget. |
LpexWindow |
getFirstLpexWindow()
Returns the primary window of the underlying LPEX text widget. |
Point |
getHoverEventLocation()
|
Object |
getInput()
Returns the input (IDocument) of this viewer. |
LpexDocumentLocation |
getLpexDocumentLocation(int offset)
Returns the location inside the document section currently loaded in LPEX for the given offset in IDocument. |
LpexMultiWindow |
getLpexMultiWindow()
Returns the underlying LPEX text widget multiwindow. |
LpexView |
getLpexView()
Returns the focus view of the underlying LPEX text widget, or the primary view if none. |
LpexWindow |
getLpexWindow()
Returns the window of the underlying LPEX text widget that has the focus, or else the primary window. |
int |
getMark()
The LpexTextViewer implementation of this method returns -1. |
IRegion |
getModelCoverage()
Implements the contract of ITextViewerExtension5#getModelCoverage() . |
IEditingSupport[] |
getRegisteredSupports()
|
IRewriteTarget |
getRewriteTarget()
|
Point |
getSelectedRange()
Returns the range of the current selection / cursor position in the active document view, in coordinates of this viewer's document. |
ISelection |
getSelection()
Returns the current selection in this viewer's active document view. |
ISelectionProvider |
getSelectionProvider()
|
protected ISlaveDocumentManager |
getSlaveDocumentManager()
Returns the slave document manager. |
LpexAbstractTextEditor |
getTextEditor()
|
protected ITextHover |
getTextHover(int offset)
Return the text hover for a given offset in the IDocument, according to the document content type / document-parser language at that offset. |
protected ITextHover |
getTextHover(int offset,
int stateMask)
Returns the text hover for a given offset and a given state mask. |
protected AbstractInformationControlManager |
getTextHoveringController()
Return the text hovering controller of this viewer. |
ITextOperationTarget |
getTextOperationTarget()
Return the text-operations target of this viewer. |
StyledText |
getTextWidget()
This method returns null . |
int |
getTopIndex()
Return the ZERO-based index of the visible document-section line with the smallest line number. |
int |
getTopIndexStartOffset()
This method returns -1. |
int |
getTopInset()
Return the vertical offset, in pixels, of the text-widget screen's primary window. |
IUndoManager |
getUndoManager()
This method returns null in LpexTextViewer. |
IDocument |
getVisibleDocument()
Returns the viewer's visible document. |
protected int |
getVisibleLinesInViewport()
Deprecated. Deprecated in Eclipse as of 3.2 |
IRegion |
getVisibleRegion()
This method returns the region of this viewer's input document. |
protected void |
handleDispose()
Frees all the resources allocated by this viewer. |
protected void |
handleVisibleDocumentAboutToBeChanged(DocumentEvent event)
Hook method called when the visible document is about to be changed. |
protected void |
handleVisibleDocumentChanged(DocumentEvent event)
Hook method called when the visible document has been changed. |
protected void |
initializeDocumentInformationMapping(IDocument visibleDocument)
Initializes the document information mapping between the given slave document and its master document. |
protected void |
initializeLpexView(LpexView lpexView)
Hook to initialize a newly instantiated primary or secondary LpexView. |
void |
invalidateTextPresentation()
This method does nothing. |
void |
invalidateTextPresentation(int offset,
int length)
This method does nothing. |
boolean |
isEditable()
Query whether the shown text can be manipulated. |
int |
modelLine2WidgetLine(int modelLine)
Implements the contract of ITextViewerExtension5#modelLine2WidgetLine(int) . |
int |
modelOffset2WidgetOffset(int modelOffset)
Implements the contract of ITextViewerExtension5#modelOffset2WidgetOffset(int) . |
protected IRegion |
modelRange2ClosestWidgetRange(IRegion modelRange)
Similar to modelRange2WidgetRange(IRegion) , but more forgiving:
if modelRange describes a region entirely hidden in the
image, then this method returns the zero-length region at the offset of
the folded region. |
IRegion |
modelRange2WidgetRange(IRegion modelRange)
Implements the contract of ITextViewerExtension5#modelRange2WidgetRange(IRegion) . |
protected IRegion |
modelRange2WidgetRange(Position modelPosition)
Same as modelRange2WidgetRange(IRegion) but for a
Position . |
protected Point |
modelSelection2WidgetSelection(Point modelSelection)
Translates the given selection range of the viewer's document into the corresponding widget range or returns null of this fails. |
boolean |
moveFocusToWidgetToken()
|
boolean |
overlapsWithVisibleRegion(int start,
int length)
This method always returns true . |
void |
prependAutoEditStrategy(IAutoEditStrategy strategy,
String contentType)
This method does nothing. |
void |
prependVerifyKeyListener(VerifyKeyListener listener)
The LpexTextViewer implementation of this method does nothing. |
void |
print(StyledTextPrintOptions options)
|
protected boolean |
redraws()
The LpexTextViewer implementation of this method returns true . |
void |
refresh()
Refreshes this viewer completely with information freshly obtained from this viewer's model (its IDocument). |
void |
register(IEditingSupport helper)
|
void |
releaseWidgetToken(IWidgetTokenKeeper tokenKeeper)
|
void |
removeAutoEditStrategy(IAutoEditStrategy strategy,
String contentType)
This method does nothing. |
void |
removePostSelectionChangedListener(ISelectionChangedListener listener)
|
void |
removeTextHovers(String contentType)
Removes all text hovers for the given content type independent from their state mask. |
void |
removeTextInputListener(ITextInputListener listener)
Removes the text input listener from the ITextViewer . |
void |
removeTextListener(ITextListener listener)
The implementation of this method does nothing. |
void |
removeTextPresentationListener(ITextPresentationListener listener)
|
void |
removeVerifyKeyListener(VerifyKeyListener listener)
The LpexTextViewer implementation of this method does nothing. |
void |
removeViewportListener(IViewportListener listener)
This method does nothing. |
boolean |
requestWidgetToken(IWidgetTokenKeeper requester)
|
boolean |
requestWidgetToken(IWidgetTokenKeeper requester,
int priority)
|
void |
resetPlugins()
Resets the installed 'plugins'. |
void |
resetVisibleRegion()
This method does nothing. |
void |
revealRange(int start,
int len)
Ensures the given character range is visible in the active document view. |
protected Object |
selectContentTypePlugin(int offset,
Map<?,?> plugins)
Select from the given map the plug-in which is registered under the content type at the given document offset. |
protected void |
selectionChanged(int offset,
int len)
Sends out a text selection-changed event to all registered listeners. |
protected void |
setAutoEditStrategies(IAutoEditStrategy[] strategies,
String contentType)
This method does nothing. |
void |
setAutoIndentStrategy(IAutoIndentStrategy strategy,
String contentType)
This method does nothing. |
void |
setDefaultPrefixes(String[] defaultPrefixes,
String contentType)
This method does nothing in LpexTextViewer. |
void |
setDocument(IDocument document)
Sets the given IDocument as the text viewer's model, and update the presentation accordingly. |
void |
setDocument(IDocument document,
int modelRangeOffset,
int modelRangeLength)
Sets the given document as this viewer's model and exposes the specified region. |
void |
setDocumentPartitioning(String partitioning)
Sets the document partitioning of this viewer. |
void |
setEditable(boolean editable)
Sets the editable state for this text viewer. |
protected void |
setEditorInput(IEditorInput editorInput)
Indicate which is the editor-input resource for this text viewer. |
void |
setEventConsumer(IEventConsumer consumer)
This method does nothing. |
void |
setHoverControlCreator(IInformationControlCreator creator)
Set the creator for the hover controls. |
void |
setHoverEnrichMode(ITextViewerExtension8.EnrichMode mode)
|
void |
setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors,
int eventStateMask)
|
void |
setHyperlinkPresenter(IHyperlinkPresenter hyperlinkPresenter)
Sets the hyperlink presenter. |
void |
setIndentPrefixes(String[] indentPrefixes,
String contentType)
This method does nothing. |
void |
setInput(Object input)
Sets or clears the input (IDocument) for this viewer. |
void |
setMark(int offset)
The LpexTextViewer implementation of this method does nothing. |
void |
setRedraw(boolean redraw)
The LpexTextViewer implementation of this method does nothing. |
protected void |
setRedraw(boolean redraw,
int topIndex)
The LpexTextViewer implementation of this method does nothing. |
void |
setSelectedRange(int selectionOffset,
int selectionLength)
Sets the selection to the specified range in the active document view. |
void |
setSelection(ISelection selection,
boolean reveal)
Sets a new selection for this viewer. |
void |
setTextColor(Color color)
This method does nothing. |
void |
setTextColor(Color color,
int start,
int length,
boolean controlRedraw)
This method does nothing. |
void |
setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy,
String contentType)
This method does nothing in LpexTextViewer. |
void |
setTextHover(ITextHover hover,
String contentType)
Sets this viewer's text hover for the given content type. |
void |
setTextHover(ITextHover hover,
String contentType,
int stateMask)
Sets this viewer's text hover for the given content type and the given state mask. |
void |
setTopIndex(int index)
Scrolls the edit window so that ZERO-based index is the
smallest document-section line number of all visible lines. |
void |
setUndoManager(IUndoManager undoManager)
This method does nothing in LpexTextViewer. |
protected void |
setVisibleDocument(IDocument document)
Sets this viewer's visible document. |
void |
setVisibleRegion(int start,
int len)
This method does nothing. |
LpexView |
splitView(LpexView lpexView)
Creates a new view of the document in this text viewer's window. |
void |
unregister(IEditingSupport helper)
|
protected void |
updateProfile(LpexView lpexView)
Hook for post-updateProfile command processing. |
protected boolean |
updateSlaveDocument(IDocument slaveDocument,
int modelRangeOffset,
int modelRangeLength)
Updates the given slave document to show the specified range of its master document. |
protected void |
updateViewportListeners(int origin)
This method does nothing. |
protected void |
validateSelectionRange(int[] selectionRange)
Validates and adapts the given selection range if it is not a valid widget selection. |
int |
widgetLine2ModelLine(int widgetLine)
Implements the contract of ITextViewerExtension5#widgetLine2ModelLine(int) . |
int |
widgetLineOfWidgetOffset(int widgetOffset)
Implements the contract of ITextViewerExtension5#widgetLineOfWidgetOffset(int) . |
int |
widgetlLine2ModelLine(int widgetLine)
Implements the contract of ITextViewerExtension5#widgetLine2ModelLine(int) . |
int |
widgetOffset2ModelOffset(int widgetOffset)
Implements the contract of ITextViewerExtension5#widgetOffset2ModelOffset(int) . |
IRegion |
widgetRange2ModelRange(IRegion widgetRange)
Implements the contract of ITextViewerExtension5#widgetRange2ModelRange(IRegion) . |
protected Point |
widgetSelection2ModelSelection(Point widgetSelection)
Translates the given widget selection into the corresponding region of the viewer's document or returns null if this fails. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean TRACE_ERRORS
protected static final int SCROLLER
protected static final int MOUSE
protected static final int MOUSE_END
protected static final int KEY
protected static final int RESIZE
protected static final int INTERNAL
protected Map<LpexTextViewer.TextHoverKey,ITextHover> fTextHovers
protected List<ITextInputListener> fTextInputListeners
protected IInformationControlCreator fHoverControlCreator
protected IDocumentInformationMapping fInformationMapping
protected String fPartitioning
protected IHyperlinkDetector[] fHyperlinkDetectors
protected IHyperlinkPresenter fHyperlinkPresenter
protected LpexHyperlinkManager fHyperlinkManager
protected int fHyperlinkStateMask
Constructor Detail |
---|
protected LpexTextViewer()
public LpexTextViewer(Composite parent, int styles)
parent
- the parent of the viewer's controlstyles
- the SWT style bits for the viewer's control (LpexWindow)createControl(Composite, int)
Method Detail |
---|
public LpexAbstractTextEditor getTextEditor()
protected com.ibm.lpex.alef.DocumentAdapter createDocumentAdapter()
LpexTextViewer creates a com.ibm.lpex.alef.DocumentAdapter, which is used to translate IDocument changes into LPEX document text changes, and vice versa. TextViewer creates an org.eclipse.jface.text.DefaultDocumentAdapter, which adapts an IDocument to the StyledTextContent interface.
protected void createControl(Composite parent, int styles)
Here are the steps carried out by this method:
The user must add their own LPEX actions and commands by extending updateProfile(LpexView), which is called when we are notified of the completion of the updateProfile command.
parent
- the parent of the viewer's controlstyles
- the SWT style bits for the viewer's controlinitializeLpexView(com.ibm.lpex.core.LpexView)
,
updateProfile(LpexView)
public LpexView splitView(LpexView lpexView)
lpexView
- source document view
null
if the current window could not be split
for a new document viewpublic Control getControl()
Viewer
public void activatePlugins()
Defined by ITextViewer, as part of its plugins support.
ITextViewer
public void resetPlugins()
ITextViewer
protected void handleDispose()
public StyledText getTextWidget()
null
. In TextViewer, this method returns
the StyledText control, its underlying text widget.
Note: Do not use this method in LpexTextViewer. LpexTextViewer uses an LPEX text widget, which consists of an LpexMultiWindow (an SWT SashForm) and its LpexWindow(s) and LpexView(s), rather than a StyledText widget.
null
ITextViewer
,
getLpexWindow()
,
getFirstLpexWindow()
,
getLpexView()
,
getFirstLpexView()
public void setAutoIndentStrategy(IAutoIndentStrategy strategy, String contentType)
protected final void setAutoEditStrategies(IAutoEditStrategy[] strategies, String contentType)
public void prependAutoEditStrategy(IAutoEditStrategy strategy, String contentType)
public void removeAutoEditStrategy(IAutoEditStrategy strategy, String contentType)
public void setEventConsumer(IEventConsumer consumer)
In TextViewer, implementers can register and receive VerifyEvents before the text viewer touches them. If the IEventConsumer marks an event as processed, the text viewer will ignore it. For example, keys consumed by a content-assist popup should not be again processed by us (this is not quite AWT's e.consume(), but that's the way Eclipse operates).
ITextViewer
public void setIndentPrefixes(String[] indentPrefixes, String contentType)
In TextViewer, this method sets the strings that are used as prefixes when lines of the given content type are shifted using the shift operations. Defined by ITextViewer, as part of its plugins support.
ITextViewer
public int getTopInset()
ITextViewer
public boolean isEditable()
ITextViewer
public void setEditable(boolean editable)
ITextViewer
,
isEditable()
,
updateProfile(LpexView)
public void setDefaultPrefixes(String[] defaultPrefixes, String contentType)
Defined by ITextViewer, as part of its plugins support.
ITextViewer
public void setUndoManager(IUndoManager undoManager)
IUndoManager
.
Defined by ITextViewer, as part of its plugins support.
ITextViewer
public IUndoManager getUndoManager()
null
in LpexTextViewer.
LPEX uses its own built-in undo manager, therefore it
does not support IUndoManager
.
ITextViewerExtension6
public void setTextHover(ITextHover hover, String contentType)
hover
- the new hover; null is a valid argumentcontentType
- the type for which the hover is registeredITextViewer
public void setTextHover(ITextHover hover, String contentType, int stateMask)
hover
- the new hover or nullcontentType
- the type for which the hover is to be registered or unregisteredstateMask
- the SWT event state mask; DEFAULT_HOVER_STATE_MASK indicates that
the hover is installed as the default hoverITextViewerExtension2
public void removeTextHovers(String contentType)
contentType
- the type for which all text hovers are to be unregisteredITextViewerExtension2
protected ITextHover getTextHover(int offset)
offset
- the IDocument offset for which to return the text hover
protected ITextHover getTextHover(int offset, int stateMask)
offset
- the offset for which to return the text hoverstateMask
- the SWT event state mask
protected AbstractInformationControlManager getTextHoveringController()
public void setHoverControlCreator(IInformationControlCreator creator)
creator
- the hover control creatorpublic boolean requestWidgetToken(IWidgetTokenKeeper requester)
public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority)
public void releaseWidgetToken(IWidgetTokenKeeper tokenKeeper)
public Point getSelectedRange()
This method adjusts positions which are outside the current IDocument text. In LPEX the cursor, character/element/rectangle block positions, etc. can be located outside the actual line text and on show elements. Also note that the cursor position in LPEX is not necessarily a boundary of the current selection, unless the selection is of type stream. Use getCurrentOffset() to retrieve the cursor position for this viewer.
{offset,length}
inside IDocument if there is a selection in the active view, or {offset,0}
(the cursor position) if there is no selection, or {-1,-1}
if no text is visible in the active viewgetCurrentOffset()
public void setSelectedRange(int selectionOffset, int selectionLength)
Preferred method: use the block command or blockMark___ actions. To reposition the cursor, use the locate command and the position parameter.
ITextViewer
public int getCurrentOffset()
In LPEX the cursor can be located outside the actual line text and on show elements. This method adjusts a position which is outside the current IDocument text.
getSelectedRange()
protected void validateSelectionRange(int[] selectionRange)
[-1, -1]
indicates that the selection range could not be validated.
Subclasses may reimplement this method.
selectionRange
- selectionRange[0] is the offset, selectionRange[1]
the length of the selection to validate.public void setSelection(ISelection selection, boolean reveal)
To set selections in LPEX, use the block command or blockMark___ actions. To reposition the cursor, use the locate command and the position parameter.
Viewer
public ISelection getSelection()
In LPEX, this stream-oriented method is inefficient, and should be avoided.
Viewer
public ISelectionProvider getSelectionProvider()
ITextViewer
public void addPostSelectionChangedListener(ISelectionChangedListener listener)
public void removePostSelectionChangedListener(ISelectionChangedListener listener)
protected void selectionChanged(int offset, int len)
offset
- the offset of the newly selected range in the visible documentlen
- the length of the newly selected range in the visible documentgetSelectedRange()
,
getCurrentOffset()
protected void fireSelectionChanged(int offset, int len)
offset
- the offset of the newly selected range in the visible documentlen
- the length of the newly selected range in the visible documentpublic void addTextListener(ITextListener listener)
In TextViewer, this method adds a text listener to the text widget. A listener is registered only once, subsequent calls are without effect.
ITextViewer
public void removeTextListener(ITextListener listener)
In TextViewer, this method removes the text listener from the text widget. If the listener is not registered with the widget, the call is without effect.
ITextViewer
public void addTextInputListener(ITextInputListener listener)
ITextViewer
. A listener is
registered only once, subsequent calls are without effect.
Text input listeners registered with a text viewer are informed when the document serving as the text viewer's model is replaced.
ITextViewer
public void removeTextInputListener(ITextInputListener listener)
ITextViewer
. If the
listener is not registered with the viewer, the call is without effect.
ITextViewer
protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput)
oldInput
- the old input documentnewInput
- the new input documentprotected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput)
oldInput
- the old input documentnewInput
- the new input documentpublic Object getInput()
Viewer
public IDocument getDocument()
Defined by ITextViewer, as part of its model-manipulation support.
ITextViewer
public void setInput(Object input)
Viewer
public void setDocument(IDocument document)
Defined by ITextViewer, as part of its model-manipulation support.
ITextViewer
public void setDocument(IDocument document, int modelRangeOffset, int modelRangeLength)
setDocument(document); setVisibleRegion(offset, length);
Defined by ITextViewer as part of its visible-region support.
ITextViewer
,
setDocument(IDocument)
protected IDocument createSlaveDocument(IDocument document)
document
- the master document
protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException
slaveDocument
- the slave documentmodelRangeOffset
- the offset of the master document rangemodelRangeLength
- the length of the master document range
true
if the slave has been adapted successfully
BadLocationException
- in case the specified range is not valid in the master documentpublic void addViewportListener(IViewportListener listener)
ITextViewer
public void removeViewportListener(IViewportListener listener)
ITextViewer
protected void updateViewportListeners(int origin)
In TextViewer, this method checks whether the viewport changed and, if so, informs all registered listeners about the change.
origin
- describes under which circumstances this method has been calledIViewportListener
public int getTopIndex()
ITextViewer
public void setTopIndex(int index)
index
is the
smallest document-section line number of all visible lines.
Preferred method: in LPEX you may consider various options, depending on the intended usage. For example, to set the cursor in the edit window on a certain line in the document:
LpexView lpexView = getLpexView(); lpexView.doCommand("locate emphasis line " + (index + 1 + lpexView.linesBeforeStart())); lpexView.triggerAction(lpexView.actionId("textWindow"));To position the line that contains the cursor on a certain screen row:
LpexView lpexView = getLpexView(); lpexView.doCommand("set cursorRow " + row); lpexView.doDefaultCommand("screenShow");
You must consider certain characteristics of the LPEX edit window, such as:
ITextViewer
protected int getVisibleLinesInViewport()
Preferred method: use getLpexView().queryInt("rows").
public int getBottomIndex()
ITextViewer
public int getTopIndexStartOffset()
ITextViewer
public int getBottomIndexEndOffset()
ITextViewer
public void revealRange(int start, int len)
Note that in LPEX the cursor is currently always visible. This method ensures that filtered elements at the start and end of the given range are expanded.
ITextViewer
protected final int getAverageCharWidth(LpexWindow lpexWindow)
public void refresh()
Viewer
,
setDocument(IDocument)
protected ISlaveDocumentManager getSlaveDocumentManager()
protected ISlaveDocumentManager createSlaveDocumentManager()
ChildDocumentManager
.
public final void invalidateTextPresentation()
public final void invalidateTextPresentation(int offset, int length)
offset
- the offset of the range to be invalidatedlength
- the length of the range to be invalidatedprotected void freeSlaveDocument(IDocument slave)
slave
- the potential slave documentprotected void setVisibleDocument(IDocument document)
document
- the visible documentprotected void handleVisibleDocumentAboutToBeChanged(DocumentEvent event)
event
- the document eventprotected void handleVisibleDocumentChanged(DocumentEvent event)
event
- the document eventprotected void initializeDocumentInformationMapping(IDocument visibleDocument)
visibleDocument
- the slave documentpublic IDocument getVisibleDocument()
protected int _getVisibleRegionOffset()
In TextViewer, this method returns the offset of the visible region.
public IRegion getVisibleRegion()
In TextViewer, this method returns the current visible region of this viewer's document. Defined by ITextViewer as part of its visible-region support.
ITextViewer
public void setVisibleRegion(int start, int len)
In TextViewer, this method sets the region of this viewer's document which will be visible in the presentation. It does this by defining a child document for this region, and setting it as the visible document for the text widget (i.e., reloading the text widgets with the contents of this child document). It is defined by ITextViewer as part of its visible-region support.
ITextViewer
public void resetVisibleRegion()
In TextViewer, this method resets the region of this viewer's document which is visible in the presentation, so that the whole document is presented again. It is defined by ITextViewer, as part of its visible-region support.
ITextViewer
public boolean overlapsWithVisibleRegion(int start, int length)
true
.
In LpexTextViewer, the visible document is always the viewer's (entire)
input document. To display only certain region(s) of the document in the
viewer, set marks for these regions, and set their included or excluded
attribute. See the mark, markIncluded, and
markExcluded parameters.
In TextViewer, this method returns whether a given range overlaps with the visible region of this viewer's document. It is defined by ITextViewer, as part of its visible-region support.
ITextViewer
public void setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy, String contentType)
ITextDoubleClickStrategy
. Token/word selection and bracket
matching can be customized via new LpexActions.
Defined by ITextViewer, as part of its plugins support.
ITextViewer
protected Object selectContentTypePlugin(int offset, Map<?,?> plugins)
This method first checks for a plug-in for the IDocument content type
(for example, IDocument.DEFAULT_CONTENT_TYPE) of the document partition
in which the given offset is located.
If none found, it checks for a plug-in registered for the LPEX
document-parser language, as defined in
LpexCommonParser.getLanguage(LpexDocumentLocation)
(for example, LpexCommonParser.LANGUAGE_JAVA), as content type.
offset
- the document offset for which to find the plug-inplugins
- the map from which to choose
public boolean canDoOperation(int operation)
Note that most LPEX actions (as defined in, for example, LpexAbstractTextEditor) call the editor directly for querying their availability.
operation
- LPEX-defined operation id (including the equivalents of
ITextOperationTarget.UNDO, .REDO, etc.)ITextOperationTarget
public void doOperation(int operation)
canDoOperation()
returns true
.
Note that most LPEX actions (as defined in, for example, LpexAbstractTextEditor) call the editor directly.
operation
- LPEX-defined operation id (including the equivalents of
ITextOperationTarget.UNDO, .REDO, etc.)ITextOperationTarget
public void enableOperation(int operation, boolean enable)
public void setTextColor(Color color)
Defined by ITextViewer, as part of its presentation-manipulation support.
ITextViewer
public void setTextColor(Color color, int start, int length, boolean controlRedraw)
Defined by ITextViewer, as part of its presentation-manipulation support.
ITextViewer
protected IRegion _internalGetVisibleRegion()
null
.
In LpexTextViewer, the visible document is always the viewer's (entire)
input document. To display only certain region(s) of the document in the
viewer, set marks for these regions, and set their included or excluded
attribute. See the mark, markIncluded, and
markExcluded parameters.
In TextViewer, this method returns the visible region if it is not equal
to the whole document, or null
if it is.
public void changeTextPresentation(TextPresentation presentation, boolean controlRedraw)
In TextViewer, this method applies in the text widget the color information of the specified text presentation.
Defined by ITextViewer, as part of its presentation-manipulation support.
ITextViewer
public IFindReplaceTarget getFindReplaceTarget()
null
.
LPEX implements its own findAndReplace actions.
Defined by ITextViewer, as part of its target-handling support.
ITextViewer
public ITextOperationTarget getTextOperationTarget()
Defined by ITextViewer, as part of its target-handling support.
ITextViewer
public void appendVerifyKeyListener(VerifyKeyListener listener)
ITextViewerExtension
public void prependVerifyKeyListener(VerifyKeyListener listener)
ITextViewerExtension
public void removeVerifyKeyListener(VerifyKeyListener listener)
ITextViewerExtension
public int getMark()
ITextViewerExtension
public void setMark(int offset)
ITextViewerExtension
public final void setRedraw(boolean redraw)
ITextViewerExtension
protected final void setRedraw(boolean redraw, int topIndex)
In TextViewer, this method has basically the same functionality as
ITextViewerExtension.setRedraw(boolean)
. Adds a way for
subclasses to pass in a desired top index that should be used when
redraw
is true
. If topIndex
is -1, this method is identical to
ITextViewerExtension.setRedraw(boolean)
.
redraw
- redraw / suspend redrawingtopIndex
- what pixel to position at the top of the text widget
(when redrawing is reinstated)ITextViewerExtension
protected final boolean redraws()
true
.
LPEX only refreshes its screen at the end of user operations, or when explicitly
called to do it. See the screenShow editor command.
In TextViewer, the method returns true
if this viewer
redraws itself (i.e., redrawing is not temporarily suspended).
setRedraw(boolean,int)
public IRewriteTarget getRewriteTarget()
public ITextHover getCurrentTextHover()
public Point getHoverEventLocation()
public int modelLine2WidgetLine(int modelLine)
ITextViewerExtension5#modelLine2WidgetLine(int)
.
modelLine
- the model line
-1
public int modelOffset2WidgetOffset(int modelOffset)
ITextViewerExtension5#modelOffset2WidgetOffset(int)
.
modelOffset
- the model offset
-1
public IRegion modelRange2WidgetRange(IRegion modelRange)
ITextViewerExtension5#modelRange2WidgetRange(IRegion)
.
modelRange
- the model range
null
protected IRegion modelRange2ClosestWidgetRange(IRegion modelRange)
modelRange2WidgetRange(IRegion)
, but more forgiving:
if modelRange
describes a region entirely hidden in the
image, then this method returns the zero-length region at the offset of
the folded region.
modelRange
- the model range
null
public int widgetlLine2ModelLine(int widgetLine)
ITextViewerExtension5#widgetLine2ModelLine(int)
.
widgetLine
- the widget line
public int widgetLine2ModelLine(int widgetLine)
ITextViewerExtension5#widgetLine2ModelLine(int)
.
Returns the line of the viewer's document that corresponds to the given
widget line, or -1 if there is no such line.
widgetLine
- the widget line
-1
public int widgetOffset2ModelOffset(int widgetOffset)
ITextViewerExtension5#widgetOffset2ModelOffset(int)
.
widgetOffset
- the widget offset
-1
public IRegion widgetRange2ModelRange(IRegion widgetRange)
ITextViewerExtension5#widgetRange2ModelRange(IRegion)
.
widgetRange
- the widget range
null
public IRegion getModelCoverage()
ITextViewerExtension5#getModelCoverage()
.
protected int getClosestWidgetLineForModelLine(int modelLine)
-1
.
modelLine
- the line in the viewer's document
-1
protected IRegion modelRange2WidgetRange(Position modelPosition)
modelRange2WidgetRange(IRegion)
but for a
Position
.
modelPosition
- the position describing a range in the viewer's document
protected Point widgetSelection2ModelSelection(Point widgetSelection)
null
if this fails.
widgetSelection
- the widget selection
null
protected Point modelSelection2WidgetSelection(Point modelSelection)
null
of this fails.
modelSelection
- the selection range of the viewer's document
null
public int widgetLineOfWidgetOffset(int widgetOffset)
ITextViewerExtension5#widgetLineOfWidgetOffset(int)
.
widgetOffset
- the widget offset
-1
public boolean moveFocusToWidgetToken()
public void setDocumentPartitioning(String partitioning)
partitioning
- the partitioning nameprotected String getDocumentPartitioning()
public void addTextPresentationListener(ITextPresentationListener listener)
ITextViewerExtension4#addTextPresentationListener(ITextPresentationListener)
public void removeTextPresentationListener(ITextPresentationListener listener)
ITextViewerExtension4#removeTextPresentationListener(ITextPresentationListener)
public void register(IEditingSupport helper)
public void unregister(IEditingSupport helper)
public IEditingSupport[] getRegisteredSupports()
public void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask)
public void setHyperlinkPresenter(IHyperlinkPresenter hyperlinkPresenter) throws IllegalStateException
hyperlinkPresenter
- the hyperlink presenter
IllegalStateException
- if the hyperlink manager has already been createdprotected void initializeLpexView(LpexView lpexView)
Extend this method to set any file/view-specific parameters for this LpexView. Here you may set any "File Open" preferences page settings for your solution's plug-in, such as sequenceNumbers, sourceEncoding, save.textLimit, and save.trim. The updateProfile command will be called later.
lpexView
- the newly instantiated primary or secondary document viewprotected void updateProfile(LpexView lpexView)
Called when a new document view is created (a new document is opened in this viewer), and whenever the updateProfile command is issued afterwards.
lpexView
- the primary or secondary document view whose profile
has been updatedprotected void setEditorInput(IEditorInput editorInput)
This method should be called prior to the setDocument() for this text viewer, and whenever the input changes for this text viewer.
public LpexMultiWindow getLpexMultiWindow()
public LpexWindow getLpexWindow()
public LpexWindow getFirstLpexWindow()
public LpexWindow getActiveLpexWindow()
public LpexView getLpexView()
public LpexView getFirstLpexView()
public LpexView getActiveLpexView()
public LpexDocumentLocation getLpexDocumentLocation(int offset)
offset
- ZERO-based offset in IDocument
public int getDocOffset(LpexDocumentLocation documentLocation)
documentLocation
- a document location (element = inside the
document section currently loaded in LPEX,
position = inside the editable text part of the line)
public void setHoverEnrichMode(ITextViewerExtension8.EnrichMode mode)
ITextViewerExtension8
public void print(StyledTextPrintOptions options)
ITextViewerExtension8
|
LPEX 4.4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |