1 /* DefaultTreeSelectionModel.java --
2 Copyright (C) 2002, 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.swing
.tree
;
41 import java
.beans
.PropertyChangeListener
;
42 import java
.io
.IOException
;
43 import java
.io
.ObjectInputStream
;
44 import java
.io
.ObjectOutputStream
;
45 import java
.io
.Serializable
;
46 import java
.util
.EventListener
;
47 import java
.util
.Vector
;
49 import javax
.swing
.DefaultListSelectionModel
;
50 import javax
.swing
.event
.EventListenerList
;
51 import javax
.swing
.event
.SwingPropertyChangeSupport
;
52 import javax
.swing
.event
.TreeSelectionEvent
;
53 import javax
.swing
.event
.TreeSelectionListener
;
56 * DefaultTreeSelectionModel
57 * @author Andrew Selkirk
59 public class DefaultTreeSelectionModel
60 implements Cloneable
, Serializable
, TreeSelectionModel
62 static final long serialVersionUID
= 3288129636638950196L;
65 * SELECTION_MODE_PROPERTY
67 public static final String SELECTION_MODE_PROPERTY
= "selectionMode";
72 protected SwingPropertyChangeSupport changeSupport
;
77 protected TreePath
[] selection
;
82 protected EventListenerList listenerList
;
87 protected transient RowMapper rowMapper
;
92 protected DefaultListSelectionModel listSelectionModel
;
97 protected int selectionMode
;
102 protected TreePath leadPath
;
107 protected int leadIndex
;
112 protected int leadRow
;
115 * Constructor DefaultTreeSelectionModel
117 public DefaultTreeSelectionModel()
124 * @exception CloneNotSupportedException TODO
127 public Object
clone() throws CloneNotSupportedException
136 public String
toString()
144 * @exception IOException TODO
146 private void writeObject(ObjectOutputStream value0
) throws IOException
154 * @exception IOException TODO
155 * @exception ClassNotFoundException TODO
157 private void readObject(ObjectInputStream value0
)
158 throws IOException
, ClassNotFoundException
167 public void setRowMapper(RowMapper value0
)
176 public RowMapper
getRowMapper()
185 public void setSelectionMode(int value0
)
194 public int getSelectionMode()
203 public void setSelectionPath(TreePath value0
)
212 public void setSelectionPaths(TreePath
[] value0
)
221 public void addSelectionPath(TreePath value0
)
230 public void addSelectionPaths(TreePath
[] value0
)
236 * removeSelectionPath
239 public void removeSelectionPath(TreePath value0
)
245 * removeSelectionPaths
248 public void removeSelectionPaths(TreePath
[] value0
)
257 public TreePath
getSelectionPath()
266 public TreePath
[] getSelectionPaths()
275 public int getSelectionCount()
285 public boolean isPathSelected(TreePath value0
)
287 return false; // TODO
294 public boolean isSelectionEmpty()
296 return false; // TODO
302 public void clearSelection()
308 * Adds a <code>TreeSelectionListener</code> object to this model.
310 * @param listener the listener to add
312 public void addTreeSelectionListener(TreeSelectionListener listener
)
314 listenerList
.add(TreeSelectionListener
.class, listener
);
318 * Removes a <code>TreeSelectionListener</code> object from this model.
320 * @param listener the listener to remove
322 public void removeTreeSelectionListener(TreeSelectionListener listener
)
324 listenerList
.remove(TreeSelectionListener
.class, listener
);
328 * Returns all <code>TreeSelectionListener</code> added to this model.
330 * @return an array of listeners
334 public TreeSelectionListener
[] getTreeSelectionListeners()
336 return (TreeSelectionListener
[]) listenerList
.getListeners(TreeSelectionListener
.class);
342 * @param event the event to fire.
344 protected void fireValueChanged(TreeSelectionEvent event
)
346 TreeSelectionListener
[] listeners
= getTreeSelectionListeners();
348 for (int i
= listeners
.length
- 1; i
>= 0; --i
)
349 listeners
[i
].valueChanged(event
);
353 * Returns all added listeners of a special type.
355 * @param listenerType the listener type
357 * @return an array of listeners
361 public EventListener
[] getListeners(Class listenerType
)
363 return listenerList
.getListeners(listenerType
);
370 public int[] getSelectionRows()
379 public int getMinSelectionRow()
388 public int getMaxSelectionRow()
398 public boolean isRowSelected(int value0
)
400 return false; // TODO
406 public void resetRowSelection()
412 * getLeadSelectionRow
415 public int getLeadSelectionRow()
421 * getLeadSelectionPath
424 public TreePath
getLeadSelectionPath()
430 * Adds a <code>PropertyChangeListener</code> object to this model.
432 * @param listener the listener to add.
434 public void addPropertyChangeListener(PropertyChangeListener listener
)
436 changeSupport
.addPropertyChangeListener(listener
);
440 * Removes a <code>PropertyChangeListener</code> object from this model.
442 * @param listener the listener to remove.
444 public void removePropertyChangeListener(PropertyChangeListener listener
)
446 changeSupport
.removePropertyChangeListener(listener
);
450 * Returns all added <code>PropertyChangeListener</code> objects.
452 * @return an array of listeners.
456 public PropertyChangeListener
[] getPropertyChangeListeners()
458 return changeSupport
.getPropertyChangeListeners();
462 * insureRowContinuity
464 protected void insureRowContinuity()
474 protected boolean arePathsContiguous(TreePath
[] value0
)
476 return false; // TODO
484 protected boolean canPathsBeAdded(TreePath
[] value0
)
486 return false; // TODO
494 protected boolean canPathsBeRemoved(TreePath
[] value0
)
496 return false; // TODO
504 protected void notifyPathChange(Vector value0
, TreePath value1
)
512 protected void updateLeadIndex()
520 protected void insureUniqueness()