Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » ChangeCommand Test(How it works, is it in working condition ?)
| | | | | | | | | |
Re: ChangeCommand Test [message #649170 is a reply to message #648970] |
Tue, 18 January 2011 00:35 |
tenor Messages: 57 Registered: October 2010 |
Member |
|
|
Vide in the book.
Notice that calling applyAndReverse() repeatedly provides a convenient undo/redo capability for a change description.
I was under impression, it can lead me to undo the "Each Step Changes" back to original state, but it does NOT!!
It goes in one shot to original.
So, Merks, my Q is
1) How i can write for before press of OK button, it should call startRecording and on press of OK button, it should call endRecording, and save changes happened in between, to a stack. And if user presses undo , at this point of time, it should revert the change, to last sequential value. if again pressed undo, again till last value from this reverted back value, ie journey back and tracing back.
2)if so, any close example?
Thanks.
|
|
|
Re: ChangeCommand Test [message #649171 is a reply to message #649170] |
Tue, 18 January 2011 00:47 |
Ed Merks Messages: 33163 Registered: July 2009 |
Senior Member |
|
|
Comments below.
tenor wrote:
> Vide in the book.
>
> Notice that calling applyAndReverse() repeatedly provides a convenient
> undo/redo capability for a change description.
Yes, call it once is undo, call it twice is redo, call it three times is
undo again...
>
> I was under impression, it can lead me to undo the "Each Step Changes"
> back to original state, but it does NOT!!
No, that's what a command stack does.
>
> It goes in one shot to original.
>
> So, Merks, my Q is
>
> 1) How i can write for before press of OK button, it should call
> startRecording and on press of OK button, it should call endRecording,
> and save changes happened in between, to a stack. And if user presses
> undo , at this point of time, it should revert the change, to last
> sequential value. if again pressed undo, again till last value from
> this reverted back value, ie journey back and tracing back.
Are you writing a wizard or dialog? It's best that such a thing make no
changes to the actual model until you press OK. When you press OK, you
should execute a command that makes all the changes.
>
> 2)if so, any close example?
The problem is if you make changes to the actual objects before pressing
okay, the rest of the editor will see those changes.
>
>
> Thanks.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | | | | | | | | | | |
Re: ChangeCommand Test [message #650398 is a reply to message #650191] |
Mon, 24 January 2011 17:47 |
tenor Messages: 57 Registered: October 2010 |
Member |
|
|
Dont despair on me.
I am trying to get it right, but miss basics.
I had a look at following generated editor class. ie
LibraryEditor
LibraryActionBarContributor
And
public class LibraryActionBarContributor
extends EditingDomainActionBarContributor
And i notice , that there is following method in the EditingDomainActionBarContributor
protected UndoAction createUndoAction()
{
return new UndoAction();
}
Now in UndoAction.class, i set bp here, it breakspoint here
@Override
public void run()
{
domain.getCommandStack().undo();
}
Further debugging, takes to BasicCommandStack class.
So i need domain, as domain has commandstack.
First set of questions
1. If LibraryEditor.java can be subclassed to provide redo/undo functionality?
2. How to put button there, if LibraryEditor is to do calling for redo/undo ?
And as in the link
http://www.eclipsezone.com/eclipse/forums/t115960.html
the last part ie
Furthermore EMF global undo/redo etc actions are only added to the actual
Actions in eclipse via the ActionHandler mechanism, which is called from
the EditorActionBar.init function or from the shareGlobalActions function
if you are attaching them via a View such as an Outline or PropertySheet.
The shareGlobalActions function is in turn called from setActionBars on
the Page class, which you will have in your View? If you look at how the
generated Editor's ContentOutlinePage and PropertySheetPage handle these
things, you could incorporate this into your code, bearing in mind that
you need to be an EditorPart to use the EMF ActionBarContributor as is.
Second set of Qs
1. Where to hook for redo/undo button, if i have NOTHING to do with Property sheet, as i will have my own view.
So, in this view, if i place a button which bit of piece i should hook to ?
2. As above, EditorPart is MUST ? if so,
menuManager.add(new ActionContributionItem(undoAction)); is one of means to achieve a button on my view?
3. Unrelated to this, in the copy by EMF.edit, does it copy contained references?
|
|
|
Re: ChangeCommand Test [message #650416 is a reply to message #650398] |
Mon, 24 January 2011 18:38 |
Ed Merks Messages: 33163 Registered: July 2009 |
Senior Member |
|
|
Tenor,
Comments below.
tenor wrote:
> Dont despair on me.
I'm not generally a patient person despite appearances to the contrary.
> I am trying to get it right, but miss basics.
> I had a look at following generated editor class. ie
> LibraryEditor
> LibraryActionBarContributor
> And
> public class LibraryActionBarContributor
> extends EditingDomainActionBarContributor
> And i notice , that there is following method in the
> EditingDomainActionBarContributor
> protected UndoAction createUndoAction()
> {
> return new UndoAction();
> }
>
> Now in UndoAction.class, i set bp here, it breakspoint here
>
> @Override
> public void run()
> {
> domain.getCommandStack().undo();
> }
>
> Further debugging, takes to BasicCommandStack class.
>
> So i need domain, as domain has commandstack.
> First set of questions
> 1. If LibraryEditor.java can be subclassed to provide redo/undo
> functionality?
It already directly supports it.
> 2. How to put button there, if LibraryEditor is to do calling for
> redo/undo ?
There's a menu action in the edit menu. Ho to provide button for the
same thing isn't an EMF question.
>
> And as in the link http://www.eclipsezone.com/eclipse/forums/t115960.html
> the last part ie
> Furthermore EMF global undo/redo etc actions are only added to the
> actual Actions in eclipse via the ActionHandler mechanism, which is
> called from the EditorActionBar.init function or from the
> shareGlobalActions function if you are attaching them via a View such
> as an Outline or PropertySheet. The shareGlobalActions function is in
> turn called from setActionBars on the Page class, which you will have
> in your View? If you look at how the generated Editor's
> ContentOutlinePage and PropertySheetPage handle these things, you
> could incorporate this into your code, bearing in mind that you need
> to be an EditorPart to use the EMF ActionBarContributor as is. Second
> set of Qs
> 1. Where to hook for redo/undo button, if i have NOTHING to do
> with Property sheet, as i will have my own view.
> So, in this view, if i place a button which bit of piece i should hook
> to ?
You can see that the action just calls undo on the command stack so you
can do the same thing from any button you decide to put anywhere.
> 2. As above, EditorPart is MUST ?
No.
> if so, menuManager.add(new ActionContributionItem(undoAction)); is one
> of means to achieve a button on my view?
Make the button any way you want (it's not an EMF question) and invoke
undo on the command stack (simple).
>
> 3. Unrelated to this, in the copy by EMF.edit, does it copy
> contained references?
Yes it does.
>
>
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Mon Jun 17 06:49:18 GMT 2024
Powered by FUDForum. Page generated in 0.04701 seconds
|