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

Quick Search    Search Deep

com.port80.swt.widgets
Class GraphViewIncrementalFinder  view GraphViewIncrementalFinder download GraphViewIncrementalFinder.java

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

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

An incremental find target for IGraphViewer. 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.IStructuredContentProvider 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  IStatusLine fStatusLine
          The status line manager for output
private  IGraphViewer 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
GraphViewIncrementalFinder(IGraphViewer viewer, IStatusLine 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)
           
 boolean canPerformFind()
           
 void endSession()
           
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  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

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

TAB

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


PATTERN_NOTFOUND

private static java.lang.String PATTERN_NOTFOUND

PATTERN_FOUND

private static java.lang.String PATTERN_FOUND

PROMPT

private static java.lang.String PROMPT

fViewer

private final IGraphViewer fViewer
The text viewer to operate on


fStatusLine

private final IStatusLine 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

fContentProvider

private org.eclipse.jface.viewers.IStructuredContentProvider fContentProvider

fLabelProvider

private org.eclipse.jface.viewers.ILabelProvider fLabelProvider

fPrevKeyListener

private org.eclipse.swt.events.KeyListener fPrevKeyListener

fStack

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

Constructor Detail

GraphViewIncrementalFinder

public GraphViewIncrementalFinder(IGraphViewer viewer,
                                  IStatusLine manager,
                                  org.eclipse.swt.events.KeyListener prev)
Creates an instance of an incremental find target.

Method Detail

canPerformFind

public boolean canPerformFind()

isEditable

public boolean isEditable()

getSelection

public org.eclipse.jface.viewers.StructuredSelection getSelection()

getSelectionText

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


setSelection

public void setSelection(java.lang.Object object)

findAndSelect

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


beginSession

public void beginSession(boolean forward,
                         java.lang.String defaultString)

endSession

public void endSession()

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

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)