Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.text
Class DefaultPositionUpdater


java.lang.Object
  extended by 
org.eclipse.jface.text.DefaultPositionUpdater
All Implemented Interfaces:
IPositionUpdater
Direct Known Subclasses:
MultiPassContentFormatter.NonDeletingPositionUpdater

public class DefaultPositionUpdater
extends Object
implements IPositionUpdater

Default implementation of IPositionUpdater.

A default position updater must be configured with the position category whose positions it will update. Other position categories are not affected by this updater.

This implementation follows the specification below:

  • Inserting or deleting text before the position shifts the position accordingly.
  • Inserting text at the position offset shifts the position accordingly.
  • Inserting or deleting text strictly contained by the position shrinks or stretches the position.
  • Inserting or deleting text after a position does not affect the position.
  • Deleting text which strictly contains the position deletes the position. Note that the position is not deleted if its only shrunken to length zero. To delete a position, the modification must delete from strictly before to strictly after the position.
  • Replacing text overlapping with the position is considered as a sequence of first deleting the replaced text and afterwards inserting the new text. Thus, a position might first be shifted and shrunken and then be stretched.
This class can be used as is or be adapted by subclasses. Fields are protected to allow subclasses direct access. Because of the frequency with which position updaters are used this is a performance decision.


Field Summary
protected   IDocument fDocument
          Catches the document
protected  int fLength
          Caches the length of the replaced text
protected  int fOffset
          Caches the offset of the replaced text
protected   Position fOriginalPosition
          Remembers the original state of the investigated position
protected   Position fPosition
          Caches the currently investigated position
protected  int fReplaceLength
          Caches the length of the newly inserted text
 
Constructor Summary
DefaultPositionUpdater ( String category)
          Creates a new default position updater for the given category.
 
Method Summary
protected  void adaptToInsert ()
          Adapts the currently investigated position to an insertion.
protected  void adaptToRemove ()
          Adapts the currently investigated position to a deletion.
protected  void adaptToReplace ()
          Adapts the currently investigated position to the replace operation.
protected   String getCategory ()
          Returns the category this updater is responsible for.
protected  boolean isAffectingReplace ()
          Returns whether the current event describes a well formed replace by which the current position is directly affected.
protected  boolean notDeleted ()
          Determines whether the currently investigated position has been deleted by the replace operation specified in the current event.
 void update ( DocumentEvent event)
          Adapts positions to the change specified by the document event.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fPosition

protected 
Position fPosition
Caches the currently investigated position


fOriginalPosition

protected 
Position fOriginalPosition
Remembers the original state of the investigated position

Since:
2.1

fOffset

protected int fOffset
Caches the offset of the replaced text


fLength

protected int fLength
Caches the length of the replaced text


fReplaceLength

protected int fReplaceLength
Caches the length of the newly inserted text


fDocument

protected 
IDocument fDocument
Catches the document

Constructor Detail

DefaultPositionUpdater

public DefaultPositionUpdater(
String category)
Creates a new default position updater for the given category.

Parameters:
category - the category the updater is responsible for
Method Detail

getCategory

protected 
String getCategory()
Returns the category this updater is responsible for.

Returns:
the category this updater is responsible for

isAffectingReplace

protected boolean isAffectingReplace()
Returns whether the current event describes a well formed replace by which the current position is directly affected.

Returns:
true the current position is directly affected
Since:
3.0

adaptToInsert

protected void adaptToInsert()
Adapts the currently investigated position to an insertion.


adaptToRemove

protected void adaptToRemove()
Adapts the currently investigated position to a deletion.


adaptToReplace

protected void adaptToReplace()
Adapts the currently investigated position to the replace operation. First it checks whether the change replaces the whole range of the position. If not, it performs first the deletion of the previous text and afterwards the insertion of the new text.


notDeleted

protected boolean notDeleted()
Determines whether the currently investigated position has been deleted by the replace operation specified in the current event. If so, it deletes the position and removes it from the document's position category.

Returns:
true if position has not been deleted

update

public void update(
DocumentEvent event)
Description copied from interface: IPositionUpdater
Adapts positions to the change specified by the document event. It is ensured that the document's partitioning has been adapted to this document change and that all the position updaters which have a smaller index in the document's position updater list have been called.

Specified by:
update in interface IPositionUpdater
Parameters:
event - the document event describing the document change

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire