當前位置: 首頁>>代碼示例>>Java>>正文


Java DropTargetDropEvent.getTransferable方法代碼示例

本文整理匯總了Java中java.awt.dnd.DropTargetDropEvent.getTransferable方法的典型用法代碼示例。如果您正苦於以下問題:Java DropTargetDropEvent.getTransferable方法的具體用法?Java DropTargetDropEvent.getTransferable怎麽用?Java DropTargetDropEvent.getTransferable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.dnd.DropTargetDropEvent的用法示例。


在下文中一共展示了DropTargetDropEvent.getTransferable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    try {
        Transferable t = dtde.getTransferable();
        DataFlavor[] dataFlavors = t.getTransferDataFlavors();
        for (DataFlavor df : dataFlavors) {
            if (df.isFlavorJavaFileListType()) {
                File[] filesArray = (File[]) ((List<File>) t.getTransferData(df)).toArray();
                pathNameTextField.setText(getFilesName(filesArray));
            }
        }
    } catch (UnsupportedFlavorException e2) {
    } catch (IOException ex) {
        Logger.getLogger(SubtitleDownloaderUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:atulgpt,項目名稱:SubtitleDownloader,代碼行數:18,代碼來源:SubtitleDownloaderUI.java

示例2: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        dtde.rejectDrop();
        return;
    }

    Transferable t = dtde.getTransferable();
    List<Village> v;
    MapPanel.getSingleton().setCurrentCursor(MapPanel.getSingleton().getCurrentCursor());
    try {
        v = (List<Village>) t.getTransferData(VillageTransferable.villageDataFlavor);
        fireVillagesDraggedEvent(v, dtde.getLocation());
    } catch (Exception ignored) {
    }
}
 
開發者ID:Torridity,項目名稱:dsworkbench,代碼行數:19,代碼來源:AbstractDSWorkbenchFrame.java

示例3: extractDropFile

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Nullable
private File extractDropFile(@Nonnull final DropTargetDropEvent dtde) throws Exception {
  File result = null;
  for (final DataFlavor df : dtde.getCurrentDataFlavors()) {
    final Class<?> representation = df.getRepresentationClass();
    if (FileTransferable.class.isAssignableFrom(representation)) {
      final FileTransferable t = (FileTransferable) dtde.getTransferable();
      final List<File> listOfFiles = t.getFiles();
      result = listOfFiles.isEmpty() ? null : listOfFiles.get(0);
      break;
    } else if (df.isFlavorJavaFileListType()) {
      try {
        final List list = (List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
        if (list != null && !list.isEmpty()) {
          result = (File) list.get(0);
        }
        break;
      }
      catch (final Exception ex) {
        LOGGER.error("Can't extract file from DnD", ex); //NOI18N
      }
    }
  }
  return result;
}
 
開發者ID:raydac,項目名稱:netbeans-mmd-plugin,代碼行數:26,代碼來源:MMDEditor.java

示例4: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent arg0) {
    Transferable tr = arg0.getTransferable();
    arg0.acceptDrop(DnDConstants.ACTION_REFERENCE);
    if(arg0.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
        try {
            @SuppressWarnings("unchecked")
            List<File> fileList = (List<File>)tr.getTransferData(DataFlavor.javaFileListFlavor);
            for(File file: fileList){
                AttackResultFrame resultFrame = new AttackResultFrame();
                if (resultFrame.loadResult(file) == true){
                    resultFrame.setVisible(true);
                    resultFrame.invalidate();
                }else{
                    resultFrame = null;
                }
            }
        } catch (UnsupportedFlavorException | IOException e) {
            logger.debug(e);
        }
    }
}
 
開發者ID:OgaworldEX,項目名稱:ORS,代碼行數:23,代碼來源:MainFrameDropTargetListener.java

示例5: extractTransferData

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
private void extractTransferData(DropTargetDropEvent dtde) {
    if (dtde == null) {
        System.out.println("ERROR> BDnDC::getTransferData(): dropEvent is null");
        return;
    }

    Transferable tr = dtde.getTransferable();
    try {
        transferData = (Vector) tr.getTransferData(DefaultTransferableObject.OBJECT_FLAVOR);

        // cache beanInfos
        if (transferData.size() >= 2) {
            Object bean = transferData.get(0);
            BeanInfo beanInfo = (BeanInfo) transferData.get(1);
            beanInfoMap.put(bean.getClass().getName(), beanInfo);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:d2fn,項目名稱:passage,代碼行數:22,代碼來源:BeanBoxDnDCatcher.java

示例6: extractTransferData

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
/**
 * Gets the object that is passed in transferable in DropTargetDropEvent.
 */

private Object extractTransferData(DropTargetDropEvent dtde) {
    if (dtde == null) {
        Debug.message("defaultdndcatcher",
                "ERROR> DefaultDnDCatcher::getTransferData(): dropEvent is null");
        return null;
    }

    Transferable tr = dtde.getTransferable();
    try {
        return tr.getTransferData(DefaultTransferableObject.OBJECT_FLAVOR);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:d2fn,項目名稱:passage,代碼行數:20,代碼來源:DefaultDnDCatcher.java

示例7: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    try {
        final Transferable transferable = dtde.getTransferable();
        if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            final List<File> fileList = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
            if (fileList.size() > 0) {
                final OpenProductAction open = new OpenProductAction();
                open.setFiles(fileList.toArray(new File[fileList.size()]));
                dtde.dropComplete(Boolean.TRUE.equals(open.execute()));
            }
        } else {
            dtde.rejectDrop();
        }
    } catch (UnsupportedFlavorException | IOException ignored) {
        dtde.rejectDrop();
    }
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:20,代碼來源:ProductExplorerTopComponent.java

示例8: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
	if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) {
		// Accept the drop and get the transfer data
		dtde.acceptDrop(dtde.getDropAction());
		Transferable transferable = dtde.getTransferable();
		boolean dropSucceeded = false;

		try {
			window
					.setCursor(Cursor
							.getPredefinedCursor(Cursor.WAIT_CURSOR));

			dropSucceeded = dropFile(dtde.getDropAction(), transferable,
					dtde.getLocation());

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			window.setCursor(Cursor.getDefaultCursor());
			dtde.dropComplete(dropSucceeded);
		}
	} else {
		dtde.dropComplete(false);
	}
}
 
開發者ID:yjgoo,項目名稱:pdm-viewer,代碼行數:26,代碼來源:DropFileLoader.java

示例9: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
    gestureStarted = false;
    if ((dtde.getDropAction() & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE) {
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
        Transferable t = dtde.getTransferable();

        try {
            DBTableInternalFrame iFrame = (DBTableInternalFrame) t
                    .getTransferData(InternalFrameTransferable.DATA_FLAVOR);
            if (iFrame != DBTableInternalFrame.this) {
                JoinLine joinLine = new JoinLine(iFrame, iFrame
                        .getSelectedRow(), DBTableInternalFrame.this,
                        columnsListBox.getSelectedIndex());
                desktop.addJoinLine(joinLine);
                desktop.repaint();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        dtde.dropComplete(true);
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-designer,代碼行數:24,代碼來源:DBTableInternalFrame.java

示例10: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent event) {
    int dropAction = event.getDropAction();
    JComponent c = (JComponent) event.getDropTargetContext().getComponent();
    DataObjectTransferHandler transferHandler = (DataObjectTransferHandler) c.getTransferHandler();

    if (canImport && (transferHandler != null) && actionSupported(dropAction)) {
        event.acceptDrop(dropAction);
        try {
            Transferable transferable = event.getTransferable();
            transferHandler.setDropPoint(event.getLocation());
            transferHandler.setDropComponent(c);
            event.dropComplete(transferHandler.importData(c, transferable));
        } catch (RuntimeException e) {
            event.dropComplete(false);
        }
    } else {
        event.rejectDrop();
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-designer,代碼行數:20,代碼來源:DataObjectTransferHandler.java

示例11: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void drop(DropTargetDropEvent dtde) {
	if (!dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
		dtde.rejectDrop();
		return;
	}
	dtde.acceptDrop(dtde.getDropAction());
	try {
		Transferable transferable = dtde.getTransferable();
		List<File> transferData = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
		if (transferData != null && transferData.size() > 0) {
			dtde.dropComplete(true);
			// load first file
			mainWindow.openFile(transferData.get(0));
		}
	} catch (Exception e) {
		LOG.error("File drop operation failed", e);
	}
}
 
開發者ID:skylot,項目名稱:jadx,代碼行數:21,代碼來源:MainDropTarget.java

示例12: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
    try {
        Transferable tr = dtde.getTransferable();
        if (tr.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            String data = (String) tr.getTransferData(DataFlavor.stringFlavor);
            // create the new TreeTable containing the selected dragged path
            this.addSelectedTestdirectoryToMetaCampaign(data);
            dtde.getDropTargetContext().dropComplete(true);
        } else {
            System.err.println("Rejected");
            dtde.rejectDrop();
        }
    } catch (IOException | UnsupportedFlavorException io) {
        logger.error(io);
        dtde.rejectDrop();
    }
}
 
開發者ID:qspin,項目名稱:qtaste,代碼行數:19,代碼來源:TestCaseTree.java

示例13: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public synchronized void drop(DropTargetDropEvent dropTargetDropEvent) {
    try {
        final Transferable transferable = dropTargetDropEvent.getTransferable();
        if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY);
            dropTargetDropEvent.getDropTargetContext().dropComplete(true);
        }
        else {
            dropTargetDropEvent.rejectDrop();
        }
    }
    catch (Exception ex) {
        Log.error(ex);
        dropTargetDropEvent.rejectDrop();
    }
}
 
開發者ID:visit,項目名稱:spark-svn-mirror,代碼行數:17,代碼來源:FileDragLabel.java

示例14: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent dtde) {
	try {
		Transferable t = dtde.getTransferable();
		List<File> files = null;
		if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
			dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
			files = (List<File>) t
					.getTransferData(DataFlavor.javaFileListFlavor);
		} else if (uriFlavor != null && t.isDataFlavorSupported(uriFlavor)) {
			dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
			files = textURIListToFileList((String) t
					.getTransferData(uriFlavor));
		} else
			dtde.rejectDrop();

		if (files != null && files.size() == 1) {
			openFile(files.get(0));
			dtde.dropComplete(true);
		} else
			dtde.dropComplete(false);
	} catch (UnsupportedFlavorException ex) {
		dtde.rejectDrop();
	} catch (IOException e) {
		dtde.rejectDrop();
	}
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:29,代碼來源:FileDropTargetListener.java

示例15: isDropAcceptable

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public boolean isDropAcceptable(DropTargetDropEvent event) {
    Transferable transferable = event.getTransferable();
    if (transferable != null) {
        if (transferable.isDataFlavorSupported(FSTabbedPaneTransferable.FLAVOR)) {
            FSTabbedPaneTransferable tabTransferable = getTabTransferable(event);
            return tabTransferable.index >= 0;
        }
    }
    return false;
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:11,代碼來源:FSTabbedPaneDropTargetAdapter.java


注:本文中的java.awt.dnd.DropTargetDropEvent.getTransferable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。