views:

1083

answers:

2

In Eclipse RCP way of doing things, where should I keep my model objects? And when they are loaded or changed, how should they talk to the views?

I am attempting to port my existing application to Eclipse RCP. It could be viewed as an IDE-like application: I open a file, which contains links to source files. The source files are displayed in the tree view. I can edit the source, and build the sources into some output...

For example, when I handle the Open command, where would I create the model object so my views can see them? I'd rather avoid the use of singleton manager class, but that maybe the simplest way.

Interesting code I found browsing JDT's source code are JavaCore, JavaModel, JavaModelManager. and JavaProject.


IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();


public static IJavaProject create(IProject project) {
 if (project == null) {
  return null;
 }
 JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
 return javaModel.getJavaProject(project);
}


Related:

+1  A: 
VonC
I understand the MVC. I was wondering if there is a common practice in the placement of model objects instead of rolling out my own Manager using Singleton.
eed3si9n
+2  A: 

We tend to use IEditorParts to store keep a copy of the model (derived from the IEditorInput).

If a view needs to know about the model, then use the ISelection framework and focus to move the model around from the editor to the view.

jamesh