当前位置: 首页>>代码示例>>Java>>正文


Java DropTargetDropEvent.isDataFlavorSupported方法代码示例

本文整理汇总了Java中java.awt.dnd.DropTargetDropEvent.isDataFlavorSupported方法的典型用法代码示例。如果您正苦于以下问题:Java DropTargetDropEvent.isDataFlavorSupported方法的具体用法?Java DropTargetDropEvent.isDataFlavorSupported怎么用?Java DropTargetDropEvent.isDataFlavorSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.dnd.DropTargetDropEvent的用法示例。


在下文中一共展示了DropTargetDropEvent.isDataFlavorSupported方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: getString

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
 * Gets the string.
 *
 * @param event
 *            the event
 * @return the string
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws UnsupportedFlavorException
 *             the unsupported flavor exception
 */
@SuppressWarnings("unchecked")
static String getString(DropTargetDropEvent event) throws IOException, UnsupportedFlavorException {
	String text = null;
	DataFlavor fileList = DataFlavor.javaFileListFlavor;

	if (event.isDataFlavorSupported(fileList)) {
		event.acceptDrop(DnDConstants.ACTION_COPY);
		List<File> list = (List<File>) event.getTransferable().getTransferData(fileList);
		text = list.get(0).getAbsolutePath();
	} else if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
		event.acceptDrop(DnDConstants.ACTION_COPY);
		text = (String) event.getTransferable().getTransferData(DataFlavor.stringFlavor);
		if (text.startsWith("file://"))
			text = text.substring(7);
		text = stripSuffix(stripSuffix(text, "\n"), "\r").replaceAll("%20", " ");
	} else {
		event.rejectDrop();
		return null;
	}

	event.dropComplete(text != null);
	return text;
}
 
开发者ID:thorstenwagner,项目名称:ij-ridgedetection,代码行数:35,代码来源:GenericDialogPlus.java

示例4: chooseDropFlavor

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
 * Called by drop and retrieves the <code>DataFlavor</code> for the
 * input <code>DropTargetDropEvent</code>
 *
 * @param e
 *            the DropTargetDropEvent object
 * @return the chosen DataFlavor or null if none match
 */
private DataFlavor chooseDropFlavor(final DropTargetDropEvent e) {
    if ((e.isLocalTransfer() == true) && e.isDataFlavorSupported(StringTransferable.LOCAL_STRING_FLAVOR)) {
        return StringTransferable.LOCAL_STRING_FLAVOR;
    }

    DataFlavor chosen = null;

    if (e.isDataFlavorSupported(StringTransferable.LOCAL_STRING_FLAVOR)) {
        chosen = StringTransferable.LOCAL_STRING_FLAVOR;
    }

    if (e.isDataFlavorSupported(NewObservationUsingConceptNameButton.BUTTON_FLAVOR)) {
        chosen = NewObservationUsingConceptNameButton.BUTTON_FLAVOR;
    }

    return chosen;
}
 
开发者ID:hohonuuli,项目名称:vars,代码行数:26,代码来源:ConceptButtonDropPanel.java

示例5: 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

示例6: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
    if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        dtde.dropComplete(true);
        if (activeDragItem != null) {
            activeDragItem.dragAccepted();
        }
    } else {
        dtde.rejectDrop();
    }
    component.setCursor(oCursor);
    activeDragItem = null;
    component.repaint();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DragManager.java

示例7: drag

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public static void drag()//定义的拖拽方法
{
    //panel表示要接受拖拽的控件
    new DropTarget(JlPath, DnDConstants.ACTION_COPY_OR_MOVE, new DropTargetAdapter() {
        public void drop(DropTargetDropEvent dtde)//重写适配器的drop方法
        {
            try {
                if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor))//如果拖入的文件格式受支持
                {
                    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);//接收拖拽来的数据
                    List<File> list = (List<File>) (dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor));
                    String temp = "";
                    for (File file : list) {
                        temp = file.getAbsolutePath();
                        JlPath.setText(temp);
                        break;
                    }
                    //JOptionPane.showMessageDialog(null, temp);
                    dtde.dropComplete(true);//指示拖拽操作已完成
                } else {
                    dtde.rejectDrop();//否则拒绝拖拽来的数据
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
 
开发者ID:Harlber,项目名称:Method_Trace_Tool,代码行数:29,代码来源:Trace.java

示例8: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop( DropTargetDropEvent dtde ) {
	if ( !dtde.isDataFlavorSupported( DataFlavor.javaFileListFlavor ) ) {
		dtde.rejectDrop();
		return;
	}
	dtde.acceptDrop( dtde.getDropAction() );

	Transferable trans = dtde.getTransferable();
	List<File> files;
	try {
		files = (List<File>) trans.getTransferData( DataFlavor.javaFileListFlavor );
	}
	catch ( UnsupportedFlavorException | IOException e ) {
		log.error( e );
		dtde.dropComplete( false );
		return;
	}

	log.debug( "file drop" );

	ProgressTask pt = OpenAction.openFiles( DIHelper.getInstance().getDesktop(),
			files, null );
	OperationsProgress.getInstance( PlayPane.UIPROGRESS ).add( pt );

	dtde.dropComplete( true );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:28,代码来源:CustomDesktopPane.java

示例9: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent event) {
	try {
		Transferable trans = event.getTransferable(); 
		if (event.isDataFlavorSupported(Constraint.dataFlavor)) {
			Constraint.ConstraintData cons = (Constraint.ConstraintData) trans.getTransferData(Constraint.dataFlavor);
			event.acceptDrop(DnDConstants.ACTION_COPY);
			
			boolean res = processDroppedConstraint(event.getLocation(), cons);
			
			if (res) {
				if (cons.getFacetType() == Facet.FacetType.CATEGORICAL) 
					for (Long id : cons.valueIDs) {
						Constraint.ConstraintData sepcons = new Constraint.ConstraintData(cons.facetID);
						sepcons.valueIDs.add(id);
						rootFrame.historyPanel.addOperation(sepcons);
					}
				else 
					rootFrame.historyPanel.addOperation(cons);
			}
			
			event.dropComplete(true);
			return;
		}
		else if (event.isDataFlavorSupported(NodesFilter.dataFlavor)) {
			NodesFilter f = (NodesFilter) trans.getTransferData(NodesFilter.dataFlavor);
			event.acceptDrop(DnDConstants.ACTION_MOVE);
			processDroppedFilter(event.getLocation(), f);
			event.dropComplete(true);
			return;
		}
		
		event.rejectDrop();
		
	} catch (Exception e) {
		e.printStackTrace();
		event.rejectDrop();
		rootFrame.showErrorMessage("Drag&Drop error:\n" + e.toString());
	}
}
 
开发者ID:jeffjianzhao,项目名称:PivotSlice,代码行数:40,代码来源:FacetBrowser.java

示例10: initJListFileDropOnWindows

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
* Initialisiert Drop auf Windows
* @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899516
*/  
private void initJListFileDropOnWindows(){
    DropTarget target = new DropTarget(jList1, new DropTargetAdapter() {
        @Override
        public void drop(DropTargetDropEvent dtde) {
            if(dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
                dtde.acceptDrop(dtde.getDropAction());
                try {
                    //siehe: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899516
                    final List<File> list = (List<File>) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
                    //Hier steht der eigentliche Drop Code
                    if(CollectionManager.INSTANCE.isACollectionCreated()){
                        //ImportGUI im extra Thread, damit durch den Import Prozess keine Verzögerungen auftreten                     
                        Runnable runImport = new Runnable() {
                            @Override
                            public void run() {                           
                                 ImportDirectoryGUI fileImport = new ImportDirectoryGUI(
                                         MovieManagerGUI.getInstance(), 
                                         true, 
                                         MovieManagerGUI.getInstance().getTabNames(),
                                         list,
                                         collection);
                                 fileImport.showGUI();                           
                            } 
                        };
                        SwingUtilities.invokeLater(runImport);
                    }
                } 
                catch (UnsupportedFlavorException | IOException ex) {
                    LOG.error("Error while dropping file into MovieList.", ex);
                }                  
            }
        }
     });
     jList1.setDropTarget(target);
}
 
开发者ID:R3d-Dragon,项目名称:jMovieManager,代码行数:40,代码来源:MovieTabGUI.java

示例11: initJListFileDropOnWindows

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
* Initialisiert Drop auf Windows
* @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899516
*/  
private void initJListFileDropOnWindows(){
    DropTarget target = new DropTarget(jTree1, new DropTargetAdapter() {
        @Override
        public void drop(DropTargetDropEvent dtde) {
            if(dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
                dtde.acceptDrop(dtde.getDropAction());
                try {
                    //siehe: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899516
                    final List<File> list = (List<File>) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
                    //Hier steht der eigentliche Drop Code                       
                    if(CollectionManager.INSTANCE.isACollectionCreated()){            
                        //ImportGUI im extra Thread, damit durch den Import Prozess keine Verzögerungen auftreten                     
                        Runnable runImport = new Runnable() {
                            @Override
                            public void run() {
                                 ImportDirectoryGUI fileImport = new ImportDirectoryGUI(
                                         MovieManagerGUI.getInstance(), 
                                         true, 
                                         MovieManagerGUI.getInstance().getTabNames(),
                                         list,
                                         collection);
                                 fileImport.showGUI(); 
                            } 
                        };
                        SwingUtilities.invokeLater(runImport);
                    }
                } 
                catch (UnsupportedFlavorException | IOException ex) {
                    LOG.error("Error while dropping file into SeriesTree.", ex);
                }                    
            }
        }
     });
     jTree1.setDropTarget(target);
}
 
开发者ID:R3d-Dragon,项目名称:jMovieManager,代码行数:40,代码来源:SerieTabGUI.java

示例12: chooseDropFlavor

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
protected DataFlavor chooseDropFlavor(DropTargetDropEvent e)
{
    if (e.isDataFlavorSupported(SDFileMoleculeTransferable.DF_SERIALIZEDSTRUCTURETRANSFERDATA))
            return SDFileMoleculeTransferable.DF_SERIALIZEDSTRUCTURETRANSFERDATA;
    else
        return super.chooseDropFlavor(e);
}
 
开发者ID:Actelion,项目名称:openchemlib,代码行数:8,代码来源:SDFileMoleculeDropAdapter.java

示例13: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void drop(DropTargetDropEvent event) {
    if (event.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

        DataFlavor df = DataFlavor.javaFileListFlavor;
        List<File> list = null;
        try {
            list = (List<File>) (event.getTransferable().getTransferData(df));
        } catch (Exception e) {
            e.printStackTrace();
        }
        Iterator<File> iterator = list.iterator();
        while (iterator.hasNext()) {
            File file = iterator.next();
            if (file.exists() && file.isFile()) {
                String filePath = file.getAbsolutePath();
                if (filePath == null || filePath.equals("")) {
                    System.out.println("文件名为 null 或为 \"\"~");
                    break;
                }
                if (!filePath.endsWith(".jar")) {
                    String str = "此工具专门为jar包设计,不通用!! 请注意!!";
                    JOptionPane.showMessageDialog(null, str);
                    break;
                }
                tas.jTextField_file.setText(filePath);
                System.out.println("jarFilePath=" + filePath);

            }
            // 一次只能处理一个,要避免处理多个的情况,因此 break 跳出~  
            break;
        }
        event.dropComplete(true);
    } else {
        event.rejectDrop();
    }
}
 
开发者ID:AndroidStudioTranslate,项目名称:Android-Studio-Translate-Tool,代码行数:40,代码来源:TAS1.java

示例14: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde)
{
	if (dtde.isDataFlavorSupported(CardFlavor.cardFlavor) && this.canDrop)
	{
		Transferable trans = dtde.getTransferable();
		try
		{
			Object data = trans.getTransferData(CardFlavor.cardFlavor);
			CardWindow card =(CardWindow)data;
			DropTargetContext context = dtde.getDropTargetContext();
			CardCollection comp = (CardCollection)context.getComponent();
			Container parent = comp.getParent();
			GameController.getController(false)
				.makeMove(CardCollection.getMoveFromIndex(comp.getCardMouseLocation(), new OrderedCard(card.card, card.cardLocation)));
			if (parent != null)
				parent.remove(card);
			comp.setCard(card, comp.getCardMouseLocation());
			dtde.acceptDrop(DnDConstants.ACTION_MOVE);
			comp.validate();
			comp.repaint();
			
			dtde.dropComplete(true);
		}
		catch (Exception e)
		{
			dtde.rejectDrop();
			dtde.dropComplete(false);
			JOptionPane.showMessageDialog(MainWindow.getMainWindow(), "Invalid move.", "Invalid Move Error", JOptionPane.ERROR_MESSAGE);
			e.printStackTrace();
		}
	}
	else
	{
		dtde.rejectDrop();
		dtde.dropComplete(false);
		JOptionPane.showMessageDialog(MainWindow.getMainWindow(), "Invalid move.", "Invalid Move Error", JOptionPane.ERROR_MESSAGE);
	}
}
 
开发者ID:slaymaker1907,项目名称:triple-triad-ai,代码行数:40,代码来源:CardDropHandler.java

示例15: getString

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static String getString(final DropTargetDropEvent event) throws IOException,
	UnsupportedFlavorException
{
	String text = null;
	final DataFlavor fileList = DataFlavor.javaFileListFlavor;

	if (event.isDataFlavorSupported(fileList)) {
		event.acceptDrop(DnDConstants.ACTION_COPY);
		final List<File> list = (List<File>) event.getTransferable()
			.getTransferData(fileList);
		text = list.get(0).getAbsolutePath();
	}
	else if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
		event.acceptDrop(DnDConstants.ACTION_COPY);
		text = (String) event.getTransferable().getTransferData(
			DataFlavor.stringFlavor);
		if (text.startsWith("file://")) text = text.substring(7);
		text = stripSuffix(stripSuffix(text, "\n"), "\r").replaceAll("%20", " ");
	}
	else {
		event.rejectDrop();
		return null;
	}

	event.dropComplete(text != null);
	return text;
}
 
开发者ID:EFTEMj,项目名称:EFTEMj,代码行数:29,代码来源:GenericDialogPlus.java


注:本文中的java.awt.dnd.DropTargetDropEvent.isDataFlavorSupported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。