1 /*******************************************************************************
2 * Copyright (c) 2000, 2018 IBM Corporation and others.
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/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.dnd;
16 import org.eclipse.swt.events.*;
17 import org.eclipse.swt.widgets.*;
20 * The DropTargetEvent contains the event information passed in the methods of the DropTargetListener.
22 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
24 public class DropTargetEvent extends TypedEvent {
26 * The x-cordinate of the cursor relative to the <code>Display</code>
31 * The y-cordinate of the cursor relative to the <code>Display</code>
36 * The operation being performed.
41 * @see DND#DROP_DEFAULT
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.
53 * @see DND#DROP_DEFAULT
55 public int operations;
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
73 * If the associated control is a table or tree, this field contains the item located
74 * at the cursor coordinates.
79 * The type of data that will be dropped.
81 public TransferData currentDataType;
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.
87 public TransferData[] dataTypes;
89 static final long serialVersionUID = 3256727264573338678L;
92 * Constructs a new instance of this class based on the
93 * information in the given untyped event.
95 * @param e the untyped event containing the information
97 public DropTargetEvent(DNDEvent e) {
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;
109 void updateEvent(DNDEvent e) {
110 e.widget = this.widget;
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;
123 * Returns a string containing a concise, human-readable
124 * description of the receiver.
126 * @return a string representation of the event
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(' ');
146 sb.append(" currentDataType="); sb.append(currentDataType != null ? currentDataType.type : '0');
148 return sb.toString();