Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Undo/Redo support for non EMF based domain objects
Undo/Redo support for non EMF based domain objects [message #556346] Tue, 31 August 2010 17:41 Go to next message
Shenxue Zhou is currently offline Shenxue Zhou
Messages: 50
Registered: July 2009
Member
It seems that if my domain objects are not EMF based, then we don't get the undo/redo support (whether it's a move feature or add feature). After some digging, I noticed that Graphiti uses GFCommandStack class which seems to replace GEF's command stack with emf's command stack.

How do I get undo/redo support if my domain objects are not EMF based? Thank you for your suggestions!

Shenxue
Re: Undo/Redo support for non EMF based domain objects [message #557283 is a reply to message #556346] Mon, 06 September 2010 08:32 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1590
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Yes, you are right. The advantage of doing it that way is that we can
completely handle undo/redo on EMF level by simply using the
RecordingCommand of EMF.

Also in a scenario with non-EMF domain objects, the part concerning the
graphical objects are handled automatically by Graphiti. Only the undo/redo
of the non-EMF domain object changes need to be implemented by you. In order
to do that you can use a GEF CommandStackEventListener that you register at
the CommandStack by
getEditDomain().getCommandStack().addCommandStackEventListen er(listener)
after the initiallization (e.g. by overriding setInput in DiagramEditor and
after calling super.setInput). There you can react to events POST_REDO and
POST_UNDO.

Hope that helps.

-Michael


"Shenxue Zhou" <shenxue.zhou@oracle.com> wrote in message
news:i5jsv9$74t$1@build.eclipse.org...
> It seems that if my domain objects are not EMF based, then we don't get
> the undo/redo support (whether it's a move feature or add feature). After
> some digging, I noticed that Graphiti uses GFCommandStack class which
> seems to replace GEF's command stack with emf's command stack.
> How do I get undo/redo support if my domain objects are not EMF based?
> Thank you for your suggestions!
>
> Shenxue
Re: Undo/Redo support for non EMF based domain objects [message #557499 is a reply to message #557283] Tue, 07 September 2010 15:47 Go to previous messageGo to next message
Shenxue Zhou is currently offline Shenxue Zhou
Messages: 50
Registered: July 2009
Member
Michael,

Thanks for your reply. I did some experiment based on your suggestion. In my editor, I overrode the setInput() method. My setInput() method looks like this:

@Override
protected void setInput(IEditorInput input)
{
super.setInput(input);
getEditDomain().getCommandStack().addCommandStackEventListen er(this);
}

But I'm registering a command stack event listener to GFCommandStack() since the default domain's GEF command stack has been replaced by GFCommandStack after super.setInput() is called. GFCommandStack doesn't seem to notify listeners about POST_REDO/POST_UNDO events.

Thoughts?

Shenxue
Re: Undo/Redo support for non EMF based domain objects [message #557655 is a reply to message #557499] Wed, 08 September 2010 08:35 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1590
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Shenxue,

I just had a closer look and saw that you are right. This is a gap in our
command stack implementation. After a short team discussion we also saw that
there is currently no other hook to actually undo/redo non-EMF changes.

Could you please open an enhancement request Bugzilla (Under modeling,
product GMP, component Graphiti) for this? We have a rough idea how to
implement the feature, but this needs to be detailed out.

Thanks,
Michael


"Shenxue Zhou" <shenxue.zhou@oracle.com> wrote in message
news:i664t9$44g$1@build.eclipse.org...
> Michael,
>
> Thanks for your reply. I did some experiment based on your suggestion. In
> my editor, I overrode the setInput() method. My setInput() method looks
> like this:
>
> @Override
> protected void setInput(IEditorInput input) {
> super.setInput(input);
> getEditDomain().getCommandStack().addCommandStackEventListen er(this); }
>
> But I'm registering a command stack event listener to GFCommandStack()
> since the default domain's GEF command stack has been replaced by
> GFCommandStack after super.setInput() is called. GFCommandStack doesn't
> seem to notify listeners about POST_REDO/POST_UNDO events.
>
> Thoughts?
>
> Shenxue
Re: Undo/Redo support for non EMF based domain objects [message #567972 is a reply to message #557283] Tue, 07 September 2010 15:47 Go to previous message
Shenxue Zhou is currently offline Shenxue Zhou
Messages: 50
Registered: July 2009
Member
Michael,

Thanks for your reply. I did some experiment based on your suggestion. In my editor, I overrode the setInput() method. My setInput() method looks like this:

@Override
protected void setInput(IEditorInput input)
{
super.setInput(input);
getEditDomain().getCommandStack().addCommandStackEventListen er(this);
}

But I'm registering a command stack event listener to GFCommandStack() since the default domain's GEF command stack has been replaced by GFCommandStack after super.setInput() is called. GFCommandStack doesn't seem to notify listeners about POST_REDO/POST_UNDO events.

Thoughts?

Shenxue
Re: Undo/Redo support for non EMF based domain objects [message #568043 is a reply to message #567972] Wed, 08 September 2010 08:35 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1590
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Shenxue,

I just had a closer look and saw that you are right. This is a gap in our
command stack implementation. After a short team discussion we also saw that
there is currently no other hook to actually undo/redo non-EMF changes.

Could you please open an enhancement request Bugzilla (Under modeling,
product GMP, component Graphiti) for this? We have a rough idea how to
implement the feature, but this needs to be detailed out.

Thanks,
Michael


"Shenxue Zhou" <shenxue.zhou@oracle.com> wrote in message
news:i664t9$44g$1@build.eclipse.org...
> Michael,
>
> Thanks for your reply. I did some experiment based on your suggestion. In
> my editor, I overrode the setInput() method. My setInput() method looks
> like this:
>
> @Override
> protected void setInput(IEditorInput input) {
> super.setInput(input);
> getEditDomain().getCommandStack().addCommandStackEventListen er(this); }
>
> But I'm registering a command stack event listener to GFCommandStack()
> since the default domain's GEF command stack has been replaced by
> GFCommandStack after super.setInput() is called. GFCommandStack doesn't
> seem to notify listeners about POST_REDO/POST_UNDO events.
>
> Thoughts?
>
> Shenxue
Previous Topic:Hierarchical Layout and Active Status
Next Topic:Graphiti 0.7.0 RC1 available
Goto Forum:
  


Current Time: Tue Sep 02 12:57:57 EDT 2014

Powered by FUDForum. Page generated in 0.02844 seconds