WorkingCopy and ElementChangedEvent [message #159189] |
Tue, 18 May 2004 07:23  |
Eclipse User |
|
|
|
Originally posted by: ingo.dueppe.gmx.de
Hello,
I add an ElementChangedListener to the JavaCore class and get notified
for every java changes. Also I wrote a wizard that creates a bunch of
methods at once, but since I added the Listener I get notified for every
method the wizard adds instead of one notification when the wizard is done.
Any idea what I making wrong?
I thought that it is enough to get a working copy of the type that the
wizard will manipulate or do I make something wrong?
IEditorInput input= editorPart.getEditorInput();
IWorkingCopyManager manager= JavaUI.getWorkingCopyManager();
try {
manager.connect(input);
try {
ICompilationUnit workingCopy = manager.getWorkingCopy(input);
IType[] types = workingCopy.getAllTypes();
if (types.length>0) {
StandardEventMethodsWizard.openDialog(types[0]);
}
} finally {
manager.disconnect(input);
}
} catch (CoreException e) {
DMSPlugin.log(e);
}
Thanks for any help.
Ingo
|
|
|
|
|
|
Re: WorkingCopy and ElementChangedEvent [message #159257 is a reply to message #159233] |
Tue, 18 May 2004 09:28   |
Eclipse User |
|
|
|
Originally posted by: ingo.dueppe.gmx.de
Fine, now it is running as a atmic operation. But do I still need a
working copy?
Thx
Ingo
Jerome Lanneluc wrote:
>I see: you're using Java model operations to create the methods (I thought
>you were editing the source).
>
>In this case, you should use a batch operation:
>JavaCore.run(IWorkspaceRunnable, IProgressMonitor).
>
>Jerome
>
>"Ingo Düppe" <ingo.dueppe@gmx.de> wrote in message
>news:c8d03s$546$1@eclipse.org...
>
>
>>mmh, i didn't call reconcil() at all.
>>
>>Well this is approximately what I'm doing:
>>
>>IEditorInput input= editorPart.getEditorInput();
>>IWorkingCopyManager manager= JavaUI.getWorkingCopyManager();
>>try {
>> manager.connect(input);
>> try {
>> ICompilationUnit workingCopy = manager.getWorkingCopy(input);
>> IType[] types = workingCopy.getAllTypes();
>> if (types.length>0) {
>> currentType = types[0];
>> [...]
>> ICompilationUnit working =
>>
>>
>currentType.getCompilationUnit().getWorkingCopy(null);
>
>
>>IType type = working.getType(currentType.getElementName());
>>[...]
>>// generate event methods
>>for (int i = 0; i < methods.length; i++) {
>> String source = [...];
>> IMethod method = type.createMethod(source, sibling, true, null);
>>}
>> [...]
>>// commit working
>>working.commitWorkingCopy(false, null);
>> }
>> } finally {
>> manager.disconnect(input);
>> }
>>} catch (CoreException e) {
>> DMSPlugin.log(e);
>>}
>>
>>Any idea?
>>
>>Jerome Lanneluc wrote:
>>
>>
>>
>>>You will get a notification each time reconcile is invoked on the working
>>>copy. If you want to get one notification, call reconcile() only once
>>>
>>>
>when
>
>
>>>the wizard is done.
>>>
>>>Jerome
>>>
>>>
>>>
>>>
>
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04205 seconds