Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Re: Implementing Undoable commands in PureMVC on: July 13, 2011, 10:36:49
Hi, you can find a demo here:
http://trac.puremvc.org/Demo_AS3_Flex_HistoryPanel

Hope it helps,
Dragos
2  Announcements and General Discussion / Getting Started / Re: Merging/combining commands? on: January 08, 2010, 05:20:34
When you merge multiple commands, those commands could also be UndoableCommands ?

And if you plan to merge them at runtime, how do you plan to store the information about which commands merge with what ? If you override initializeMacroCommand that won't help ? You can't use notification's body to find out the subcommands you want to run ?

Also, do you want to run the commands sequentially or in parallel ?
3  Announcements and General Discussion / Architecture / Re: Implementing Undoable commands in PureMVC on: January 12, 2009, 11:33:45
Richard, I'm not sure if I got it right, but I'm wondering why would you need an UndoSetPropertyCommand, if you already have SetPropertyCommand. Can't you undo SetPropertyCommand with SetPropertyCommand ?

In my projects I do something like this:
1. I have an UpdateCommand that undos itself, so the registered undo command is also UpdateCommand
2. When I call that command I send the updated state of the object I want to change into the body of the note. I.e. note.getBody() would be an instance of ItemVO, let's call it 'newProperties'
3. When I execute the command, I save a snapshot with the object I am about to change, so I retrieve a copy of ItemVO, let's call it 'originalProperties'
3. I perform the changes in the model so that the view updates properly according to the 'newProperties'
4. I copy the snapshot 'originalProperties' into the note's body because this is the information I need to call undo.
5. Calling undo/redo it will simply switch 'newProperties' with 'originalProperties'.

I don't know if this can be applied to your case though.
4  Announcements and General Discussion / Architecture / Re: Implementing Undoable commands in PureMVC on: January 12, 2009, 10:05:55
The current release is stable and ready to use. I didn't use it in multicore version of the framework, and indeed the fix is perfect. I'm glad it helped you Richard.
5  PureMVC Manifold / Demos and Utils / Re: History Panel - A PureMVC AS3 / Flex Demo on: June 19, 2008, 02:40:18
Hi,
To follow the discussion, the alpha version of the history panel is on the svn for quite a while.
For the moment I have illustrated the undoable command utility using Ctrl+Z/Ctrl+Y to undo/redo your actions.
Hope this will help you have an easy start.

Thanks,
Dragos
6  Announcements and General Discussion / Architecture / Re: Implementing Undoable commands in PureMVC on: January 08, 2008, 09:00:32
Hi Justin

In this case I will gladly commit the library for the command history today or tomorrow. Or if faster, I could email a zip to you.
I have been into the winter holiday until yesterday and didn't have the chance to make any commit in this time.

I wish you all a Happy New Year with this ocasion  :) !

Dragos
7  Announcements and General Discussion / Architecture / Re: External swf uses PureMVC framework ontop of existing framework. on: December 11, 2007, 09:52:46
Hi Ty !

Loading the swf into a new ApplicationDomain should create distinct ApplicationFacades for each swf. Is that what you were looking for ?

Dragos
8  Announcements and General Discussion / Architecture / Re: External swf uses PureMVC framework ontop of existing framework. on: December 11, 2007, 04:28:07
Hi Ty,
Are you working with modules ?

The ApplicationDomain should actually create two instances of ApplicationFacade for each swf you're loading. Did you try compiling the swf that you're loading, excluding the common classes ?

If you're interested to find more information about how flash player manages individual swfs you can review this link: http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000327.html

Dragos
9  Announcements and General Discussion / Architecture / Re: Implementing Undoable commands in PureMVC on: December 03, 2007, 05:46:38
Hi Cliff,

Your idea about making a Photoshop history panel sounds interesting and I would like to put some time aside for this, to shape it into an official demo. I can prepare something in the next two weeks . Just send me SVN credentials and I’ll post the project in there.

Dragos
10  Announcements and General Discussion / Architecture / Re: Implementing Undoable commands in PureMVC on: November 30, 2007, 05:05:45
Hi,

I got inspired from your ideas and I thought I should post mine, just to continue the discussion you initiated. These days I had to implement an undo/redo system into an application and this is how I did it:

1.   I created an UndoableCommandBase class that extends SimpleCommand. UndoableCommandBase is a superclass for any command within the application that must be undoable. I added 4 more methods.
a.   registerUndoCommand – registers the command that needs to be called on undo

:
/**
* Registers the undo command
* @param cmdClass The class to be executed on undo
*/
public function registerUndoCommand( cmdClass:Class ):void
{
undoCmdClass = cmdClass;
}

b.   executeCommand – method that needs to be overridden in the sub class

:
/**
* This method must be overridden in the super class.
* Post here the code the be executed by the command.
*/
public function executeCommand():void
{
throw new Error("The undoable command does not have 'executeCommand' method implemented.");
}

c.   redo – recalls executeCommand
:
public function redo():void
{
executeCommand();
}

d.   undo – creates an instance of the undoCommand (registered at point 1) and executes it

:
public function undo():void
{
if ( undoCmdClass == null )
throw new Error("Undo command not set. Could not undo. Use 'registerUndoCommand' to register an undo command");

/** The type of the notification is used as a flag,
* indicating whether to save the command into the history, or not.
* The undo command, should not be recorded into the history,
* and its notification type is set to <code>UndoableCommandEnum.NON_RECORDABLE_COMMAND</code>
**/
var oldType:String = _note.getType();
_note.setType( UndoableCommandEnum.NON_RECORDABLE_COMMAND );

try
{
var commandInstance : ICommand = new undoCmdClass();
commandInstance.execute( _note );
}
catch ( err:Error )
{
trace("Could not call undo on " + this + ". " + err.getStackTrace() );
}

_note.setType( oldType );
}

e.   execute – this method saves the command into the history and calls executeCommand method

:
/**
* Saves the command into the CommandHistoryProxy class
* ( if <code>note.getType() == UndoableCommandEnum.RECORDABLE_COMMAND</code> )
* and calls the <code>executeCommand</code> method.
*
* @param note The Notification instance
*/
override public function execute(note:INotification):void
{
_note = note;

executeCommand();

if ( note.getType() == UndoableCommandEnum.RECORDABLE_COMMAND )
{
var historyProxy:CommandHistoryProxy = facade.retrieveProxy( CommandHistoryProxy.NAME ) as CommandHistoryProxy;
historyProxy.putCommand( this );
}
}

2.   I created command classes by extending UndoableCommandBase with 2 methods:

a.   override public function execute(note:INotification) -  that calls the super.execute( note ) in order to record the command into the history, and calls registerUndoCommand in order to save the command that will be used for undo
b.   override public function executeCommand()- method that actually does what is needed inside the command

Here is a sample of how the class looks like :

:
public class AddItemCommand extends UndoableCommandBase
{
override public function execute(note:INotification):void
{
super.execute( note );
registerUndoCommand( RemoveItemCommand );
}

override public function executeCommand():void
{
var itemsProxy:ItemsProxy = facade.retrieveProxy( ItemsProxy.NAME ) as ItemsProxy;
itemsProxy.addItem( _note.getBody() as ItemVO );
}

}

If you have better ideas I’m looking forward in seeing them. Also, for people that are interested in this solution, I can share the sources of a sample application.

Dragos

PS- Cliff, thanks for sharing with us your work. I discovered pureMVC 2 weeks ago and I already started to use it with my entire team. We’re very exited of this “world”. We’re hoping to have a better scalable and maintainable product at the end, using your solution.
Pages: [1]