从插件/RCP中取得文件路径的方法
来源:互联网 发布:广州手趣网络 招聘 编辑:程序博客网 时间:2024/05/16 07:52
从插件中获得绝对路径:
得到runtimeworkspace:
IFile与File转换
从编辑器来获得编辑文件
AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath());
通过文件得到Project:
IProject project = ((IFile)o).getProject();
通过文件得到全路径:
String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();
得到整个Workspace的根:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
从根来查找资源:
IResource resource = root.findMember(new Path(containerName));
从Bundle来查找资源:
Bundle bundle = Platform.getBundle(pluginId);
URL fullPathString = BundleUtility.find(bundle, filePath);
URL fullPathString = BundleUtility.find(bundle, filePath);
得到Appliaction workspace:
Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath();
得到runtimeworkspace:
Platform.getInstanceLocation().getURL().getPath();
IFile与File转换
IFile file = editorinput.getFile();
file.refreshLocal(IResource.DEPTH_ZERO,null);
//=================================================
IProject fsProject = ResourceModelUtils.getProject(project);
IFolder tmpFolder = ResourceUtils.getFolder(fsProject, RepositoryConstants.TEMP_DIRECTORY, true);
String tmpFilename = "DOC" + documentationItem.getProperty().getId();
IFile fileTmp = tmpFolder.getFile(tmpFilename);//Get IFile reference by file name;
File file = fileTmp.getLocation().toFile(); //Get File reference by IFile reference.
File newFile = new File(fileTmp.getLocation().toOSString()); //Convert IFile to File.
file.refreshLocal(IResource.DEPTH_ZERO,null);
//=================================================
IProject fsProject = ResourceModelUtils.getProject(project);
IFolder tmpFolder = ResourceUtils.getFolder(fsProject, RepositoryConstants.TEMP_DIRECTORY, true);
String tmpFilename = "DOC" + documentationItem.getProperty().getId();
IFile fileTmp = tmpFolder.getFile(tmpFilename);//Get IFile reference by file name;
File file = fileTmp.getLocation().toFile(); //Get File reference by IFile reference.
File newFile = new File(fileTmp.getLocation().toOSString()); //Convert IFile to File.
从编辑器来获得编辑文件
IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();
IEditorInput input = editor.getEditorInput();
if(input instanceof IFileEditorInput){
IFile file = ((IFileEditorInput)input).getFile();
}
IEditorInput input = editor.getEditorInput();
if(input instanceof IFileEditorInput){
IFile file = ((IFileEditorInput)input).getFile();
}
- 从插件/RCP中取得文件路径的方法
- 从插件/RCP中取得文件路径的方法
- 从插件/RCP中取得文件路径的方法
- 从插件/RCP中取得文件路径的方法
- 从插件/RCP中取得文件路径的方法
- 从插件/RCP中取得文件路径的方法
- 关于VB中用DIR函数,从完整的文件路径中取得文件名的方法
- Eclipse RCP 文件路径相关的方法
- Eclipse插件/RCP中取路径方法综合篇
- java中取得上下文路径的方法
- path2ClassLoader 提供了两个方法用于从装载的类路径中取得资源:
- RCP应用程序中读文件的路径问题
- eclipse rcp项目中获取相对路径的方法
- Delphi从路径取得文件名的简易方法
- RCP程序中集成其他插件的配置方法
- Eclipse RCP 插件开发中经常调用的几个方法
- Eclipse RCP 插件开发中经常调用的几个方法
- rcp(插件开发)RCP中控制Editor不重复打开的方法
- Web应用程序的部署与安装(1)
- 设置与删除cookie时一定要注意路径问题(另读取cookie中firfox与ie的区别)
- 多普达S600短信不直接显示在屏幕上的设置方法
- 《Beiginning Linux programming || Linux 程序设计》读书笔记(三)
- 我的电脑怎么啦
- 从插件/RCP中取得文件路径的方法
- 使用Run-Time Library将wchar_t转换为char
- Image类的扩展,可编辑GIF动画图片,需要Magick支持.
- ibatis的入门例子
- strace命令详解
- Eclipse 3.4 (Ganymede) 开发调试PHP全攻略
- 清除远程桌面信息方法
- Java库中的排序方法
- 应用程序池假死问题解决办法IIS