Take the 2-minute tour ×

I have been given this task and would appreciate it if someone helped really. I built a Graphical Model through GMF, which is as follows;

![gmf model][1]

[1]: http://i.imgur.com/PdtRC.jpg "gmf_model" [1]

As you see one of the nodes in the model has been selected. The task here is to create an eclipse view with a table, which will be automatically updated upon the selection of a so-called "City Node". As you may guess from the model, the table should contain path costs to all of the cities. I will later expand my solution to include a modified Dijkstra Algorithm but right now i am stuck in the creation of a table view.

I tried to build it using a TableViewer but it seems fairly complex since we need to set the input of the table on ContentProvider, but the twist here is that since we need a SelectionListener to obtain the City Coordinates(as it was ordered to calculate path-costs through the distance between two connected cities divided by the max speed, which was indicated on the connecting streets in the graph) and also the currently selected city, the path-costs need to be automatically calculated and displayed in the table upon the receipt of a click-event. This means that we somehow need to update the input which is gonna be handed to ContentProvider on every selection change.

For further information, i get the current selection through selectionChanged method of ISelectionListener interface and inside this method i put the city information in an arraylist. However although i declared this arraylist outside of the method as public, i can not seem to access it from the outside of the method and thus can not pass it contentProvider. Eventually the input of the table can not be updated. I tried to write this text as simple as possible and i hope you guys can help me. As i can not foresee now what should be done, i would really appreciate it. Thanks in advance.

share|improve this question
add comment

1 Answer

You're on the right track!

In your selection listener's ISelectionListener.selectionChanged method you just have to set the new input for the viewer with TableViewer.setInput. Then, the IStructuredContentProvider.inputChanged method gets invoked on the content provider for the viewer. It's here where you can do your stuff with the new input and refresh the viewer with TableViewer.refresh.

You can also use the JFace databinding framework, but I think you should be fine with what I've mentioned above.

share|improve this answer
add comment

Your Answer


