Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.eclipse.util
Class IncrementalFindTreeTarget  view IncrementalFindTreeTarget download IncrementalFindTreeTarget.java

java.lang.Object
  extended bycom.port80.eclipse.util.IncrementalFindTreeTarget
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.events.FocusListener, IIncrementalFindTreeTarget, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.internal.SWTEventListener

public class IncrementalFindTreeTarget
extends java.lang.Object
implements IIncrementalFindTreeTarget, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.FocusListener

An incremental find target for StructuredViewer with an ILabelProvider. Replace is always disabled.

Since:
2.0

Field Summary
private static int CHAR
          A constant representing adding a character to the find pattern
private static boolean DEBUG
           
private  int fBasePosition
          The position to start the find from
private  int fCasePosition
          Index of first upper case char.
private  org.eclipse.jface.viewers.ITreeContentProvider fContentProvider
           
private  int fCurrentIndex
          The position of the last successful find
private  java.lang.Object[] fElements
           
private  java.lang.StringBuffer fFindString
          The current find string
private  boolean fForward
           
private  boolean fFound
          A flag indicating if last find was successful
private  boolean fInstalled
          A flag indicating listeners are installed.
private  org.eclipse.jface.viewers.ILabelProvider fLabelProvider
           
private  org.eclipse.swt.events.KeyListener fPrevKeyListener
           
private static java.lang.String fSavedString
           
private  java.util.Stack fStack
          Index stack to backtrace when taking back characters.
private  org.eclipse.jface.action.IStatusLineManager fStatusLine
          The status line manager for output
private  org.eclipse.jface.viewers.AbstractTreeViewer fViewer
          The text viewer to operate on
private static java.lang.String NAME
           
private static int NEXT
          A constant representing a find-next operation
private static java.lang.String PATTERN_FOUND
           
private static java.lang.String PATTERN_NOTFOUND
           
private static int PREVIOUS
          A constant representing a find-previous operation
private static java.lang.String PROMPT
           
private static java.lang.String TAB
          The string representing rendered tab
private static java.lang.Object WRAPPED
          A constant representing a wrap operation
 
Constructor Summary
IncrementalFindTreeTarget(org.eclipse.jface.viewers.AbstractTreeViewer viewer, org.eclipse.jface.action.IStatusLineManager manager, org.eclipse.swt.events.KeyListener prev)
          Creates an instance of an incremental find target.
 
Method Summary
private  void beep()
           
 void beginSession(boolean forward, java.lang.String defaultString)
          Begin an incremental find session.
 boolean canPerformFind()
           
 void endSession()
          End an incremental find session.
private  java.lang.String escapeTabs(java.lang.String string)
          Translates all tab characters into a proper status line presentation.
 int findAndSelect(int start, java.lang.String findString, boolean forward, boolean caseSensitive)
          Find item with the given string and select it.
private  int findIndex(java.lang.String findString, int startPosition, boolean forward, boolean caseSensitive, boolean wrapSearch, boolean takeBack)
          Retuns the offset at which the search string is found next using the given options
 void focusGained(org.eclipse.swt.events.FocusEvent e)
          Sent when a control gets focus.
 void focusLost(org.eclipse.swt.events.FocusEvent e)
          Sent when a control loses focus.
 org.eclipse.jface.viewers.StructuredSelection getSelection()
           
 java.lang.String getSelectionText()
          Get text representation of the currently selected item.
private  java.util.List getTreeElements(java.lang.Object[] parents, org.eclipse.jface.viewers.ViewerSorter sorter, java.util.List ret)
          Get an ordered list of elements in a tree.
private  void install()
          Installs this target.
 boolean isEditable()
           
 void keyPressed(org.eclipse.swt.events.KeyEvent event)
          Perform increment find.
 void keyReleased(org.eclipse.swt.events.KeyEvent event)
          Sent when a key is released on the system keyboard.
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
          Sent when a mouse button is pressed twice within the (operating system specified) double click period.
 void mouseDown(org.eclipse.swt.events.MouseEvent e)
          Sent when a mouse button is pressed.
 void mouseUp(org.eclipse.swt.events.MouseEvent e)
          Sent when a mouse button is released.
private  void msgDebug(java.lang.String msg)
           
private  boolean performFindNext(boolean forward, int start, boolean wrapSearch, boolean takeBack)
          Returns whether the find string can be found using the given options.
private  int popChar()
          Delete a character from the find string.
private  void pushChar(char character)
          Extends the incremental search by the given character.
 void setSelection(java.lang.Object object)
           
private  void statusClear()
          Clears the status message and the status error message.
private  void statusError(java.lang.String string)
          Sets the status error message, clears the status message.
private  void statusMessage(java.lang.String string)
          Sets the given string as status message, clears the status error message.
private  void uninstall()
          Uninstalls itself.
private  void updateStatus(boolean found)
          Updates the status line appropriate for the indicated success.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

TAB

private static final java.lang.String TAB
The string representing rendered tab


PATTERN_NOTFOUND

private static final java.lang.String PATTERN_NOTFOUND

PATTERN_FOUND

private static final java.lang.String PATTERN_FOUND

PROMPT

private static final java.lang.String PROMPT

NEXT

private static final int NEXT
A constant representing a find-next operation

See Also:
Constant Field Values

PREVIOUS

private static final int PREVIOUS
A constant representing a find-previous operation

See Also:
Constant Field Values

CHAR

private static final int CHAR
A constant representing adding a character to the find pattern

See Also:
Constant Field Values

WRAPPED

private static final java.lang.Object WRAPPED
A constant representing a wrap operation


DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

fSavedString

private static java.lang.String fSavedString

fViewer

private final org.eclipse.jface.viewers.AbstractTreeViewer fViewer
The text viewer to operate on


fStatusLine

private final org.eclipse.jface.action.IStatusLineManager fStatusLine
The status line manager for output


fFindString

private java.lang.StringBuffer fFindString
The current find string


fCasePosition

private int fCasePosition
Index of first upper case char. in the find string. -1 if no upper case.


fBasePosition

private int fBasePosition
The position to start the find from


fCurrentIndex

private int fCurrentIndex
The position of the last successful find


fFound

private boolean fFound
A flag indicating if last find was successful


fForward

private boolean fForward

fInstalled

private boolean fInstalled
A flag indicating listeners are installed.


fElements

private java.lang.Object[] fElements

fLabelProvider

private org.eclipse.jface.viewers.ILabelProvider fLabelProvider

fContentProvider

private org.eclipse.jface.viewers.ITreeContentProvider fContentProvider

fPrevKeyListener

private org.eclipse.swt.events.KeyListener fPrevKeyListener

fStack

private java.util.Stack fStack
Index stack to backtrace when taking back characters.

Constructor Detail

IncrementalFindTreeTarget

public IncrementalFindTreeTarget(org.eclipse.jface.viewers.AbstractTreeViewer viewer,
                                 org.eclipse.jface.action.IStatusLineManager manager,
                                 org.eclipse.swt.events.KeyListener prev)
Creates an instance of an incremental find target.

Method Detail

canPerformFind

public boolean canPerformFind()
Specified by:
canPerformFind in interface IIncrementalFindTreeTarget

isEditable

public boolean isEditable()
Specified by:
isEditable in interface IIncrementalFindTreeTarget

getSelection

public org.eclipse.jface.viewers.StructuredSelection getSelection()
Specified by:
getSelection in interface IIncrementalFindTreeTarget

getSelectionText

public java.lang.String getSelectionText()
Get text representation of the currently selected item.

Specified by:
getSelectionText in interface IIncrementalFindTreeTarget

setSelection

public void setSelection(java.lang.Object object)
Specified by:
setSelection in interface IIncrementalFindTreeTarget

findAndSelect

public int findAndSelect(int start,
                         java.lang.String findString,
                         boolean forward,
                         boolean caseSensitive)
Find item with the given string and select it.

Specified by:
findAndSelect in interface IIncrementalFindTreeTarget

beginSession

public void beginSession(boolean forward,
                         java.lang.String defaultString)
Description copied from interface: IIncrementalFindTreeTarget
Begin an incremental find session. This should be called before any increment find action can proceed.

Specified by:
beginSession in interface IIncrementalFindTreeTarget

endSession

public void endSession()
Description copied from interface: IIncrementalFindTreeTarget
End an incremental find session. This should be called at the end of every incremental find session.

Specified by:
endSession in interface IIncrementalFindTreeTarget

install

private void install()
Installs this target. I.e. adds all required listeners.


uninstall

private void uninstall()
Uninstalls itself. I.e. removes all listeners installed in install.


performFindNext

private boolean performFindNext(boolean forward,
                                int start,
                                boolean wrapSearch,
                                boolean takeBack)
Returns whether the find string can be found using the given options.


findIndex

private int findIndex(java.lang.String findString,
                      int startPosition,
                      boolean forward,
                      boolean caseSensitive,
                      boolean wrapSearch,
                      boolean takeBack)
Retuns the offset at which the search string is found next using the given options


updateStatus

private void updateStatus(boolean found)
Updates the status line appropriate for the indicated success.


keyPressed

public void keyPressed(org.eclipse.swt.events.KeyEvent event)
Perform increment find. All non-printable characters need to be escaped. TODO: escape non-printable characters.

Specified by:
keyPressed in interface org.eclipse.swt.events.KeyListener

keyReleased

public void keyReleased(org.eclipse.swt.events.KeyEvent event)
Description copied from interface: org.eclipse.swt.events.KeyListener
Sent when a key is released on the system keyboard.

Specified by:
keyReleased in interface org.eclipse.swt.events.KeyListener

pushChar

private void pushChar(char character)
Extends the incremental search by the given character.


popChar

private int popChar()
Delete a character from the find string.


beep

private void beep()

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
Description copied from interface: org.eclipse.swt.events.MouseListener
Sent when a mouse button is pressed twice within the (operating system specified) double click period.

Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent e)
Description copied from interface: org.eclipse.swt.events.MouseListener
Sent when a mouse button is pressed.

Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent e)
Description copied from interface: org.eclipse.swt.events.MouseListener
Sent when a mouse button is released.

Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener

focusGained

public void focusGained(org.eclipse.swt.events.FocusEvent e)
Description copied from interface: org.eclipse.swt.events.FocusListener
Sent when a control gets focus.

Specified by:
focusGained in interface org.eclipse.swt.events.FocusListener

focusLost

public void focusLost(org.eclipse.swt.events.FocusEvent e)
Description copied from interface: org.eclipse.swt.events.FocusListener
Sent when a control loses focus.

Specified by:
focusLost in interface org.eclipse.swt.events.FocusListener

getTreeElements

private java.util.List getTreeElements(java.lang.Object[] parents,
                                       org.eclipse.jface.viewers.ViewerSorter sorter,
                                       java.util.List ret)
Get an ordered list of elements in a tree.


statusMessage

private void statusMessage(java.lang.String string)
Sets the given string as status message, clears the status error message.


statusError

private void statusError(java.lang.String string)
Sets the status error message, clears the status message.


statusClear

private void statusClear()
Clears the status message and the status error message.


escapeTabs

private java.lang.String escapeTabs(java.lang.String string)
Translates all tab characters into a proper status line presentation.


msgDebug

private void msgDebug(java.lang.String msg)