Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Customize 'save' action
Customize 'save' action [message #483184] Mon, 31 August 2009 09:47 Go to next message
Mickael Istria is currently offline Mickael Istria
Messages: 611
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi all,

I am trying to add some custom behavior on the Save action of my GMF diagram. More precisely, when saving file "foo" I'd like my custom save action to:
* Check for existence of a file "bar"
* save file "foo" if "bar" does not exist
* Rename "foo" into "bar".

I'd like to avoid modification of generated code, I'd really prefer to use providers extensions and override the definition of 'save' for my diagram in an extension.

Is this do-able? How should I proceed?

Regards,
Mickael
Re: Customize 'save' action [message #483369 is a reply to message #483184] Tue, 01 September 2009 07:29 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Mickael,

You need to modify generated ???DocumentProvider.

-----------------
Alex Shatalin
Re: Customize 'save' action [message #483610 is a reply to message #483369] Wed, 02 September 2009 06:19 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael Istria
Messages: 611
Registered: July 2009
Location: Grenoble, France
Senior Member
Hello Alex,

Thanks for your tips.
However, I found a nicer solution. I share it with the newsgroup in case it may be helpful for someone else one day:

I simply overrode the ???DiagramEditor.performSave method to perform a "save as", specifying the name of target file in a URIEditorInput, depending on the semantic model. That is working well for my use case and is much easier to customize.

Regards,
Mickael

Alex Shatalin a écrit :
> Hello Mickael,
>
> You need to modify generated ???DocumentProvider.
>
> -----------------
> Alex Shatalin
>
>
Re: Customize 'save' action [message #483635 is a reply to message #483610] Wed, 02 September 2009 08:14 Go to previous message
Mickael Istria is currently offline Mickael Istria
Messages: 611
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi again,

Actually, this solution does not work so well because "save as" as an unexpected behavior when using same file for diagram and model.
I filed http://bugs.eclipse.org/288346 to describe the issue.

Mickael

Mickael Istria a écrit :
> Hello Alex,
>
> Thanks for your tips.
> However, I found a nicer solution. I share it with the newsgroup in case
> it may be helpful for someone else one day:
>
> I simply overrode the ???DiagramEditor.performSave method to perform a
> "save as", specifying the name of target file in a URIEditorInput,
> depending on the semantic model. That is working well for my use case
> and is much easier to customize.
>
> Regards,
> Mickael
>
> Alex Shatalin a écrit :
>> Hello Mickael,
>>
>> You need to modify generated ???DocumentProvider.
>>
>> -----------------
>> Alex Shatalin
>>
>>
Previous Topic:update nodes on link creation and deletion
Next Topic:Create EditPart from ModelExplorer view
Goto Forum:
  


Current Time: Sun May 19 10:44:40 EDT 2013

Powered by FUDForum. Page generated in 0.01605 seconds