src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java

Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:


   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.awt.datatransfer.Transferable;

  29 
  30 import java.awt.dnd.DnDConstants;
  31 import java.awt.dnd.InvalidDnDOperationException;
  32 
  33 import java.util.Map;
  34 
  35 import sun.util.logging.PlatformLogger;
  36 
  37 import sun.misc.Unsafe;
  38 
  39 /**
  40  * XDragSourceProtocol implementation for XDnD protocol.
  41  *
  42  * @since 1.5
  43  */
  44 class XDnDDragSourceProtocol extends XDragSourceProtocol {
  45     private static final PlatformLogger logger =
  46         PlatformLogger.getLogger("sun.awt.X11.xembed.xdnd.XDnDDragSourceProtocol");
  47 
  48     private static final Unsafe unsafe = XlibWrapper.unsafe;


  53 
  54     /**
  55      * Creates an instance associated with the specified listener.
  56      *
  57      * @throws NullPointerException if listener is <code>null</code>.
  58      */
  59     static XDragSourceProtocol createInstance(XDragSourceProtocolListener listener) {
  60         return new XDnDDragSourceProtocol(listener);
  61     }
  62 
  63     public String getProtocolName() {
  64         return XDragAndDropProtocols.XDnD;
  65     }
  66 
  67     /**
  68      * Performs protocol-specific drag initialization.
  69      *
  70      * @returns true if the initialized successfully.
  71      */
  72     protected void initializeDragImpl(int actions, Transferable contents,
  73                                          Map formatMap, long[] formats)
  74       throws InvalidDnDOperationException,
  75         IllegalArgumentException, XException {
  76         assert XToolkit.isAWTLockHeldByCurrentThread();
  77 
  78         long window = XDragSourceProtocol.getDragSourceWindow();
  79 
  80         long data = Native.allocateLongArray(3);
  81         int action_count = 0;
  82         try {
  83             if ((actions & DnDConstants.ACTION_COPY) != 0) {
  84                 Native.putLong(data, action_count,
  85                                XDnDConstants.XA_XdndActionCopy.getAtom());
  86                 action_count++;
  87             }
  88             if ((actions & DnDConstants.ACTION_MOVE) != 0) {
  89                 Native.putLong(data, action_count,
  90                                XDnDConstants.XA_XdndActionMove.getAtom());
  91                 action_count++;
  92             }
  93             if ((actions & DnDConstants.ACTION_LINK) != 0) {




   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.awt.datatransfer.Transferable;
  29 import java.awt.datatransfer.DataFlavor;
  30 
  31 import java.awt.dnd.DnDConstants;
  32 import java.awt.dnd.InvalidDnDOperationException;
  33 
  34 import java.util.Map;
  35 
  36 import sun.util.logging.PlatformLogger;
  37 
  38 import sun.misc.Unsafe;
  39 
  40 /**
  41  * XDragSourceProtocol implementation for XDnD protocol.
  42  *
  43  * @since 1.5
  44  */
  45 class XDnDDragSourceProtocol extends XDragSourceProtocol {
  46     private static final PlatformLogger logger =
  47         PlatformLogger.getLogger("sun.awt.X11.xembed.xdnd.XDnDDragSourceProtocol");
  48 
  49     private static final Unsafe unsafe = XlibWrapper.unsafe;


  54 
  55     /**
  56      * Creates an instance associated with the specified listener.
  57      *
  58      * @throws NullPointerException if listener is <code>null</code>.
  59      */
  60     static XDragSourceProtocol createInstance(XDragSourceProtocolListener listener) {
  61         return new XDnDDragSourceProtocol(listener);
  62     }
  63 
  64     public String getProtocolName() {
  65         return XDragAndDropProtocols.XDnD;
  66     }
  67 
  68     /**
  69      * Performs protocol-specific drag initialization.
  70      *
  71      * @returns true if the initialized successfully.
  72      */
  73     protected void initializeDragImpl(int actions, Transferable contents,
  74                                       Map<Long, DataFlavor> formatMap, long[] formats)
  75       throws InvalidDnDOperationException,
  76         IllegalArgumentException, XException {
  77         assert XToolkit.isAWTLockHeldByCurrentThread();
  78 
  79         long window = XDragSourceProtocol.getDragSourceWindow();
  80 
  81         long data = Native.allocateLongArray(3);
  82         int action_count = 0;
  83         try {
  84             if ((actions & DnDConstants.ACTION_COPY) != 0) {
  85                 Native.putLong(data, action_count,
  86                                XDnDConstants.XA_XdndActionCopy.getAtom());
  87                 action_count++;
  88             }
  89             if ((actions & DnDConstants.ACTION_MOVE) != 0) {
  90                 Native.putLong(data, action_count,
  91                                XDnDConstants.XA_XdndActionMove.getAtom());
  92                 action_count++;
  93             }
  94             if ((actions & DnDConstants.ACTION_LINK) != 0) {