src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2013, 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


 222       throws UnsupportedFlavorException, IOException,
 223         InvalidDnDOperationException
 224     {
 225 
 226         SecurityManager sm = System.getSecurityManager();
 227         try {
 228             if (!dropInProcess && sm != null) {
 229                 sm.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);
 230             }
 231         } catch (Exception e) {
 232             Thread currentThread = Thread.currentThread();
 233             currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, e);
 234             return null;
 235         }
 236 
 237         Long lFormat = null;
 238         Transferable localTransferable = local;
 239 
 240         if (localTransferable != null) {
 241             return localTransferable.getTransferData(df);


 242         }
 243 
 244         if (dropStatus != STATUS_ACCEPT || dropComplete) {
 245             throw new InvalidDnDOperationException("No drop current");
 246         }
 247 
 248         Map flavorMap = DataTransferer.getInstance().getFlavorsForFormats
 249             (currentT, DataTransferer.adaptFlavorMap
 250                 (currentDT.getFlavorMap()));
 251 
 252         lFormat = (Long)flavorMap.get(df);
 253         if (lFormat == null) {
 254             throw new UnsupportedFlavorException(df);
 255         }
 256 
 257         if (df.isRepresentationClassRemote() &&
 258             currentDA != DnDConstants.ACTION_LINK) {
 259             throw new InvalidDnDOperationException("only ACTION_LINK is permissable for transfer of java.rmi.Remote objects");
 260         }
 261 


   1 /*
   2  * Copyright (c) 2000, 2014, 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


 222       throws UnsupportedFlavorException, IOException,
 223         InvalidDnDOperationException
 224     {
 225 
 226         SecurityManager sm = System.getSecurityManager();
 227         try {
 228             if (!dropInProcess && sm != null) {
 229                 sm.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);
 230             }
 231         } catch (Exception e) {
 232             Thread currentThread = Thread.currentThread();
 233             currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, e);
 234             return null;
 235         }
 236 
 237         Long lFormat = null;
 238         Transferable localTransferable = local;
 239 
 240         if (localTransferable != null) {
 241             return localTransferable.getTransferData(df);
 242         } else if (df.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
 243             return null;
 244         }
 245 
 246         if (dropStatus != STATUS_ACCEPT || dropComplete) {
 247             throw new InvalidDnDOperationException("No drop current");
 248         }
 249 
 250         Map flavorMap = DataTransferer.getInstance().getFlavorsForFormats
 251             (currentT, DataTransferer.adaptFlavorMap
 252                 (currentDT.getFlavorMap()));
 253 
 254         lFormat = (Long)flavorMap.get(df);
 255         if (lFormat == null) {
 256             throw new UnsupportedFlavorException(df);
 257         }
 258 
 259         if (df.isRepresentationClassRemote() &&
 260             currentDA != DnDConstants.ACTION_LINK) {
 261             throw new InvalidDnDOperationException("only ACTION_LINK is permissable for transfer of java.rmi.Remote objects");
 262         }
 263