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


Java FileObject.getPath方法代码示例

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


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

示例1: getRelativeSourcePath

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static String getRelativeSourcePath(FileObject file, FileObject sourceRoot) {
    String relativePath = "";
    try {
        String absolutePath = file.getPath();
        String sourceRootPath = sourceRoot.getPath();
        int index = absolutePath.indexOf(sourceRootPath);
        if (index == -1) {
            // file is not under the source root - constructing relativePath
            relativePath = constructRelativePath(absolutePath, sourceRootPath);
            if (relativePath==null) {
                return "";
            }
            return relativePath;
        }
        relativePath = absolutePath.substring(index + sourceRootPath.length() + 1);
    } catch (Exception e) {
        logger.info("exception while parsing relative path");
        Exceptions.printStackTrace(e);
    }
    return relativePath;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:HibernateUtil.java

示例2: getLocation

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static String getLocation( Task t ) {
    URL url = getURL(t);
    if( null != url ) {
        return url.toString();
    }
    FileObject fo = getFile(t);
    String location = fo.getPath();
    int line = getLine(t);
    if( line >= 0 )
        location += ":" + line;
    return location;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Accessor.java

示例3: getChatLink

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static String getChatLink(FileObject fo, int line) {
    ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
    String ret = "";       // NOI18N
    if (cp != null) {
        ret = cp.getResourceName(fo);
    } else {
        Project p = FileOwnerQuery.getOwner(fo);
        if (p != null) {
            ret = "{$" +   // NOI18N
                    ProjectUtils.getInformation(p).getName() +
                   "}/" +  // NOI18N 
                   FileUtil.getRelativePath(p.getProjectDirectory(), fo);
            } else {
            ret = fo.getPath();
        }
    }
    ret += ":" + line;      // NOI18N
    ret =  "FILE:" + ret;   // NOI18N
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:VCSKenaiAccessor.java

示例4: testAntJavaScriptSupport

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Tests whether JavaScript code can be executed from Ant build script.
 * FX Project build scripts rely on JavaScript to pass parameters to
 * <fx:jar> and <fx:deploy> tasks in FX SDK.
 */
public void testAntJavaScriptSupport() {
    if(!DISABLE_ALL_TESTS) {
        checkJDKVersion();
        assertTrue("JDK version could not be determined.", versionChecked);
        try {
            FileObject buildScript = createAntTestScript();
            assertTrue(buildScript.isData());
            String commandLine = (JDKOSType == OSType.WINDOWS ? "cmd /c " : "")
                    + "ant -buildfile " + buildScript.getPath();
            System.out.println("Executing " + commandLine);
            Process proc = Runtime.getRuntime().exec(commandLine);
            BufferedReader bri = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            BufferedReader bre = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
            boolean scriptExecuted = false;
            String line;
            while ((line = bri.readLine()) != null) {
                System.out.println("Log: " + line);
                if(line.contains(JS_MESSAGE)) {
                    scriptExecuted = true;
                }
            }
            bri.close();
            while ((line = bre.readLine()) != null) {
                System.out.println("Log: " + line);
                if(line.contains(JS_MESSAGE)) {
                    scriptExecuted = true;
                }
            }
            bre.close();
            proc.waitFor();
            assertTrue("JavaScript execution from Ant failed.", scriptExecuted);
            System.out.println(TEST_RESULT + "JavaScript is callable from Ant script.");
        }
        catch (Exception err) {
            fail("Exception thrown while creating or executing Ant build script; " + err.getMessage());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:JDKSetupTest.java

示例5: getDescription

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public String getDescription(boolean fullPath, boolean useName, boolean useKey) {
    String fileDescription;
    if (this != BOOKMARKS_WINDOW) {
        FileObject fo = getFileBookmarks().getFileObject();
        if (fo != null) {
            fileDescription = fullPath ? fo.getPath() : fo.getNameExt();
        } else {
            fileDescription = NbBundle.getMessage(BookmarkInfo.class, "LBL_NonExistentFile");
        }
    } else {
        fileDescription = null;
    }
    return getDescription(fileDescription, useName, useKey, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:BookmarkInfo.java

示例6: getDocument

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static Document getDocument(FileObject f) throws IOException {
    try {
        DataObject d = DataObject.find(f);
        EditorCookie ec = d.getCookie(EditorCookie.class);
        Document doc = ec.openDocument();
        if (doc == null) {
            throw new IOException("Document cannot be opened for : " + f.getPath());
        }
        return doc;
    } catch (DataObjectNotFoundException ex) {
        throw new IOException("DataObject does not exist for : " + f.getPath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:Util.java

示例7: notifyRebuild

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void notifyRebuild(FileObject f) {
    String path = f.getPath();
    if (path.startsWith(basePath)) {
        if (synchronous) rebuild();
        else task.schedule(1000);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:MimeTypesTracker.java

示例8: createPositionRef

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static Position createPositionRef(FileObject file, int position, Position.Bias bias) {
    try {
        PositionRefProvider prp = PositionRefProvider.get(file);
        Position positionRef = prp != null ? prp.createPosition(position, bias) : null;
        if (positionRef != null) {
            return positionRef;
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    throw new IllegalStateException("Cannot create PositionRef for file " + file.getPath() + ". CloneableEditorSupport not found");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:DocTreePathHandle.java

示例9: fileChanged

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void fileChanged(FileEvent fe) {
    FileObject definitionFile = fe.getFile();
    String fileName = definitionFile.getPath();
    final Libs data = this.initStorage(false);
    final LibraryImplementation impl = data.get(fileName);
    if (impl != null) {
        try {
            readLibrary (definitionFile, impl);
            LibraryTypeProvider provider = ltRegistry.getLibraryTypeProvider (impl.getType());
            if (provider == null) {
                LOG.warning("LibrariesStorage: Can not invoke LibraryTypeProvider.libraryCreated(), the library type provider is unknown.");  //NOI18N
            }
            try {
                //TODO: LibraryTypeProvider should be extended by libraryUpdated method
                provider.libraryCreated (impl);
                updateTimeStamp(definitionFile);
                saveTimeStamps();
            } catch (RuntimeException e) {
                String message = NbBundle.getMessage(LibrariesStorage.class,"MSG_libraryCreatedError");
                Exceptions.printStackTrace(Exceptions.attachMessage(e,message));
            }
        } catch (SAXException se) {
            //The library is broken, probably edited by user, log as warning
            logBrokenLibraryDescripor(definitionFile, se);
        } catch (ParserConfigurationException pce) {
            Exceptions.printStackTrace(pce);
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:LibrariesStorage.java

示例10: LayerWhereUsedRefactoringElement

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public LayerWhereUsedRefactoringElement(FileObject fo, FileObject layerFo, String attribute) {
    super(fo);
    attr = attribute;
    this.path = layerFo.getPath();
    if (attr != null) {
        Object vl = layerFo.getAttribute("literal:" + attr); //NOI18N
        if (vl instanceof String) {
            attrValue = ((String) vl).replaceFirst("^(new|method):", ""); // NOI18N
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:NbWhereUsedRefactoringPlugin.java

示例11: attachNotifier

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * @param mfo FileObject from default file system
 * @param layer the layer where notifier will be searched on
 * @return true if attached notifier is the delegate FO
 */
private synchronized boolean attachNotifier (FileObject mfo, int layer) {
    FileSystem fsLayer = getLayer (layer);
    String fn = mfo.getPath();
    FileObject fo = null;
    boolean isDelegate = true;

    if (fsLayer == null)
        return false;

    // find new notifier - the FileObject with closest match to getFile ()
    while (fn.length () > 0 && null == (fo = fsLayer.findResource (fn))) {
        int pos = fn.lastIndexOf ('/');
        isDelegate = false;

        if (-1 == pos)
            break;
        
        fn = fn.substring (0, pos);
    }
    
    if (fo == null)
        fo = fsLayer.getRoot ();

    if (fo != notifiers [layer]) {
        // remove listener from existing notifier if any
        if (notifiers [layer] != null)
            notifiers [layer].removeFileChangeListener (weakL [layer]);

        // create new listener and attach it to new notifier
        weakL [layer] = FileUtil.weakFileChangeListener (this, fo);
        fo.addFileChangeListener (weakL [layer]);
        notifiers [layer] = fo;
    }
    
    return isDelegate;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:FileStateManager.java

示例12: getFileObjectLocalizedName

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
static String getFileObjectLocalizedName( FileObject fo ) {
    Object o = fo.getAttribute("SystemFileSystem.localizingBundle"); // NOI18N
    if ( o instanceof String ) {
        String bundleName = (String)o;
        try {
            ResourceBundle rb = NbBundle.getBundle(bundleName);
            String localizedName = rb.getString(fo.getPath());
            return localizedName;
        }
        catch(MissingResourceException ex ) {
            // Do nothing return file path;
        }
    }
    return fo.getPath();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:AnalyzerImpl.java

示例13: skipFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private boolean skipFile(FileObject fo) {
    String s = fo.getPath();

    if (s.startsWith ("Templates/") && !s.startsWith ("Templates/Services")) {
        if (s.endsWith (".shadow") || s.endsWith (".java")) {
            return true;
        }
    }

    for (String skipped : SKIPPED) {
        if (s.startsWith(skipped)) {
            return true;
        }
    }
    
    String iof = (String) fo.getAttribute("instanceOf");
    if (iof != null) {
        for (String clz : iof.split("[, ]+")) {
            try {
                Class<?> c = Lookup.getDefault().lookup(ClassLoader.class).loadClass(clz);
            } catch (ClassNotFoundException x) {
                // E.g. Services/Hidden/org-netbeans-lib-jsch-antlibrary.instance in ide cluster
                // cannot be loaded (and would just be ignored) if running without java cluster
                System.err.println("Warning: skipping " + fo.getPath() + " due to inaccessible interface " + clz);
                return true;
            }
        }
    }

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

示例14: getFileObjectLocalizedName

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private String getFileObjectLocalizedName( FileObject fo ) {
    Object o = fo.getAttribute("SystemFileSystem.localizingBundle"); // NOI18N
    if ( o instanceof String ) {
        String bundleName = (String)o;
        try {
            ResourceBundle rb = NbBundle.getBundle(bundleName);            
            String localizedName = rb.getString(fo.getPath());                
            return localizedName;
        }
        catch(MissingResourceException ex ) {
            // Do nothing return file path;
        }
    }
    return fo.getPath();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:HintsPanel.java

示例15: addProjectFiles

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void addProjectFiles (Collection<VCSFileProxy> rootFiles,
        Map<FileObject, VCSFileProxy> rootFilesExclusions, Project project,
        Set<SourceGroup> srcGroups) {
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
    srcGroups.addAll(Arrays.asList(sourceGroups));
    for (int j = 0; j < sourceGroups.length; j++) {
        SourceGroup sourceGroup = sourceGroups[j];
        FileObject srcRootFo = sourceGroup.getRootFolder();
        VCSFileProxy rootFile = VCSFileProxy.createFileProxy(srcRootFo);
        if (rootFile == null) continue;
        if (!srcRootFo.isValid()) {
            LOG.log(Level.WARNING, "addProjectFiles: invalid source root {0}", srcRootFo); //NOI18N
            continue;
        }
        rootFiles.add(rootFile);
        FileObject [] rootChildren = srcRootFo.getChildren();
        for (int i = 0; i < rootChildren.length; i++) {
            FileObject rootChildFo = rootChildren[i];
            VCSFileProxy child = VCSFileProxy.createFileProxy(rootChildFo);
            // TODO: #60516 deep scan is required here but not performed due to performace reasons
            try {
                if (!srcRootFo.isValid()) {
                    LOG.log(Level.WARNING, "addProjectFiles: source root {0} changed from valid to invalid", srcRootFo); //NOI18N
                    break;
                }
                if (rootChildFo != null && 
                    rootChildFo.isValid() && 
                    !sourceGroup.contains(rootChildFo)) 
                {
                    child = child.normalizeFile();
                    rootChildFo = child.toFileObject();
                    if(rootChildFo != null && 
                       SharabilityQuery.getSharability(rootChildFo) != Sharability.NOT_SHARABLE) 
                    {
                        rootFilesExclusions.put(rootChildFo, child);
                    }
                }
            } catch (IllegalArgumentException ex) {
                // #161904
                Logger logger = LOG;
                logger.log(Level.WARNING, "addProjectFiles: IAE");
                logger.log(Level.WARNING, "rootFO: {0}", srcRootFo);
                if (srcRootFo != sourceGroup.getRootFolder()) {
                    logger.log(Level.WARNING, "root FO has changed");
                }
                String children = "[";
                for (FileObject fo : rootChildren) {
                    children += "\"" + fo.getPath() + "\", ";
                }
                children += "]";
                logger.log(Level.WARNING, "srcRootFo.getChildren(): {0}", children);
                if(rootChildFo != null) {
                    if (!rootChildFo.isValid()) {
                        logger.log(Level.WARNING, "{0} does not exist ", rootChildFo);
                    }
                    if (!FileUtil.isParentOf(srcRootFo, rootChildFo)) {
                        logger.log(Level.WARNING, "{0} is not under {1}", new Object[]{rootChildFo, srcRootFo});
                    }
                }
                logger.log(Level.WARNING, null, ex);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:VCSContext.java


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