0N/A/*
2362N/A * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.awt.X11;
0N/A
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Collections;
0N/Aimport java.util.Iterator;
0N/Aimport java.util.List;
0N/A
0N/A/**
0N/A * This class is a registry for the supported drag and drop protocols.
0N/A *
0N/A * @since 1.5
0N/A */
0N/Afinal class XDragAndDropProtocols {
0N/A private final static List dragProtocols;
0N/A private final static List dropProtocols;
0N/A
0N/A public static final String XDnD = "XDnD";
0N/A public static final String MotifDnD = "MotifDnD";
0N/A
0N/A static {
0N/A // Singleton listener for all drag source protocols.
0N/A XDragSourceProtocolListener dragSourceProtocolListener =
0N/A XDragSourceContextPeer.getXDragSourceProtocolListener();
0N/A // Singleton listener for all drop target protocols.
0N/A XDropTargetProtocolListener dropTargetProtocolListener =
0N/A XDropTargetContextPeer.getXDropTargetProtocolListener();
0N/A
0N/A List tDragSourceProtocols = new ArrayList();
0N/A XDragSourceProtocol xdndDragSourceProtocol =
0N/A XDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
0N/A tDragSourceProtocols.add(xdndDragSourceProtocol);
0N/A XDragSourceProtocol motifdndDragSourceProtocol =
0N/A MotifDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
0N/A tDragSourceProtocols.add(motifdndDragSourceProtocol);
0N/A
0N/A List tDropTargetProtocols = new ArrayList();
0N/A XDropTargetProtocol xdndDropTargetProtocol =
0N/A XDnDDropTargetProtocol.createInstance(dropTargetProtocolListener);
0N/A tDropTargetProtocols.add(xdndDropTargetProtocol);
0N/A XDropTargetProtocol motifdndDropTargetProtocol =
0N/A MotifDnDDropTargetProtocol.createInstance(dropTargetProtocolListener);
0N/A tDropTargetProtocols.add(motifdndDropTargetProtocol);
0N/A
0N/A dragProtocols = Collections.unmodifiableList(tDragSourceProtocols);
0N/A dropProtocols = Collections.unmodifiableList(tDropTargetProtocols);
0N/A }
0N/A
0N/A static Iterator getDragSourceProtocols() {
0N/A return dragProtocols.iterator();
0N/A }
0N/A
0N/A static Iterator getDropTargetProtocols() {
0N/A return dropProtocols.iterator();
0N/A }
0N/A
0N/A /*
0N/A * Returns a XDragSourceProtocol whose name equals to the specified string
0N/A * or null if no such protocol is registered.
0N/A */
0N/A public static XDragSourceProtocol getDragSourceProtocol(String name) {
0N/A // Protocol name cannot be null.
0N/A if (name == null) {
0N/A return null;
0N/A }
0N/A
0N/A Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
0N/A while (dragProtocols.hasNext()) {
0N/A XDragSourceProtocol dragProtocol =
0N/A (XDragSourceProtocol)dragProtocols.next();
0N/A if (dragProtocol.getProtocolName().equals(name)) {
0N/A return dragProtocol;
0N/A }
0N/A }
0N/A
0N/A return null;
0N/A }
0N/A
0N/A /*
0N/A * Returns a XDropTargetProtocol which name equals to the specified string
0N/A * or null if no such protocol is registered.
0N/A */
0N/A public static XDropTargetProtocol getDropTargetProtocol(String name) {
0N/A // Protocol name cannot be null.
0N/A if (name == null) {
0N/A return null;
0N/A }
0N/A
0N/A Iterator dropProtocols = XDragAndDropProtocols.getDropTargetProtocols();
0N/A while (dropProtocols.hasNext()) {
0N/A XDropTargetProtocol dropProtocol =
0N/A (XDropTargetProtocol)dropProtocols.next();
0N/A if (dropProtocol.getProtocolName().equals(name)) {
0N/A return dropProtocol;
0N/A }
0N/A }
0N/A
0N/A return null;
0N/A }
0N/A}