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


Java DataFlavor.javaFileListFlavor方法代碼示例

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


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

示例1: testJavaFileListPasteTypes

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void testJavaFileListPasteTypes() throws ClassNotFoundException, IOException {
    FileObject testFO = FileUtil.createData( testFileSystem.getRoot(), "testFile.txt" );
    File testFile = FileUtil.toFile( testFO );
    ArrayList fileList = new ArrayList(1);
    fileList.add( testFile );
    Transferable t = new MockTransferable( new DataFlavor[] {DataFlavor.javaFileListFlavor}, fileList );

    DataFolder.FolderNode node = (DataFolder.FolderNode)folderNode;
    ArrayList list = new ArrayList();
    node.createPasteTypes( t, list );
    assertFalse( list.isEmpty() );
    PasteType paste = (PasteType)list.get( 0 );
    paste.paste();

    FileObject[] children = testFileSystem.getRoot().getFileObject( "testDir" ).getChildren();
    assertEquals( 1, children.length );
    assertEquals( children[0].getNameExt(), "testFile.txt" );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:DataFolderPasteTypesTest.java

示例2: testJavaFileListWithRelativePaths

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
/**
 * Test for bug 233673.
 *
 * @throws java.io.IOException
 */
public void testJavaFileListWithRelativePaths() throws IOException {

    FileObject testFO = FileUtil.createData(testFileSystem.getRoot(),
            "absoluteTestFile.txt");
    File absoluteTestFile = FileUtil.toFile(testFO);
    File relativeTestFile = new File("relativeFile.txt");

    ArrayList fileList = new ArrayList(2);
    fileList.add(relativeTestFile);
    fileList.add(absoluteTestFile);
    Transferable t = new MockTransferable(
            new DataFlavor[]{DataFlavor.javaFileListFlavor}, fileList);

    DataFolder.FolderNode node = (DataFolder.FolderNode) folderNode;
    ArrayList<PasteType> list = new ArrayList<PasteType>();
    node.createPasteTypes(t, list);
    assertEquals("Relative path should be skipped", 1, list.size());
    PasteType paste = (PasteType) list.get(0);
    paste.paste();

    FileObject[] children = testFileSystem.getRoot().getFileObject(
            "testDir").getChildren();
    assertEquals(1, children.length);
    assertEquals(children[0].getNameExt(), "absoluteTestFile.txt");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:DataFolderPasteTypesTest.java

示例3: testCanDrop

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void testCanDrop() throws ClassNotFoundException {
    DefaultExternalDropHandler handler = new DefaultExternalDropHandler();

    DataFlavor[] flavors = new DataFlavor[] { DataFlavor.imageFlavor };
    assertFalse( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.imageFlavor, DataFlavor.stringFlavor };
    assertFalse( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );

    DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");

    flavors = new DataFlavor[] { uriListFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { uriListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { uriListFlavor, DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:DefaultExternalDropHandlerTest.java

示例4: setDataFlavor

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
/**
 * Sets and returns the type of the Transferable object of the clipboard
 * 
 * @param t - Transferable object in clipboard
 *            
 * @return t'type - Type of DataFlavor
 */
public static DataFlavor setDataFlavor(Transferable t) {
	DataFlavor[] flavors = t.getTransferDataFlavors();

	for (int i = 0; i < flavors.length; i++) {

		if (flavors[i].equals(DataFlavor.stringFlavor)) {
			type = Contents.TYPE_STRING;
			return DataFlavor.stringFlavor;
		} else if (flavors[i].equals(DataFlavor.imageFlavor)) {
			type = Contents.TYPE_IMAGE;
			return DataFlavor.imageFlavor;
		} else if (flavors[i].equals(DataFlavor.javaFileListFlavor)) {
			type = Contents.TYPE_FILE;
			return DataFlavor.javaFileListFlavor;
		} else {
		}
	}
	return null;
}
 
開發者ID:Team-Sprout,項目名稱:Clipcon-Client,代碼行數:27,代碼來源:ClipboardController.java

示例5: testGetFileList

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public void testGetFileList() throws ClassNotFoundException, URISyntaxException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
    DefaultExternalDropHandler handler = new DefaultExternalDropHandler();
    DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");

    Transferable t = new TransferableImpl( new ArrayList(), new DataFlavor[] { DataFlavor.imageFlavor, DataFlavor.stringFlavor } );
    assertNull( handler.getFileList( t ) );

    List<File> list = new ArrayList<File>( 2 );
    list.add( new File("//somedir/somefile.someext") );
    list.add( new File("c:\\somedir\\somefile.someext") );
    t = new TransferableImpl( list, new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.stringFlavor } );

    List<File> extractedList = handler.getFileList( t );
    assertNotNull( extractedList );
    assertEquals( 2, extractedList.size() );
    for( Iterator i=list.iterator(); i.hasNext(); ) {
        assertTrue( extractedList.contains( i.next() ) );
    }

    String uriList = "file:///somedir/somefile.someext\r\nfile:/c:/somedir/somefile.someext";
    t = new TransferableImpl( uriList, new DataFlavor[] { uriListFlavor, DataFlavor.stringFlavor } );
    extractedList = handler.getFileList( t );
    assertNotNull( extractedList );
    assertEquals( 2, extractedList.size() );
    assertTrue( extractedList.contains( new File( new URI("file:///somedir/somefile.someext") ) ) );
    assertTrue( extractedList.contains( new File( new URI("file:/c:/somedir/somefile.someext") ) ) );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:DefaultExternalDropHandlerTest.java

示例6: getTransferDataFlavors

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.javaFileListFlavor};
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:5,代碼來源:FolderList.java

示例7: isDataFlavorSupported

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
    return DataFlavor.javaFileListFlavor == flavor;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:5,代碼來源:FolderList.java

示例8: getTransferDataFlavors

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
@Override
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[] {DataFlavor.javaFileListFlavor};
}
 
開發者ID:Njol,項目名稱:Motunautr,代碼行數:5,代碼來源:FileListTransferable.java

示例9: getTransferDataFlavors

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
@Override
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[] { DataFlavor.javaFileListFlavor };
}
 
開發者ID:Team-Sprout,項目名稱:Clipcon-Client,代碼行數:5,代碼來源:FileTransferable.java

示例10: getTransferDataFlavors

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor [] {DataFlavor.javaFileListFlavor};
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:4,代碼來源:FileListTransferable.java

示例11: getRicherFlavors

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
/**
 * Best format of the file chooser is DataFlavor.javaFileListFlavor.
 */
protected DataFlavor[] getRicherFlavors() {
	DataFlavor[] flavors = new DataFlavor[1];
	flavors[0] = DataFlavor.javaFileListFlavor;
	return flavors;
}
 
開發者ID:kmarius,項目名稱:xdman,代碼行數:9,代碼來源:FileTransferHandler.java


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