Renaming a Resource opened in Editor [message #1709767] |
Wed, 30 September 2015 14:52  |
Eclipse User |
|
|
|
Hi,
I've developed a diagram editor for my EMF model. The editor receives IFileEditorInput and loads the EMF Resource from the input file.
However, if the model file is renamed while being edited, the editor still keeps the old file.
Can you recommend how to avoid this? What is the best practice?
Best Regards,
Dinko
|
|
|
|
|
Re: Renaming a Resource opened in Editor [message #1710137 is a reply to message #1710111] |
Mon, 05 October 2015 00:42   |
Eclipse User |
|
|
|
Dinko,
Yes, by implementing
org.eclipse.core.resources.IResourceChangeListener.resourceChanged(IResourceChangeEvent)
and registering it using
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
you can detect renaming of workspace resources and use that to change
the URIs of resources in the resource set and I suppose changing the
editor input if the input resource is the one that's renamed.
On 04/10/2015 3:05 PM, Dinko Ivanov wrote:
> Hello Ed,
>
> That's correct, I'm talking about the scenario, when user tries to
> rename the file in the workspace.
>
> I read somewhere that there's a way to set EMF Resource URI to point
> to the new IFile location. Resource change notification will tell me
> what's added and what removed, not sure how to detect which file was
> file moved/renamed.
>
> Right now I've solved the problem by registering an
> org.eclipse.ltk.core.refactoring.participants.RenameParticipant that
> closes the editor (&save if dirty) before rename.
> Best Regards,
> Dinko
|
|
|
|
Powered by
FUDForum. Page generated in 0.05037 seconds