Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a7d783eb0bf30d70c8646fb94a80ff7270013d91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package org.eclipse.swt.dnd;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved
 */
 
import org.eclipse.swt.*;

/**
 *
 * Class DND contains all the constants used in defining a 
 * DragSource or a DropTarget.
 *
 */


public class DND {
	
	/**
	 * Drag and Drop Operation: no drag/drop operation is performed
	 */
	public final static int DROP_NONE = 0;
	/**
	 * Drag and Drop Operation: a copy of the data in the drag source is added to the drop target
	 */
	public final static int DROP_COPY = 1;
	/**
	 * Drag and Drop Operation: the data is added to the drop target and removed from the drag source
	 */
	public final static int DROP_MOVE = 2;
	/**
	 * Drag and Drop Operation: the drop target makes a link to the data in the drag source
	 */
	public final static int DROP_LINK = 4;

	/**
	 * DragSource Event: the drop has successfully completed or has been terminated (such as hitting the ESC key);
	 *                   perform cleanup such as removing data on a move operation
	 */
	public static final int DragEnd		= 2000;
	/**
	 * DragSource Event: the data to be dropped is required from the drag source
	 */
	public static final int DragSetData = 2001;
	/**
	 * DropTarget Event: the cursor has entered the drop target boundaries
	 */
	public static final int DragEnter	= 2002;
	/**
	 * DropTarget Event: the cursor has left the drop target boundaries
	 */
	public static final int DragLeave	= 2003;
	/**
	 * DropTarget Event: the cursor is moving over the drop target
	 */
	public static final int	DragOver	= 2004;
	/**
	 * DropTarget Event: the operation being performed has changed 
	 *                   (usually due to the user changing the selected key while dragging)
	 */
	public static final int DragOperationChanged = 2005;
	/**
	 * DropTarget Event: the data is being dropped
	 */
	public static final int	Drop		= 2006;
	/**
	 * DropTarget Event: the drop target is given a last chance to modify the drop
	 */
	public static final int	DropAccept	= 2007;
	/**
	 * DragSource Event: a drag is about to begin
	 */
	public static final int	DragStart	= 2008;

	public static final int FEEDBACK_NONE = 0;
	public static final int FEEDBACK_SELECT = 1;
	public static final int FEEDBACK_INSERT_BEFORE = 2;
	public static final int FEEDBACK_INSERT_AFTER = 3;

	/**
	 * Error code for SWTError - drag source can not be initialized
	 */
	public static final int ERROR_CANNOT_INIT_DRAG = 2000;
	/**
	 * Error code for SWTError - drop target cannot be initialized
	 */
	public static final int ERROR_CANNOT_INIT_DROP = 2001;
	/**
	 * Error code for SWTError - Data can not be set on system clipboard
	 */
	public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
	

	static final String INIT_DRAG_MESSAGE =  "Can not initialize Drag";
	static final String INIT_DROP_MESSAGE =  "Can not initialize Drop";
	static final String CANNOT_SET_CLIPBOARD_MESSAGE =  "Can not set data in clipboard";
	
public static void error (int code) {
	error (code, 0);
}

public static void error (int code, int hresult) {		
	switch (code) {		
		/* OS Failure/Limit (fatal, may occur only on some platforms) */
		case DND.ERROR_CANNOT_INIT_DRAG:{
			String msg = DND.INIT_DRAG_MESSAGE;
			if (hresult != 0) msg += "result = "+hresult;
			throw new SWTError (code, msg);
		}
		case DND.ERROR_CANNOT_INIT_DROP:{
			String msg = DND.INIT_DROP_MESSAGE;
			if (hresult != 0) msg += "result = "+hresult;
			throw new SWTError (code, msg);
		}
		case DND.ERROR_CANNOT_SET_CLIPBOARD:{
			String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
			if (hresult != 0) msg += "result = "+hresult;
			throw new SWTError (code, msg);
		}
	}
			
	/* Unknown/Undefined Error */
	SWT.error(code);
}

}

Back to the top