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


Java FileObject.getChildren方法代码示例

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


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

示例1: testGetChildren

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testGetChildren() throws IOException {
    FileObject fobj = getFileObject(testFile);
    FileObject parent = fobj.getParent();
    parent = parent.createFolder("parent");
    File pFile = getFile(parent);
    for (int i = 0; i < 10; i++) {
        assertTrue(new File(pFile, "file" + i).createNewFile());
        assertTrue(new File(pFile, "fold" + i).mkdir());
    }
    monitor.reset();
    FileObject[] children = parent.getChildren();
    //20 x children, 1 x File.listFiles 
    monitor.getResults().assertResult(21, StatFiles.ALL);
    monitor.getResults().assertResult(21, StatFiles.READ);
    //second time
    monitor.reset();
    children = parent.getChildren();
    monitor.getResults().assertResult(0, StatFiles.ALL);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:StatFilesTest.java

示例2: checkUpdatingExistingTestClass

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@NbBundle.Messages({"MSG_UPDATE_SINGLE_TEST_CLASS=The existing test class will be updated.",
"MSG_UPDATE_ALL_TEST_CLASSES=Any existing test classes will be updated."})
private void checkUpdatingExistingTestClass() {
    if(tfClassName == null) {
        setMessage(Bundle.MSG_UPDATE_ALL_TEST_CLASSES(), MSG_TYPE_UPDATE_ALL_TEST_CLASSES);
    } else {
        FileObject locationFO = getTargetFolder();
        if (locationFO != null) {
            String targetFolderPath = FileUtil.toFile(locationFO).getAbsolutePath();
            String className = tfClassName.getText();
            int index = className.lastIndexOf('.'); // index == -1 most probably means class is under <default package>
            String packageName = index == -1 ? "" : className.substring(0, index);
            String fileName = index == -1 ? className : className.substring(index + 1);
            FileObject testFolderFO = FileUtil.toFileObject(new File(targetFolderPath.concat(File.separator).concat(packageName.replace(".", "/"))));
            if(testFolderFO != null) {
                for(FileObject testClassFO : testFolderFO.getChildren()) {
                    if(testClassFO.getName().equals(fileName)) {
                        setMessage(Bundle.MSG_UPDATE_SINGLE_TEST_CLASS(), MSG_TYPE_UPDATE_SINGLE_TEST_CLASS);
                        return;
                    }
                }
            }
        }
        setMessage(null, MSG_TYPE_UPDATE_SINGLE_TEST_CLASS);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:CommonTestsCfgOfCreate.java

示例3: existingModes

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
static @CheckForNull Set<String> existingModes(NewTCIterator.DataModel data) throws IOException {
    FileSystem fs = data.getProject().getLookup().lookup(NbModuleProvider.class).getEffectiveSystemFilesystem();
    data.setSFS(fs);
    FileObject foRoot = fs.getRoot().getFileObject("Windows2/Modes"); //NOI18N
    if (foRoot != null) {
        FileObject[] fos = foRoot.getChildren();
        Set<String> col = new TreeSet<String>();
        for (FileObject fo : fos) {
            if (fo.isData() && "wsmode".equals(fo.getExt())) { //NOI18N
                col.add(fo.getName());
                data.existingMode(fo.getName());
            }
        }
        return col;
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DesignSupport.java

示例4: testGetCachedChildren

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testGetCachedChildren() throws IOException {
    FileObject fobj = getFileObject(testFile);
    FileObject parent = fobj.getParent();
    List<FileObject> l = new ArrayList<FileObject>();
    parent = parent.createFolder("parent");
    for (int i = 0; i < 10; i++) {
        l.add(parent.createData("file" + i));
        l.add(parent.createFolder("fold" + i));
    }

    monitor.reset();
    //20 x FileObject + 1 File.listFiles
    FileObject[] children = parent.getChildren();
    monitor.getResults().assertResult(1, StatFiles.ALL);
    monitor.getResults().assertResult(1, StatFiles.READ);
    //second time
    monitor.reset();
    children = parent.getChildren();
    monitor.getResults().assertResult(0, StatFiles.ALL);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:StatFilesTest.java

示例5: deepCopy

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void deepCopy(FileObject source, FileObject targetDirectory) throws IOException {
    for (FileObject child : source.getChildren()) {
        if (child.isFolder()) {
            FileObject target = targetDirectory.createFolder(child.getNameExt());
            
            deepCopy(child, target);
        } else {
            FileUtil.copyFile(child, targetDirectory, child.getName());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:GeneratorTestBase.java

示例6: createKeys

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override protected boolean createKeys(List<FileObject> keys) {
    FileObject d = project.getProjectDirectory();
    keys.add(d.getFileObject("pom.xml")); // NOI18N
    keys.add(d.getFileObject(M2Configuration.FILENAME));
    for (FileObject kid : d.getChildren()) {
        String n = kid.getNameExt();
        if (n.startsWith(M2Configuration.FILENAME_PREFIX) && n.endsWith(M2Configuration.FILENAME_SUFFIX)) {
            keys.add(kid);
        }
    }
    keys.add(d.getFileObject(M2AuxilaryConfigImpl.CONFIG_FILE_NAME));
    keys.add(FileUtil.toFileObject(MavenCli.DEFAULT_USER_SETTINGS_FILE));
    keys.removeAll(Collections.singleton(null));
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ProjectFilesNode.java

示例7: refreshModesFolder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void refreshModesFolder () {
    FileObject [] arr = modesModuleFolder.getChildren();

    modesModuleChildren.clear();
    for (FileObject fo : arr) {
        if (fo.isFolder()) {
            modesModuleChildren.add(fo);
            fo.getChildren();  // #156573 - to get events about children
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ModuleChangeHandler.java

示例8: addSourcesInPackage

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void addSourcesInPackage(FileObject pkgFileObject, Collection<FileObject> javaSrcFiles) {
        for (FileObject childFileObject : pkgFileObject.getChildren()) {
            if (childFileObject.isData() && JAVA_EXTENSION.equalsIgnoreCase(childFileObject.getExt())) {
                javaSrcFiles.add(childFileObject);
            }
            //We do not recursively delete subpackages
//            else if (childFileObject.isFolder()) {
//                addSourcesInPackage(childFileObject, javaSrcFiles);
//            }
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:PackagetoTreePathHandleTask.java

示例9: writeFilesAndWaitForScan

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
protected static void writeFilesAndWaitForScan(FileObject sourceRoot, File... files) throws Exception {
    for (FileObject c : sourceRoot.getChildren()) {
        c.delete();
    }

    for (File f : files) {
        FileObject fo = FileUtil.createData(sourceRoot, f.filename);
        TestUtilities.copyStringToFile(fo, f.content);
    }

    IndexingManager.getDefault().refreshIndexAndWait(sourceRoot.toURL(), null, true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:RefactoringTestBase.java

示例10: findRegisteredFileFilters

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static List<FileFilter> findRegisteredFileFilters() {
    List<FileFilter> filters = new LinkedList<FileFilter>();
    FileObject root = FileUtil.getConfigFile(
            "Services/MIMEResolver");                               //NOI18N
    Map<String, Set<FileObject>> filterNameToResolversMap =
            new HashMap<String, Set<FileObject>>();
    for (FileObject child : root.getChildren()) {
        if (child.isFolder()) {
            continue;
        }
        int i = 0;
        String f;
        while ((f = (String) child.getAttribute("fileChooser." + i))//NOI18N
                != null) {
            Set<FileObject> set = filterNameToResolversMap.get(f);
            if (set == null) {
                set = new HashSet<FileObject>();
                filterNameToResolversMap.put(f, set);
            }
            set.add(child);
            i++;
        }
    }
    for (Map.Entry<String, Set<FileObject>> e :
            filterNameToResolversMap.entrySet()) {
        filters.add(createFilter(e.getKey(), e.getValue()));
    }
    return sortFiltersByDescription(filters);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:FileFilterSupport.java

示例11: getInstallations

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public Collection<Installation> getInstallations() {
    if (!Utilities.isWindows()) {
        return Collections.<Installation>emptyList();
    }
    if (installations != null) {
        return installations;
    }
    FileObject fo = FileUtil.toFileObject(
            WindowsStandaloneInstallation.DEFAULT_BASE_PATH);

    if (fo != null) {
        List<Installation> found = new ArrayList<Installation>(3);
        for (FileObject child : fo.getChildren()) {
            if (child.getNameExt().startsWith(
                    WindowsStandaloneInstallation.FOLDER_NAME_PREFIX)
                    && child.isFolder()) {
                found.add(
                        new WindowsStandaloneInstallation(
                        child.getNameExt()));
            }
        }
        installations = found;
    } else {
        installations = Collections.emptyList();
    }
    return installations;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:WindowsStandaloneMultiInstallation.java

示例12: refreshPlatforms

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void refreshPlatforms() {
    platformsList.clear();
    FileObject storage = FileUtil.getConfigFile(STORAGE);
    if (storage != null) {
        java.util.Map<String, PlatformCategoriesDescriptor> categories = new HashMap<String, PlatformCategoriesDescriptor>();
        for (FileObject child : storage.getChildren()) {
            try {
                final DataObject dobj = DataObject.find(child);
                Node node = dobj.getNodeDelegate();
                AndroidSdk platform = node.getLookup().lookup(AndroidSdk.class);
                if (platform != null) {
                    platformsList.add(platform);
                    final String platformType = "Android";
                    final String platformTypeDisplayName = "Android";
                    PlatformCategoriesDescriptor platforms = categories.get(platformType);
                    if (platforms == null) {
                        platforms = new PlatformCategoriesDescriptor(platformTypeDisplayName);
                        categories.put(platformType, platforms);
                    }
                    platforms.add(node);
                } else {
                    LOG.log(Level.WARNING, "Platform node for : {0} has no platform in its lookup.", node.getDisplayName());   //NOI18N
                }
            } catch (DataObjectNotFoundException e) {
                Exceptions.printStackTrace(e);
            }
        }
        List<PlatformCategoriesDescriptor> keys = new ArrayList<SdksCustomizer.PlatformCategoriesDescriptor>(categories.values());
        Collections.sort(keys);
        setKeys(keys);
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:33,代码来源:SdksCustomizer.java

示例13: init

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void init() {
    FileObject folder = FileUtil.getConfigFile("NativeExecution/ExtTerminalSupport"); //NOI18N
    if (folder != null && folder.isFolder()) {
        FileObject[] files = folder.getChildren();
        for (FileObject file : files) {
            try {
                readConfiguration(file.getInputStream());
            } catch (FileNotFoundException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ExternalTerminalProvider.java

示例14: collectFromClasspath

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private Collection<FileObject> collectFromClasspath(ClassPath cp, String parentDir, 
        Collection<FileObject> result,
        Set<String> names, 
        String filesMatch,
        String extMatch) {
    if (cp == null) {
        return result;
    }
    if (extMatch != null) {
        extMatch = extMatch.toLowerCase();
    }
    if (filesMatch != null) {
        filesMatch = filesMatch.toLowerCase();
    }
    for (ClassPath.Entry en : cp.entries()) {
        FileObject root = en.getRoot();
        FileObject dir = root.getFileObject(parentDir);
        if (dir == null) {
            continue;
        }
        for (FileObject f : dir.getChildren()) {
            if (filesMatch != null && !filesMatch.isEmpty() && 
                !f.getNameExt().toLowerCase().startsWith(filesMatch)) {
                continue;
            }
            if (f.isFolder() || extMatch == null || extMatch.equals(f.getExt().toLowerCase())) {
                String k = f.getNameExt();
                if (names.add(k)) {
                    result.add(f);
                }
            }
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ResourcePathCompleter.java

示例15: getFiles

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@NonNull
@Override
public Iterable<JavaFileObject> getFiles(
        @NonNull final String folderName,
        @NullAllowed final ClassPath.Entry entry,
        @NullAllowed final Set<JavaFileObject.Kind> kinds,
        @NullAllowed final JavaFileFilterImplementation filter,
        final boolean recursive) throws IOException {
    final FileObject folder = root.getFileObject(folderName);
    if (folder == null || !(entry == null || entry.includes(folder))) {
        return Collections.<JavaFileObject>emptySet();
    }
    final Enumeration<? extends FileObject> children;
    final List<JavaFileObject> result;
    if (recursive) {
        children = Enumerations.filter(
                folder.getChildren(recursive),
                (p,x)->{
                    return  !p.isFolder() && isInJavaPackage(folder,p) ?
                            p :
                            null;
                });
        result = new ArrayList<>(/*unknown size*/);
    } else {
        final FileObject[] chlds = folder.getChildren();
        children = Enumerations.array(chlds);
        result = new ArrayList<>(chlds.length);
    }
    while (children.hasMoreElements()) {
        final FileObject fo = children.nextElement();
        if (fo.isData() && (entry == null || entry.includes(fo))) {
            final Kind kind = FileObjects.getKind(fo.getExt());
            if (kinds == null || kinds.contains (kind)) {
                JavaFileObject file;
                if (kind == Kind.CLASS) {
                    file = FileObjects.fileObjectFileObject(fo, root, filter, null);
                } else {
                    file = FileObjects.sourceFileObject(fo, root, filter,false);
                }
                result.add(file);
            }
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:FileObjectArchive.java


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