AidenPearce
AidenPearce

Reputation: 93

Always open (create) Eclipse RCP views

I am working on an Eclipse-RCP-application where I have one perspective with two different folders. The views in the left folder show information the user can click to get further information. Therefore, the details are displayed in the right folder.
When there was only one view in the right folder there were no problems. However, things got messy as I added another view to the right folder. Since The views have to communicacte somehow, I wrote some code for that. During createPartControl(Composite) the view registers for changes of the user selection. But the second view of the folder is not loaded until the user clicks on it, so it will not update itself when the user selects a table-row or something else.

This might be complicated to understand, so here's an example: The user opens the application and sees two tabfolders. Then he selects row X in a table. The front view of the right folder now contains information about row X. The second view of that folder hasn't loaded yet, so it hasn't registered for selection-changes. If the user now opens this view, it will be in default state because it hasn't gotten the information about the selection change.
Only after the user opened the view it will be able to display information. Is there a way to create a view that will automatically load (be created) once the perspective is loaded?

Together with this, I want to open the right tab folder if the user selects row X and the right tab folder is minimized. For this I used IWorkbenchPage.showView(String). To open the first view of the tab folder. But whenever I have the other view open and I select row Y, "opening" the first view will result in bringing it to front. Is there a way to prevent this?

Upvotes: 0

Views: 280

Answers (1)

greg-449
greg-449

Reputation: 111142

You can open a view without making it active using:

IWorkbenchPage page = ...

page.showView("view id", null, IWorkbenchPage.VIEW_VISIBLE);

You can also use

IViewPart part = page.findView("view id");

to find the view if it is already open.

Upvotes: 1

Related Questions