region managers, and the interaction between DrJava and the Plastic
L&F. This revision modifies the JTree renderer in FindResultsPanel so
that the "reverse video" display of a selected node in the Plastic L&F
works.
The revision also corrects a serious design problem with the
DocumentRegion class and its descendants. DocumentRegion defines
compareTo and overrides equals so that regions are lexicographically
ordered by the offsets of their two positions. The overriding of
equals makes it agree with the equivalence defined by compareTo. The
compareTo operation (from the Comparable interface) is used in
TreeSets of DocumentRegions in ConcreteRegionManager. By using the
Comparable ordering and TreeSets, the cost of insertion, removal, and
membership testing for TreeSets is reduced to O(log N), which is
important in FindAll searches with many matches in a single document.
But the corresponding view classes, namely RegionsTreePanel and
FindResultsPanel among others, rely on hash tables that use regions as
keys. Since positions in regions can move, a definition of hashCode
that is consistent with equals is disastrous; it breaks hash tales
that use regions as keys because region hash codes change as the
document is edited.
In this revision, hashCode is NOT overriden in DocumentRegion or any
of its descendants and IdentiyHashMaps are used instead of Hashtables
so that the overridden equals does not break hash table operation.
Note that merely avoiding the override of hashCode is insufficient
because the overridden definition of equals can break hash table
operations in some cases (distinct regions become equal if
their offsets coincide after editing).
The following files were modified:
M src/edu/rice/cs/drjava/IndentFiles.java
M src/edu/rice/cs/drjava/model/RegionManager.java
M src/edu/rice/cs/drjava/model/ConcreteRegionManager.java
M src/edu/rice/cs/drjava/model/DocumentRegion.java
M src/edu/rice/cs/drjava/model/AbstractGlobalModel.java
M src/edu/rice/cs/drjava/model/BrowserDocumentRegion.java
M src/edu/rice/cs/drjava/model/OpenDefinitionsDocument.java
M src/edu/rice/cs/drjava/ui/MainFrame.java
M src/edu/rice/cs/drjava/ui/TabbedPanel.java
M src/edu/rice/cs/drjava/ui/DebugPanel.java
M src/edu/rice/cs/drjava/ui/MainFrameTest.java
M src/edu/rice/cs/drjava/ui/RegionsTreePanel.java
M src/edu/rice/cs/drjava/ui/FindResultsPanel.java
M src/edu/rice/cs/drjava/ui/FindReplacePanel.java
M src/edu/rice/cs/drjava/ui/JUnitPanel.java