[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: emfforms incubator: When should an editor be an IResourceChangeListener

John,

Comments below.

John J. Franey wrote:
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.
  
Probably best to ask about on the PDE newsgroup, but I'll do my best...
I'm still new to emf and pde development.  Really liking it though.
  
:-)

emfforms provides an editor that implements and registers as an 
IResourceChangeListener.  Its resourceChanged handler flushes the command 
stack.

  
Yes, EMF's generated editors do that too....

Updating markers fire a resourceChange event, AFAICT after a painful 
debugging session this morning.
  
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.

ÂÂÂÂÂÂÂÂÂÂÂ public boolean visit(IResourceDelta delta)
ÂÂÂÂÂÂÂÂÂÂÂ {
ÂÂÂÂÂÂÂÂÂÂÂÂÂ if (delta.getResource().getType() == IResource.FILE)
ÂÂÂÂÂÂÂÂÂÂÂÂÂ {
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (delta.getKind() == IResourceDelta.REMOVED ||
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ {

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.
  
Of course!

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. 
No, but the contain one.
 protected IResourceChangeListener resourceChangeListener =
ÂÂÂ new IResourceChangeListener()
ÂÂÂ {
 So, I'm left to wonder what is 
behind the design decision for emfform's editor to be an 
IResourceChangeListener.
  
Sounds like a sledge hammer design that needs to be refined...
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).
  
Yes, you should report the issue.

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.
  
Sounds cool.
Regards,
John