@Override public void setScope(IRegion scope) { if (fRange != null) fRange.uninstall(); if (scope == null) { fRange= null; return; } fRange= new FindReplaceRange(scope); fRange.setHighlightColor(fScopeHighlightColor); fRange.install(); }
/** * Uninstalls this range. * @see #install() */ public void uninstall() { // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19612 IDocument document= TextViewer.this.getDocument(); if (document != null) { document.removePositionUpdater(this); document.removePosition(fPosition); } if (fTextWidget != null && !fTextWidget.isDisposed()) fTextWidget.removeLineBackgroundListener(this); TextViewer.this.removeTextListener(this); clear(); }
@Override public IRegion getScope() { return fRange == null ? null : fRange.getRange(); }
/** * Installs this range. The range registers itself as background * line painter and text listener. Also, it creates a category with the * viewer's document to maintain its own extent. */ public void install() { TextViewer.this.addTextListener(this); fTextWidget.addLineBackgroundListener(this); IDocument document= TextViewer.this.getDocument(); try { document.addPositionCategory(RANGE_CATEGORY); document.addPosition(RANGE_CATEGORY, fPosition); document.addPositionUpdater(this); } catch (BadPositionCategoryException e) { // should not happen } catch (BadLocationException e) { // should not happen } paint(); }
/** * Installs this range. The range registers itself as background * line painter and text listener. Also, it creates a category with the * viewer's document to maintain its own extent. */ public void install() { TextViewer.this.addTextListener(this); fTextWidget.addLineBackgroundListener(this); IDocument document= TextViewer.this.getDocument(); try { document.addPositionCategory(RANGE_CATEGORY); document.addPosition(RANGE_CATEGORY, fPosition); document.addPositionUpdater(this); } catch (BadPositionCategoryException e) { // should not happen } catch (BadLocationException e) { // should not happen } paint(); }
/** * Uninstalls this range. * @see #install() */ public void uninstall() { // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19612 IDocument document= TextViewer.this.getDocument(); if (document != null) { document.removePositionUpdater(this); document.removePosition(fPosition); } if (fTextWidget != null && !fTextWidget.isDisposed()) fTextWidget.removeLineBackgroundListener(this); TextViewer.this.removeTextListener(this); clear(); }
@Override public void endSession() { if (fRange != null) { fRange.uninstall(); fRange= null; } }
@Override public void textChanged(TextEvent event) { if (event.getViewerRedrawState()) paint(); }
@Override public void setScopeHighlightColor(Color color) { if (fRange != null) fRange.setHighlightColor(color); fScopeHighlightColor= color; }
@Override public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) { int modelOffset= widgetOffset == -1 ? -1 : widgetOffset2ModelOffset(widgetOffset); if (fRange != null) { IRegion range= fRange.getRange(); modelOffset= TextViewer.this.findAndSelectInRange(modelOffset, findString, searchForward, caseSensitive, wholeWord, range.getOffset(), range.getLength(), regExSearch); } else { modelOffset= TextViewer.this.findAndSelect(modelOffset, findString, searchForward, caseSensitive, wholeWord, regExSearch); } widgetOffset= modelOffset == -1 ? -1 : modelOffset2WidgetOffset(modelOffset); return widgetOffset; }
/** Creates a new find/replace range with the given extent. * * @param range the extent of this range */ public FindReplaceRange(IRegion range) { setRange(range); }
@Override public void textChanged(TextEvent event) { if (event.getViewerRedrawState()) paint(); }
/** * Sets the highlight color of this range. Causes the range to be redrawn. * * @param color the highlight color */ public void setHighlightColor(Color color) { fHighlightColor= color; paint(); }
@Override public void setScopeHighlightColor(Color color) { if (fRange != null) fRange.setHighlightColor(color); fScopeHighlightColor= color; }
@Override public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) { int modelOffset= widgetOffset == -1 ? -1 : widgetOffset2ModelOffset(widgetOffset); if (fRange != null) { IRegion range= fRange.getRange(); modelOffset= TextViewer.this.findAndSelectInRange(modelOffset, findString, searchForward, caseSensitive, wholeWord, range.getOffset(), range.getLength(), regExSearch); } else { modelOffset= TextViewer.this.findAndSelect(modelOffset, findString, searchForward, caseSensitive, wholeWord, regExSearch); } widgetOffset= modelOffset == -1 ? -1 : modelOffset2WidgetOffset(modelOffset); return widgetOffset; }
@Override public void endSession() { if (fRange != null) { fRange.uninstall(); fRange= null; } }
/** * Sets the highlight color of this range. Causes the range to be redrawn. * * @param color the highlight color */ public void setHighlightColor(Color color) { fHighlightColor= color; paint(); }
@Override public void setScope(IRegion scope) { if (fRange != null) fRange.uninstall(); if (scope == null) { fRange= null; return; } fRange= new FindReplaceRange(scope); fRange.setHighlightColor(fScopeHighlightColor); fRange.install(); }
@Override public IRegion getScope() { return fRange == null ? null : fRange.getRange(); }
/** Creates a new find/replace range with the given extent. * * @param range the extent of this range */ public FindReplaceRange(IRegion range) { setRange(range); }