KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > cs > drjava > model > RegionManager


1 /*BEGIN_COPYRIGHT_BLOCK
2  *
3  * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
4  * or http://sourceforge.net/projects/drjava/
5  *
6  * DrJava Open Source License
7  *
8  * Copyright (C) 2001-2005 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
9  *
10  * Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13  * documentation files (the "Software"), to deal with the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15  * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16  *
17  * - Redistributions of source code must retain the above copyright notice, this list of conditions and the
18  * following disclaimers.
19  * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
20  * following disclaimers in the documentation and/or other materials provided with the distribution.
21  * - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
22  * endorse or promote products derived from this Software without specific prior written permission.
23  * - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
24  * names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
27  * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * WITH THE SOFTWARE.
31  *
32  *END_COPYRIGHT_BLOCK*/

33
34 package edu.rice.cs.drjava.model;
35
36 import edu.rice.cs.util.Lambda;
37 import java.util.Vector JavaDoc;
38
39 /** Interface for a region manager.
40   * @version $Id$
41   */

42 public interface RegionManager<R extends DocumentRegion> {
43   /** Returns the region in this manager at the given offset, or null if one does not exist.
44    * @param odd the document
45    * @param offset the offset in the document
46    * @return the DocumentRegion at the given line number, or null if it does not exist.
47    */

48   public R getRegionAt(OpenDefinitionsDocument odd, int offset);
49
50   /** Get the DocumentRegion that is stored in this RegionsTreePanel overlapping the area for the given document,
51    * or null if it doesn't exist.
52    * @param odd the document
53    * @param startOffset the start offset
54    * @param endOffset the end offset
55    * @return the DocumentRegion or null
56    */

57   public R getRegionOverlapping(OpenDefinitionsDocument odd, int startOffset, int endOffset);
58   
59   /** Add the supplied DocumentRegion to the manager.
60    * @param region the DocumentRegion to be inserted into the manager
61    */

62   public void addRegion(R region);
63
64   /** Remove the given DocumentRegion from the manager.
65    * @param region the DocumentRegion to be removed.
66    */

67   public void removeRegion(R region);
68
69   /** Apply the given command to the specified region to change it.
70    * @param region the region to find and change
71    * @param cmd command that mutates the region. */

72   public void changeRegion(R region, Lambda<Object JavaDoc,R> cmd);
73
74   /** @return a Vector<R> containing the DocumentRegion objects in this mangager. */
75   public Vector JavaDoc<R> getRegions();
76
77   /** Tells the manager to remove all regions. */
78   public void clearRegions();
79   
80   /** @return the current region or null if none selected */
81   public R getCurrentRegion();
82   
83   /** @return the index of the current region or -1 if none selected */
84   public int getCurrentRegionIndex();
85   
86   /** @return true if the current region is the first in the list, i.e. prevCurrentRegion is without effect */
87   public boolean isCurrentRegionFirst();
88   
89   /** @return true if the current region is the last in the list, i.e. nextCurrentRegion is without effect */
90   public boolean isCurrentRegionLast();
91   
92   /** Set the current region.
93    * @param region new current region */

94   public void setCurrentRegion(R region);
95   
96   /** Make the region that is more recent the current region.
97    * @return new current region */

98   public R nextCurrentRegion();
99   
100   /** Make the region that is less recent the current region.
101    * @return new current region */

102   public R prevCurrentRegion();
103   
104   /**
105    * Set the maximum number of regions that can be stored in this manager.
106    * If the maximum capacity has been reached and another region is added, the region at the end farther
107    * away from the insertion location will be discarded.
108    * @param size maximum number of regions, or 0 if no maximum
109    */

110   public void setMaximumSize(int size);
111   
112   /** @return the maximum number of regions that can be stored in this manager. */
113   public int getMaximumSize();
114
115   /** Adds a listener to the notifier.
116    * @param listener a listener that reacts on events
117    */

118   public void addListener(RegionManagerListener<R> listener);
119   
120   /** Removes a listener from the notifier.
121    * @param listener a listener that reacts on events
122    */

123   public void removeListener(RegionManagerListener<R> listener);
124
125   /** Removes all listeners from this notifier. */
126   public void removeAllListeners();
127 }
128
Popular Tags