Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Re: How to Undo/Redo model changes?
Re: How to Undo/Redo model changes? [message #214649] Wed, 19 April 2006 20:23 Go to next message
Steven R. Shaw is currently offline Steven R. ShawFriend
Messages: 128
Registered: July 2009
Senior Member
Slightly more robust answer here:

http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _instrument_domain_model_changes_that_support_undo.2Fredo

-Steve

"Steven Shaw" <steveshaw@ca.ibm.com> wrote in message news:...
> You can define custom request types that represent model changes for your
> domain. An example would be how the logic example increments / decrements
> the LED model item. The IncrementDecrementAction creates a new request
>
> ...
> request = new Request(INCREMENT_REQUEST);
> ...
>
> Then the request is sent to the selected objects on the diagram surface.
> The LEDEditPart has a custom EditPolicy LEDEditPolicy installed on it that
> understands the INCREMENT_REQUEST. It then returns a custom command that
> can handle undo/redo that will get executed on the command stack
>
> @see LEDEditPolicy#IncrementDecrementCommand
>
> Regards,
>
> Steve.
>
> "Jan H. van der Ven" <jhvdven@xs4all.nl> wrote in message
> news:e1tbda$8q6$1@utils.eclipse.org...
> > Dear all,
> >
> >
> > I have an Entity Relation Diagram editor based on the work by Phil Zoio.
> > I am currently working on a function that refreshes the diagram
> > contents to match the definition in the database (you have an older
> > diagram and want to continue working on that but meanwhile someone has
> > changed the table definition, more columns, other types.)
> > I created an action for that, that invokes a member of the diagram (as
> > part of the model group). The model can access the database definition,
> > and as such this is the logical place to see if the diagram's model
> > matches the database.
> > I call all my functions and the property aware stuff makes sure that the
> > diagram is updated.
> > However the modifications to the model are not part of the command
> > stack, as I have not gone through the action, request, command sequence.
> >
> > That's because I thought these were only for user interactions and not
> > for programmatic model changes.
> >
> > Can anyone point me in a direction for correct implementation? Where do
> > I create the request? What kind of request would that be? And what kind
> > of Policy would be required?
> >
> > Thanks in advance.
> >
> > Jan van der Ven
>
>
Re: How to Undo/Redo model changes? [message #214701 is a reply to message #214649] Thu, 20 April 2006 16:53 Go to previous message
Jan van der Ven is currently offline Jan van der VenFriend
Messages: 18
Registered: July 2009
Junior Member
Thanks for the response. I think I can manage from here.

I have one doubt though, the link describes the response to a user
action. My user action is high level: refresh the diagram! It needs the
model to figure out what to do (I wanted to say which set of actions to
perform), but can the model start an action?

Kind regards,


Jan

Steven Shaw wrote:
> Slightly more robust answer here:
>
> http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _instrument_domain_model_changes_that_support_undo.2Fredo
>
> -Steve
>
> "Steven Shaw" <steveshaw@ca.ibm.com> wrote in message news:...
>> You can define custom request types that represent model changes for your
>> domain. An example would be how the logic example increments / decrements
>> the LED model item. The IncrementDecrementAction creates a new request
>>
>> ...
>> request = new Request(INCREMENT_REQUEST);
>> ...
>>
>> Then the request is sent to the selected objects on the diagram surface.
>> The LEDEditPart has a custom EditPolicy LEDEditPolicy installed on it that
>> understands the INCREMENT_REQUEST. It then returns a custom command that
>> can handle undo/redo that will get executed on the command stack
>>
>> @see LEDEditPolicy#IncrementDecrementCommand
>>
>> Regards,
>>
>> Steve.
>>
>> "Jan H. van der Ven" <jhvdven@xs4all.nl> wrote in message
>> news:e1tbda$8q6$1@utils.eclipse.org...
>>> Dear all,
>>>
>>>
>>> I have an Entity Relation Diagram editor based on the work by Phil Zoio.
>>> I am currently working on a function that refreshes the diagram
>>> contents to match the definition in the database (you have an older
>>> diagram and want to continue working on that but meanwhile someone has
>>> changed the table definition, more columns, other types.)
>>> I created an action for that, that invokes a member of the diagram (as
>>> part of the model group). The model can access the database definition,
>>> and as such this is the logical place to see if the diagram's model
>>> matches the database.
>>> I call all my functions and the property aware stuff makes sure that the
>>> diagram is updated.
>>> However the modifications to the model are not part of the command
>>> stack, as I have not gone through the action, request, command sequence.
>>>
>>> That's because I thought these were only for user interactions and not
>>> for programmatic model changes.
>>>
>>> Can anyone point me in a direction for correct implementation? Where do
>>> I create the request? What kind of request would that be? And what kind
>>> of Policy would be required?
>>>
>>> Thanks in advance.
>>>
>>> Jan van der Ven
>>
>
>
Previous Topic:Equal spaces between figures
Next Topic:Using the PaletteView with multiple editor instances
Goto Forum:
  


Current Time: Thu Apr 25 16:47:20 GMT 2024

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

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

Back to the top