01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.swt.events;
11:
12: import org.eclipse.swt.widgets.*;
13: import org.eclipse.swt.internal.SWTEventObject;
14:
15: /**
16: * This is the super class for all typed event classes provided
17: * by SWT. Typed events contain particular information which is
18: * applicable to the event occurrence.
19: *
20: * @see org.eclipse.swt.widgets.Event
21: */
22: public class TypedEvent extends SWTEventObject {
23:
24: /**
25: * the display where the event occurred
26: *
27: * @since 2.0
28: */
29: public Display display;
30:
31: /**
32: * the widget that issued the event
33: */
34: public Widget widget;
35:
36: /**
37: * the time that the event occurred.
38: *
39: * NOTE: This field is an unsigned integer and should
40: * be AND'ed with 0xFFFFFFFFL so that it can be treated
41: * as a signed long.
42: */
43: public int time;
44:
45: /**
46: * a field for application use
47: */
48: public Object data;
49:
50: static final long serialVersionUID = 3257285846578377524L;
51:
52: /**
53: * Constructs a new instance of this class.
54: *
55: * @param object the object that fired the event
56: */
57: public TypedEvent(Object object) {
58: super (object);
59: }
60:
61: /**
62: * Constructs a new instance of this class based on the
63: * information in the argument.
64: *
65: * @param e the low level event to initialize the receiver with
66: */
67: public TypedEvent(Event e) {
68: super (e.widget);
69: this .display = e.display;
70: this .widget = e.widget;
71: this .time = e.time;
72: this .data = e.data;
73: }
74:
75: /**
76: * Returns the name of the event. This is the name of
77: * the class without the package name.
78: *
79: * @return the name of the event
80: */
81: String getName() {
82: String string = getClass().getName();
83: int index = string.lastIndexOf('.');
84: if (index == -1)
85: return string;
86: return string.substring(index + 1, string.length());
87: }
88:
89: /**
90: * Returns a string containing a concise, human-readable
91: * description of the receiver.
92: *
93: * @return a string representation of the event
94: */
95: public String toString() {
96: return getName() + "{" + widget + " time=" + time + " data="
97: + data + "}";
98: }
99: }
|