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

Quick Search    Search Deep

com.port80.eclipse.jdt.actions
Class RegexReplaceDialog  view RegexReplaceDialog download RegexReplaceDialog.java

java.lang.Object
  extended byorg.eclipse.jface.window.Window
      extended byorg.eclipse.jface.dialogs.Dialog
          extended bycom.port80.eclipse.jdt.actions.RegexReplaceDialog

public class RegexReplaceDialog
extends org.eclipse.jface.dialogs.Dialog


Nested Class Summary
private  class RegexReplaceDialog.PatternChanged
           
 
Nested classes inherited from class org.eclipse.jface.window.Window
org.eclipse.jface.window.Window.IExceptionHandler
 
Field Summary
private static boolean DEBUG
           
(package private)  int fAnchor
           
private  org.eclipse.swt.widgets.Button fButtonClose
           
private  org.eclipse.swt.widgets.Button fButtonFind
           
private  org.eclipse.swt.widgets.Button fButtonNext
           
private  org.eclipse.swt.widgets.Button fButtonPrev
           
private  org.eclipse.swt.widgets.Button fButtonRelaceFind
           
private  org.eclipse.swt.widgets.Button fButtonReplaceAll
           
private  org.eclipse.swt.widgets.Button fButtonReplaceClose
           
private  org.eclipse.swt.widgets.Button fCaseSensitive
           
private static RegexReplaceDialog fDefault
           
private  org.eclipse.jface.text.IDocument fDoc
           
private  org.eclipse.ui.texteditor.ITextEditor fEditor
           
(package private)  org.eclipse.jface.text.Position fEnd
           
(package private)  com.port80.util.struct.IntList fHistory
           
(package private)  int fLastReplaced
           
(package private)  org.apache.oro.text.regex.PatternMatcherInput fMatchInput
           
(package private)  int fOffset
           
private  org.eclipse.swt.widgets.Shell fParent
           
private  org.eclipse.swt.widgets.Combo fPattern
           
(package private)  RegexReplaceDialog.PatternChanged fPatternChangedHandler
           
private static java.util.List fPatterns
           
private static org.apache.oro.text.perl.Perl5Util fReEngine
           
private  org.eclipse.swt.widgets.Combo fReplace
           
(package private)  boolean fReplaceAllRunning
           
private static java.util.List fReplaces
           
private  org.eclipse.swt.widgets.Button fSingleLine
           
(package private)  int fStart
           
private  org.eclipse.swt.widgets.Label fStatus
           
private static org.eclipse.swt.graphics.Point fWindowPosition
           
(package private)  boolean isWrapped
           
private static int MAX_PERSISTENT
           
private static java.lang.String NAME
           
private static int WIDTH
           
 
Fields inherited from class org.eclipse.jface.dialogs.Dialog
blockedHandler, buttonBar, dialogArea, DLG_IMG_ERROR, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
private RegexReplaceDialog(org.eclipse.swt.widgets.Shell parentShell, org.eclipse.ui.texteditor.ITextEditor editor)
          Constructor for RegexReplaceDialog.
 
Method Summary
(package private)  void actionClose()
           
(package private)  void actionFind()
           
(package private)  void actionHistoryPrev()
           
(package private)  void actionReplaceAll()
           
(package private)  void actionReplaceClose()
           
(package private)  void actionReplaceFind()
           
(package private)  int adjustOffset(java.lang.String pat, java.lang.StringBuffer buf)
          Adjust fOffset after replace.
private  void appendHistory(int offset, int len)
           
 boolean close()
          Closes this window, disposes its shell, and removes this window from its window manager (if it has one).
protected  void constrainShellSize()
          Constrain the shell size to be no larger than the display bounds.
protected  org.eclipse.swt.widgets.Control createButtonBar(org.eclipse.swt.widgets.Composite parent)
          Creates and returns the contents of this dialog's button bar.
protected  org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.Composite parent)
          The Dialog implementation of this Window method creates and lays out the top level composite for the dialog, and determines the appropriate horizontal and vertical dialog units based on the font size.
protected  org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
          Creates and returns the contents of the upper part of this dialog (above the button bar).
 void dispose()
           
private  java.lang.String escapeReplaceString(java.lang.String s)
           
(package private)  boolean find(java.lang.String pat, java.lang.String opt)
           
(package private)  boolean find1(java.lang.String pat, java.lang.String opt)
          A simplified version of find() for actionReplaceAll to avoid accessing UI, eg.
private  java.lang.String fixPatternForReplace(java.lang.String s)
          Since we perfrom replace on the matched string of the previous find action, the leading look behind and trailing look ahead are not included in the matched string.
static RegexReplaceDialog getDefault(org.eclipse.swt.widgets.Shell shell, org.eclipse.ui.texteditor.ITextEditor editor)
           
(package private)  org.eclipse.ui.texteditor.ITextEditor getEditor()
           
(package private)  java.lang.String getSearchOptions()
           
(package private)  void init(org.eclipse.ui.texteditor.ITextEditor editor)
           
(package private)  void patternChanged(org.eclipse.swt.events.ModifyEvent event)
           
(package private)  boolean replace(java.lang.String pat, java.lang.String replace, java.lang.String opt, java.lang.StringBuffer buf)
           
(package private)  void replaceAllDone(java.lang.StringBuffer buf, int[] offset, int[] replaced)
           
private  void savePattern(java.lang.String pat)
           
private  void saveReplace(java.lang.String replace)
           
(package private)  void setEnableFind(boolean enable)
           
(package private)  void setEnablePrev(boolean b)
           
(package private)  void setEnableReplace(boolean enable)
           
private  int skipTill(char delim, java.lang.String s, int start)
           
private  boolean wrap()
           
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, cancelPressed, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, createButtonsForButtonBar, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getImage, getOKButton, initializeBounds, initializeDialogUnits, okPressed, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
 
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, configureShell, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getInitialLocation, getInitialSize, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setExceptionHandler, setReturnCode, setShellStyle, setWindowManager
 
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

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

MAX_PERSISTENT

private static final int MAX_PERSISTENT
See Also:
Constant Field Values

WIDTH

private static final int WIDTH
See Also:
Constant Field Values

fDefault

private static RegexReplaceDialog fDefault

fWindowPosition

private static org.eclipse.swt.graphics.Point fWindowPosition

fPatterns

private static java.util.List fPatterns

fReplaces

private static java.util.List fReplaces

fReEngine

private static org.apache.oro.text.perl.Perl5Util fReEngine

fParent

private org.eclipse.swt.widgets.Shell fParent

fEditor

private org.eclipse.ui.texteditor.ITextEditor fEditor

fDoc

private org.eclipse.jface.text.IDocument fDoc

fMatchInput

org.apache.oro.text.regex.PatternMatcherInput fMatchInput

fStart

int fStart

fEnd

org.eclipse.jface.text.Position fEnd

fOffset

int fOffset

fAnchor

int fAnchor

fLastReplaced

int fLastReplaced

fHistory

com.port80.util.struct.IntList fHistory

fPatternChangedHandler

RegexReplaceDialog.PatternChanged fPatternChangedHandler

isWrapped

boolean isWrapped

fReplaceAllRunning

boolean fReplaceAllRunning

fPattern

private org.eclipse.swt.widgets.Combo fPattern

fReplace

private org.eclipse.swt.widgets.Combo fReplace

fButtonReplaceAll

private org.eclipse.swt.widgets.Button fButtonReplaceAll

fButtonReplaceClose

private org.eclipse.swt.widgets.Button fButtonReplaceClose

fButtonRelaceFind

private org.eclipse.swt.widgets.Button fButtonRelaceFind

fButtonFind

private org.eclipse.swt.widgets.Button fButtonFind

fButtonPrev

private org.eclipse.swt.widgets.Button fButtonPrev

fButtonNext

private org.eclipse.swt.widgets.Button fButtonNext

fSingleLine

private org.eclipse.swt.widgets.Button fSingleLine

fCaseSensitive

private org.eclipse.swt.widgets.Button fCaseSensitive

fButtonClose

private org.eclipse.swt.widgets.Button fButtonClose

fStatus

private org.eclipse.swt.widgets.Label fStatus
Constructor Detail

RegexReplaceDialog

private RegexReplaceDialog(org.eclipse.swt.widgets.Shell parentShell,
                           org.eclipse.ui.texteditor.ITextEditor editor)
Constructor for RegexReplaceDialog.

Method Detail

getDefault

public static RegexReplaceDialog getDefault(org.eclipse.swt.widgets.Shell shell,
                                            org.eclipse.ui.texteditor.ITextEditor editor)

dispose

public void dispose()

init

void init(org.eclipse.ui.texteditor.ITextEditor editor)

constrainShellSize

protected void constrainShellSize()
Description copied from class: org.eclipse.jface.window.Window
Constrain the shell size to be no larger than the display bounds.


createContents

protected org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.Composite parent)
Description copied from class: org.eclipse.jface.dialogs.Dialog
The Dialog implementation of this Window method creates and lays out the top level composite for the dialog, and determines the appropriate horizontal and vertical dialog units based on the font size. It then calls the createDialogArea and createButtonBar methods to create the dialog area and button bar, respectively. Overriding createDialogArea and createButtonBar are recommended rather than overriding this method.


createDialogArea

protected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
Description copied from class: org.eclipse.jface.dialogs.Dialog
Creates and returns the contents of the upper part of this dialog (above the button bar).

The Dialog implementation of this framework method creates and returns a new Composite with standard margins and spacing.

The returned control's layout data must be an instance of GridData. This method must not modify the parent's layout.

Subclasses must override this method but may call super as in the following example:

 Composite composite = (Composite) super.createDialogArea(parent);
 //add controls to composite as necessary
 return composite;
 


createButtonBar

protected org.eclipse.swt.widgets.Control createButtonBar(org.eclipse.swt.widgets.Composite parent)
Description copied from class: org.eclipse.jface.dialogs.Dialog
Creates and returns the contents of this dialog's button bar.

The Dialog implementation of this framework method lays out a button bar and calls the createButtonsForButtonBar framework method to populate it. Subclasses may override.

The returned control's layout data must be an instance of GridData.


close

public boolean close()
Description copied from class: org.eclipse.jface.window.Window
Closes this window, disposes its shell, and removes this window from its window manager (if it has one).

This framework method may be extended (super.close must be called).


getEditor

org.eclipse.ui.texteditor.ITextEditor getEditor()

setEnableFind

void setEnableFind(boolean enable)

setEnableReplace

void setEnableReplace(boolean enable)

setEnablePrev

void setEnablePrev(boolean b)

find

boolean find(java.lang.String pat,
             java.lang.String opt)

find1

boolean find1(java.lang.String pat,
              java.lang.String opt)
A simplified version of find() for actionReplaceAll to avoid accessing UI, eg. fStatus.


replace

boolean replace(java.lang.String pat,
                java.lang.String replace,
                java.lang.String opt,
                java.lang.StringBuffer buf)

appendHistory

private void appendHistory(int offset,
                           int len)

actionClose

void actionClose()

actionFind

void actionFind()

actionReplaceFind

void actionReplaceFind()

actionReplaceClose

void actionReplaceClose()

actionReplaceAll

void actionReplaceAll()

replaceAllDone

void replaceAllDone(java.lang.StringBuffer buf,
                    int[] offset,
                    int[] replaced)

actionHistoryPrev

void actionHistoryPrev()

getSearchOptions

java.lang.String getSearchOptions()

patternChanged

void patternChanged(org.eclipse.swt.events.ModifyEvent event)

savePattern

private void savePattern(java.lang.String pat)

saveReplace

private void saveReplace(java.lang.String replace)

wrap

private boolean wrap()

adjustOffset

int adjustOffset(java.lang.String pat,
                 java.lang.StringBuffer buf)
Adjust fOffset after replace. If 'pat' ends with '$' and current offset is at end of line, advance fOffset to next line.


fixPatternForReplace

private java.lang.String fixPatternForReplace(java.lang.String s)
Since we perfrom replace on the matched string of the previous find action, the leading look behind and trailing look ahead are not included in the matched string. Have to adjust the pattern for that. Since the pattern is already matched, the zero-width pattern is not actually required, we just remove them from the pattern. NOTE: As of jarkata-oro-2.0.6, it do not support look behind yet.


skipTill

private int skipTill(char delim,
                     java.lang.String s,
                     int start)

escapeReplaceString

private java.lang.String escapeReplaceString(java.lang.String s)