简体   繁体   中英

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!

您可以使用EPartService addPartListener方法添加一个侦听器,该侦听器将收到有关所有零件激活(和其他)事件的通知。

我认为EPartService.isPartVisible(MPart) (而不是MPart.isVisible() )解决了您的第一个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM