]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/dnd/DropTargetEvent.java
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / dnd / DropTargetEvent.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2018 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.dnd;
15
16 import org.eclipse.swt.events.*;
17 import org.eclipse.swt.widgets.*;
18
19 /**
20  * The DropTargetEvent contains the event information passed in the methods of the DropTargetListener.
21  *
22  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
23  */
24 public class DropTargetEvent extends TypedEvent {
25         /**
26          * The x-cordinate of the cursor relative to the <code>Display</code>
27          */
28         public int x;
29
30         /**
31          * The y-cordinate of the cursor relative to the <code>Display</code>
32          */
33         public int y;
34
35         /**
36          * The operation being performed.
37          * @see DND#DROP_NONE
38          * @see DND#DROP_MOVE
39          * @see DND#DROP_COPY
40          * @see DND#DROP_LINK
41          * @see DND#DROP_DEFAULT
42          */
43         public int detail;
44
45         /**
46          * A bitwise OR'ing of the operations that the DragSource can support
47          * (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK).
48          * The detail value must be a member of this list or DND.DROP_NONE.
49          * @see DND#DROP_NONE
50          * @see DND#DROP_MOVE
51          * @see DND#DROP_COPY
52          * @see DND#DROP_LINK
53          * @see DND#DROP_DEFAULT
54          */
55         public int operations;
56
57         /**
58          * A bitwise OR'ing of the drag under effect feedback to be displayed to the user
59          * (e.g. DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND).
60          * <p>A value of DND.FEEDBACK_NONE indicates that no drag under effect will be displayed.</p>
61          * <p>Feedback effects will only be applied if they are applicable.</p>
62          * <p>The default value is DND.FEEDBACK_SELECT.</p>
63          * @see DND#FEEDBACK_NONE
64          * @see DND#FEEDBACK_SELECT
65          * @see DND#FEEDBACK_INSERT_BEFORE
66          * @see DND#FEEDBACK_INSERT_AFTER
67          * @see DND#FEEDBACK_SCROLL
68          * @see DND#FEEDBACK_EXPAND
69          */
70         public int feedback;
71
72         /**
73          * If the associated control is a table or tree, this field contains the item located
74          * at the cursor coordinates.
75          */
76         public Widget item;
77
78         /**
79          * The type of data that will be dropped.
80          */
81         public TransferData currentDataType;
82
83         /**
84          * A list of the types of data that the DragSource is capable of providing.
85          * The currentDataType must be a member of this list.
86          */
87         public TransferData[] dataTypes;
88
89         static final long serialVersionUID = 3256727264573338678L;
90
91 /**
92  * Constructs a new instance of this class based on the
93  * information in the given untyped event.
94  *
95  * @param e the untyped event containing the information
96  */
97 public DropTargetEvent(DNDEvent e) {
98         super(e);
99         this.data = e.data;
100         this.x = e.x;
101         this.y = e.y;
102         this.detail = e.detail;
103         this.currentDataType = e.dataType;
104         this.dataTypes = e.dataTypes;
105         this.operations = e.operations;
106         this.feedback = e.feedback;
107         this.item = e.item;
108 }
109 void updateEvent(DNDEvent e) {
110         e.widget = this.widget;
111         e.time = this.time;
112         e.data = this.data;
113         e.x = this.x;
114         e.y = this.y;
115         e.detail = this.detail;
116         e.dataType = this.currentDataType;
117         e.dataTypes = this.dataTypes;
118         e.operations = this.operations;
119         e.feedback = this.feedback;
120         e.item = this.item;
121 }
122 /**
123  * Returns a string containing a concise, human-readable
124  * description of the receiver.
125  *
126  * @return a string representation of the event
127  */
128 @Override
129 public String toString() {
130         String string = super.toString ();
131         StringBuilder sb = new StringBuilder();
132         sb.append(string.substring (0, string.length() - 1)); // remove trailing '}'
133         sb.append(" x="); sb.append(x);
134         sb.append(" y="); sb.append(y);
135         sb.append(" item="); sb.append(item);
136         sb.append(" operations="); sb.append(operations);
137         sb.append(" operation="); sb.append(detail);
138         sb.append(" feedback="); sb.append(feedback);
139         sb.append(" dataTypes={ ");
140         if (dataTypes != null) {
141                 for (int i = 0; i < dataTypes.length; i++) {
142                         sb.append(dataTypes[i].type); sb.append(' ');
143                 }
144         }
145         sb.append('}');
146         sb.append(" currentDataType="); sb.append(currentDataType != null ? currentDataType.type : '0');
147         sb.append('}');
148         return sb.toString();
149 }
150 }