/[classpath]/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
ViewVC logotype

Diff of /classpath/javax/swing/tree/DefaultTreeSelectionModel.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mkoch, Mon Oct 25 15:43:40 2004 UTC revision 1.8 by rabbit78, Mon Apr 18 14:02:50 2005 UTC
# Line 67  public class DefaultTreeSelectionModel Line 67  public class DefaultTreeSelectionModel
67    public static final String SELECTION_MODE_PROPERTY = "selectionMode";    public static final String SELECTION_MODE_PROPERTY = "selectionMode";
68    
69    /**    /**
70     * changeSupport     * Our Swing property change support.
71     */     */
72    protected SwingPropertyChangeSupport changeSupport;    protected SwingPropertyChangeSupport changeSupport;
73    
74    /**    /**
75     * selection     * The current selection.
76     */     */
77    protected TreePath[] selection;    protected TreePath[] selection;
78    
79    /**    /**
80     * listenerList     * Our TreeSelectionListeners.
81     */     */
82    protected EventListenerList listenerList;    protected EventListenerList listenerList;
83    
84    /**    /**
85     * rowMapper     * The current RowMapper.
86     */     */
87    protected transient RowMapper rowMapper;    protected transient RowMapper rowMapper;
88    
89    /**    /**
90     * listSelectionModel     * The current listSelectionModel.
91     */     */
92    protected DefaultListSelectionModel listSelectionModel;    protected DefaultListSelectionModel listSelectionModel;
93    
94    /**    /**
95     * selectionMode     * The current selection mode.
96     */     */
97    protected int selectionMode;    protected int selectionMode;
98    
99    /**    /**
100     * leadPath     * The path that has been added last.
101     */     */
102    protected TreePath leadPath;    protected TreePath leadPath;
103    
104    /**    /**
105     * leadIndex     * The index of the last added path.
106     */     */
107    protected int leadIndex;    protected int leadIndex;
108    
109    /**    /**
110     * leadRow     * The row of the last added path according to the RowMapper.
111     */     */
112    protected int leadRow;    protected int leadRow;
113    
114    /**    /**
115     * Constructor DefaultTreeSelectionModel     * Constructs a new DefaultTreeSelectionModel.
116     */     */
117    public DefaultTreeSelectionModel()    public DefaultTreeSelectionModel()
118    {    {
# Line 120  public class DefaultTreeSelectionModel Line 120  public class DefaultTreeSelectionModel
120    }    }
121    
122    /**    /**
123     * clone     * Creates a clone of this DefaultTreeSelectionModel with the same
124     * @exception CloneNotSupportedException TODO     * selection.
125     * @return Object     *
126       * @exception CloneNotSupportedException should not be thrown here
127       *
128       * @return a clone of this DefaultTreeSelectionModel
129     */     */
130    public Object clone() throws CloneNotSupportedException    public Object clone() throws CloneNotSupportedException
131    {    {
# Line 130  public class DefaultTreeSelectionModel Line 133  public class DefaultTreeSelectionModel
133    }    }
134    
135    /**    /**
136     * toString     * Returns a string that shows this object's properties.
137     * @return String     *
138       * @return a string that shows this object's properties
139     */     */
140    public String toString()    public String toString()
141    {    {
# Line 161  public class DefaultTreeSelectionModel Line 165  public class DefaultTreeSelectionModel
165    }    }
166    
167    /**    /**
168     * setRowMapper     * Sets the RowMapper that should be used to map between paths and their
169     * @param value0 TODO     * rows.
170       *
171       * @param rowMapper the RowMapper to set
172       *
173       * @see {@link RowMapper
174     */     */
175    public void setRowMapper(RowMapper value0)    public void setRowMapper(RowMapper value0)
176    {    {
# Line 170  public class DefaultTreeSelectionModel Line 178  public class DefaultTreeSelectionModel
178    }    }
179    
180    /**    /**
181     * getRowMapper     * Returns the RowMapper that is currently used to map between paths and
182     * @return RowMapper     * their rows.
183       *
184       * @return the current RowMapper
185       *
186       * @see {@link RowMapper
187     */     */
188    public RowMapper getRowMapper()    public RowMapper getRowMapper()
189    {    {
# Line 179  public class DefaultTreeSelectionModel Line 191  public class DefaultTreeSelectionModel
191    }    }
192    
193    /**    /**
194     * setSelectionMode     * Sets the current selection mode. Possible values are
195     * @param value0 TODO     * {@link #SINGLE_TREE_SELECTION}, {@link CONTIGUOUS_TREE_SELECTION}
196       * and {@link #DISCONTIGUOUS_TREE_SELECTION}.
197       *
198       * @param mode the selection mode to be set
199       *
200       * @see {@link #getSelectionMode}
201       * @see {@link #SINGLE_TREE_SELECTION}
202       * @see {@link #CONTIGUOUS_TREE_SELECTION}
203       * @see {@link #DISCONTIGUOUS_TREE_SELECTION}
204     */     */
205    public void setSelectionMode(int value0)    public void setSelectionMode(int value0)
206    {    {
# Line 188  public class DefaultTreeSelectionModel Line 208  public class DefaultTreeSelectionModel
208    }    }
209    
210    /**    /**
211     * getSelectionMode     * Returns the current selection mode.
212     * @return int     *
213       * @return the current selection mode
214       *
215       * @see {@link #setSelectionMode}
216       * @see {@link #SINGLE_TREE_SELECTION}
217       * @see {@link #CONTIGUOUS_TREE_SELECTION}
218       * @see {@link #DISCONTIGUOUS_TREE_SELECTION}
219     */     */
220    public int getSelectionMode()    public int getSelectionMode()
221    {    {
# Line 197  public class DefaultTreeSelectionModel Line 223  public class DefaultTreeSelectionModel
223    }    }
224    
225    /**    /**
226     * setSelectionPath     * Sets this path as the only selection.
227     * @param value0 TODO     *
228       * If this changes the selection the registered TreeSelectionListeners
229       * are notified.
230       *
231       * @param path the path to set as selection
232     */     */
233    public void setSelectionPath(TreePath value0)    public void setSelectionPath(TreePath value0)
234    {    {
# Line 206  public class DefaultTreeSelectionModel Line 236  public class DefaultTreeSelectionModel
236    }    }
237    
238    /**    /**
239     * setSelectionPaths     * Sets the paths as selection. This method checks for duplicates and
240     * @param value0 TODO     * removes them.
241       *
242       * If this changes the selection the registered TreeSelectionListeners
243       * are notified.
244       *
245       * @param paths the paths to set as selection
246     */     */
247    public void setSelectionPaths(TreePath[] value0)    public void setSelectionPaths(TreePath[] value0)
248    {    {
# Line 215  public class DefaultTreeSelectionModel Line 250  public class DefaultTreeSelectionModel
250    }    }
251    
252    /**    /**
253     * addSelectionPath     * Adds a path to the list of selected paths. This method checks if the
254     * @param value0 TODO     * path is already selected and doesn't add the same path twice.
255       *
256       * If this changes the selection the registered TreeSelectionListeners
257       * are notified.
258       *
259       * @param path the path to add to the selection
260     */     */
261    public void addSelectionPath(TreePath value0)    public void addSelectionPath(TreePath value0)
262    {    {
# Line 224  public class DefaultTreeSelectionModel Line 264  public class DefaultTreeSelectionModel
264    }    }
265    
266    /**    /**
267     * addSelectionPaths     * Adds the paths to the list of selected paths. This method checks if the
268     * @param value0 TODO     * paths are already selected and doesn't add the same path twice.
269       *
270       * If this changes the selection the registered TreeSelectionListeners
271       * are notified.
272       *
273       * @param paths the paths to add to the selection
274     */     */
275    public void addSelectionPaths(TreePath[] value0)    public void addSelectionPaths(TreePath[] value0)
276    {    {
# Line 233  public class DefaultTreeSelectionModel Line 278  public class DefaultTreeSelectionModel
278    }    }
279    
280    /**    /**
281     * removeSelectionPath     * Removes the path from the selection.
282     * @param value0 TODO     *
283       * If this changes the selection the registered TreeSelectionListeners
284       * are notified.
285       *
286       * @param path the path to remove
287     */     */
288    public void removeSelectionPath(TreePath value0)    public void removeSelectionPath(TreePath value0)
289    {    {
# Line 242  public class DefaultTreeSelectionModel Line 291  public class DefaultTreeSelectionModel
291    }    }
292    
293    /**    /**
294     * removeSelectionPaths     * Removes the paths from the selection.
295     * @param value0 TODO     *
296       * If this changes the selection the registered TreeSelectionListeners
297       * are notified.
298       *
299       * @param paths the path to remove
300     */     */
301    public void removeSelectionPaths(TreePath[] value0)    public void removeSelectionPaths(TreePath[] value0)
302    {    {
# Line 251  public class DefaultTreeSelectionModel Line 304  public class DefaultTreeSelectionModel
304    }    }
305    
306    /**    /**
307     * getSelectionPath     * Returns the first path in the selection. This is especially useful
308     * @return TreePath     * when the selectionMode is {@link #SINGLE_TREE_SELECTION}.
309       *
310       * @return the first path in the selection
311     */     */
312    public TreePath getSelectionPath()    public TreePath getSelectionPath()
313    {    {
# Line 260  public class DefaultTreeSelectionModel Line 315  public class DefaultTreeSelectionModel
315    }    }
316    
317    /**    /**
318     * getSelectionPaths     * Returns the complete selection.
319     * @return TreePath[]     *
320       * @return the complete selection
321     */     */
322    public TreePath[] getSelectionPaths()    public TreePath[] getSelectionPaths()
323    {    {
# Line 269  public class DefaultTreeSelectionModel Line 325  public class DefaultTreeSelectionModel
325    }    }
326    
327    /**    /**
328     * getSelectionCount     * Returns the number of paths in the selection.
329     * @return int     *
330       * @return the number of paths in the selection
331     */     */
332    public int getSelectionCount()    public int getSelectionCount()
333    {    {
# Line 278  public class DefaultTreeSelectionModel Line 335  public class DefaultTreeSelectionModel
335    }    }
336    
337    /**    /**
338     * isPathSelected     * Checks if a given path is in the selection.
339     * @param value0 TODO     *
340     * @return boolean     * @param path the path to check
341       *
342       * @return <code>true</code> if the path is in the selection,
343       *         <code>false</code> otherwise
344     */     */
345    public boolean isPathSelected(TreePath value0)    public boolean isPathSelected(TreePath value0)
346    {    {
# Line 288  public class DefaultTreeSelectionModel Line 348  public class DefaultTreeSelectionModel
348    }    }
349    
350    /**    /**
351     * isSelectionEmpty     * Checks if the selection is empty.
352     * @return boolean     *
353       * @return <code>true</code> if the selection is empty,
354       *         <code>false</code> otherwise
355     */     */
356    public boolean isSelectionEmpty()    public boolean isSelectionEmpty()
357    {    {
# Line 297  public class DefaultTreeSelectionModel Line 359  public class DefaultTreeSelectionModel
359    }    }
360    
361    /**    /**
362     * clearSelection     * Removes all paths from the selection.
363     */     */
364    public void clearSelection()    public void clearSelection()
365    {    {
# Line 364  public class DefaultTreeSelectionModel Line 426  public class DefaultTreeSelectionModel
426    }    }
427    
428    /**    /**
429     * getSelectionRows     * Returns the currently selected rows.
430     * @return int[]     *
431       * @return the currently selected rows
432     */     */
433    public int[] getSelectionRows()    public int[] getSelectionRows()
434    {    {
# Line 373  public class DefaultTreeSelectionModel Line 436  public class DefaultTreeSelectionModel
436    }    }
437    
438    /**    /**
439     * getMinSelectionRow     * Returns the smallest row index from the selection.
440     * @return int     *
441       * @return the smallest row index from the selection
442     */     */
443    public int getMinSelectionRow()    public int getMinSelectionRow()
444    {    {
# Line 382  public class DefaultTreeSelectionModel Line 446  public class DefaultTreeSelectionModel
446    }    }
447    
448    /**    /**
449     * getMaxSelectionRow     * Returns the largest row index from the selection.
450     * @return int     *
451       * @return the largest row index from the selection
452     */     */
453    public int getMaxSelectionRow()    public int getMaxSelectionRow()
454    {    {
# Line 391  public class DefaultTreeSelectionModel Line 456  public class DefaultTreeSelectionModel
456    }    }
457    
458    /**    /**
459     * isRowSelected     * Checks if a particular row is selected.
460     * @param value0 TODO     *
461     * @return boolean     * @param row the index of the row to check
462       *
463       * @return <code>true</code> if the row is in this selection,
464       *         <code>false</code> otherwise
465     */     */
466    public boolean isRowSelected(int value0)    public boolean isRowSelected(int value0)
467    {    {
# Line 401  public class DefaultTreeSelectionModel Line 469  public class DefaultTreeSelectionModel
469    }    }
470    
471    /**    /**
472     * resetRowSelection     * Updates the mappings from TreePaths to row indices.
473     */     */
474    public void resetRowSelection()    public void resetRowSelection()
475    {    {
# Line 459  public class DefaultTreeSelectionModel Line 527  public class DefaultTreeSelectionModel
527    }    }
528    
529    /**    /**
530     * insureRowContinuity     * Makes sure the currently selected paths are valid according to the
531       * current selectionMode.
532       *
533       * If the selectionMode is set to {@link CONTIGUOUS_TREE_SELECTION}
534       * and the selection isn't contiguous then the selection is reset to
535       * the first set of contguous paths.
536       *
537       * If the selectionMode is set to {@link SINGLE_TREE_SELECTION}
538       * and the selection has more than one path, the selection is reset to
539       * the contain only the first path.
540     */     */
541    protected void insureRowContinuity()    protected void insureRowContinuity()
542    {    {
# Line 467  public class DefaultTreeSelectionModel Line 544  public class DefaultTreeSelectionModel
544    }    }
545    
546    /**    /**
547     * arePathsContiguous     * Returns <code>true</code> if the paths are contiguous or we
548     * @param value0 TODO     * have no RowMapper assigned.
549     * @return boolean     *
550       * @param paths the paths to check for continuity
551       * @return <code>true</code> if the paths are contiguous or we
552       *         have no RowMapper assigned
553     */     */
554    protected boolean arePathsContiguous(TreePath[] value0)    protected boolean arePathsContiguous(TreePath[] value0)
555    {    {
# Line 477  public class DefaultTreeSelectionModel Line 557  public class DefaultTreeSelectionModel
557    }    }
558    
559    /**    /**
560     * canPathsBeAdded     * Checks if the paths can be added. This returns <code>true</code> if:
561     * @param value0 TODO     * <ul>
562     * @return boolean     * <li><code>paths</code> is <code>null</code> or empty</li>
563       * <li>we have no RowMapper assigned</li>
564       * <li>nothing is currently selected</li>
565       * <li>selectionMode is {@link DISCONTIGUOUS_TREE_SELECTION</li>
566       * <li>adding the paths to the selection still results in a contiguous set
567       *   of paths</li>
568       *
569       * @param paths the paths to check
570       *
571       * @return <code>true</code> if the paths can be added with respect to the
572       *         selectionMode
573     */     */
574    protected boolean canPathsBeAdded(TreePath[] value0)    protected boolean canPathsBeAdded(TreePath[] value0)
575    {    {
# Line 487  public class DefaultTreeSelectionModel Line 577  public class DefaultTreeSelectionModel
577    }    }
578    
579    /**    /**
580     * canPathsBeRemoved     * Checks if the paths can be removed without breaking the continuity of
581     * @param value0 TODO     * the selection according to selectionMode.
582     * @return boolean     *
583       * @param paths the paths to check
584       * @return  <code>true</code> if the paths can be removed with respect to the
585       *         selectionMode
586     */     */
587    protected boolean canPathsBeRemoved(TreePath[] value0)    protected boolean canPathsBeRemoved(TreePath[] value0)
588    {    {
# Line 507  public class DefaultTreeSelectionModel Line 600  public class DefaultTreeSelectionModel
600    }    }
601    
602    /**    /**
603     * updateLeadIndex     * Updates the lead index instance field.
604     */     */
605    protected void updateLeadIndex()    protected void updateLeadIndex()
606    {    {
# Line 515  public class DefaultTreeSelectionModel Line 608  public class DefaultTreeSelectionModel
608    }    }
609    
610    /**    /**
611     * insureUniqueness     * Deprecated and not used.
612     */     */
613    protected void insureUniqueness()    protected void insureUniqueness()
614    {    {

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26