I have an Eclipse Editor plugin associated with .xxx filetype, how can I detect when the user switches from a document to another?
I mean 开发者_如何学编程when a user switches from a tab with graph1.xxx to another opened tab with graph2.xxx
I would add an IPartListener (or IPartListener2) event listener to the PartService of the Active Workbench Window, and listen for the various changes. Something similar to the following code could be used (if you register the listener inside your editor code, you should get the workbench window through the inherited methods):
Workbench.getInstance().getActiveWorkbenchWindow()
.getPartService().addPartListener(new IPartListener2() { ... }
Be careful, that both Editors and Views are parts, so some notification will be unnecessary for your job.
精彩评论