How do I open an editor on a file outside the workspace?
来源:互联网 发布:单根均线交易系统优化 编辑:程序博客网 时间:2024/04/29 09:57
Since 3.3 you can use the new EFS support to open an text editor on a file outside the workspace:
String name= new FileDialog(aShell, SWT.OPEN).open();
if (name == null)
return;
IFileStore fileStore= EFS.getLocalFileSystem().getStore(new Path(filterPath));
fileStore= fileStore.getChild(names[i]);
if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
IWorkbenchPage page= window.getActivePage();
try {
IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
/* some code */
}
if (name == null)
return;
IFileStore fileStore= EFS.getLocalFileSystem().getStore(new Path(filterPath));
fileStore= fileStore.getChild(names[i]);
if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
IWorkbenchPage page= window.getActivePage();
try {
IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
/* some code */
}
Alternatively, you can create a linked resource in an existing project, which points to a file elsewhere in the file system. This example snippet creates a project called “External Files,” and then prompts the user to select any file in the file system. The code then creates a linked resource in the project to that external file, allowing the platform to open the file in read/write mode in one of the standard editors:
IWorkspace ws = ResourcesPlugin.getWorkspace();
IProject project = ws.getRoot().getProject("External Files");
if (!project.exists())
project.create(null);
if (!project.isOpen())
project.open(null);
Shell shell = window.getShell();
String name = new FileDialog(shell, SWT.OPEN).open();
if (name == null)
return;
IPath location = new Path(name);
IFile file = project.getFile(location.lastSegment());
file.createLink(location, IResource.NONE, null);
IWorkbenchPage page = window.getActivePage();
if (page != null)
page.openEditor(file);
- How do I open an editor on a file outside the workspace?
- How do I open an editor on something that is not a file?
- How do I create a MEX file
- How do I rename a data file
- How do I rename a data file
- How do I bind the values of an enum to a ComboBox?
- How do I sort an array of hashes by a value in the hash?
- the file is already open in an editor 解决方法
- the file is already open in an editor 解决方法 .
- How do I execute or run an XML file?
- How do I select a random line from a file?
- How Do I Install the Android Market on Android SDK
- How do I set the DISPLAY variable on Linux
- How Do I Replace A System File? Try .KDFILES
- How do I create a log file of my installation?
- 关于“This file has been modified outside of the source editor. Do you want to reload it?”错误的处理
- 关于“This file has been modified outside of the source editor. Do you want to reload it?”错误的处理
- 关于“This file has been modified outside of the source editor. Do you want to reload it?”
- clipboardData 对象
- ora-01128,ora-00275
- Linux内核升级手记(2.4.20-8 ~ 2.6.8)
- 这就是我
- 技术与产品的故事
- How do I open an editor on a file outside the workspace?
- SaaS的前途和命运(转)
- hsqldb简单使用
- 悟透JavaScript
- 关于i++ 与 ++i 的问题
- ASP.NET with C#使用md5,sha1加密初探
- 在asp.net 2.0中使用SqlBulkCopy类迁移数据
- 详解 ARP欺骗
- How do I open an editor on something that is not a file?