For such a simple action I'd just use a JavaScript instead of a java Action.
Install the JavaScript addon from googlecode or github (newer version) And just write your Javascript code according the api and run it in runtime in the console to test your code.