package sun.awt.X11;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
final class XDragAndDropProtocols {
private static final List<XDragSourceProtocol> dragProtocols;
private static final List<XDropTargetProtocol> dropProtocols;
public static final String XDnD = "XDnD";
public static final String MotifDnD = "MotifDnD";
static {
XDragSourceProtocolListener dragSourceProtocolListener =
XDragSourceContextPeer.getXDragSourceProtocolListener();
XDropTargetProtocolListener dropTargetProtocolListener =
XDropTargetContextPeer.getXDropTargetProtocolListener();
List<XDragSourceProtocol> tDragSourceProtocols = new ArrayList<>();
XDragSourceProtocol xdndDragSourceProtocol =
XDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
tDragSourceProtocols.add(xdndDragSourceProtocol);
XDragSourceProtocol motifdndDragSourceProtocol =
MotifDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
tDragSourceProtocols.add(motifdndDragSourceProtocol);
List<XDropTargetProtocol> tDropTargetProtocols = new ArrayList<>();
XDropTargetProtocol xdndDropTargetProtocol =
XDnDDropTargetProtocol.createInstance(dropTargetProtocolListener);
tDropTargetProtocols.add(xdndDropTargetProtocol);
XDropTargetProtocol motifdndDropTargetProtocol =
MotifDnDDropTargetProtocol.createInstance(dropTargetProtocolListener);
tDropTargetProtocols.add(motifdndDropTargetProtocol);
dragProtocols = Collections.unmodifiableList(tDragSourceProtocols);
dropProtocols = Collections.unmodifiableList(tDropTargetProtocols);
}
static Iterator<XDragSourceProtocol> getDragSourceProtocols() {
return dragProtocols.iterator();
}
static Iterator<XDropTargetProtocol> getDropTargetProtocols() {
return dropProtocols.iterator();
}
public static XDragSourceProtocol getDragSourceProtocol(String name) {
if (name == null) {
return null;
}
Iterator<XDragSourceProtocol> dragProtocols =
XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
XDragSourceProtocol dragProtocol = dragProtocols.next();
if (dragProtocol.getProtocolName().equals(name)) {
return dragProtocol;
}
}
return null;
}
public static XDropTargetProtocol getDropTargetProtocol(String name) {
if (name == null) {
return null;
}
Iterator<XDropTargetProtocol> dropProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropProtocols.hasNext()) {
XDropTargetProtocol dropProtocol = dropProtocols.next();
if (dropProtocol.getProtocolName().equals(name)) {
return dropProtocol;
}
}
return null;
}
}