当前位置: 首页>>代码示例>>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;未经允许,请勿转载。