| [news.eclipse.tools.emf] Re: emfforms incubator: When should an editor be an IResourceChangeListener |
|
John, Comments below. John J. Franey wrote: Probably best to ask about on the PDE newsgroup, but I'll do my best...Not sure if this is the right news group for this question related to emf, emf validation, editors and PDE's incubation project: emfforms. Its a start. :-)I'm still new to emf and pde development. Really liking it though. Yes, EMF's generated editors do that too....emfforms provides an editor that implements and registers as an IResourceChangeListener. Its resourceChanged handler flushes the command stack. It's important to filter appropriately, e.g., like this in the EMF generated editor where we don't want to take action for marker-based deltas.Updating markers fire a resourceChange event, AFAICT after a painful debugging session this morning. ÂÂÂÂÂÂÂÂÂÂÂ public boolean visit(IResourceDelta delta) ÂÂÂÂÂÂÂÂÂÂÂ { ÂÂÂÂÂÂÂÂÂÂÂÂÂ if (delta.getResource().getType() == IResource.FILE) ÂÂÂÂÂÂÂÂÂÂÂÂÂ { ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (delta.getKind() == IResourceDelta.REMOVED || ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ { Of course!Can any emf-validation expert confirm? This combination has this unfortunate side effect: validation of the model wipes out unsaved changes. This is not a nice, I think. Validation should run against unsaved changes and regardless of the outcome leave them intact. No, but the contain one.I checked two editors that came from the emf project: the editor that emf generated from my model, and the editor in the Library example. Neither of these are IResourceChangeListeners. Â protected IResourceChangeListener resourceChangeListener = Sounds like a sledge hammer design that needs to be refined...So, I'm left to wonder what is behind the design decision for emfform's editor to be an IResourceChangeListener. Yes, you should report the issue.Anyway, I'm going to change emfform's editor so it is not a ResourceChangedListener, and see if I get a better user experience. I will feed back to the emfform's originator (b. cabe, somehow, I guess maybe a bugzilla). Sounds cool.By the way, I tried to use emfform's builder example. I could not get it to work. Instead, I'm using the emf validation's library example. This approach lets me implement and test a validation plugin in isolation from a builder. Later, after I learn more, I'll build a builder plugin based on the example from emfforms. Regards, John |