Friday, October 26, 2007

IFolderLayout and Multiple Tabbed Views in Eclipse RCP/SWT

I ran across another issue that needed fixing this week. It isn't a very big problem but I figured even the little problems can be hard for some to solve since I consider the RCP / SWT documentation to be so weak.

This most recent problem had to do with having multiple views in an IFolderLayout. I had two as you will see in the image below (look at top right of image circled in red) with the table being the currently displayed view, albeit with no data.


Now what the user may do is click on the chart preview in the window on the left side view (It is a PDF viewer). The problem I had is the chart view, which is the "hidden" view on the right behind the table view, would not come to the fore ground.

This is a simple fix once you know what to do. I have a function called public void updateChartView(IWorkbenchPage page) which gets called to update the chart with new data or whatever. All I needed to do was, using the IWorkbenchPage passed was to call page.bringToTop(view) If you attempt to use activate(view) you may get errors.. How did I get my view in here? I did this: ChartView view = (ChartView)page.findView(ChartView.ID). This only works if you have one instance of chartview but there are primary and secondary id's used in another form of findView if you have multiple instances of the same view.

So by adding the bringToTop(view) function it now works properly when the user clicks on the left chart preview. See below:

No comments: