Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/awt/X11/XDragAndDropProtocols.java
32288 views
1
/*
2
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle 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 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.
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 {
39
private final static List dragProtocols;
40
private final static List dropProtocols;
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
53
List tDragSourceProtocols = new ArrayList();
54
XDragSourceProtocol xdndDragSourceProtocol =
55
XDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
56
tDragSourceProtocols.add(xdndDragSourceProtocol);
57
XDragSourceProtocol motifdndDragSourceProtocol =
58
MotifDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
59
tDragSourceProtocols.add(motifdndDragSourceProtocol);
60
61
List tDropTargetProtocols = new ArrayList();
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
73
static Iterator getDragSourceProtocols() {
74
return dragProtocols.iterator();
75
}
76
77
static Iterator getDropTargetProtocols() {
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
91
Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
92
while (dragProtocols.hasNext()) {
93
XDragSourceProtocol dragProtocol =
94
(XDragSourceProtocol)dragProtocols.next();
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
113
Iterator dropProtocols = XDragAndDropProtocols.getDropTargetProtocols();
114
while (dropProtocols.hasNext()) {
115
XDropTargetProtocol dropProtocol =
116
(XDropTargetProtocol)dropProtocols.next();
117
if (dropProtocol.getProtocolName().equals(name)) {
118
return dropProtocol;
119
}
120
}
121
122
return null;
123
}
124
}
125
126