I'm developing a plug-in for Eclipse Luna and I need to update some list of files depending on which project is selected. How would I add some kind of listener which will be activated every time user selects project in Project Explorer?
我正在为Eclipse Luna开发一个插件,我需要根据选择的项目更新一些文件列表。我将如何添加某种类型的侦听器,每次用户在Project Explorer中选择项目时都会激活该侦听器?
1 个解决方案
#1
2
Use the ISelectionService
to listen to selection events.
使用ISelectionService来监听选择事件。
In a view or editor you can get the service with:
在视图或编辑器中,您可以通过以下方式获取服务:
ISelectionService service = (ISelectionService)getSite().getService(ISelectionService.class);
Add a listener for selection events with:
为选择事件添加一个监听器:
service.addSelectionListener(listener);
or for events from a particular part:
或来自特定部分的事件:
service.addSelectionListener("part id", listener);
#1
2
Use the ISelectionService
to listen to selection events.
使用ISelectionService来监听选择事件。
In a view or editor you can get the service with:
在视图或编辑器中,您可以通过以下方式获取服务:
ISelectionService service = (ISelectionService)getSite().getService(ISelectionService.class);
Add a listener for selection events with:
为选择事件添加一个监听器:
service.addSelectionListener(listener);
or for events from a particular part:
或来自特定部分的事件:
service.addSelectionListener("part id", listener);