Sharing Views/Selections

Hi,



I want to take a JGoDocument and show the usual JGoView but I also want to show a JTable view of some of the entries in the JGoDocument. I’m using an adapter pattern to get a TableModel from a JGoDocument but I can’t yet see a clean way of sharing selections between the JGoView and the JTable. i.e. when something is selected in the JTable the selection is replicated in the JGoView and vice-versa.



Any comments would be appreciated.



Thanks



Mike

You could add a viewChanged event listener to the JGoView and examine the JGoDocumentEvent Hint. If it’s SELECTION_GAINED or SELECTION_LOST, examine the current JGoSelection to see what objects are currently selected. Perhaps something like the following:

void JGoView1_viewChanged(JGoViewEvent e) {
switch (e.getHint()) {
case JGoViewEvent.SELECTION_GAINED:
case JGoViewEvent.SELECTION_LOST:
// Get your JGoView object and call getSelection() to get
// the currently selected objects
}
}