Last active
December 15, 2015 15:59
-
-
Save dscho/5286408 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Command_Launcher.clj starts here | |
(import '(java.awt Color) | |
'(java.awt.event TextListener) | |
'(ij.gui GenericDialog) | |
'(ij IJ) | |
'(ij Menus)) | |
(let [commands (keys (. Menus getCommands)) | |
gd (GenericDialog. "Command Launcher")] | |
(.addStringField gd "Command: " "") | |
(let [prompt (. (. gd getStringFields) get 0)] | |
(doto prompt | |
(.setForeground (. Color red)) | |
(.addTextListener (proxy [TextListener] [] | |
(textValueChanged [tvc] | |
(let [text (.getText prompt)] | |
(.setForeground prompt | |
(if (some #{text} commands) | |
(. Color black) | |
(. Color red))))))))) | |
(.showDialog gd) | |
(when-not (.wasCanceled gd) | |
(IJ/doCommand (.getNextString gd)))) | |
;; end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment