Ejemplo n.º 1
0
 /**
  * Imports the drop data by going over the list of supported callbacks. This method will return
  * true if a callback could be found that could successfully import the drop data, or false
  * otherwise.
  *
  * @param support The TransferSupport describing the drop event.
  * @return true if a callback could be found that could successfully import the drop data, or
  *     false otherwise.
  */
 @Override
 public boolean importData(final TransferSupport support) {
   try {
     final DataFlavor[] flavors = support.getDataFlavors();
     for (DataFlavor flavor : flavors) {
       final LinkedList<DropHandlerCallback> callbacks = _callbackMapping.get(flavor);
       if (callbacks == null) continue;
       final Object data = support.getTransferable().getTransferData(flavor);
       for (DropHandlerCallback callback : callbacks)
         if (callback.importData(support.getComponent(), data)) return true;
     }
   } catch (Exception e) {
     return false;
   }
   return false;
 }
Ejemplo n.º 2
0
 /**
  * Checks whether a callback has been registered for any of the data flavors supported by this
  * drop event.
  *
  * @param support The TransferSupport describing the drop event.
  * @return Whether or not a callback for any of the support's data flavors has been registered.
  */
 @Override
 public boolean canImport(final TransferSupport support) {
   for (DataFlavor flavor : _callbackMapping.keySet()) {
     final LinkedList<DropHandlerCallback> callbackLinkedList = _callbackMapping.get(flavor);
     if (callbackLinkedList.size() > 0 && support.isDataFlavorSupported(flavor)) return true;
   }
   return false;
 }