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


Java DataFlavor.isFlavorJavaFileListType方法代码示例

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


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

示例1: dragEnter

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public void dragEnter(DropTargetDragEvent dtde) {
    accept = null;
    value = null;
    for (DataFlavor dataFlavor : dtde.getCurrentDataFlavors()) {
        Object obj = null;
        try {
            obj = dtde.getTransferable().getTransferData(dataFlavor);
        } catch (Exception ex) {
            continue;
        }
        if (dataFlavor.isFlavorJavaFileListType()) {
            accept = dataFlavor;
            value = obj;
            break;
        }
        if ("text".equals(dataFlavor.getPrimaryType()) && "uri-list".equals(dataFlavor.getSubType()) && dataFlavor.getRepresentationClass() == String.class) {
            accept = dataFlavor;
            value = (String) obj;
            break;
        }
    }
    if (accept != null) {
        dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:LocallDownloadDnD.java

示例2: drop

import java.awt.datatransfer.DataFlavor; //导入方法依赖的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

示例3: getFlavorsForFormatsAsSet

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
 * Returns a Set of all DataFlavors for which
 * 1) a mapping from at least one of the specified formats exists in the
 * specified map and
 * 2) the data translation for this mapping can be performed by the data
 * transfer subsystem.
 *
 * @param formats the data formats
 * @param map the FlavorTable which contains mappings between
 *            DataFlavors and data formats
 * @throws NullPointerException if formats or map is {@code null}
 */
public Set<DataFlavor> getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
    Set<DataFlavor> flavorSet = new HashSet<>(formats.length);

    for (long format : formats) {
        List<DataFlavor> flavors = map.getFlavorsForNative(getNativeForFormat(format));
        for (DataFlavor flavor : flavors) {
            // Don't explicitly test for String, since it is just a special
            // case of Serializable
            if (flavor.isFlavorTextType() ||
                    flavor.isFlavorJavaFileListType() ||
                    DataFlavor.imageFlavor.equals(flavor) ||
                    flavor.isRepresentationClassSerializable() ||
                    flavor.isRepresentationClassInputStream() ||
                    flavor.isRepresentationClassRemote()) {
                flavorSet.add(flavor);
            }
        }
    }

    return flavorSet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:DataTransferer.java

示例4: getFlavorsForFormatsAsSet

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
 * Returns a Set of all DataFlavors for which
 * 1) a mapping from at least one of the specified formats exists in the
 * specified map and
 * 2) the data translation for this mapping can be performed by the data
 * transfer subsystem.
 *
 * @param formats the data formats
 * @param map the FlavorTable which contains mappings between
 *            DataFlavors and data formats
 * @throws NullPointerException if formats or map is <code>null</code>
 */
public Set getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
    Set flavorSet = new HashSet(formats.length);

    for (int i = 0; i < formats.length; i++) {
        String nat = getNativeForFormat(formats[i]);
        List flavors = map.getFlavorsForNative(nat);

        for (Iterator iter = flavors.iterator(); iter.hasNext(); ) {
            DataFlavor flavor = (DataFlavor)iter.next();

            // Don't explicitly test for String, since it is just a special
            // case of Serializable
            if (flavor.isFlavorTextType() ||
                flavor.isFlavorJavaFileListType() ||
                DataFlavor.imageFlavor.equals(flavor) ||
                flavor.isRepresentationClassSerializable() ||
                flavor.isRepresentationClassInputStream() ||
                flavor.isRepresentationClassRemote())
            {
                flavorSet.add(flavor);
            }
        }
    }

    return flavorSet;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:DataTransferer.java

示例5: main

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    df = new DataFlavor("application/x-java-file-list;class=java.util.ArrayList");
    boolean fl = df.isFlavorJavaFileListType();
    finished = true;
    if (!fl)
        throw new RuntimeException("Test FAILED");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:DataFlavorFileListTest.java

示例6: drop

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent dtde) {
	try {
		Transferable tr = dtde.getTransferable();
		DataFlavor[] flavours = tr.getTransferDataFlavors();
		
		// Iterate the flavours we have for this event
		for (DataFlavor flavour : flavours) {
		
			List<File> files = new ArrayList<>(0);
			
			// Is the OS playing nicely? This is the correct data flavour
			// for what we want
			if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
				if (flavour.isFlavorJavaFileListType()) {
					dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
					files = (List<File>) tr.getTransferData(flavour);
				}
			}
			// Check if this is the URI way of providing the dnd data
			else if (uriListFlavor != null && dtde.isDataFlavorSupported(uriListFlavor)) {
				if (flavour.isMimeTypeEqual(uriListFlavor)) {
					dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
			        String data = (String) tr.getTransferData(uriListFlavor);
			        files = textURIListToFileList(data);
				}
			} else {
				log.error("No supported data flavors!");
			}
			
			// We didn't get the desired flavour, keep trying until we do
			// (or run out).
			if (files.size() == 0) {
				continue;
			}
			
			// Filter unsupported files from our list of files.
			for (File f : files) {
				if (!ImageToZxSpec.isSupported(f)) {
					files.remove(f);
				}
			}
			
			// Only convert the first file.
			File[] inFiles = files.toArray(new File[0]);
			ImageToZxSpec.setInFiles(inFiles);
			if (inFiles[0].isDirectory()) {
				ImageToZxSpec.setOutFolder(inFiles[0]);
			} else {
				ImageToZxSpec.setOutFolder(inFiles[0].getParentFile());
			}

			// For drag and drop we want feedback so we're showing the
			// preview dialog which will show the first file.
			uiCallback.processPopupPreview();
			
			// We got what we came for - don't bother to keep checking
			break;
		}
	} catch (Exception io) {
		log.error("Drag and drop error {}", io);
	} finally {
		dtde.dropComplete(true);
	}
}
 
开发者ID:KodeMunkie,项目名称:imagetozxspec,代码行数:67,代码来源:CustomDropTargetListener.java

示例7: getFormatsForFlavors

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
 * Returns a Map whose keys are all of the possible formats into which data
 * in the specified DataFlavors can be translated. The value of each key
 * is the DataFlavor in which the Transferable's data should be requested
 * when converting to the format.
 * <p>
 * The map keys are sorted according to the native formats preference
 * order.
 *
 * @param flavors the data flavors
 * @param map the FlavorTable which contains mappings between
 *            DataFlavors and data formats
 * @throws NullPointerException if flavors or map is {@code null}
 */
public SortedMap<Long, DataFlavor> getFormatsForFlavors(DataFlavor[] flavors,
                                                        FlavorTable map)
{
    Map<Long,DataFlavor> formatMap = new HashMap<>(flavors.length);
    Map<Long,DataFlavor> textPlainMap = new HashMap<>(flavors.length);
    // Maps formats to indices that will be used to sort the formats
    // according to the preference order.
    // Larger index value corresponds to the more preferable format.
    Map<Long, Integer> indexMap = new HashMap<>(flavors.length);
    Map<Long, Integer> textPlainIndexMap = new HashMap<>(flavors.length);

    int currentIndex = 0;

    // Iterate backwards so that preferred DataFlavors are used over
    // other DataFlavors. (See javadoc for
    // Transferable.getTransferDataFlavors.)
    for (int i = flavors.length - 1; i >= 0; i--) {
        DataFlavor flavor = flavors[i];
        if (flavor == null) continue;

        // Don't explicitly test for String, since it is just a special
        // case of Serializable
        if (flavor.isFlavorTextType() ||
            flavor.isFlavorJavaFileListType() ||
            DataFlavor.imageFlavor.equals(flavor) ||
            flavor.isRepresentationClassSerializable() ||
            flavor.isRepresentationClassInputStream() ||
            flavor.isRepresentationClassRemote())
        {
            List<String> natives = map.getNativesForFlavor(flavor);

            currentIndex += natives.size();

            for (String aNative : natives) {
                Long lFormat = getFormatForNativeAsLong(aNative);
                Integer index = currentIndex--;

                formatMap.put(lFormat, flavor);
                indexMap.put(lFormat, index);

                // SystemFlavorMap.getNativesForFlavor will return
                // text/plain natives for all text/*. While this is good
                // for a single text/* flavor, we would prefer that
                // text/plain native data come from a text/plain flavor.
                if (("text".equals(flavor.getPrimaryType()) &&
                        "plain".equals(flavor.getSubType())) ||
                        flavor.equals(DataFlavor.stringFlavor)) {
                    textPlainMap.put(lFormat, flavor);
                    textPlainIndexMap.put(lFormat, index);
                }
            }

            currentIndex += natives.size();
        }
    }

    formatMap.putAll(textPlainMap);
    indexMap.putAll(textPlainIndexMap);

    // Sort the map keys according to the formats preference order.
    Comparator<Long> comparator = DataFlavorUtil.getIndexOrderComparator(indexMap).reversed();
    SortedMap<Long, DataFlavor> sortedMap = new TreeMap<>(comparator);
    sortedMap.putAll(formatMap);

    return sortedMap;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:81,代码来源:DataTransferer.java


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