/[svn]/jsampler/trunk/src/org/jsampler/event/ListSelectionEvent.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/event/ListSelectionEvent.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2288 - (show annotations) (download)
Wed Nov 23 21:19:44 2011 UTC (12 years, 4 months ago) by iliev
File size: 4818 byte(s)
* Added option to select a sampler engine in Add/Edit Instrument dialog
* Moved all Swing dependent code outside the JSampler core

1 /*
2 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package org.jsampler.event;
27
28 import java.util.EventObject;
29
30
31 /**
32 * An event that characterizes a change in selection. The change is limited to a
33 * a single inclusive interval. The selection of at least one index within the
34 * range will have changed. A decent {@code ListSelectionModel} implementation
35 * will keep the range as small as possible. {@code ListSelectionListeners} will
36 * generally query the source of the event for the new selected status of each
37 * potentially changed row.
38 * <p>
39 * <strong>Warning:</strong>
40 * Serialized objects of this class will not be compatible with
41 * future Swing releases. The current serialization support is
42 * appropriate for short term storage or RMI between applications running
43 * the same version of Swing. As of 1.4, support for long term storage
44 * of all JavaBeans<sup><font size="-2">TM</font></sup>
45 * has been added to the <code>java.beans</code> package.
46 * Please see {@link java.beans.XMLEncoder}.
47 *
48 * @author Hans Muller
49 * @author Ray Ryan
50 * @see ListSelectionModel
51 */
52 public class ListSelectionEvent extends EventObject
53 {
54 private int firstIndex;
55 private int lastIndex;
56 private boolean isAdjusting;
57
58 /**
59 * Represents a change in selection status between {@code firstIndex} and
60 * {@code lastIndex}, inclusive. {@code firstIndex} is less than or equal to
61 * {@code lastIndex}. The selection of at least one index within the range will
62 * have changed.
63 *
64 * @param firstIndex the first index in the range, &lt;= lastIndex
65 * @param lastIndex the last index in the range, &gt;= firstIndex
66 * @param isAdjusting whether or not this is one in a series of
67 * multiple events, where changes are still being made
68 */
69 public ListSelectionEvent(Object source, int firstIndex, int lastIndex,
70 boolean isAdjusting)
71 {
72 super(source);
73 this.firstIndex = firstIndex;
74 this.lastIndex = lastIndex;
75 this.isAdjusting = isAdjusting;
76 }
77
78 /**
79 * Returns the index of the first row whose selection may have changed.
80 * {@code getFirstIndex() &lt;= getLastIndex()}
81 *
82 * @return the first row whose selection value may have changed,
83 * where zero is the first row
84 */
85 public int getFirstIndex() { return firstIndex; }
86
87 /**
88 * Returns the index of the last row whose selection may have changed.
89 * {@code getLastIndex() &gt;= getFirstIndex()}
90 *
91 * @return the last row whose selection value may have changed,
92 * where zero is the first row
93 */
94 public int getLastIndex() { return lastIndex; }
95
96 /**
97 * Returns whether or not this is one in a series of multiple events,
98 * where changes are still being made. See the documentation for
99 * {@link javax.swing.ListSelectionModel#setValueIsAdjusting} for
100 * more details on how this is used.
101 *
102 * @return {@code true} if this is one in a series of multiple events,
103 * where changes are still being made
104 */
105 public boolean getValueIsAdjusting() { return isAdjusting; }
106
107 /**
108 * Returns a {@code String} that displays and identifies this
109 * object's properties.
110 *
111 * @return a String representation of this object
112 */
113 public String toString() {
114 String properties =
115 " source=" + getSource() +
116 " firstIndex= " + firstIndex +
117 " lastIndex= " + lastIndex +
118 " isAdjusting= " + isAdjusting +
119 " ";
120 return getClass().getName() + "[" + properties + "]";
121 }
122 }

  ViewVC Help
Powered by ViewVC