GitXplorerGitXplorer
t

robotlegs-utilities-UndoableCommand

public
24 stars
6 forks
0 issues

Commits

List of commits on branch master.
Unverified
5c220ac70cef2225fd4e1ca21f29fac148fef506

fix linky

ttimoxley committed 12 years ago
Unverified
377e219d037864fbd40369dd77ea2df224bb1dd0

Deprecated!

ttimoxley committed 12 years ago
Unverified
dabe8b10d02e673aba28951099a419ee7d40f8dd

Update to remove potentially offensive comment in light of https://github.com/felixge/nodeguide.com/pull/15

ttimoxley committed 13 years ago
Unverified
b99381c26dc6732fc418846708bfef46dd84a6e9

Added MIT license

ttimoxley committed 14 years ago
Unverified
52703e19884ccf2ea90f032eb50b5fd936c5013a

Updated Readme

ttimoxley committed 14 years ago
Unverified
df4e71d8be556fb1b482917ba4e4e36021dab64b

Updated comments, made minor changes and updated docs

ttimoxley committed 14 years ago

README

The README file for this repository.

h1. Undoable Commands and History Controller for the Robotlegs Framework

Undoable Commands aims to provide the most useful functions you'd need for undo/redo functionality in a gui app. I've successfully used in on a number of private projects.

h2. Ddddddeprecated!

Great news everyone! After years of inactivity (sadly, I no longer work on the Flash platform), UndoableCommand development continues courteousy of d3zza on his fork: "d3zza/robotlegs-utilities-UndoableCommand":https://github.com/d3zza/robotlegs-utilities-UndoableCommand. Check it out! Thanks d3zza!

h2. Features

  • Keeps a linear history of executed Commands
  • Undo/Redo
  • Rewind/Fast Forward history
  • Rewrite history
  • Cancellable commands
  • Gets the ladies and/or gents

h2. Important Classes

h3. UndoableCommandBase

Fairly barebones undoable command. You can use this with your own history controller or use the classes below to gain access to history control.

h3. CommandHistory

The history controller that provides the interface to move forward and backward through your command history.

h3. UndoableCommand

This command handles adding itself to a provided/injected CommandHistory object.

See the generated asdocs provided in the repository for more information

h2. Quickstart

  • Download the "latest release swc":http://github.com/secoif/robotlegs-utilities-UndoableCommand/downloads or feel free to download the source and compile for yourself, the test cases depend on FlexUnit4.

  • Include downloaded swc in your project

  • Create your command which extends UndoableCommand

  • Override the protected methods doExecute and undoExecute. doExecute should contain the code you want to execute when the command is fired. undoExecute should contain whatever code is needed to manually undo the actions performed by doExecute. The last line in both of these methods should be the call to super.doExecute()/undoExecute().

  • Put the following lines (+ necessary imports) into your Robotlegs context:

      // Create a CommandHistory to manages undo/redo history
      injector.mapSingleton(CommandHistory);
      // Events to trigger undo and redo
      commandMap.mapEvent(HistoryEvent.STEP_FORWARD, StepForwardCommand, HistoryEvent);
      commandMap.mapEvent(HistoryEvent.STEP_BACKWARD, StepBackwardCommand, HistoryEvent);
      
  • Map some event to the Command you created (just like you would with any normal robotlegs command)

  • Set a Button/Mediator to actually fire the HistoryEvent.STEP_FORWARD/BACKWARD events on the robotlegs event bus and you're done! :)

h4. Cancelling a Command

If you want to cancel a command you can call cancel() in your doExecute method and the command will not be added to the history stack (though you will have to ensure you don't actually make any changes to your data after you do this)

h4. TODO Implement a minimal linked list variation based on UndoableCommandBase with no history controller