Eclipse RCP在编辑器中进行更改后更新视图 [英] Eclipse RCP update a View after changes in the editor
问题描述
我是Eclipse RCP的新手,并具有以下情形:
i am new to Eclipse RCP and have the following Scenario:
- 一个插件即Application
- 另一个女巫是一个视图,确实向
显示了一些数据 - 第三个巫婆是
编辑器。
在视图中,我可以右键单击一条记录,然后选择 edit,然后打开编辑器并更改数据。
in the view I can right click on a record and choose edit what does open the Editor and lets me change the data.
否,我想在保存编辑器时刷新视图。我认为这是实现白板模式的经典方案。不幸的是,我并不真正熟悉它,也许有人可以展示一个简单的示例,说明如何在Eclipse RCP中实现它。
No I'd like to refresh the View when I save the Editor. I think this is a classical scenario to implement a Whiteboard pattern. Unfortunately I am not really familiar with it, may be some one could show a simple example how to implement it in Eclipse RCP.
感谢提前
Johannes
Thanks in Advance Johannes
推荐答案
您的视图需要实现IPartListener2(http://help.eclipse.org/helios/index.jsp?topic=/ org.eclipse.platform.doc.isv / reference / api / org / eclipse / ui / IPartListener2.html)
Your view needs to implements IPartListener2 (http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IPartListener2.html)
您可以将方法partInputChanged(IWorkbenchPartReference partRef)覆盖为用两种方式刷新视图:
1)如果带有视图的插件依赖于具有编辑器的插件
you can override the method partInputChanged(IWorkbenchPartReference partRef) to refresh thw view in two ways: 1) If the plug-in with view has dependency to plugin with editor
If (partRef instanceOf YourEditorClass){
YourData yourData = editor.getInput().getxxx();
}
2)如果带有视图的插件不依赖于插件使用编辑器
时,您需要使用适配器。您可以在编辑器中重写getAdapter方法以返回所需的数据,然后视图从适配器中获取数据
2) If the plug-in with view doesn't have dependency to plugin with editor you need to use an adapter. You override the getAdapter method in the editor to return the Data that you need and the view get the data from the adapter
If (partRef instanceOf EditorPart){
YourData yourData = Platform.getAdapterManager().getAdapter(this, YourData.class);
}
两个代码只是显示此想法的一个示例!
Two codes are just an example to show the idea!
希望我能帮助您
这篇关于Eclipse RCP在编辑器中进行更改后更新视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!