author | prr |
Sat, 19 Sep 2015 15:45:59 -0700 | |
changeset 32865 | f9cb6e427f9e |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.awt.X11; |
|
27 |
||
28 |
import java.util.ArrayList; |
|
29 |
import java.util.Collections; |
|
30 |
import java.util.Iterator; |
|
31 |
import java.util.List; |
|
32 |
||
33 |
/** |
|
34 |
* This class is a registry for the supported drag and drop protocols. |
|
35 |
* |
|
36 |
* @since 1.5 |
|
37 |
*/ |
|
38 |
final class XDragAndDropProtocols { |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
25859
diff
changeset
|
39 |
private static final List<XDragSourceProtocol> dragProtocols; |
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
25859
diff
changeset
|
40 |
private static final List<XDropTargetProtocol> dropProtocols; |
2 | 41 |
|
42 |
public static final String XDnD = "XDnD"; |
|
43 |
public static final String MotifDnD = "MotifDnD"; |
|
44 |
||
45 |
static { |
|
46 |
// Singleton listener for all drag source protocols. |
|
47 |
XDragSourceProtocolListener dragSourceProtocolListener = |
|
48 |
XDragSourceContextPeer.getXDragSourceProtocolListener(); |
|
49 |
// Singleton listener for all drop target protocols. |
|
50 |
XDropTargetProtocolListener dropTargetProtocolListener = |
|
51 |
XDropTargetContextPeer.getXDropTargetProtocolListener(); |
|
52 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
53 |
List<XDragSourceProtocol> tDragSourceProtocols = new ArrayList<>(); |
2 | 54 |
XDragSourceProtocol xdndDragSourceProtocol = |
55 |
XDnDDragSourceProtocol.createInstance(dragSourceProtocolListener); |
|
56 |
tDragSourceProtocols.add(xdndDragSourceProtocol); |
|
57 |
XDragSourceProtocol motifdndDragSourceProtocol = |
|
58 |
MotifDnDDragSourceProtocol.createInstance(dragSourceProtocolListener); |
|
59 |
tDragSourceProtocols.add(motifdndDragSourceProtocol); |
|
60 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
61 |
List<XDropTargetProtocol> tDropTargetProtocols = new ArrayList<>(); |
2 | 62 |
XDropTargetProtocol xdndDropTargetProtocol = |
63 |
XDnDDropTargetProtocol.createInstance(dropTargetProtocolListener); |
|
64 |
tDropTargetProtocols.add(xdndDropTargetProtocol); |
|
65 |
XDropTargetProtocol motifdndDropTargetProtocol = |
|
66 |
MotifDnDDropTargetProtocol.createInstance(dropTargetProtocolListener); |
|
67 |
tDropTargetProtocols.add(motifdndDropTargetProtocol); |
|
68 |
||
69 |
dragProtocols = Collections.unmodifiableList(tDragSourceProtocols); |
|
70 |
dropProtocols = Collections.unmodifiableList(tDropTargetProtocols); |
|
71 |
} |
|
72 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
73 |
static Iterator<XDragSourceProtocol> getDragSourceProtocols() { |
2 | 74 |
return dragProtocols.iterator(); |
75 |
} |
|
76 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
77 |
static Iterator<XDropTargetProtocol> getDropTargetProtocols() { |
2 | 78 |
return dropProtocols.iterator(); |
79 |
} |
|
80 |
||
81 |
/* |
|
82 |
* Returns a XDragSourceProtocol whose name equals to the specified string |
|
83 |
* or null if no such protocol is registered. |
|
84 |
*/ |
|
85 |
public static XDragSourceProtocol getDragSourceProtocol(String name) { |
|
86 |
// Protocol name cannot be null. |
|
87 |
if (name == null) { |
|
88 |
return null; |
|
89 |
} |
|
90 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
91 |
Iterator<XDragSourceProtocol> dragProtocols = |
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
92 |
XDragAndDropProtocols.getDragSourceProtocols(); |
2 | 93 |
while (dragProtocols.hasNext()) { |
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
94 |
XDragSourceProtocol dragProtocol = dragProtocols.next(); |
2 | 95 |
if (dragProtocol.getProtocolName().equals(name)) { |
96 |
return dragProtocol; |
|
97 |
} |
|
98 |
} |
|
99 |
||
100 |
return null; |
|
101 |
} |
|
102 |
||
103 |
/* |
|
104 |
* Returns a XDropTargetProtocol which name equals to the specified string |
|
105 |
* or null if no such protocol is registered. |
|
106 |
*/ |
|
107 |
public static XDropTargetProtocol getDropTargetProtocol(String name) { |
|
108 |
// Protocol name cannot be null. |
|
109 |
if (name == null) { |
|
110 |
return null; |
|
111 |
} |
|
112 |
||
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
113 |
Iterator<XDropTargetProtocol> dropProtocols = |
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
114 |
XDragAndDropProtocols.getDropTargetProtocols(); |
2 | 115 |
while (dropProtocols.hasNext()) { |
24538
25bf8153fbfe
8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents:
5506
diff
changeset
|
116 |
XDropTargetProtocol dropProtocol = dropProtocols.next(); |
2 | 117 |
if (dropProtocol.getProtocolName().equals(name)) { |
118 |
return dropProtocol; |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
return null; |
|
123 |
} |
|
124 |
} |