Thomas
Thomas

Reputation: 51

Best way to update view from command or filedialog in an eclipse rcp application

In my application I have a menu which open a SelectionDialog, this dialog is used to choose an object. When this object is selected I have to display it in the view.

What is the best way to update my view?

Currently, I call myview.update(object) after the dialog is closed (in the handler of the menu). But I think this solution is not well design.

I have read about update my model and notify my view but my model does not change (no data are changed, I only display different Data ).

Does anyone has some ideas for a well design solution ?

Upvotes: 3

Views: 408

Answers (2)

sambi reddy
sambi reddy

Reputation: 3085

  1. Define model listener ( dataPopulated(Event e))
  2. Make your view implement model listener and register it with the Model.
  3. Define a Model class that can contain the objects that you want to populate in the view
  4. When Model.setInput(Object input) is invoked fire dataPopulated() event on all registered model listeners.

Above steps works properly when you have view activated. You need to consider cases like when if view is deactivated or not visible ( make sure you refresh view is visible else you will have unnecessary overhead of refreshing view though it is notvisible)

Upvotes: 1

becks
becks

Reputation: 2718

Try adding a selection listener in the view and register this selection in the dialog.

In the listener action, add the code to show the selected object.

Upvotes: 0

Related Questions