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


Java FileUtil.isParentOf方法代码示例

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


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

示例1: findProject

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static Project findProject(Lookup context) {
    Project prj = context.lookup(Project.class);
    if (prj == null) {
        FileObject f = context.lookup(FileObject.class);
        if (f != null) {
            File cache = Places.getCacheDirectory();
            FileObject cacheFO = FileUtil.toFileObject(cache);
            prj = FileOwnerQuery.getOwner(f);
            if (cacheFO != null && prj != null) {
                if (FileUtil.isParentOf(prj.getProjectDirectory(), cacheFO)) {
                    prj = null;
                }
            }
        }
    }
    return prj;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:PersistentSnippetsSupport.java

示例2: findJavaPlatforms

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@NonNull
private Collection<? extends JavaPlatform> findJavaPlatforms(@NonNull final File jfxrt) {
    final JavaPlatform[] jps = JavaPlatformManager.getDefault().getPlatforms(
            null,
            new Specification(
                "j2se", //NOI18N
                null));
    final Collection<JavaPlatform> res = new ArrayList<JavaPlatform>(jps.length);
    final FileObject jfxrfFo = FileUtil.toFileObject(jfxrt);
    if (jfxrfFo != null) {
        for (JavaPlatform jp : jps) {
            for (FileObject installFolder : jp.getInstallFolders()) {
                if (FileUtil.isParentOf(installFolder, jfxrfFo)) {
                    res.add(jp);
                }
            }
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavaFXPlatformJavadoc.java

示例3: findGroup

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/** Finds the one source group, if any, which contains all of the listed files. */
private static @CheckForNull SourceGroup findGroup(SourceGroup[] groups, FileObject[] files) {
    SourceGroup selected = null;
    for (FileObject file : files) {
        for (SourceGroup group : groups) {
            FileObject root = group.getRootFolder();
            if (file == root || FileUtil.isParentOf(root, file)) { // or group.contains(file)?
                if (selected == null) {
                    selected = group;
                } else if (selected != group) {
                    return null;
                }
            }
        }
    }
    return selected;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Selenium2MavenSupportImpl.java

示例4: createNodeForSourceGroup

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@CheckForNull
static Node createNodeForSourceGroup(
        @NonNull final SourceGroup group,
        @NonNull final Project project) {
    if ("sharedlibraries".equals(group.getName())) { //NOI18N
        //HACK - ignore shared libs group in UI, it's only useful for version control commits.
        return null;
    }
    final FileObject rootFolder = group.getRootFolder();
    if (!rootFolder.isValid() || !rootFolder.isFolder()) {
        return null;
    }
    final FileObject projectDirectory = project.getProjectDirectory();
    return new ProjectIconNode(new GroupNode(
            project,
            group,
            projectDirectory.equals(rootFolder) || FileUtil.isParentOf(rootFolder, projectDirectory),
            DataFolder.findFolder(rootFolder)),
            true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:PhysicalView.java

示例5: isTestClass

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static boolean isTestClass(Node activatedNode) {
    FileObject fileObject = org.netbeans.modules.gsf.testrunner.ui.api.UICommonUtils.getFileObjectFromNode(activatedNode);
    if (fileObject != null && CommonTestUtil.isJavaFile(fileObject)) {
        Project project = FileOwnerQuery.getOwner(fileObject);
        if (project != null) {
            SourceGroup[] javaSGs = new JavaUtils(project).getJavaSourceGroups();
            for (int i = 0; i < javaSGs.length; i++) {
                SourceGroup javaSG = javaSGs[i];
                FileObject rootFolder = javaSG.getRootFolder();
                URL[] testRoots = UnitTestForSourceQuery.findUnitTests(rootFolder);
                URL[] sourceRoots = UnitTestForSourceQuery.findSources(rootFolder);
                if (((fileObject == rootFolder) || FileUtil.isParentOf(rootFolder, fileObject)) && javaSG.contains(fileObject)) {
                    // activated FO is contained in the javaSG source group
                    if (testRoots.length == 0 && sourceRoots.length > 0) {
                        // javaSG has corresponding source root but no corresponding test root,
                        // thus the activated FO is a test class, so activate action
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TestSingleMethodSupport.java

示例6: getEncoding

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public Charset getEncoding(FileObject file) {
    if (file == interestedIn || FileUtil.isParentOf(interestedIn, file)) {
        return Charset.forName("UTF-8"); //NOI18N
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ReferencesCountTest.java

示例7: getRoot

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private FileObject getRoot(FileObject fo) {
    if (fo != null) {
        for (FileObject root : packageRoots) {
            if (root == fo || FileUtil.isParentOf(root, fo))
                return root;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ClassPathFileChooser.java

示例8: getPreselectedGroup

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@CheckForNull
private SourceGroup getPreselectedGroup( SourceGroup[] groups, FileObject folder ) {        
    for( int i = 0; folder != null && i < groups.length; i++ ) {
        if( FileUtil.isParentOf( groups[i].getRootFolder(), folder )
            || groups[i].getRootFolder().equals(folder)) {
            return groups[i];
        }
    }
    if (groups.length > 0) {
        return groups[0];
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:SimpleTargetChooserPanelGUI.java

示例9: findSourceGroupOwners

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Finds all <code>SourceGroup</code>s of the given project
 * containing a class of the given name.
 *
 * @param  project  project to be searched for matching classes
 * @param  className  class name pattern
 * @return  unmodifiable collection of <code>SourceGroup</code>s
 *          which contain files corresponding to the given name
 *          (may be empty but not <code>null</code>)
 * @author  Marian Petras
 */
public static Collection<SourceGroup> findSourceGroupOwners(
        final Project project,
        final String className) {
    final SourceGroup[] sourceGroups
            = new JavaUtils(project).getJavaSourceGroups();
    if (sourceGroups.length == 0) {
        return Collections.<SourceGroup>emptyList();
    }
    
    final String relativePath = className.replace('.', '/')
                                + ".java";                          //NOI18N
    
    ArrayList<SourceGroup> result = new ArrayList<SourceGroup>(4);
    for (int i = 0; i < sourceGroups.length; i++) {
        SourceGroup srcGroup = sourceGroups[i];
        FileObject root = srcGroup.getRootFolder();
        FileObject file = root.getFileObject(relativePath);
        if (file != null && FileUtil.isParentOf(root, file)
                         && srcGroup.contains(file)) {
            result.add(srcGroup);
        }
    }
    if (result.isEmpty()) {
        return Collections.<SourceGroup>emptyList();
    }
    result.trimToSize();
    return Collections.unmodifiableList(result);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:CommonTestUtil.java

示例10: getRootOf

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Checks which of the provided source roots contains the given file.
 *
 * @param roots A list of source roots
 * @param file A FileObject to look for
 * @return The source roots that contains the specified file or null if none of them contain it.
 */
public static FileObject getRootOf(final FileObject[] roots, final FileObject file) {
    FileObject srcDir = null;

    for (int i = 0; i < roots.length; i++) {
        if (FileUtil.isParentOf(roots[i], file)) {
            srcDir = roots[i];

            break;
        }
    }

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

示例11: isValidRoot

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static boolean isValidRoot (File file, File[] relatedRoots, File projectFolder) {
    Project p;
    if ((p = FileOwnerQuery.getOwner(Utilities.toURI(file)))!=null
        && !file.getAbsolutePath().startsWith(projectFolder.getAbsolutePath()+File.separatorChar)) {
        final Sources sources = p.getLookup().lookup(Sources.class);
        if (sources == null) {
            return false;
        }
        final SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
        final SourceGroup[] javaGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        final SourceGroup[] groups = new SourceGroup [sourceGroups.length + javaGroups.length];
        System.arraycopy(sourceGroups,0,groups,0,sourceGroups.length);
        System.arraycopy(javaGroups,0,groups,sourceGroups.length,javaGroups.length);
        final FileObject projectDirectory = p.getProjectDirectory();
        final FileObject fileObject = FileUtil.toFileObject(file);
        if (projectDirectory == null || fileObject == null) {
            return false;
        }
        for (int i = 0; i< groups.length; i++) {
            final FileObject sgRoot = groups[i].getRootFolder();
            if (fileObject.equals(sgRoot)) {
                return false;
            }
            if (!projectDirectory.equals(sgRoot) && FileUtil.isParentOf(sgRoot, fileObject)) {
                return false;
            }
        }
        return true;
    }
    else if (contains (file, relatedRoots)) {
        return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:FolderList.java

示例12: rebase

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@CheckForNull
static FileObject rebase(
        @NonNull final FileObject binRoot,
        @NonNull final FileObject sourceTarget) {

    if (shouldIgnore(sourceTarget.toURI(), binRoot.toURI())) {
        return null;
    }
    final URL providedBinRootURL = (URL) sourceTarget.getAttribute("classfile-root");    //NOI18N
    final String providedBinaryName = (String) sourceTarget.getAttribute("classfile-binaryName");   //NOI18N
    if (providedBinRootURL != null && providedBinaryName != null) {
        final FileObject providedBinRoot = URLMapper.findFileObject(providedBinRootURL);
        if (binRoot.equals(providedBinRoot)) {
            return binRoot.getFileObject(providedBinaryName + SUBST);
        }
    } else {
        for (FileObject srcRoot : SourceForBinaryQuery.findSourceRoots(binRoot.toURL()).getRoots()) {
            if (FileUtil.isParentOf(srcRoot, sourceTarget)) {
                final FileObject[] newTarget = ActionUtils.regexpMapFiles(
                    new FileObject[]{sourceTarget},
                    srcRoot,
                    SRCDIRJAVA,
                    binRoot,
                    SUBST,
                    true);
                if (newTarget != null) {
                    return newTarget[0];
                }
            }
        }
    }
    if (FileUtil.isParentOf(binRoot, sourceTarget) || binRoot.equals(sourceTarget))  {
        return sourceTarget;
    }
    ignore(sourceTarget.toURI(), binRoot.toURI());
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ActionFilterNode.java

示例13: findClassPath

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public ClassPath findClassPath(FileObject file, String type) {
    for(FileObject fo : projects.keySet()) {
        if(FileUtil.isParentOf(fo, file)) {
            return projects.get(fo).getCpp().findClassPath(file, type);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ProjectTestBase.java

示例14: findClassPath

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public ClassPath findClassPath(FileObject file, String type) {
    final FileObject _root = root;
    if (_root != null && (_root.equals(file) || FileUtil.isParentOf(_root, file))) {
        switch (type) {
            case ClassPath.SOURCE:
                return ClassPathSupport.createClassPath(_root);
            case ClassPath.COMPILE:
                return ClassPath.EMPTY;
            case ClassPath.BOOT:
                return ClassPathSupport.createClassPath(System.getProperty("sun.boot.class.path")); //NOI18N
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:SourceAnalyzerTest.java

示例15: findPath

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public Node findPath(Node root, Object target) {
    // Check each child node in turn.
    Node[] kids = root.getChildren().getNodes(true);
    for (Node kid : kids) {
        // First ask natures.
        for (ProjectNature nature : Lookup.getDefault().lookupAll(ProjectNature.class)) {
            Node n = nature.findSourceFolderViewPath(project, kid, target);
            if (n != null) {
                return n;
            }
        }
        // Otherwise, check children and look for <source-folder>/<source-file> matches.
        if (target instanceof DataObject || target instanceof FileObject) {
            DataObject d = kid.getLookup().lookup(DataObject.class);
            if (d == null) {
                continue;
            }
            // Copied from org.netbeans.spi.java.project.support.ui.TreeRootNode.PathFinder.findPath:
            FileObject kidFO = d.getPrimaryFile();
            FileObject targetFO = target instanceof DataObject ? ((DataObject) target).getPrimaryFile() : (FileObject) target;
            if (kidFO == targetFO) {
                return kid;
            } else if (FileUtil.isParentOf(kidFO, targetFO)) {
                String relPath = FileUtil.getRelativePath(kidFO, targetFO);
                List<String> path = Collections.list(NbCollections.checkedEnumerationByFilter(new StringTokenizer(relPath, "/"), String.class, true)); // NOI18N
                // XXX see original code for justification
                path.set(path.size() - 1, targetFO.getName());
                try {
                    return NodeOp.findPath(kid, Collections.enumeration(path));
                } catch (NodeNotFoundException e) {
                    return null;
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:View.java


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