Beautifying JavaFX Script From NetBeans Using AutoIt
Join the DZone community and get the full member experience.
Join For Freenetbeans is the official ide for javafx development. however, the latest v6.71 (or beta 6.8) of netbeans is unable to beautify javafx script (jfxscript) code as the “format” option is not working (it just do nothing. see bug acknowledgement ).
editors note: this content was submitted by geekycoder
the code beautifier is one of the most important tools for learning and using javafx as most raw code copied from internet/ebook tends to be unformatted, making it hard to read and use. performing manual format is just too tedious. so until the next netbeans’s release, users have to resort to using painstakingly manual code formatting .
code beautifier turn this (the following jfxscript code is formatted in netbeans ! read on to see how it’s done.)
into this
introducing autoit script
autoit script
is a productive and powerful
free
windows automation utility with scripting capability using a simple
easy-to-use basic variant language. now with autoit script, users no
longer have to sweat the formatting stuff.
watch how autoit script perform its magic.
autoit script accomplishes it in just seconds.
how it works
the javascript code beautifier in netbeans is surprisingly able to format the jfxscript code extremely well. therefore, autoit script leverages on this “discovered” capability to automate the formatting by copying the jfxscript code to a opened javascript file for beautifying, and then replace original code. this is all done through keystroke simulation, and takes just few seconds. with netbeans’s undo feature, you can also undo the formatting instantly.
instructions
the following download includes the source code, dummy file and 32bit executable compiled script. if you need to run in 64bit, you need to download the autoit environment to either recompile the source or run the source with autoit interpreter.
please perform the important steps before using the script.
important #1:
you need to keymap the <open file> menu item to <ctrl+f10> keys.
go to:
important #2:
create a empty file called dummy.js or
copy one from the following zip file into <c:\temp> dir. this
dummy file is used as a proxy to format code.
you can customize the keymap keys and dummy file through the script source from the following lines:
local $keybeautify = "^{f2}" ; default to ctnl + f2
local $keyopenfile = "^{f10}" ; open file, default to ctnl + f10
local $dummyjsfile = "c:\temp\dummy.js" ; dummy js file
if you experience some problems making it work, play around with the delay. increase the delay in the sleep function (eg sleep(330) ). the argument is in millisec.
unzip the following file and run < netbeans_beautify_jfxscript.exe >
the autoit trayicon (blue a icon) will appear. now you can go to netbeans source code editor and invoke <ctnl+f2> to format the jfxscript code !
to exit, click on the icon again and choose exit.
contents of file:
Opinions expressed by DZone contributors are their own.
Comments