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


Java FileObject.createFolder方法代码示例

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


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

示例1: testClearNonProjectCache

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testClearNonProjectCache() throws Exception {
    FileObject p1 = scratch.createFolder("p1");
    p1.createFolder("testproject");
    Project proj1 = pm.findProject(p1);
    assertNotNull("p1 immediately recognized as a project", proj1);
    FileObject p2 = scratch.createFolder("p2");
    assertNull("p2 not yet recognized as a project", pm.findProject(p2));
    FileObject p2a = scratch.createFolder("p2a");
    assertNull("p2a not yet recognized as a project", pm.findProject(p2a));
    FileObject p3 = scratch.createFolder("p3");
    FileObject p3broken = p3.createFolder("testproject").createData("broken");
    try {
        pm.findProject(p3);
        fail("p3 should throw an error");
    } catch (IOException e) {
        // Correct.
    }
    p2.createFolder("testproject");
    p2a.createFolder("testproject");
    p3broken.delete();
    pm.clearNonProjectCache();
    assertNotNull("now p2 is recognized as a project", pm.findProject(p2));
    assertNotNull("now p2a is recognized as a project", pm.findProject(p2a));
    assertNotNull("now p3 is recognized as a non-broken project", pm.findProject(p3));
    assertEquals("p1 still recognized as a project", proj1, pm.findProject(p1));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ProjectManagerTest.java

示例2: setUp

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    MockLookup.setInstances(AntBasedTestUtil.testAntBasedProjectType());
    super.setUp();
    this.clearWorkDir();
    File wd = getWorkDir();
    FileObject scratch = FileUtil.toFileObject(wd);
    assertNotNull(wd);
    projdir = scratch.createFolder("proj");
    helper = ProjectGenerator.createProject(projdir, "test");
    assertNotNull(helper);
    eval = helper.getStandardPropertyEvaluator();
    assertNotNull(eval);
    prj = ProjectManager.getDefault().findProject(projdir);
    assertNotNull(prj);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:FileEncodingQueryImplTest.java

示例3: createNewCategory

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
void createNewCategory() throws java.io.IOException {
    java.util.ResourceBundle bundle = Utils.getBundle();
    NotifyDescriptor.InputLine input = new NotifyDescriptor.InputLine(
        bundle.getString("CTL_NewCategoryName"), // NOI18N
        bundle.getString("CTL_NewCategoryTitle")); // NOI18N
    input.setInputText(bundle.getString("CTL_NewCategoryValue")); // NOI18N

    while (DialogDisplayer.getDefault().notify(input)
                                          == NotifyDescriptor.OK_OPTION)
    {
        String categoryName = input.getInputText();
        if( CategoryNode.checkCategoryName( this, categoryName, null ) ) {
            DataFolder paletteFolder = (DataFolder)getCookie( DataFolder.class );
            FileObject parentFolder = paletteFolder.getPrimaryFile();
            String folderName = CategoryNode.convertCategoryToFolderName( parentFolder, categoryName, null );
            FileObject folder = parentFolder.createFolder(folderName);
            if (!folderName.equals(categoryName))
                folder.setAttribute( CategoryNode.CAT_NAME, categoryName );
            break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:RootNode.java

示例4: testDelete2

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDelete2() throws IOException {
    File f = testFile;
    
    FileObject testFo = FileBasedFileSystem.getFileObject(testFile);
    assertNotNull(testFo);
    assertEquals(0,testFo.getChildren().length);
    
    FileObject newFolder = testFo.createFolder("testDelete2");
    assertNotNull(newFolder);
    assertEquals(1,testFo.getChildren().length);
    
    newFolder.delete();
    assertFalse(newFolder.isValid());
    assertEquals(0,testFo.getChildren().length);
    assertNull(testFo.getFileObject(newFolder.getNameExt()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:FolderObjTest.java

示例5: setUp

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected void setUp () throws IOException {
    MockServices.setServices(new Class[] {CPProvider.class, SFBQImpl.class});
    this.clearWorkDir();
    File wd = this.getWorkDir();
    FileObject root = FileUtil.toFileObject(wd);
    assertNotNull(root);
    srcRoot1 = root.createFolder("src1");
    assertNotNull(srcRoot1);
    srcRoot2 = root.createFolder("src2");
    assertNotNull(srcRoot2);
    binaryRoot2 = root.createFolder("binary2");
    assertNotNull(binaryRoot2);       
    SFBQImpl.clear();
    CPProvider.clear();
    SFBQImpl.register(srcRoot2.toURL(), binaryRoot2.toURL());
    CPProvider.register(srcRoot2, ClassPath.SOURCE, ClassPathSupport.createClassPath(new FileObject[] {srcRoot2}));
    CPProvider.register(srcRoot2, ClassPath.EXECUTE, ClassPathSupport.createClassPath(new FileObject[] {binaryRoot2}));        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:BinaryForSourceQueryTest.java

示例6: createDocuments

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
protected Document[] createDocuments(String... fileName) {
    try {
        List<Document> docs = new ArrayList<>();
        FileSystem memFS = FileUtil.createMemoryFileSystem();
        for (String fName : fileName) {

            //we may also create folders
            StringTokenizer items = new StringTokenizer(fName, "/");
            FileObject fo = memFS.getRoot();
            while(items.hasMoreTokens()) {
                String item = items.nextToken();
                if(items.hasMoreTokens()) {
                    //folder
                    fo = fo.createFolder(item);
                } else {
                    //last, create file
                    fo = fo.createData(item);
                }
                assertNotNull(fo);
            }
            
            DataObject dobj = DataObject.find(fo);
            assertNotNull(dobj);

            EditorCookie cookie = dobj.getCookie(EditorCookie.class);
            assertNotNull(cookie);

            Document document = (Document) cookie.openDocument();
            assertEquals(0, document.getLength());

            docs.add(document);

        }
        return docs.toArray(new Document[]{});
    } catch (Exception ex) {
        throw new IllegalStateException("Error setting up tests", ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:TestBase.java

示例7: setUp

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public void setUp() throws IOException, PropertyVetoException {

    // create projects
    projects.add(createProject("projectDir1"));
    projects.add(createProject("projectDir2"));

    List l = new LinkedList<DataObject>();
    clearWorkDir();
    FileObject root = FileUtil.toFileObject(getWorkDir());
    FileObject test1 = root.createFolder("test1");
    FileObject test2 = root.createFolder("test2");
    FileObject test1a = test1.createFolder("A");
    FileObject test1aTestClassJava = test1a.createData("TestClass.java");
    FileObject test2DataTxt = test2.createData("data.txt");
    createZipFile(test2);
    DataObject shadowFile = createShadowFile(test2DataTxt);

    FileObject archiveZip = test2.getFileObject("archive.zip");
    assertTrue(FileUtil.isArchiveFile(archiveZip));
    FileObject archiveRoot = FileUtil.getArchiveRoot(archiveZip);
    assertNotNull(archiveRoot);
    FileObject test2ArchiveZipBTxt = archiveRoot.getFileObject("b.txt");

    // test1/A/TestClass.java
    l.add(DataObject.find(test1aTestClassJava));
    // test2/data.txt
    l.add(DataObject.find(test2DataTxt));
    // test2/archive.zip:b.txt
    l.add(DataObject.find(test2ArchiveZipBTxt));
    // /testDataShadows/testShadowFile -> test2/data.txt
    l.add(shadowFile);
    dataObjects = l;
    List<Lookup.Provider> context = new LinkedList<Lookup.Provider>();
    context.addAll(projects);
    context.addAll(dataObjects);
    action = new CopyPathToClipboardAction(context);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:CopyPathToClipboardActionTest.java

示例8: prepareTest

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void prepareTest() throws Exception {
    File work = getWorkDir();
    FileObject workFO = FileUtil.toFileObject(work);

    assertNotNull(workFO);

    sourceRoot = workFO.createFolder("src");
    FileObject buildRoot  = workFO.createFolder("build");
    FileObject cache = workFO.createFolder("cache");

    SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PostFlowAnalysisTest.java

示例9: testFolderOrder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testFolderOrder() throws Exception {
    Layer l = new Layer("");
    FileSystem fs = l.read();
    FileObject r = fs.getRoot();
    FileObject a = r.createData("a");
    FileObject b = r.createData("b");
    FileObject f = r.createFolder("f");
    FileObject c = f.createData("c");
    FileObject d = f.createData("d");
    FileObject e = f.createData("e");
    DataFolder.findFolder(r).setOrder(new DataObject[] {DataObject.find(a), DataObject.find(b)});
    DataFolder.findFolder(f).setOrder(new DataObject[] {DataObject.find(c), DataObject.find(d), DataObject.find(e)});
    assertEquals("correct ordering XML",
            "    <file name=\"a\">\n" +
            "        <attr name=\"position\" intvalue=\"100\"/>\n" +
            "    </file>\n" +
            "    <file name=\"b\">\n" +
            "        <attr name=\"position\" intvalue=\"200\"/>\n" +
            "    </file>\n" +
            "    <folder name=\"f\">\n" +
            "        <file name=\"c\">\n" +
            "            <attr name=\"position\" intvalue=\"100\"/>\n" +
            "        </file>\n" +
            "        <file name=\"d\">\n" +
            "            <attr name=\"position\" intvalue=\"200\"/>\n" +
            "        </file>\n" +
            "        <file name=\"e\">\n" +
            "            <attr name=\"position\" intvalue=\"300\"/>\n" +
            "        </file>\n" +
            "    </folder>\n",
            l.write());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:WritableXMLFileSystemTest.java

示例10: setUp

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    FileObject fo = FileUtil.createFolder(
        FileUtil.getConfigRoot(),
        "Folder" + getName()
    );
    final FileObject file = fo.createFolder("File");
    file.createData("org-openide-actions-CutAction.instance").setAttribute("position", 100);
    file.createData("javax-swing-JSeparator.instance").setAttribute("position", 200);
    file.createData("org-openide-actions-CopyAction.instance").setAttribute("position", 300);
    df = DataFolder.findFolder(fo);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:MenuBarSeparatorInAWTTest.java

示例11: testAddRemoveOnData2

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testAddRemoveOnData2() throws IOException {
    FileObject root = FileUtil.toFileObject(getWorkDir());
    FileObject folder = root.createFolder("dir");
    FileObject data = root.createData("data.txt");
    
    notify.assertRegistered("No registered paths yet");
    
    data.addFileChangeListener(listener);
    root.addFileChangeListener(listener);
    
    notify.assertRegistered("One path is being listened to", root.getPath());
    
    root.removeFileChangeListener(listener);

    notify.assertRegistered("Still one path is being listened to", root.getPath());
    
    data.removeFileChangeListener(listener);
    
    notify.assertRegistered("Path has been cleared", (String)null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:WatcherTest.java

示例12: testAddFileChangeListenerFolder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Tests FileChangeListener on folder. As declared in
 * {@link FileUtil#addFileChangeListener(org.openide.filesystems.FileChangeListener, java.io.File) }
 * - fileFolderCreated event is fired when the folder is created or a child folder created
 * - fileDataCreated event is fired when a child file is created
 * - fileDeleted event is fired when the folder is deleted or a child file/folder removed
 * - fileChanged event is fired when a child file is modified
 * - fileRenamed event is fired when the folder is renamed or a child file/folder is renamed
 * - fileAttributeChanged is fired when FileObject's attribute is changed
 */
public void testAddFileChangeListenerFolder() throws IOException {
    clearWorkDir();
    // test files: dir/file1, dir/subdir/subfile
    File rootF = getWorkDir();
    File dirF = new File(rootF, "dir");
    TestFileChangeListener fcl = new TestFileChangeListener();
    FileUtil.addFileChangeListener(fcl, dirF);
    // create dir
    FileObject dirFO = FileUtil.createFolder(dirF);
    assertEquals("Event not fired when folder created.", 1, fcl.check(EventType.FOLDER_CREATED));
    FileObject subdirFO = dirFO.createFolder("subdir");
    assertEquals("Event not fired when sub folder created.", 1, fcl.check(EventType.FOLDER_CREATED));

    // create file
    FileObject file1FO = dirFO.createData("file1");
    assertEquals("Event not fired when data created.", 1, fcl.check(EventType.DATA_CREATED));
    FileObject subfileFO = subdirFO.createData("subfile");
    assertEquals("Event fired when data in sub folder created.", 0, fcl.checkAll());

    // modify
    file1FO.getOutputStream().close();
    assertEquals("fileChanged event not fired.", 1, fcl.check(EventType.CHANGED));
    subfileFO.getOutputStream().close();
    assertEquals("Event fired when file sub folder modified.", 0, fcl.checkAll());

    // delete
    file1FO.delete();
    assertEquals("Event not fired when child file deleted.", 1, fcl.check(EventType.DELETED));
    subfileFO.delete();
    assertEquals("Event fired when child file in sub folder deleted.", 0, fcl.checkAll());
    subdirFO.delete();
    assertEquals("Event not fired when sub folder deleted.", 1, fcl.check(EventType.DELETED));
    dirFO.delete();
    assertEquals("Event not fired when folder deleted.", 1, fcl.check(EventType.DELETED));

    // rename
    dirFO = FileUtil.createFolder(dirF);
    file1FO = dirFO.createData("file1");
    subdirFO = dirFO.createFolder("subdir");
    subfileFO = subdirFO.createData("subfile");
    fcl.checkAll();
    FileLock lock = file1FO.lock();
    file1FO.rename(lock, "file1Renamed", null);
    lock.releaseLock();
    assertEquals("Event not fired when child file renamed.", 1, fcl.check(EventType.RENAMED));
    lock = subfileFO.lock();
    subfileFO.rename(lock, "subfileRenamed", null);
    lock.releaseLock();
    assertEquals("Event fired when child file in sub folder renamed.", 0, fcl.check(EventType.RENAMED));
    lock = subdirFO.lock();
    subdirFO.rename(lock, "subdirRenamed", null);
    lock.releaseLock();
    assertEquals("Event not fired when sub folder renamed.", 1, fcl.check(EventType.RENAMED));
    lock = dirFO.lock();
    dirFO.rename(lock, "dirRenamed", null);
    lock.releaseLock();
    assertEquals("Event not fired when sub folder renamed.", 1, fcl.check(EventType.RENAMED));
    fcl.printAll();
    assertEquals("No other events should be fired.", 0, fcl.checkAll());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:70,代码来源:FileUtilTest.java

示例13: testModuleSourcesChangesFires

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testModuleSourcesChangesFires() throws IOException {
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    final FileObject modulesFolder = wd.createFolder("modules"); //NOI18N
    assertNotNull(modulesFolder);
    final FileObject classesFolder = modulesFolder.createFolder("module").createFolder("classes");        //NOI18N
    assertTrue(mtu.updateModuleRoots(false, "classes:resources",modulesFolder));   //NOI18N
    final SourceRoots modules = mtu.newModuleRoots(false);
    assertTrue(Arrays.equals(new FileObject[]{modulesFolder}, modules.getRoots()));
    final SourceRoots sources = mtu.newSourceRoots(false);
    assertEquals(
            Arrays.stream(new FileObject[]{classesFolder})
                .map((fo) -> fo.getPath())
                .sorted()
                .collect(Collectors.toList()),
            Arrays.stream(sources.getRoots())
                .map((fo) -> fo.getPath())
                .sorted()
                .collect(Collectors.toList()));
    final MultiModule model = MultiModule.getOrCreate(modules, sources);
    assertNotNull(model);
    final SourceRoots testModules = mtu.newModuleRoots(true);
    assertTrue(Arrays.equals(new FileObject[]{}, testModules.getRoots()));
    final SourceRoots testSources = mtu.newSourceRoots(true);
    final MultiModule testModel = MultiModule.getOrCreate(testModules, testSources);
    final MultiModuleSourceForBinaryQueryImpl q =
            new MultiModuleSourceForBinaryQueryImpl(
                    tp.getUpdateHelper().getAntProjectHelper(),
                    tp.getEvaluator(),
                    model,
                    testModel,
                    new String[]{ProjectProperties.DIST_DIR},
                    new String[]{});
    final URL origDistJar = mtu.distFor(classesFolder.getParent().getNameExt());
    SourceForBinaryQueryImplementation2.Result res = q.findSourceRoots2(origDistJar);
    assertNotNull(res);
    assertTrue(res.preferSources());
    assertEquals(Arrays.asList(classesFolder), Arrays.asList(res.getRoots()));

    final MockChangeListener l = new MockChangeListener();
    res.addChangeListener(l);
    final FileObject resourcesFolder = modulesFolder.getFileObject("module").createFolder("resources");        //NOI18N
    l.assertEventCount(1);
    assertEquals(Arrays.asList(classesFolder,resourcesFolder), Arrays.asList(res.getRoots()));

    classesFolder.delete();
    l.assertEventCount(1);
    assertEquals(Arrays.asList(resourcesFolder), Arrays.asList(res.getRoots()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:MultiModuleSourceForBinaryQueryImplTest.java

示例14: createSourcePath

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static ClassPath createSourcePath (FileObject testBase) throws IOException {
    FileObject root = testBase.createFolder("src");        
    return ClassPathSupport.createClassPath(new FileObject[]{root});
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ClasspathInfoTest.java

示例15: prepareTest

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void prepareTest(String code, boolean allowErrors) throws Exception {
    clearWorkDir();

    FileObject workFO = FileUtil
            .toFileObject(getWorkDir());

    assertNotNull(workFO);

    FileObject sourceRoot = workFO
            .createFolder("src");
    FileObject buildRoot = workFO
            .createFolder("build");
    FileObject cache = workFO
            .createFolder("cache");

    FileObject data = FileUtil
            .createData(sourceRoot, "test/Test.java");

    org.netbeans.api.java.source.TestUtilities
            .copyStringToFile(FileUtil
            .toFile(data), code);

    data
            .refresh();

    if (sourceLevel != null) {
        SourceUtilsTestUtil.setSourceLevel(data, sourceLevel);
    }
    SourceUtilsTestUtil
            .prepareTest(sourceRoot, buildRoot, cache);

    DataObject od = DataObject
            .find(data);
    EditorCookie ec = od
            .getCookie(EditorCookie.class);

    assertNotNull(ec);

    doc = ec
            .openDocument();

    doc
            .putProperty(Language.class, JavaTokenId
            .language());
    doc
            .putProperty("mimeType", "text/x-java");

    JavaSource js = JavaSource
            .forFileObject(data);

    assertNotNull(js);

    info = SourceUtilsTestUtil
            .getCompilationInfo(js, Phase.RESOLVED);

    assertNotNull(info);

    if (!allowErrors) {
        assertTrue(info
                .getDiagnostics()
                .toString(), info
                .getDiagnostics()
                .isEmpty());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:FlowTest.java


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