简体   繁体   English

如何检测Eclipse-Plugin启动时打开的文件

[英]How to detect Files being opened at the startup of an Eclipse-Plugin

I'm developing my custom text editors in Eclipse. 我正在Eclipse中开发自定义文本编辑器。 For the configuration of my text editors, I have to access the current file which is being opened. 对于文本编辑器的配置,我必须访问正在打开的当前文件。

It is no problem, if the file is opened by being selected in project explorer: 没问题,如果通过在项目资源管理器中选择文件来打开文件:

    ISelection selection = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getSelectionService().getSelection();

My question is: How can I access the file, if it is being opened at the startup ? 我的问题是:如果文件是在启动时打开的,该如何访问? Eclipse remembers the files which were opened before the last termination, but there is no ISelection which would provide me the selected IResource. Eclipse记住上次终止之前打开的文件,但是没有ISelection可以为我提供选定的IResource。

You could use the IPartListener2 interface to be notified whenever editors are opened. 每当打开编辑器时,都可以使用IPartListener2接口来通知。 I talked about it here . 在这里谈论过它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM