@Override
 public boolean importData(TransferSupport support) {
   DataFlavor f = getStringFlavor(support.getDataFlavors());
   Object drop = null;
   String s = null;
   if (f != null) {
     try {
       drop = support.getTransferable().getTransferData(f);
     } catch (UnsupportedFlavorException e) {
       Logger.getLogger(this.getClass()).debug("Internal error.", e); // $NON-NLS-1$
     } catch (IOException e) {
       Logger.getLogger(this.getClass()).debug("Internal error.", e); // $NON-NLS-1$
     }
   } else {
     try {
       drop = support.getTransferable().getTransferData(DataFlavor.stringFlavor);
     } catch (UnsupportedFlavorException e) {
       Logger.getLogger(this.getClass()).debug("Internal error.", e); // $NON-NLS-1$
     } catch (IOException e) {
       Logger.getLogger(this.getClass()).debug("Internal error.", e); // $NON-NLS-1$
     }
   }
   if (drop != null) {
     s = String.valueOf(drop);
   }
   if (s != null) {
     return importString(s, support);
   }
   return false;
 }
Пример #2
0
    @Override
    public boolean canImport(TransferSupport support) {
      if (support.isDrop() && !mDropEnabled) return false;

      if (support.getComponent() == mTextArea && mTextHandler.canImport(support)) return true;

      for (DataFlavor flavor : support.getDataFlavors()) {
        if (flavor.isFlavorJavaFileListType()) {
          return true;
        }
      }

      return false;
    }
 /**
  * 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;
 }
 @Override
 public boolean canImport(TransferSupport support) {
   DataFlavor f = getStringFlavor(support.getDataFlavors());
   return f != null;
 }