ISourceView Interface

com.bea.ide.sourceeditor
ISourceView Interface

public interface ISourceView

    extends IDocumentView

The ISourceView interface allows for manipulation of many end-user visible attributes of a document's text view.


All Superinterfaces
ICookieSupport, IDocumentView, IDriverSupport, IPropertySupport

Field Summary

public static final String
RIGHT_CLICK_POINT_KEY
Key for a cookie on the Application that stores where the user last right clicked in the SourceView
public static final int
SCROLL_MIDDLE
If a new selection is off the screen, scroll it to the middle of the screen.
public static final int
SCROLL_MIDDLE_ALWAYS
Always scroll to the middle.
public static final int
SCROLL_MIDDLE_FORCE
If a new selection is not in the middle of the screen, scroll it to the middle of the screen.
public static final int
SCROLL_MINIMAL
If a new selection is off the screen, scroll it barely onto the screen.
   
Fields from interface com.bea.ide.document.IDocumentView
PROP_SelectedElement, SOURCE_VIEW
 

Method Summary

public void
addHoverListener(IHoverListener hoverListener)
Adds a hover listener to this source view.
public boolean
expandCollapsibleElement(ISourceElement elmt, boolean expand)
Expands or collapses the text for a source element.
public Caret
getCaret()
Returns the current caret.
public int
getCaretPosition()
Returns the zero-based character offset of the caret within the view.
public String
getEditableLineText(int sourceLine, Range range)
Returns that portion of a line's text which is not collapsed.
public Range
getLineRangeAround(int pos)
public int
getOffset(Point p)
Returns the offset in the document for the element at the given point, -1 if there is no element at that location
public String
getSelectedText()
Returns the text selected in the source view.
public int
getSelectionEnd()
Returns the zero-based offset of the end of the text selection.
public int
getSelectionStart()
Returns the zero-based offset of the start of the text selection.
public String
getWordAtCaret()
public Range
getWordRangeAround(int pos)
public boolean
isDraggingDroppableObject()
Used to differentiate between dragging to create a selection, and dragging to do a drag-drop.
public boolean
isSingleLineSelection()
public void
removeHoverListener(IHoverListener hoverListener)
Removes a hover listener from this source view.
public boolean
replaceSelectedText(String strReplacement)
Replaces any selected text with the specified string.
public void
setCaretPosition(int pos, int scrollMode)
Sets the caret position within the source view.
public boolean
setSelection(int lineStart, int colStart, int lineEnd, int colEnd, int scrollMode)
Selects the indicated text range.
public boolean
setSelection(Range selRange, int scrollMode)
Selects the range of text indicated.
public boolean
setSelection(ISourceElement el, int scrollMode)
Selects the specified element.
public void
setSelectionDot(int offset, int scrollMode)
Sets the offset of the movable dot of the source selection.
public void
setSelectionEnd(int offset, int scrollMode)
Sets the offset of the end of the source selection.
public void
setSelectionMark(int offset, int scrollMode)
Sets the offset of the anchor mark of the source selection.
public void
setSelectionStart(int offset, int scrollMode)
Sets the offset of the start of the source selection.
public void
showPopupTip(IPopupTip tip)
Displays a popup tip in an active source editor.
 
Methods from interface com.bea.ide.core.ICookieSupport
addCookie, getCookie, removeCookie
 
Methods from interface com.bea.ide.document.IDocumentView
getDocument, getDocumentElement, getNavigationPoint, onActivate, onClose, onDeactivate, requestViewFocus, setCurrentPoint
 
Methods from interface com.bea.ide.core.IDriverSupport
getDriver
 
Methods from interface com.bea.ide.core.IPropertySupport
addPropertyChangeListener, addPropertyChangeListener, getProperty, removePropertyChangeListener, removePropertyChangeListener, setProperty
   

Field Detail

RIGHT_CLICK_POINT_KEY

public static final String RIGHT_CLICK_POINT_KEY
Key for a cookie on the Application that stores where the user last right clicked in the SourceView


SCROLL_MIDDLE

public static final int SCROLL_MIDDLE
If a new selection is off the screen, scroll it to the middle of the screen.


SCROLL_MIDDLE_ALWAYS

public static final int SCROLL_MIDDLE_ALWAYS
Always scroll to the middle. Even if we are only one line away now.


SCROLL_MIDDLE_FORCE

public static final int SCROLL_MIDDLE_FORCE
If a new selection is not in the middle of the screen, scroll it to the middle of the screen. That is, selections in the top 2 or bottom 5 visible lines will scroll to the middle.


SCROLL_MINIMAL

public static final int SCROLL_MINIMAL
If a new selection is off the screen, scroll it barely onto the screen.

 

Method Detail

addHoverListener(IHoverListener) Method

public void addHoverListener(IHoverListener hoverListener)
Adds a hover listener to this source view. This listener will be notified whenever the mouse hovers over a particular point for a fixed period of time. Note that hover listeners are only useful while the source view is active.


expandCollapsibleElement(ISourceElement, boolean) Method

public boolean expandCollapsibleElement(ISourceElement elmt, 
                                        boolean expand)
Expands or collapses the text for a source element.

Parameters

elmt
is either itself a collapsible element, or else it should be a member of an ISourceElementGroup. In the first case, that element is expanded/collapsed. In the latter case the entire group is expanded/collapsed.
expand
is true to expand this node, false to collapse it. Note that when expanding, all parent elements are expanded too, since this method is intended to make the element's text visible. It is not possible to expand a collapsible group by passing it directly, because in theory the same group object could wrap multiple sets of discontiguous source elements.

Returns

false if no collapsible node was found matching the ISourceElement.

getCaret() Method

public Caret getCaret()
Returns the current caret.


getCaretPosition() Method

public int getCaretPosition()
Returns the zero-based character offset of the caret within the view.


getEditableLineText(int, Range) Method

public String getEditableLineText(int sourceLine, 
                                  Range range)
Returns that portion of a line's text which is not collapsed. This could be null if the entire line is collapsed. It could be just the beginning, end, or middle of the line if it borders one or more collapsed blocks. Or it could be the entire line text if the line is not collapsed.

Parameters

sourceLine
is the 0-based line in the file.
range
is an out-parameter that gets set to the position range that equates to the string. It may be null if it is not requested.

getLineRangeAround(int) Method

public Range getLineRangeAround(int pos)

getOffset(Point) Method

public int getOffset(Point p)
Returns the offset in the document for the element at the given point, -1 if there is no element at that location


getSelectedText() Method

public String getSelectedText()
Returns the text selected in the source view. May return an empty string or null.


getSelectionEnd() Method

public int getSelectionEnd()
Returns the zero-based offset of the end of the text selection. This is equivalent to the value returned from <code>getSelectionStart</code> in the case where there is no selected text.


getSelectionStart() Method

public int getSelectionStart()
Returns the zero-based offset of the start of the text selection. This is equivalent to the value returned from <code>getSelectionEnd</code> in the case where there is no selected text.


getWordAtCaret() Method

public String getWordAtCaret()

getWordRangeAround(int) Method

public Range getWordRangeAround(int pos)

isDraggingDroppableObject() Method

public boolean isDraggingDroppableObject()
Used to differentiate between dragging to create a selection, and dragging to do a drag-drop.

Returns

true if a drag-drop operation is being attempted.

isSingleLineSelection() Method

public boolean isSingleLineSelection()

removeHoverListener(IHoverListener) Method

public void removeHoverListener(IHoverListener hoverListener)
Removes a hover listener from this source view.


replaceSelectedText(String) Method

public boolean replaceSelectedText(String strReplacement)
Replaces any selected text with the specified string. If no text is selected, the text will be inserted at the current caret insertion point.


setCaretPosition(int, int) Method

public void setCaretPosition(int pos, 
                             int scrollMode)
Sets the caret position within the source view.

Parameters

pos
the zero-based character offset of the desired caret position
scrollMode
specifies whether the source view should scroll, if necessary, to ensure that the caret is visible.

setSelection(int, int, int, int, int) Method

public boolean setSelection(int lineStart, 
                            int colStart, 
                            int lineEnd, 
                            int colEnd, 
                            int scrollMode)
Selects the indicated text range. To simply move the cursor, rather than select text, pass -1 for lineEnd and colEnd. To goto the start of a line, pass -1 for colStart. For example, selectSource(12, -1, -1, -1) moves the cursor to the start of line 12.


setSelection(Range, int) Method

public boolean setSelection(Range selRange, 
                            int scrollMode)
Selects the range of text indicated.


setSelection(ISourceElement, int) Method

public boolean setSelection(ISourceElement el, 
                            int scrollMode)
Selects the specified element. Note that calls to this method, unlike the other setSelection methods, are passed through to ISourceViewDriver.getSelectionRange to determine the exact text range that should be selected.


setSelectionDot(int, int) Method

public void setSelectionDot(int offset, 
                            int scrollMode)
Sets the offset of the movable dot of the source selection.

Parameters

offset
the zero-based character offset of the desired selection dot.
scrollMode
specifies the scroll mode that should be used to ensure that the selection is visible.

setSelectionEnd(int, int) Method

public void setSelectionEnd(int offset, 
                            int scrollMode)
Sets the offset of the end of the source selection. The start and end are always normalized (start <= end).

Parameters

offset
the zero-based character offset of the desired selection end.
scrollMode
specifies the scroll mode that should be used to ensure that the selection is visible.

setSelectionMark(int, int) Method

public void setSelectionMark(int offset, 
                             int scrollMode)
Sets the offset of the anchor mark of the source selection.

Parameters

offset
the zero-based character offset of the desired selection mark.
scrollMode
specifies the scroll mode that should be used to ensure that the selection is visible.

setSelectionStart(int, int) Method

public void setSelectionStart(int offset, 
                              int scrollMode)
Sets the offset of the start of the source selection. The start and end are always normalized (start <= end).

Parameters

offset
the zero-based character offset of the desired selection start.
scrollMode
specifies the scroll mode that should be used to ensure that the selection is visible.

showPopupTip(IPopupTip) Method

public void showPopupTip(IPopupTip tip)
Displays a popup tip in an active source editor. If the source view is not active, this method does nothing.

Parameters

tip
the tip to display