|
Re: Update View after command has changed model [message #676697 is a reply to message #676475] |
Mon, 06 June 2011 07:52 |
Eclipse User |
|
|
|
Originally posted by:
On 2011-06-04 20:40, AmFreak wrote:
> Hi,
>
> i have a TreeView with a list of Projects and Persons in this Projects
> (leaf).
> Now i want to make a new Project. I have a Command for that. This
> command opens a dialog to insert the details of the new Project. But how
> do i update the treeView now?
> I do it like this currently:
>
> NewProjectDialog dialog = new NewProjectDialog(window.getShell());
> if (dialog.open() == Window.OK) {
> Project project = dialog.getProject();
> // Saving the new project in databank
> dbModel = new DatabankModel();
> dbModel.persistEntity(project);
> dbModel.save();
> // Update treeViewer
> projects = new ProjectsModel();
> view.getViewer().setInput(projects.getProjects());
> }
>
> but it seems a little ugly to me to update the view from the command?
I agree. IMO your model should be able to send model-change events and
the content provider of your viewer should listen to these events,
eventually ensuring the refresh.
HTH & Greetings from Bremen,
Daniel Krügler
|
|
|
|
Powered by
FUDForum. Page generated in 0.02539 seconds