KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > dnd > DNDListener


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.dnd;
12
13 import org.eclipse.swt.internal.*;
14 import org.eclipse.swt.widgets.*;
15
16
17 class DNDListener extends TypedListener {
18     Widget dndWidget;
19 /**
20  * DNDListener constructor comment.
21  * @param listener org.eclipse.swt.internal.SWTEventListener
22  */

23 DNDListener(SWTEventListener listener) {
24     super(listener);
25 }
26 public void handleEvent (Event e) {
27     switch (e.type) {
28         case DND.DragStart: {
29             DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
30             DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
31             if (sourceEffect != null) {
32                 sourceEffect.dragStart (event);
33             }
34             ((DragSourceListener) eventListener).dragStart (event);
35             event.updateEvent((DNDEvent)e);
36             break;
37         }
38         case DND.DragEnd: {
39             DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
40             DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
41             if (sourceEffect != null) {
42                 sourceEffect.dragFinished (event);
43             }
44             ((DragSourceListener) eventListener).dragFinished (event);
45             event.updateEvent((DNDEvent)e);
46             break;
47         }
48         case DND.DragSetData: {
49             DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
50             DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
51             if (sourceEffect != null) {
52                 sourceEffect.dragSetData (event);
53             }
54             ((DragSourceListener) eventListener).dragSetData (event);
55             event.updateEvent((DNDEvent)e);
56             break;
57         }
58         case DND.DragEnter: {
59             DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
60             ((DropTargetListener) eventListener).dragEnter (event);
61             DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
62             if (dropEffect != null) {
63                 dropEffect.dragEnter (event);
64             }
65             event.updateEvent((DNDEvent)e);
66             break;
67         }
68         case DND.DragLeave: {
69             DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
70             ((DropTargetListener) eventListener).dragLeave (event);
71             DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
72             if (dropEffect != null) {
73                 dropEffect.dragLeave (event);
74             }
75             event.updateEvent((DNDEvent)e);
76             break;
77         }
78         case DND.DragOver: {
79             DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
80             ((DropTargetListener) eventListener).dragOver (event);
81             DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
82             if (dropEffect != null) {
83                 dropEffect.dragOver (event);
84             }
85             event.updateEvent((DNDEvent)e);
86             break;
87         }
88         case DND.Drop: {
89             DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
90             ((DropTargetListener) eventListener).drop (event);
91             DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
92             if (dropEffect != null) {
93                 dropEffect.drop (event);
94             }
95             event.updateEvent((DNDEvent)e);
96             break;
97         }
98         case DND.DropAccept: {
99             DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
100             ((DropTargetListener) eventListener).dropAccept (event);
101             DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
102             if (dropEffect != null) {
103                 dropEffect.dropAccept (event);
104             }
105             event.updateEvent((DNDEvent)e);
106             break;
107         }
108         case DND.DragOperationChanged: {
109             DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
110             ((DropTargetListener) eventListener).dragOperationChanged (event);
111             DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
112             if (dropEffect != null) {
113                 dropEffect.dragOperationChanged (event);
114             }
115             event.updateEvent((DNDEvent)e);
116             break;
117         }
118         
119     }
120 }
121 }
122
Popular Tags