Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Renaming a Resource opened in Editor
Renaming a Resource opened in Editor [message #1709767] Wed, 30 September 2015 18:52 Go to next message
Dinko Ivanov is currently offline Dinko IvanovFriend
Messages: 27
Registered: July 2009
Junior Member
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 07:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Renaming a Resource opened in Editor [message #1710111 is a reply to message #1710090] Sun, 04 October 2015 13:05 Go to previous messageGo to next message
Dinko Ivanov is currently offline Dinko IvanovFriend
Messages: 27
Registered: July 2009
Junior Member
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 04:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Renaming a Resource opened in Editor [message #1710213 is a reply to message #1710137] Mon, 05 October 2015 11:50 Go to previous message
Dinko Ivanov is currently offline Dinko IvanovFriend
Messages: 27
Registered: July 2009
Junior Member
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: Thu Apr 25 06:51:24 GMT 2024

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

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

Back to the top