fengye87
fengye87

Reputation: 2543

e4 RCP: how to tell if a part is showing

I'm writting an RCP application which has an application model that can be simplified as below:

==================================================
= lpart                ||  rpart1 | rpart2       =
= -------------------- || ---------------------- =
=     <a table>        ||  <some sfuff about     =
=                      ||   the selected item>   =
==================================================
  1. The window is divided into two part stacks: left and right
  2. The left PS contains one part, and the part contains only a table
  3. The right PS contains two parts, each will show some details about the selected item in the table

The problem:

  1. It seems that Eclipse is lazily initializing my part implementation class. If I call MPart.getObject() on rpart2 before I ever clicked the tab, it returns null. Can I make Eclipse to initialize all my part implementation class when it starts up.
  2. How can I tell which one of rpart1 and rpart2 is showing. I want to avoid loading data for both parts whenever the selection of the table changes, after all, only one of them is really showing.

What I want to achieve:

  1. Whenever an item gets selected, both rpart1 and rpart2 get notified and remember the selection (item id or sth. similar). It will be impossible if rpart2 is lazily initialized.
  2. Only the part that is currently showing will fetch the details it needs. It will be impossible if a part cannot tell whether it is showing.
  3. When the other part gets selected, it will fetch and display its data according to the remembered selection. Well, this is the only part I know how to do it.

Any help would be really appreciated! Thanks a lot!

Upvotes: 0

Views: 1555

Answers (2)

Zephyr
Zephyr

Reputation: 236

I think EPartService.isPartVisible(MPart) (rather than MPart.isVisible()) solves your first problem.

Upvotes: 1

greg-449
greg-449

Reputation: 111216

You can use the EPartService addPartListener method to add a listener that is notified about all part activation (and other) events.

Upvotes: 3

Related Questions