1 |
/* DefaultTreeSelectionModel.java -- |
/* |
2 |
Copyright (C) 2002, 2004 Free Software Foundation, Inc. |
* DefaultTreeSelectionModel.java -- Copyright (C) 2002, 2004 Free Software |
3 |
|
* Foundation, Inc. |
4 |
This file is part of GNU Classpath. |
* |
5 |
|
* 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 |
* GNU Classpath is free software; you can redistribute it and/or modify it |
8 |
the Free Software Foundation; either version 2, or (at your option) |
* under the terms of the GNU General Public License as published by the Free |
9 |
any later version. |
* Software Foundation; either version 2, or (at your option) any later version. |
10 |
|
* |
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
* GNU Classpath is distributed in the hope that it will be useful, but WITHOUT |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
14 |
General Public License for more details. |
* details. |
15 |
|
* |
16 |
You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License along with |
17 |
along with GNU Classpath; see the file COPYING. If not, write to the |
* GNU Classpath; see the file COPYING. If not, write to the Free Software |
18 |
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
19 |
02111-1307 USA. |
* |
20 |
|
* Linking this library statically or dynamically with other modules is making a |
21 |
Linking this library statically or dynamically with other modules is |
* combined work based on this library. Thus, the terms and conditions of the |
22 |
making a combined work based on this library. Thus, the terms and |
* GNU General Public License cover the whole combination. |
23 |
conditions of the GNU General Public License cover the whole |
* |
24 |
combination. |
* As a special exception, the copyright holders of this library give you |
25 |
|
* permission to link this library with independent modules to produce an |
26 |
As a special exception, the copyright holders of this library give you |
* executable, regardless of the license terms of these independent modules, and |
27 |
permission to link this library with independent modules to produce an |
* to copy and distribute the resulting executable under terms of your choice, |
28 |
executable, regardless of the license terms of these independent |
* provided that you also meet, for each linked independent module, the terms |
29 |
modules, and to copy and distribute the resulting executable under |
* and conditions of the license of that module. An independent module is a |
30 |
terms of your choice, provided that you also meet, for each linked |
* module which is not derived from or based on this library. If you modify this |
31 |
independent module, the terms and conditions of the license of that |
* library, you may extend this exception to your version of the library, but |
32 |
module. An independent module is a module which is not derived from |
* you are not obligated to do so. If you do not wish to do so, delete this |
33 |
or based on this library. If you modify this library, you may extend |
* exception statement from your version. |
34 |
this exception to your version of the library, but you are not |
*/ |
|
obligated to do so. If you do not wish to do so, delete this |
|
|
exception statement from your version. */ |
|
35 |
|
|
36 |
package javax.swing.tree; |
package javax.swing.tree; |
37 |
|
|
233 |
*/ |
*/ |
234 |
public void setSelectionPath(TreePath path) |
public void setSelectionPath(TreePath path) |
235 |
{ |
{ |
236 |
selection = new TreePath[] { path }; |
selection = new TreePath[] { |
237 |
|
path }; |
238 |
} |
} |
239 |
|
|
240 |
/** |
/** |
274 |
selection = new TreePath[temp.length]; |
selection = new TreePath[temp.length]; |
275 |
System.arraycopy(temp, 0, selection, 0, temp.length); |
System.arraycopy(temp, 0, selection, 0, temp.length); |
276 |
} |
} |
277 |
|
|
278 |
|
fireValueChanged(new TreeSelectionEvent(this, value0, true, |
279 |
|
leadPath, value0)); |
280 |
} |
} |
281 |
} |
} |
282 |
|
|
307 |
selection = new TreePath[temp.length]; |
selection = new TreePath[temp.length]; |
308 |
System.arraycopy(temp, 0, selection, 0, temp.length); |
System.arraycopy(temp, 0, selection, 0, temp.length); |
309 |
} |
} |
310 |
|
|
311 |
|
fireValueChanged(new TreeSelectionEvent(this, v0, true, |
312 |
|
leadPath, value0[0])); |
313 |
} |
} |
314 |
} |
} |
315 |
} |
} |
341 |
selection.length - index - 1); |
selection.length - index - 1); |
342 |
selection = new TreePath[temp.length]; |
selection = new TreePath[temp.length]; |
343 |
System.arraycopy(temp, 0, selection, 0, temp.length); |
System.arraycopy(temp, 0, selection, 0, temp.length); |
344 |
|
|
345 |
|
fireValueChanged(new TreeSelectionEvent(this, value0, false, |
346 |
|
leadPath, value0)); |
347 |
} |
} |
348 |
} |
} |
349 |
|
|
378 |
selection.length - index - 1); |
selection.length - index - 1); |
379 |
selection = new TreePath[temp.length]; |
selection = new TreePath[temp.length]; |
380 |
System.arraycopy(temp, 0, selection, 0, temp.length); |
System.arraycopy(temp, 0, selection, 0, temp.length); |
381 |
|
|
382 |
|
fireValueChanged(new TreeSelectionEvent(this, v0, false, |
383 |
|
leadPath, value0[0])); |
384 |
} |
} |
385 |
} |
} |
386 |
} |
} |
432 |
*/ |
*/ |
433 |
public boolean isPathSelected(TreePath value0) |
public boolean isPathSelected(TreePath value0) |
434 |
{ |
{ |
435 |
|
if (selection == null) |
436 |
|
return false; |
437 |
|
|
438 |
for (int i = 0; i < selection.length; i++) |
for (int i = 0; i < selection.length; i++) |
439 |
{ |
{ |
440 |
if (selection[i].equals(value0)) |
if (selection[i].equals(value0)) |
491 |
*/ |
*/ |
492 |
public TreeSelectionListener[] getTreeSelectionListeners() |
public TreeSelectionListener[] getTreeSelectionListeners() |
493 |
{ |
{ |
494 |
return (TreeSelectionListener[]) listenerList |
return (TreeSelectionListener[]) |
495 |
.getListeners(TreeSelectionListener.class); |
getListeners(TreeSelectionListener.class); |
496 |
} |
} |
497 |
|
|
498 |
/** |
/** |
504 |
{ |
{ |
505 |
TreeSelectionListener[] listeners = getTreeSelectionListeners(); |
TreeSelectionListener[] listeners = getTreeSelectionListeners(); |
506 |
|
|
507 |
for (int i = listeners.length - 1; i >= 0; --i) |
for (int i = 0; i < listeners.length; ++i) |
508 |
listeners[i].valueChanged(event); |
listeners[i].valueChanged(event); |
509 |
} |
} |
510 |
|
|
606 |
if ((rowMapper == null) || (leadPath == null)) |
if ((rowMapper == null) || (leadPath == null)) |
607 |
return -1; |
return -1; |
608 |
else |
else |
609 |
return rowMapper.getRowsForPaths(new TreePath[] { leadPath })[0]; |
return rowMapper.getRowsForPaths(new TreePath[] { |
610 |
|
leadPath })[0]; |
611 |
} |
} |
612 |
|
|
613 |
/** |
/** |