OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [javax/] [swing/] [event/] [TreeSelectionEvent.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* TreeSelectionEvent.java --
2
   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
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)
9
any later version.
10
 
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.
15
 
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., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
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
24
combination.
25
 
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. */
37
 
38
 
39
package javax.swing.event;
40
 
41
import java.util.EventObject;
42
 
43
import javax.swing.tree.TreePath;
44
 
45
/**
46
 * TreeSelectionEvent
47
 * @author Andrew Selkirk
48
 * @version     1.0
49
 */
50
public class TreeSelectionEvent extends EventObject {
51
 
52
  //-------------------------------------------------------------
53
  // Variables --------------------------------------------------
54
  //-------------------------------------------------------------
55
 
56
  /**
57
   * paths
58
   */
59
  protected TreePath[] paths;
60
 
61
  /**
62
   * areNew
63
   */
64
  protected boolean[] areNew;
65
 
66
  /**
67
   * oldLeadSelectionPath
68
   */
69
  protected TreePath oldLeadSelectionPath;
70
 
71
  /**
72
   * newLeadSelectionPath
73
   */
74
  protected TreePath newLeadSelectionPath;
75
 
76
 
77
  //-------------------------------------------------------------
78
  // Initialization ---------------------------------------------
79
  //-------------------------------------------------------------
80
 
81
  /**
82
   * Constructor TreeSelectionEvent
83
   * @param source TODO
84
   * @param paths TODO
85
   * @param areNew TODO
86
   * @param oldLeadSelectionPath TODO
87
   * @param newLeadSelectionPath TODO
88
   */
89
  public TreeSelectionEvent(Object source, TreePath[] paths,
90
                            boolean[] areNew, TreePath oldLeadSelectionPath,
91
                            TreePath newLeadSelectionPath)
92
  {
93
    super(source);
94
    this.paths                                  = paths;
95
    this.areNew                                 = areNew;
96
    this.oldLeadSelectionPath   = oldLeadSelectionPath;
97
    this.newLeadSelectionPath   = newLeadSelectionPath;
98
  } // TreeSelectionEvent()
99
 
100
  /**
101
   * Constructor TreeSelectionEvent
102
   * @param source TODO
103
   * @param path TODO
104
   * @param isNew TODO
105
   * @param oldLeadSelectionPath TODO
106
   * @param newLeadSelectionPath TODO
107
   */
108
  public TreeSelectionEvent(Object source, TreePath path,
109
                            boolean isNew, TreePath oldLeadSelectionPath,
110
                            TreePath newLeadSelectionPath)
111
  {
112
    super(source);
113
    this.paths = new TreePath[]{path};
114
    this.areNew = new boolean[]{isNew};
115
    this.oldLeadSelectionPath   = oldLeadSelectionPath;
116
    this.newLeadSelectionPath   = newLeadSelectionPath;
117
  } // TreeSelectionEvent()
118
 
119
 
120
  //-------------------------------------------------------------
121
  // Methods ----------------------------------------------------
122
  //-------------------------------------------------------------
123
 
124
  /**
125
   * @returns the first path element
126
   */
127
  public TreePath getPath()
128
  {
129
    return paths[0];
130
  } // getPath()
131
 
132
  /**
133
   *
134
   * @returns the paths with selection changed
135
   */
136
  public TreePath[] getPaths()
137
  {
138
    return (TreePath[]) paths.clone();
139
  } // getPaths()
140
 
141
  /**
142
   * @return true if the first path is added to the selection, false otherwise
143
   */
144
  public boolean isAddedPath()
145
  {
146
    return areNew[0];
147
  } // isAddedPath()
148
 
149
  /**
150
   * @param path the path to check
151
   * @return true if the path is added to the selection, false otherwise
152
   */
153
  public boolean isAddedPath(TreePath path)
154
  {
155
    for (int i = paths.length - 1; i >= 0; i--)
156
      if (paths[i].equals(path))
157
        return areNew[i];
158
 
159
    return false;
160
  } // isAddedPath()
161
 
162
  /**
163
   * @param index the index'th path
164
   * @return true if the path is added to the selection, false otherwise
165
   */
166
  public boolean isAddedPath(int index)
167
  {
168
    return areNew[index];
169
  } // isAddedPath()
170
 
171
  /**
172
   * @return the previous lead selection path
173
   */
174
  public TreePath getOldLeadSelectionPath()
175
  {
176
    return oldLeadSelectionPath;
177
  } // getOldLeadSelectionPath()
178
 
179
  /**
180
   * @returns the current lead selection path
181
   */
182
  public TreePath getNewLeadSelectionPath()
183
  {
184
    return newLeadSelectionPath;
185
  } // getNewLeadSelectionPath()
186
 
187
  /**
188
   * @param source the new event source
189
   * @return a cloned event with another event source
190
   */
191
  public Object cloneWithSource(Object source)
192
  {
193
    return new TreeSelectionEvent (source, paths, areNew,
194
                                   oldLeadSelectionPath,
195
                                   newLeadSelectionPath);
196
  } // cloneWithSource()
197
 
198
 
199
} // TreeSelectionEvent

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.