PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: openoli on February 01, 2016, 07:05:19



Title: Usage of Undo Utility
Post by: openoli on February 01, 2016, 07:05:19
Hi,
I've just stumpled over the "Undo Utility" and took a quick look inside it.
To get it work, is the only thing to take care of the extension of the "UndoableCommandBase" for undoable commands?

If I'd like to use it with multicore, is it sufficient to replace the libs standard imports by the multicore ones?

Thanks for help,
Olaf


Title: Re: Usage of Undo Utility
Post by: openoli on February 03, 2016, 02:08:26
I've just replaced the standard imports by the multicore ones and it seems that it just work!
I'll test it a bit more and will publish the multicore version of the "Undo Utility" at github next days.

Thanks,
Olaf


Title: Re: Usage of Undo Utility
Post by: openoli on February 03, 2016, 02:53:17
Ups, I was a bit overhastly. The undo does nothing using the multicore version.
After taking a look at the code I found that (for comprehensible reasons) the multitonKey is empty after instantiating the command that has to be undone. But it's crucial to have a valid multitonKey here.
So i tried to pass it using the "initializeNotifier(multitonKey)" method and it seems that it works now.

Olaf

:
// Inject the multitonKey
commandInstance.initializeNotifier(multitonKey);


UndoableCommandBase.undo():
:
/**
* Calls the undo command setting its note type to
* <code>UndoableCommandTypeEnum.NON_RECORDABLE_COMMAND</code> so that it won't get recorded into the history
* since it is already in the history
*/
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 wheather to save the command into the history, or not.
* The undo command, shold 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( UndoableCommandTypeEnum.NON_RECORDABLE_COMMAND );

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

_note.setType( oldType );
}

Olaf


Title: Re: Usage of Undo Utility
Post by: puremvc on February 03, 2016, 02:56:31
Hi Olaf,

Right. This utility unfortunately hasn't been ported to Multicore. However, it shouldn't be much of a problem to do that. To do this properly all you'd need to do is change the imports. If you are of a mind to do so, I'd be happy to create the GitHub repo and all that for the Multicore version.

Cheers,
-=Cliff>


Title: Re: Usage of Undo Utility
Post by: openoli on February 04, 2016, 12:02:37
Hi Cliff,
I've already done the port to Multicore.
Additionally to the changing of the imports, I've had to inject the multitonKey at one place to get it work.
(See my post above).
Don't know if this is a proper way but it seems that it works. I'll test it a bit next days.

And yes, it would be great if you could create the GitHub repo!
I could create a pull request to this new repo that would contain all the files so that you could get it with less effort.

Olaf



Title: Re: Usage of Undo Utility
Post by: puremvc on February 14, 2016, 09:26:04
Hi Olaf,

If you create a pull request, please have a look at https://github.com/PureMVC/puremvc-as3-util-statemachine which has both a standard and multicore version in the same repo. If you can make the project structure similar, it will be helpful.

Cheers,
-=Cliff>


Title: Re: Usage of Undo Utility
Post by: openoli on February 14, 2016, 11:27:21
Thanks Cliff, I will check it out.
Olaf


Title: Re: Usage of Undo Utility
Post by: openoli on March 21, 2016, 08:26:50
>please have a look at https://github.com/PureMVC/puremvc-as3-util-statemachine which has both a >standard and multicore version in the same repo

Do you merged the standard and multicore version manually to one repo or is there a way of having both in one (FlashBuilder) project?

Thanks,
Olaf


Title: Re: Usage of Undo Utility
Post by: puremvc on March 23, 2016, 07:29:01
No, you can only use multicore version in a multicore project, and standard in standard. The project just contains the source of both.

Cheers,
-=Cliff>


Title: Re: Usage of Undo Utility
Post by: openoli on April 04, 2016, 01:02:26
No, you can only use multicore version in a multicore project, and standard in standard. The project just contains the source of both.

Yes for sure ;-)
I was wonder merely if there's a tricky way to put both into one FB project with the only goal to push it directly to the github repo without the need of merging it manually.
But at the end it's probably more effort to discuss this here instead of just doing to it ;-)

Thanks,
Olaf


Title: Re: Usage of Undo Utility
Post by: puremvc on April 05, 2016, 08:04:17
I would say clone the repo with the standard version and add a multicore tree. You should be able to temporarily change the library project settings to point to the muliticore sources and compile a swc. As I recall that was the way i had to do the statemachine swcs.


Title: Re: Usage of Undo Utility
Post by: openoli on August 12, 2016, 01:03:15
Sorry for not providing the "Undo Multicore" version until now.
As soon as I'm finished the work on a "Undo Multicore" demo I'll do a pull request for the lib.

Olaf