Hey guys,
As requested in our morning meeting here is a list of things
that need to be updated to add a new feature and implement the necessary code
to update our model to and from the JDT model.
- Edit dali.ecore and generate
the model and edit layers.
- Create a new adapter interface
(or modify the appropriate existing one). If the new feature is a
simple property foo you’ll just need a method on the adapter called
fooChanged(). Adapter interfaces are in the package
org.eclipse.dali.core.adapters. We currently support the java
implementation of the adapers. We also have support in the code for
xml, but this doesn’t do much yet.
- Create a constructor for the
emf generated impl class that takes the appropriate adapter (if
you’re creating a new impl class and not just adding a feature to an
existing one). Update DaliFactory with a new create method that
takes the adapter.
- Update the emf generated impl
class to call the adapter interface in the setter method for the new
property. Using emf you’ll want to create a new method called
setFoo(), rename the generated method to setFooGen(). Call
setFooGen() from setFoo() before calling the adapter fooChanged() method.
- Update the Java adapter
implementation. This is where the code goes to update the java model
when persistence model changes occur and vice versa.
- Implement the fooChanged()
method by updating the java code first checking if a change really
occurred. EMF forwards event notification even if no change occurs,
so we’ve had problems getting in infinite loops.
- Go to the
updatePersModel(CompilationUnit) method (or implement this if this is a
new adapter class). This method will be called if there were
changes in the java model that affected this particular class. This
is based on a jdt JavaElementChangeListener that is added in
JavaPersistenceFileModelAdapter (this will be moving to only have one
listener per project instead of one listener per file).
- There are a few helper classes
for doing simple property annotation updating (String, int, boolean,
enums) See the AbstractAnnotationElementAdapter hierarchy (this
name will probably change, these aren’t really adapters)
- Add the appropriate widgets in
the UI using the edit layer to update to/from the model
I hope this helps get people started with adding new
annotation/xml features. Feel free to add to this list if you find
something I’ve missed. We should also put this on the wiki at some
point since it is information that will change and be of interest to
extenders. Feel free to make suggestions about this process. Having
new people adding features might help uncover clearer, more efficient ways of
doing this work.
Thanks,
Karen
|