Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
March 30, 2017, 03:48:26 AM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.
Pages: [1]
Print
Author Topic: Usage of Undo Utility  (Read 4873 times)
openoli
Full Member
***
Posts: 42


View Profile
« on: February 01, 2016, 07:05:19 AM »

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
Logged
openoli
Full Member
***
Posts: 42


View Profile
« Reply #1 on: February 03, 2016, 02:08:26 AM »

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
Logged
openoli
Full Member
***
Posts: 42


View Profile
« Reply #2 on: February 03, 2016, 02:53:17 AM »

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

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


UndoableCommandBase.undo():
Code:
/**
* 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
« Last Edit: February 03, 2016, 03:08:14 AM by openoli » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2860



View Profile WWW
« Reply #3 on: February 03, 2016, 02:56:31 PM »

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>
Logged
openoli
Full Member
***
Posts: 42


View Profile
« Reply #4 on: February 04, 2016, 12:02:37 PM »

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

« Last Edit: February 04, 2016, 12:19:25 PM by openoli » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2860



View Profile WWW
« Reply #5 on: February 14, 2016, 09:26:04 AM »

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>
Logged
openoli
Full Member
***
Posts: 42


View Profile
« Reply #6 on: February 14, 2016, 11:27:21 PM »

Thanks Cliff, I will check it out.
Olaf
Logged
openoli
Full Member
***
Posts: 42


View Profile
« Reply #7 on: March 21, 2016, 08:26:50 AM »

>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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2860



View Profile WWW
« Reply #8 on: March 23, 2016, 07:29:01 AM »

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>
Logged
openoli
Full Member
***
Posts: 42


View Profile
« Reply #9 on: April 04, 2016, 01:02:26 AM »

Quote
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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2860



View Profile WWW
« Reply #10 on: April 05, 2016, 08:04:17 AM »

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.
Logged
openoli
Full Member
***
Posts: 42


View Profile
« Reply #11 on: August 12, 2016, 01:03:15 AM »

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
Logged
Pages: [1]
Print
Jump to: