GUI repl

119 views
Skip to first unread message

MikeM

unread,
Mar 30, 2008, 7:27:50 AM3/30/08
to Clojure
I'm posting a file, repl.clj, that implements a repl in a Swing GUI.

The GUI has a JTree (implementation based on Rich's inspector.clj)
that shows the currently loaded namespaces and allows the user to see
the original form text entered for each namespace entity. The repl
intercepts load-file and runs the load-file with its own eval function
so that the namespace tree is populated by the forms in the file
(caveat: If you try to load-file the repl.clj into the GUI repl, it
will crash). Single-clicking on an element in the tree puts the
original form in a text area under the tree. Double-clicking inserts
the original form text into the text area for editing and evaluation.

The text area for entering forms does paren, bracket, and brace
highlighting.

The repl can be run with the Script class or started from the standard
repl using load-file. It's all Clojure, no additional Java classes
needed.

Hope others find this interesting and/or useful, please let me know if
you have any comments on the code.

Adam Jones

unread,
Mar 30, 2008, 3:37:19 PM3/30/08
to Clojure
It looks like google lost your file ... or I'm missing something
obvious. Try again?

-Adam

Adam Jones

unread,
Mar 30, 2008, 3:49:11 PM3/30/08
to Clojure
Nevermind that, I found it. Looks interesting.

Robert Feldt

unread,
Mar 30, 2008, 3:59:34 PM3/30/08
to Clojure
Hmm,I guess there is something wrong with my Java setup but on an
updated Mac OSX Leopard I can't run your gui repl while other Swing
apps runs without problems:

robert_feldt:~/local/clojure/external$ clj gui-repl.clj
java.lang.ClassNotFoundException: javax.swing.GroupLayout
at
clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:46)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
374)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at clojure.fns.clojure.import__401.doInvoke(boot.clj:1270)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2376)
at clojure.lang.Compiler.eval(Compiler.java:3385)
at clojure.lang.Compiler.load(Compiler.java:3634)
at clojure.lang.Compiler.loadFile(Compiler.java:3607)
at clojure.lang.Script.main(Script.java:29)
robert_feldt:~/local/clojure/external$ java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-
b05-237)
Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)
robert_feldt:~/local/clojure/external$ set | grep CLASSPATH
CLASSPATH=.:/Users/robert_feldt/local/java_classpath/
processing_core.jar:/Users/robert_feldt/local/jogl-1.1.1-rc8-macosx-
universal/lib/gluegen.jar:/Users/robert_feldt/local/jogl-1.1.1-rc8-
macosx-universal/lib/jogl.jar

/Robert Feldt

MikeM

unread,
Mar 30, 2008, 4:44:25 PM3/30/08
to Clojure
GroupLayout was added with JDK 6, so it's not in your java version. Is
JDK 6 available for the Mac? I remember reading that it wasn't
available for a while, don't know if that's changed.

Robert Feldt

unread,
Mar 30, 2008, 5:51:00 PM3/30/08
to Clojure


On Mar 30, 10:44 pm, MikeM <michael.messini...@invista.com> wrote:
> GroupLayout was added with JDK 6, so it's not in your java version. Is
> JDK 6 available for the Mac? I remember reading that it wasn't
> available for a while, don't know if that's changed.

Ah, thanks, that was it. I installed the Java SE 6 dev preview from
Apple and it now works.

Nice!

/Robert

MikeM

unread,
Mar 31, 2008, 8:42:10 PM3/31/08
to Clojure
I've uploaded a new version of the GUI repl. I changed the layout to
allow for resizing of the text areas, also eliminated GroupLayout, so
it should run under java 1.5.

Rich Hickey

unread,
Apr 1, 2008, 8:03:45 AM4/1/08
to Clojure
Neat!

I needed to get rid of the imports for GroupLayout and GroupLayout
$Alignment, and comment out the let of LEADING, but then it worked for
me on java 1.5/OS X.

Rich

MikeM

unread,
Apr 1, 2008, 9:08:48 AM4/1/08
to Clojure
Thanks. I updated with your changes and uploaded to the group files.
Reply all
Reply to author
Forward
0 new messages