Problem with catching ElementChangedEvent with an open editor. (still open) [message #715921] |
Tue, 16 August 2011 00:43  |
Eclipse User |
|
|
|
I have a java project with the "pack1" package and the "Class1" class.
I open java editor on "Class1.java" and add or remove a method to "Class1".
I want to catch the moment when Java Model is changed.
myListener= new MyListener();
JavaCore.addElementChangedListener(myListener,ElementChangedEvent.POST_CHANGE);
When I open a java editor I receives:
1:
org.eclipse.jdt.core.ElementChangedEvent[source=Java Model[*]: {CHILDREN}
TestJ2[*]: {CHILDREN}
src[*]: {CHILDREN}
pack111[*]: {CHILDREN}
[Working copy] FailTezt.java[*]: {PRIMARY WORKING COPY}]
This is ok as Eclipse creates new "Working copy" of java file.
But when I make a change and save the file myListener receives the next delta:
2:
org.eclipse.jdt.core.ElementChangedEvent[source=Java Model[*]: {CHILDREN}
TestJ2[*]: {CHILDREN}
src[*]: {CHILDREN}
pack111[*]: {CHILDREN}
[Working copy] FailTezt.java[*]: {PRIMARY RESOURCE}]
This is strange as after a save my changes should be applied to Java Model, not to Working copy. When I close my editor I receives:
3:
org.eclipse.jdt.core.ElementChangedEvent[source=Java Model[*]: {CHILDREN}
TestJ2[*]: {CHILDREN}
src[*]: {CHILDREN}
pack111[*]: {CHILDREN}
FailTezt.java[*]: {PRIMARY WORKING COPY}]
This could be ok, as it could mean that the changes eventually reached Java Model. However if I open and close java editor without any changes I receives 1: 3: as well. So I cannot distinguish between model changes and just open/close editor operations.
Please help me. I've really spent many hours trying to figure this out. I have several ideas, but none of them interprets the situation above.
[Updated on: Wed, 17 August 2011 10:27] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05147 seconds