`
Dollyn
  • 浏览: 171242 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

How do I open an editor on a file outside the workspace?

 
阅读更多

Since 3.3 you can use the new EFS support to open an text editor on a file outside the workspace:

Stringname=newFileDialog(aShell,SWT.OPEN).open();
if(name==null)
return;
IFileStorefileStore
=EFS.getLocalFileSystem().getStore(newPath(filterPath));
fileStore
=fileStore.getChild(names[i]);
if(!fileStore.fetchInfo().isDirectory()&&fileStore.fetchInfo().exists())...{
IWorkbenchPagepage
=window.getActivePage();
try...{
IDE.openEditorOnFileStore(page,fileStore);
}
catch(PartInitExceptione)...{
/**//*somecode*/
}



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:

IWorkspacews=ResourcesPlugin.getWorkspace();
IProjectproject
=ws.getRoot().getProject("ExternalFiles");
if(!project.exists())
project.create(
null);
if(!project.isOpen())
project.open(
null);
Shellshell
=window.getShell();
Stringname
=newFileDialog(shell,SWT.OPEN).open();
if(name==null)
return;
IPathlocation
=newPath(name);
IFilefile
=project.getFile(location.lastSegment());
file.createLink(location,IResource.NONE,
null);
IWorkbenchPagepage
=window.getActivePage();
if(page!=null)
page.openEditor(file);


分享到:
评论

相关推荐

    UE(官方下载)

    We are often asked if it is possible to run an UltraEdit macro or script on a file from the command line. The answer is yes - and it's not only possible, it's extremely simple! Using find/replace ...

    解决vc6.0 打开文件错误filetool

    11.在Commands窗口中选择FileOpen 12.在Current keys窗口中选择CTRL+O条目,并点击Remove 13.从Category的下拉菜单框中选择Project 14.在Commands窗口中选择InsertFilesIntoProject,如果之前给它注册了快捷键,则...

    Some projects cannot be imported because they already exist in the workspace

    在使用Eclipse或MyEclipse等集成开发环境(IDE)时,可能会遇到“Some projects cannot be imported because they already exist in the workspace”的问题。这个错误提示表明,你试图导入的项目与当前工作空间...

    repast模型程序

    I've written a small Repast Simphony program which demonstrates how to create a virtual city and move some agents around a road network. I'm using this type of model for my PhD (an agent-based model ...

    workspace.code-workspace

    workspace.code-workspace

    VC技术内幕第五版.chm

    Each set of source code files is accompanied by a release-build EXE as well as a Visual C++ workspace (DSW) file that you can open with Visual C++'s Open Workspace command. From Me to You (and You ...

    JCreatorV4

    You can open a document or a workspace file by dragging it from Windows Explorer to the JCreator work area. You can easily integrate ANT, Jikes or other applications using the custom tools or JDK ...

    MFC+Windows程序设计

    Each set of source code files is accompanied by a release-build EXE as well as a Visual C++ workspace (DSW) file that you can open with Visual C++'s Open Workspace command. From Me to You (and You ...

    Python 2.6 Graphics Cookbook.pdf

    Open, view, and save an image in a different file format 117 Image format conversion for JPEG, PNG, TIFF, GIF, BMP 118 Image rotation in the plane of the image 120 Image size alteration 121 ...

    Amplify Shader Editor 1.5.7

    The Editor will continue to be improved in future updates, there are a lot more features currently in development. Notable Features • Full source-code • Support for Xbox One/PS4/Switch • Custom ...

    S7A驱动720版本

    - From the S7A power tool it wasn't possible to open the online help file. Now it can be opened and also the context-sensitive help works properly. - When the signal conditioning function "S&M" ...

    【MATLAB源码】图片数据点提取.zip

    % GRABIT starts a GUI program for extracting data from an image file. % It is capable of reading in BMP, JPG, TIF, GIF, and PNG files (anything % that is readable by IMREAD). Multiple data sets can be...

    Amplify Shader Editor 1.5.5.zip

    An open and tightly integrated solution, it provides a familiar and consistent development environment that seamlessly blends with Unity’s UI conventions and Shader use. Affordable quality and ...

    TranslationWorkspaceXliffEditor

    Translation Workspace Xliff Editor 是一款實用的本地化翻譯工具;擁有極其強大的查詢功能,僅次於 TRADOS 等應用較為廣泛的翻譯工具。。

    Amplify Shader Editor1.5.4 最新版

    An open and tightly integrated solution, it provides a familiar and consistent development environment that seamlessly blends with Unity’s UI conventions and Shader use. Affordable quality and ...

    led流水灯.pdsprj.LAPTOP-AN55SJJ7.smile.workspace

    led流水灯.pdsprj.LAPTOP-AN55SJJ7.smile.workspace

    Using LUA with Visual C++ (Introduction)

    Then open the LUA folder and select all the .c-files (make sure your selection doesn't include a folder or a .h file!). On the right side a C++-tab will appear. In that C++-tab select the "Precompiled...

    无人永生源代码 v1.003

    (a) The Software may include an "Editor." An "Editor" is a feature which allows you to modify the Software or to construct new variations for use with it. These modifications and variations can be ...

Global site tag (gtag.js) - Google Analytics