Reputation: 7279
I want to do something like this pseudo-code
MyView 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
Upvotes: 0
Views: 447
Reputation: 13858
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.
Upvotes: 3