01: /*
02: * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.awt.X11;
27:
28: import java.awt.dnd.DnDConstants;
29:
30: /**
31: * XDnD protocol global constants.
32: *
33: * @since 1.5
34: */
35: class XDnDConstants {
36: static final XAtom XA_XdndActionCopy = XAtom.get("XdndActionCopy");
37: static final XAtom XA_XdndActionMove = XAtom.get("XdndActionMove");
38: static final XAtom XA_XdndActionLink = XAtom.get("XdndActionLink");
39: static final XAtom XA_XdndActionList = XAtom.get("XdndActionList");
40: static final XAtom XA_XdndTypeList = XAtom.get("XdndTypeList");
41: static final XAtom XA_XdndAware = XAtom.get("XdndAware");
42: static final XAtom XA_XdndProxy = XAtom.get("XdndProxy");
43: static final XAtom XA_XdndSelection = XAtom.get("XdndSelection");
44: static final XAtom XA_XdndEnter = XAtom.get("XdndEnter");
45: static final XAtom XA_XdndPosition = XAtom.get("XdndPosition");
46: static final XAtom XA_XdndLeave = XAtom.get("XdndLeave");
47: static final XAtom XA_XdndDrop = XAtom.get("XdndDrop");
48: static final XAtom XA_XdndStatus = XAtom.get("XdndStatus");
49: static final XAtom XA_XdndFinished = XAtom.get("XdndFinished");
50:
51: static final XSelection XDnDSelection = new XSelection(
52: XA_XdndSelection, null);
53:
54: public static final int XDND_MIN_PROTOCOL_VERSION = 3;
55: public static final int XDND_PROTOCOL_VERSION = 5;
56:
57: public static final int XDND_PROTOCOL_MASK = 0xFF000000;
58: public static final int XDND_PROTOCOL_SHIFT = 24;
59: public static final int XDND_DATA_TYPES_BIT = 0x1;
60: public static final int XDND_ACCEPT_DROP_FLAG = 0x1;
61:
62: private XDnDConstants() {
63: }
64:
65: static long getXDnDActionForJavaAction(int javaAction) {
66: switch (javaAction) {
67: case DnDConstants.ACTION_COPY:
68: return XA_XdndActionCopy.getAtom();
69: case DnDConstants.ACTION_MOVE:
70: return XA_XdndActionMove.getAtom();
71: case DnDConstants.ACTION_LINK:
72: return XA_XdndActionLink.getAtom();
73: default:
74: return 0;
75: }
76: }
77:
78: static int getJavaActionForXDnDAction(long xdndAction) {
79: if (xdndAction == XA_XdndActionCopy.getAtom()) {
80: return DnDConstants.ACTION_COPY;
81: } else if (xdndAction == XA_XdndActionMove.getAtom()) {
82: return DnDConstants.ACTION_MOVE;
83: } else if (xdndAction == XA_XdndActionLink.getAtom()) {
84: return DnDConstants.ACTION_LINK;
85: } else {
86: return DnDConstants.ACTION_NONE;
87: }
88: }
89: }
|