Search code examples
vieweclipse-rcpjfacercpnattable

How to cross update of view between nattable and Jface view


Eclipse RCP View Communication ,where one view contains nattable and another views contains jface controls like button, dropdown.

Currently for example there is 3 view/Editor as shown below example image

View1 - contains employee details which is a Nattable and it's cell contains data like String, Long, boolean, date value. each row represent one data,and other views are corresponding data of selected row

View2 - shows Address which is corresponding to the selected row in the View 1, User can modify data of view2.

View3 - shows department details of employe, which can also be modified

So all 3 views present data of one model say Employee

   Employee 
     |_Name 
     |_EmpId
     |_Married
     |_DOJ
     |_Address
         |_Type
         |_City Name
         |_State
         |_PinCode
     |_Department Details
         |_Department
         |_Project
         |_Manager

Problem:

I want to know what is best way of communcation between views1 and other view such that

  1. On selection of row in view1 then other two view should be update correspondingly;

  2. If any data changes in view2/view3 then view 1 should get notification for data change in other view

  3. when condition 2 occurs then I want to show dirty row in view1.


Solution

  • The typical approach for inter view communication in an E4 application related to your described scenario is to use the ESelectionService to trigger handling of a selection for opening another view, and to communicate back via the Eclipse 4 event system.

    For scenario one to open a view based on the selection in a NatTable you could use the E4SelectionListener in the NatTable Eclipse 4 Extension Feature. It is a ILayerListener that forwards the selection to the ESelectionService. An example can be found in the NatTable examples.

    To inform view 1 about changes in another view, I would suggest to use the IEventBroker to send an event from view2/view3 and react on the event in view1. This way the views are decoupled as much as possible. Eclipse 4 event system is a good starting point for learning about the event system.