Skip to main content



      Home
Home » Modeling » EMF » Renaming a Resource opened in Editor
Renaming a Resource opened in Editor [message #1709767] Wed, 30 September 2015 14:52 Go to next message
Eclipse UserFriend
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 #1710090 is a reply to message #1709767] Sun, 04 October 2015 03:40 Go to previous messageGo to next message
Eclipse UserFriend
Dinko,

Comments below.

On 30/09/2015 8:52 PM, Dinko Ivanov wrote:
> 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.
How is the model file renamed? In the workspace itself?
>
> Can you recommend how to avoid this? What is the best practice?
>
> Best Regards,
> Dinko
Re: Renaming a Resource opened in Editor [message #1710111 is a reply to message #1710090] Sun, 04 October 2015 09:05 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Renaming a Resource opened in Editor [message #1710137 is a reply to message #1710111] Mon, 05 October 2015 00:42 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Renaming a Resource opened in Editor [message #1710213 is a reply to message #1710137] Mon, 05 October 2015 07:50 Go to previous message
Eclipse UserFriend
Thanks!

That will work for me.

Best Regards,
Dinko
Previous Topic:Type parameter as type of both attribute and reference
Next Topic:static model from xml
Goto Forum:
  


Current Time: Wed Jul 23 05:06:11 EDT 2025

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

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

Back to the top