将对象传递给 rcp 视图
我想做这样的伪代码
MyView v = new MyView(); //是的,我知道我不能这样做
v.setObject(myObject);
v.show();
我的情况是:我使用 swtjasperviewer
来显示我的报告,并且我必须在这个 jasperviewer 中实例化报告,如果报告使视图保持打开状态没有页面...
我想使用命令打开视图,并将报表传递给视图,这样我就可以使用通用视图。
多谢
I want to do something like this pseudo-codeMyView v = new MyView(); //yeah, I know i can't do this
v.setObject(myObject);
v.show();
my case is: i'm using swtjasperviewer
to show my reports, and i have to instantiate the report in this jasperviewer, which leave the view opened if the report has no pages...
I want to use a command to open a view, and pass the report to a view, this way, I can use a generic view.
thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上有两种方法可以做到这一点:
如果该对象在某种程度上与另一个视图或编辑器的选择相关,那么您可以使用编写一个 SelectionListener 来获取当前选择,然后使用以下方法设置正确的对象方法:
getViewSite().getPage().addSelectionListener(mySelectionListener)
否则,定义一个您的代码和视图都可以访问的对象 (例如,使用静态属性、OSGi 服务或 Eclipse 扩展),并且您可以使用该对象来传递信息。您的数据源更新此对象,并且您可以定义视图可以将自己注册到的更改侦听器/回调。
There are basically two ways to do this:
If the object is somehow related to the selection of another view or an editor, then you could use write a SelectionListener that gets the current selection, and then sets the correct object using the following method:
getViewSite().getPage().addSelectionListener(mySelectionListener)
Otherwise, define an object that both your code and the view can reach (e.g. using a static attribute, an OSGi service or an Eclipse extension), and you can use that object to pass information. Your data source updates this object, and you can define a change listener/callback that the view can register himself to.