JavaHelp for Clojure

To get everything working in clojure a few modifications need to be performed. First in project.clj you must add javahelp as a dependency, and indicate the resource path where you will store the helpset. By default leinengen will create a MyProject/resources directory and I placed my helpset in a subdirectory there:

project.clj
1
2
3
4
5
6

:dependencies [[org.clojure/clojure "1.8.0"]
[javax.help/javahelp "2.0.05"]]

:resource-paths ["resources"]

In core I only show some of the required namespace additions and the menu entries.

core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

(:require [clojure.java.io :as io] )
(:import [java.net.URL])


;; this is the Help item on my menubar
(menu :text "Help"
:halign :right
:items [(action :handler (fn [e]
(let [helpURL (io/resource "helpset/pmhelp.hs")
hs (new javax.help.HelpSet nil helpURL)
hb (. hs createHelpBroker)
dummy (. hb setCurrentID "assaytype")
dummy2 (. hb setDisplayed true)]))
:name "Help"
:key "menu H"
:tip "Launch help app.")

I have 2 dummy variables in there so I can use the let expression, but I could rearrange using doto:

core.clj
1
2
3
4
5
6
7
8
9

(menu :text "Help"
:halign :right
:items [(action :handler (fn [e]
(doto (.createHelpBroker (new javax.help.HelpSet nil (io/resource "helpset/pmhelp.hs") ))
(.setCurrentID "assaytype")(.setDisplayed true)))
:name "Help"
:key "menu H"
:tip "Launch help app.")

I prefer the let method. Though it has those messy dummy variables, I can more clearly decipher what is going on.
Code available on github

Share