本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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);
}
示例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());
}
}
示例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);
}
}
示例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");
}
示例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);
}
}
}
示例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
}
}
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
}
}
}