KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > events > SelectionEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.events;
12
13
14 import org.eclipse.swt.widgets.*;
15
16 /**
17  * Instances of this class are sent as a result of
18  * widgets being selected.
19  * <p>
20  * Note: The fields that are filled in depend on the widget.
21  * </p>
22  *
23  * @see SelectionListener
24  */

25
26 public class SelectionEvent extends TypedEvent {
27     
28     /**
29      * The item that was selected.
30      */

31     public Widget item;
32     
33     /**
34      * Extra detail information about the selection, depending on the widget.
35      *
36      * <p><b>Sash</b><ul>
37      * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
38      * </ul></p><p><b>ScrollBar and Slider</b><ul>
39      * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
40      * <li>{@link org.eclipse.swt.SWT#HOME}</li>
41      * <li>{@link org.eclipse.swt.SWT#END}</li>
42      * <li>{@link org.eclipse.swt.SWT#ARROW_DOWN}</li>
43      * <li>{@link org.eclipse.swt.SWT#ARROW_UP}</li>
44      * <li>{@link org.eclipse.swt.SWT#PAGE_DOWN}</li>
45      * <li>{@link org.eclipse.swt.SWT#PAGE_UP}</li>
46      * </ul></p><p><b>Table and Tree</b><ul>
47      * <li>{@link org.eclipse.swt.SWT#CHECK}</li>
48      * </ul></p><p><b>Text</b><ul>
49      * <li>{@link org.eclipse.swt.SWT#CANCEL}</li>
50      * </ul></p><p><b>CoolItem and ToolItem</b><ul>
51      * <li>{@link org.eclipse.swt.SWT#ARROW}</li>
52      * </ul></p>
53      */

54     public int detail;
55
56     /**
57      * The x location of the selected area.
58      */

59     public int x;
60     
61     /**
62      * The y location of selected area.
63      */

64     public int y;
65     
66     /**
67      * The width of selected area.
68      */

69     public int width;
70     
71     /**
72      * The height of selected area.
73      */

74     public int height;
75
76     /**
77      * The state of the keyboard modifier keys at the time
78      * the event was generated.
79      */

80     public int stateMask;
81
82     /**
83      * The text of the hyperlink that was selected.
84      * This will be either the text of the hyperlink or the value of its HREF,
85      * if one was specified.
86      *
87      * @see org.eclipse.swt.widgets.Link#setText(String)
88      * @since 3.1
89      */

90     public String JavaDoc text;
91     
92     /**
93      * A flag indicating whether the operation should be allowed.
94      * Setting this field to <code>false</code> will cancel the
95      * operation, depending on the widget.
96      */

97     public boolean doit;
98     
99     static final long serialVersionUID = 3976735856884987953L;
100     
101 /**
102  * Constructs a new instance of this class based on the
103  * information in the given untyped event.
104  *
105  * @param e the untyped event containing the information
106  */

107 public SelectionEvent(Event e) {
108     super(e);
109     this.item = e.item;
110     this.x = e.x;
111     this.y = e.y;
112     this.width = e.width;
113     this.height = e.height;
114     this.detail = e.detail;
115     this.stateMask = e.stateMask;
116     this.text = e.text;
117     this.doit = e.doit;
118 }
119
120 /**
121  * Returns a string containing a concise, human-readable
122  * description of the receiver.
123  *
124  * @return a string representation of the event
125  */

126 public String JavaDoc toString() {
127     String JavaDoc string = super.toString ();
128     return string.substring (0, string.length() - 1) // remove trailing '}'
129
+ " item=" + item
130         + " detail=" + detail
131         + " x=" + x
132         + " y=" + y
133         + " width=" + width
134         + " height=" + height
135         + " stateMask=" + stateMask
136         + " text=" + text
137         + " doit=" + doit
138         + "}";
139 }
140 }
141
142
Popular Tags