KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > viewers > ColumnViewerEditorActivationEvent


1 /*******************************************************************************
2  * Copyright (c) 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
12 package org.eclipse.jface.viewers;
13
14 import java.util.EventObject JavaDoc;
15
16 import org.eclipse.swt.events.KeyEvent;
17 import org.eclipse.swt.events.MouseEvent;
18 import org.eclipse.swt.events.TraverseEvent;
19
20 /**
21  * This event is passed on when a cell-editor is going to be activated
22  *
23  * @since 3.3
24  *
25  */

26 public class ColumnViewerEditorActivationEvent extends EventObject JavaDoc {
27     /**
28      *
29      */

30     private static final long serialVersionUID = 1L;
31
32     /**
33      * if a key is pressed on a selected cell
34      */

35     public static final int KEY_PRESSED = 1;
36
37     /**
38      * if a cell is selected using a single click of the mouse
39      */

40     public static final int MOUSE_CLICK_SELECTION = 2;
41
42     /**
43      * if a cell is selected using double clicking of the mouse
44      */

45     public static final int MOUSE_DOUBLE_CLICK_SELECTION = 3;
46
47     /**
48      * if a cell is activated using code like e.g
49      * {@link ColumnViewer#editElement(Object, int)}
50      */

51     public static final int PROGRAMMATIC = 4;
52
53     /**
54      * is a cell is activated by traversing
55      */

56     public static final int TRAVERSAL = 5;
57
58     /**
59      * the original event triggered
60      */

61     public EventObject JavaDoc sourceEvent;
62
63     /**
64      * The time the event is triggered
65      */

66     public int time;
67
68     /**
69      * The event type triggered:
70      * <ul>
71      * <li>{@link #KEY_PRESSED} if a key is pressed on a selected cell</li>
72      * <li>{@link #MOUSE_CLICK_SELECTION} if a cell is selected using a single
73      * click of the mouse</li>
74      * <li>{@link #MOUSE_DOUBLE_CLICK_SELECTION} if a cell is selected using
75      * double clicking of the mouse</li>
76      * </ul>
77      */

78     public int eventType;
79
80     /**
81      * <b>Only set for {@link #KEY_PRESSED}</b>
82      */

83     public int keyCode;
84
85     /**
86      * <b>Only set for {@link #KEY_PRESSED}</b>
87      */

88     public char character;
89
90     /**
91      * The statemask
92      */

93     public int stateMask;
94
95     /**
96      * Cancel the event (=> editor is not activated)
97      */

98     public boolean cancel = false;
99     
100     /**
101      * This constructor can be used when no event exists. The type set is
102      * {@link #PROGRAMMATIC}
103      *
104      * @param cell
105      * the cell
106      */

107     public ColumnViewerEditorActivationEvent(ViewerCell cell) {
108         super(cell);
109         eventType = PROGRAMMATIC;
110     }
111
112     /**
113      * This constructor is used for all types of mouse events. Currently the
114      * type is can be {@link #MOUSE_CLICK_SELECTION} and
115      * {@link #MOUSE_DOUBLE_CLICK_SELECTION}
116      *
117      * @param cell
118      * the cell source of the event
119      * @param event
120      * the event
121      */

122     public ColumnViewerEditorActivationEvent(ViewerCell cell, MouseEvent event) {
123         super(cell);
124
125         if (event.count >= 2) {
126             eventType = MOUSE_DOUBLE_CLICK_SELECTION;
127         } else {
128             eventType = MOUSE_CLICK_SELECTION;
129         }
130
131         this.sourceEvent = event;
132         this.time = event.time;
133     }
134
135     /**
136      * @param cell
137      * the cell source of the event
138      * @param event
139      * the event
140      */

141     public ColumnViewerEditorActivationEvent(ViewerCell cell, KeyEvent event) {
142         super(cell);
143         this.eventType = KEY_PRESSED;
144         this.sourceEvent = event;
145         this.time = 0;
146         this.keyCode = event.keyCode;
147         this.character = event.character;
148         this.stateMask = event.stateMask;
149     }
150
151     /**
152      * This constructor is used to mark the activation triggered by a traversal
153      *
154      * @param cell
155      * the cell source of the event
156      * @param event
157      * the event
158      */

159     public ColumnViewerEditorActivationEvent(ViewerCell cell, TraverseEvent event) {
160         super(cell);
161         this.eventType = TRAVERSAL;
162         this.sourceEvent = event;
163     }
164 }
165
Popular Tags