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


Java FileObject.getFileObject方法代码示例

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


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

示例1: createLocation

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
    public FileObject createLocation() throws IOException {
        FileObject root = getFirstSourceRoot();
        if (root == null) {
            throw new IOException("There are no source roots in the project or the first source root does not exist."); // NOI18N
        }
        FileObject metaInf = root.getFileObject("META-INF"); // NOI18N
        if (metaInf != null) {
            if (!metaInf.isFolder()) {
                throw new IOException("The META-INF directory exists, but is not a folder."); // NOI18N
            }
        } else {
            metaInf = root.createFolder("META-INF"); // NOI18N
        }
//        //
//        FileUtil.addFileChangeListener(puChangeListener, new File(FileUtil.toFile(metaInf), "persistence.xml"));
        //
        return metaInf;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:J2SEPersistenceProvider.java

示例2: writeFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Create a new data file with specified initial contents.
 * No file events should be fired until the resulting file is complete (see {@link FileObject#createAndOpen}).
 * @param root a root folder which should already exist
 * @param path a /-separated path to the new file within that root
 * @param body the complete contents of the new file (in UTF-8 encoding)
 */
public static FileObject writeFile(FileObject root, String path, String body) throws IOException {
    int slash = path.lastIndexOf('/');
    if (slash != -1) {
        root = FileUtil.createFolder(root, path.substring(0, slash));
        path = path.substring(slash + 1);
    }
    FileObject existing = root.getFileObject(path);
    OutputStream os = existing != null ? existing.getOutputStream() : root.createAndOpen(path);
    try {
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(os, "UTF-8"));
        pw.print(body);
        pw.flush();
    } finally {
        os.close();
    }
    return root.getFileObject(path);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TestFileUtils.java

示例3: getTestFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private FileObject getTestFile(File dataDir, String projectName, String testFile, PrintWriter log) throws IOException, InterruptedException {
        File projectFile = new File(dataDir, projectName);
        FileObject project = FileUtil.toFileObject(projectFile);                
        testCase.openDataProjects(projectName);
//        Object prj= ProjectSupport.openProject(projectFile);        
//        if (prj == null)
//            throw new IllegalStateException("Given directory \"" + project + "\" does not contain a project.");
//        
//        log.println("Project found: " + prj);
        
        FileObject test = project.getFileObject("src/" + testFile);
        
        if (test == null)
            throw new IllegalStateException("Given test file does not exist.");
        
        return test;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CompletionTestCase.java

示例4: testGetPlatformVersionedLocation

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testGetPlatformVersionedLocation() throws Exception {
    File plafdir = new File(getWorkDir(), "plaf");
    TestFileUtils.writeZipFile(new File(plafdir, "platform/core/core.jar"), "j:unk");
    File harnessdir = new File(getWorkDir(), "harness");
    TestFileUtils.writeZipFile(new File(harnessdir, "modules/org-netbeans-modules-apisupport-harness.jar"), "META-INF/MANIFEST.MF:OpenIDE-Module-Specification-Version: 1.23\n");
    File suitedir = new File(getWorkDir(), "suite");
    SuiteProjectGenerator.createSuiteProject(suitedir, "special", false);
    FileObject suitedirFO = FileUtil.toFileObject(suitedir);
    FileObject plafProps = suitedirFO.getFileObject("nbproject/platform.properties");
    EditableProperties ep = Util.loadProperties(plafProps);
    ep.setProperty("suite.dir", "${basedir}");
    ep.setProperty("nbplatform.special.netbeans.dest.dir", "${suite.dir}/../plaf");
    ep.setProperty("nbplatform.special.harness.dir", "${suite.dir}/../harness");
    ep.setProperty("cluster.path", new String[] {"${nbplatform.active.dir}/platform:", "${nbplatform.special.harness.dir}"});
    Util.storeProperties(plafProps, ep);
    File moduledir = new File(getWorkDir(), "suite/m");
    NbModuleProjectGenerator.createSuiteComponentModule(moduledir, "m", "m", "m/Bundle.properties", null, suitedir, false, false);
    NbModuleProject p = (NbModuleProject) ProjectManager.getDefault().findProject(FileUtil.toFileObject(moduledir));
    NbPlatform plaf = SingleModuleProperties.getInstance(p).getActivePlatform();
    assertEquals(plafdir, plaf.getDestDir());
    assertEquals(harnessdir, plaf.getHarnessLocation());
    assertEquals(HarnessVersion.V70, plaf.getHarnessVersion());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SingleModulePropertiesTest.java

示例5: addUsersFiles

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void addUsersFiles(FileObject mimeFolder, String profileId, boolean fullScan, Map<String, List<Object []>> files) {
    if (profileId == null) {
        FileObject settingHome = mimeFolder.getFileObject(settingTypeId);
        if (settingHome != null && settingHome.isFolder()) {
            if (isUsingProfiles) {
                FileObject [] profileHomes = settingHome.getChildren();
                for(FileObject f : profileHomes) {
                    if (f.isFolder()) {
                        String id = f.getNameExt();
                        addFiles(f, fullScan, files, id, f, false, false);
                    }
                }
            } else {
                addFiles(settingHome, fullScan, files, null, null, false, false);
            }
        }
    } else {
        FileObject folder = mimeFolder.getFileObject(settingTypeId + "/" + profileId); //NOI18N
        if (folder != null && folder.isFolder()) {
            addFiles(folder, fullScan, files, profileId, folder, false, false);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SettingsType.java

示例6: store

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
void store(WizardDescriptor settings) {
//        settings.putProperty(WizardProperties.JSF_FOLDER, jsfFolder.getText());
        String pkg = getPackage();
        settings.putProperty(WizardProperties.JPA_CONTROLLER_PACKAGE, pkg);
//        settings.putProperty(WizardProperties.AJAXIFY_JSF_CRUD, Boolean.valueOf(ajaxifyCheckbox.isSelected()));
        try {
            FileObject fo = getLocationValue().getRootFolder();
            String pkgSlashes = pkg.replace('.', '/');
            FileObject targetFolder = fo.getFileObject(pkgSlashes);
            if (targetFolder == null) {
                targetFolder = FileUtil.createFolder(fo, pkgSlashes);
            }
            Templates.setTargetFolder(settings, targetFolder);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JpaControllerSetupPanelVisual.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: fastCheckParameters

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public Problem fastCheckParameters() {
    URL target = refactoring.getTarget().lookup(URL.class);
    try {
        target.toURI();
    } catch (URISyntaxException ex) {
        return createProblem(null, true, NbBundle.getMessage(CopyClassesRefactoringPlugin.class, "ERR_InvalidPackage", RefactoringUtils.getPackageName(target)));
    }
    FileObject fo = target != null ? URLMapper.findFileObject(target) : null;
    if (fo == null) {
        return createProblem(null, true, NbBundle.getMessage(CopyClassesRefactoringPlugin.class, "ERR_TargetFolderNotSet"));
    }
    if (!JavaRefactoringUtils.isOnSourceClasspath(fo)) {
        return createProblem(null, true, NbBundle.getMessage(CopyClassesRefactoringPlugin.class, "ERR_TargetFolderNotJavaPackage"));
    }
    String targetPackageName = RefactoringUtils.getPackageName(target);
    if (!RefactoringUtils.isValidPackageName(targetPackageName)) {
        String msg = new MessageFormat(NbBundle.getMessage(CopyClassesRefactoringPlugin.class, "ERR_InvalidPackage")).format(
                new Object[]{targetPackageName});
        return createProblem(null, true, msg);
    }
    Collection<? extends FileObject> sources = refactoring.getRefactoringSource().lookupAll(FileObject.class);
    Problem p = null;
    for (FileObject fileObject : sources) {
        if (fo.getFileObject(fileObject.getName(), fileObject.getExt()) != null) {
            p = createProblem(p, false, NbBundle.getMessage(CopyClassesRefactoringPlugin.class, "ERR_ClassesToCopyClashes"));
            break;
        }
    }
    return p;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:CopyClassesRefactoringPlugin.java

示例9: testSimulateLocalizedBundlePackageRefactoring

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testSimulateLocalizedBundlePackageRefactoring() throws Exception {
    NbModuleProject p = generateStandaloneModule("module1");
    SingleModuleProperties props = loadProperties(p);
    assertEquals("display name from ProjectInformation", "Testing Module",
            ProjectUtils.getInformation(p).getDisplayName());
    assertEquals("display name from LocalizedBundleInfo", "Testing Module",
            props.getBundleInfo().getDisplayName());
    
    // rename package
    FileObject pDir = p.getProjectDirectory();
    FileObject pkg = pDir.getFileObject("src/org/example/module1");
    FileLock lock = pkg.lock();
    pkg.rename(lock, "module1Renamed", null);
    lock.releaseLock();
    System.gc();    // no more random
    FileObject manifestFO = pDir.getFileObject("manifest.mf");

    // change manifest
    EditableManifest mf = Util.loadManifest(manifestFO);
    mf.setAttribute(ManifestManager.OPENIDE_MODULE_LOCALIZING_BUNDLE, "org/example/module1Renamed/resources/Bundle.properties", null);
    Util.storeManifest(manifestFO, mf);
    simulatePropertiesOpening(props, p);
    
    // make sure that properties are not damaged
    assertEquals("display name was refreshed in ProjectInformation", "Testing Module",
            ProjectUtils.getInformation(p).getDisplayName());
    assertEquals("display name was refreshed in LocalizedBundleInfo", "Testing Module",
            props.getBundleInfo().getDisplayName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:SingleModulePropertiesTest.java

示例10: createJfxExtension

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Adds FX specific build script jfx-impl.xml to project build system
 * @param p
 * @param dirFO
 * @param type
 * @throws IOException 
 */
static void createJfxExtension(Project p, FileObject dirFO, WizardType type) throws IOException {
    FileObject templateFO = FileUtil.getConfigFile("Templates/JFX/jfx-impl.xml"); // NOI18N
    if (templateFO != null) {
        FileObject nbprojectFO = dirFO.getFileObject("nbproject"); // NOI18N
        FileObject jfxBuildFile = FileUtil.copyFile(templateFO, nbprojectFO, "jfx-impl"); // NOI18N
        if (type == JavaFXProjectWizardIterator.WizardType.SWING) {
            FileObject templatesFO = nbprojectFO.getFileObject("templates"); // NOI18N
            if (templatesFO == null) {
                templatesFO = nbprojectFO.createFolder("templates"); // NOI18N
            }
            FileObject swingTemplateFO1 = FileUtil.getConfigFile("Templates/JFX/FXSwingTemplate.html"); // NOI18N
            if (swingTemplateFO1 != null) {
                FileUtil.copyFile(swingTemplateFO1, templatesFO, "FXSwingTemplate"); // NOI18N
            }
            FileObject swingTemplateFO2 = FileUtil.getConfigFile("Templates/JFX/FXSwingTemplateApplet.jnlp"); // NOI18N
            if (swingTemplateFO1 != null) {
                FileUtil.copyFile(swingTemplateFO2, templatesFO, "FXSwingTemplateApplet"); // NOI18N
            }
            FileObject swingTemplateFO3 = FileUtil.getConfigFile("Templates/JFX/FXSwingTemplateApplication.jnlp"); // NOI18N
            if (swingTemplateFO1 != null) {
                FileUtil.copyFile(swingTemplateFO3, templatesFO, "FXSwingTemplateApplication"); // NOI18N
            }
        }
        JFXProjectUtils.addExtension(p);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:JFXProjectUtils.java

示例11: getPackageFolder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** */
static FileObject getPackageFolder(
        FileObject root,
        String pkgName) throws IOException {
    String relativePathName = pkgName.replace('.', '/');
    FileObject folder = root.getFileObject(relativePathName);
    if (folder == null) {
        folder = FileUtil.createFolder(root, relativePathName);
    }
    return folder;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JUnitUtils.java

示例12: testDeleteOfNonEmptySuite

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDeleteOfNonEmptySuite() throws Exception {
    SuiteProject suite = generateSuite("suite");
    FileObject prjDir = suite.getProjectDirectory();
    prjDir.createFolder("branding");
    NbModuleProject module1 = TestBase.generateSuiteComponent(suite, "module1");
    NbModuleProject module2 = TestBase.generateSuiteComponent(suite, "module2");
    assertEquals("module1 is suite component", NbModuleType.SUITE_COMPONENT, module1.getModuleType());
    assertEquals("module2 is suite component", NbModuleType.SUITE_COMPONENT, module2.getModuleType());
    module1.open();
    module2.open();
    
    suite.open();
    SuiteActions ap = (SuiteActions) suite.getLookup().lookup(ActionProvider.class);
    assertNotNull("have an action provider", ap);
    assertTrue("delete action is enabled", ap.isActionEnabled(ActionProvider.COMMAND_DELETE, null));
    
    
    // build project
    ap.invokeActionImpl(ActionProvider.COMMAND_BUILD, suite.getLookup()).waitFinished();
    prjDir.refresh();
    assertNotNull("suite was built", prjDir.getFileObject("build"));
    
    FileObject[] expectedMetadataFiles = new FileObject[] {
        prjDir.getFileObject(GeneratedFilesHelper.BUILD_XML_PATH),
        prjDir.getFileObject("nbproject"),
    };
    assertEquals("correct metadata files", Arrays.asList(expectedMetadataFiles), ProjectOperations.getMetadataFiles(suite));
    FileObject[] expectedDataFiles = new FileObject[] {
        prjDir.getFileObject("branding"),
    };
    assertEquals("correct data files", Arrays.asList(expectedDataFiles), ProjectOperations.getDataFiles(suite));
    
    // It is hard to simulate exact scenario invoked by user. Let's test at least something.
    ProjectOperations.notifyDeleting(suite);
    prjDir.getFileSystem().refresh(true);
    assertNull(prjDir.getFileObject("build"));
    
    assertEquals("module1 became standalone module", NbModuleType.STANDALONE, module1.getModuleType());
    assertEquals("module2 became standalone module", NbModuleType.STANDALONE, module2.getModuleType());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:SuiteOperationsTest.java

示例13: copyAppletHTML

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static URL copyAppletHTML(Project project, PropertyEvaluator props, FileObject profiledClassFile, String value) {
    try {
        String buildDirProp = props.getProperty("build.dir"); //NOI18N

        FileObject buildFolder = getOrCreateBuildFolder(project, buildDirProp);

        FileObject htmlFile;
        htmlFile = profiledClassFile.getParent().getFileObject(profiledClassFile.getName(), "html"); //NOI18N

        if (htmlFile == null) {
            htmlFile = profiledClassFile.getParent().getFileObject(profiledClassFile.getName(), "HTML"); //NOI18N
        }

        if (htmlFile == null) {
            return null;
        }

        FileObject existingFile = buildFolder.getFileObject(htmlFile.getName(), htmlFile.getExt());

        if (existingFile != null) {
            existingFile.delete();
        }

        htmlFile.copy(buildFolder, profiledClassFile.getName(), value).getURL();

        return htmlFile.getURL();
    } catch (IOException e) {
        ErrorManager.getDefault()
                    .annotate(e, Bundle.ProjectUtilities_FailedCopyAppletFileMsg(e.getMessage()));
        ErrorManager.getDefault().notify(ErrorManager.ERROR, e);

        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:ProjectUtilities.java

示例14: isProject2

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
    public ProjectManager.Result isProject2(FileObject dir) {
        FileObject testproject = dir.getFileObject("testproject");
        if(testproject != null && testproject.isFolder() && testproject.getFileObject("broken") != null) {
            return new ProjectManager.Result(TEST_PROJECT_ICON);
}
        if(testproject != null && testproject.isFolder()) {
            return new ProjectManager.Result(
                        dir.getName(), 
                        TEST_PROJECT_TYPE, 
                        TEST_PROJECT_ICON);
        }
        return null;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:TestUtil.java

示例15: findOpposite

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
static @CheckForNull FileObject findOpposite(FileObject rule, boolean toTest) {
    ClassPath cp = ClassPath.getClassPath(rule, ClassPath.SOURCE);
    String resourceName = cp != null ? cp.getResourceName(rule) : null;

    if (resourceName == null) {
        Logger.getLogger(TestLocatorImpl.class.getName()).log(Level.FINE, "cp==null or rule file cannot be found on its own source cp");
        return null;
    }

    String testFileName = resourceName.substring(0, resourceName.lastIndexOf('.')) + (toTest ? ".test" : ".hint");

    FileObject testFile = cp.findResource(testFileName);

    if (testFile == null) {
        URL[] sr;

        if (toTest) {
            sr = UnitTestForSourceQuery.findUnitTests(cp.findOwnerRoot(rule));
        } else {
            sr = UnitTestForSourceQuery.findSources(cp.findOwnerRoot(rule));
        }
        
        for (URL testRoot : sr) {
            FileObject testRootFO = URLMapper.findFileObject(testRoot);

            if (testRootFO != null) {
                testFile = testRootFO.getFileObject(testFileName);

                if (testFile != null) {
                    break;
                }
            }
        }
    }

    return testFile;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:TestLocatorImpl.java


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