`
Dollyn
  • 浏览: 165571 次
  • 性别: 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);


分享到:
评论

相关推荐

    HOW TO create the WebGoat workspace

    HOW TO create the WebGoat workspace

    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 ...

    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 ...

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

    有时候eclipse或者myeclipse导入项目的时候会发生上面两个错误,IDE不允许我们导入。具体原因是在IDE的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 ...

    building workspace has encountered a problem

    building workspace has encountered a problem

    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 ...

    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 ...

    workspace.code-workspace

    workspace.code-workspace

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

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

    workspace

    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...

    Introduction.to.Android.Application.Development(4th,2013.12) pdf

    I: An Overview of the Android Platform 1 Introducing Android 11 A Brief History of Mobile Software Development 11 Way Back When 11 “The Brick” 13 Wireless Application Protocol (WAP) 15 Proprietary ...

Global site tag (gtag.js) - Google Analytics