Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » WorkingCopy and ElementChangedEvent
WorkingCopy and ElementChangedEvent [message #159189] Tue, 18 May 2004 07:23 Go to next message
Eclipse UserFriend
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 #159210 is a reply to message #159189] Tue, 18 May 2004 07:57 Go to previous messageGo to next message
Eclipse UserFriend
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

"Ingo D
Re: WorkingCopy and ElementChangedEvent [message #159225 is a reply to message #159210] Tue, 18 May 2004 08:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ingo.dueppe.gmx.de

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
>
>
Re: WorkingCopy and ElementChangedEvent [message #159233 is a reply to message #159225] Tue, 18 May 2004 09:08 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: WorkingCopy and ElementChangedEvent [message #159257 is a reply to message #159233] Tue, 18 May 2004 09:28 Go to previous messageGo to next message
Eclipse UserFriend
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
>>>
>>>
>>>
>>>
>
>
>
>
Re: WorkingCopy and ElementChangedEvent [message #159265 is a reply to message #159257] Tue, 18 May 2004 09:33 Go to previous message
Eclipse UserFriend
A working copy will allow you to rollback your changes if for some reason
your wizard cannot go up to the end of the methods creation. But this is not
absolutely necessary.

"Ingo D
Previous Topic:M9: Refactoring / change signature
Next Topic:Build in Progress...
Goto Forum:
  


Current Time: Thu May 08 19:02:44 EDT 2025

Powered by FUDForum. Page generated in 0.04205 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top