コード例 #1
0
 public /*@Override*/ PasteType getDropType(Transferable t, int action, int index) {
   if (t.isDataFlavorSupported(ExTransferable.multiFlavor)) {
     try {
       MultiTransferObject mto =
           (MultiTransferObject) t.getTransferData(ExTransferable.multiFlavor);
       boolean hasPackageFlavor = false;
       for (int i = 0; i < mto.getCount(); i++) {
         DataFlavor[] flavors = mto.getTransferDataFlavors(i);
         if (isPackageFlavor(flavors)) {
           hasPackageFlavor = true;
         }
       }
       return hasPackageFlavor ? null : super.getDropType(t, action, index);
     } catch (UnsupportedFlavorException e) {
       ErrorManager.getDefault().notify(e);
       return null;
     } catch (IOException e) {
       ErrorManager.getDefault().notify(e);
       return null;
     }
   } else {
     DataFlavor[] flavors = t.getTransferDataFlavors();
     if (isPackageFlavor(flavors)) {
       return null;
     } else {
       return super.getDropType(t, action, index);
     }
   }
 }
コード例 #2
0
 public PasteType[] getPasteTypes(Transferable t) {
   if (t.isDataFlavorSupported(ExTransferable.multiFlavor)) {
     try {
       MultiTransferObject mto =
           (MultiTransferObject) t.getTransferData(ExTransferable.multiFlavor);
       boolean hasPackageFlavor = false;
       for (int i = 0; i < mto.getCount(); i++) {
         DataFlavor[] flavors = mto.getTransferDataFlavors(i);
         if (isPackageFlavor(flavors)) {
           hasPackageFlavor = true;
         }
       }
       return hasPackageFlavor ? new PasteType[0] : super.getPasteTypes(t);
     } catch (UnsupportedFlavorException e) {
       ErrorManager.getDefault().notify(e);
       return new PasteType[0];
     } catch (IOException e) {
       ErrorManager.getDefault().notify(e);
       return new PasteType[0];
     }
   } else {
     DataFlavor[] flavors = t.getTransferDataFlavors();
     if (isPackageFlavor(flavors)) {
       return new PasteType[0];
     } else {
       return super.getPasteTypes(t);
     }
   }
 }