I have simple requirement : My application contain 2 MParts. One MPart contains list of IDs displayed in TreeView from Database. By clicking on any ID, another MPart should populate/display data related to slected ID (from DB) in TableView.
I written, 1st MPart and it is displaying IDs in TreeView. On click capturing user selected ID and retrieved data related to that ID from DB. Using EPartService, i got reference of 2nd MPart. But not able to modify its TableView. (initially, i populated this TableView with empty rows. default). Basically I am trying to modify 2nd Mpart from 1st Mpart.
I am beginner, tried all related posts available in the net. Please point me right direction
In the following answer I will asume that you are talking about JFace
TreeViewerandTableViewer. If you are talking about JavaFXTreeViewandTableViewyou will need to use a different way of capturing the selection event, but the usage of theESelectionServiceremains the same.Setting the Selection
In the part with the tree you can use dependency injection to get the
ESelectionServiceYou can then add a
ISelectionChangedListenerto theTreeViewerand forward the selection to the selection service.Instead of pushing the
IStructuredSelectionto the context you could also use your ID directly, i.e. by usingselection.getFirstElement().Observing the Selection
In the part with the table showing the details you can have the current selection injected. This method will be called everytime the selection changes.
Note the use of
@Optionalhere. This will ensure that the method is also called when the active selection isnull.More Information
For more information on the
ESelectionServiceplease refer to this tutorial: http://eclipsesource.com/blogs/tutorials/eclipse-4-e4-tutorial-part-7-services/