Skip to content

Instantly share code, notes, and snippets.

@cgrand
Forked from laurentpetit/lein-script-test.clj
Last active December 29, 2015 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgrand/7693118 to your computer and use it in GitHub Desktop.
Save cgrand/7693118 to your computer and use it in GitHub Desktop.
(ns lein-script-test
(:require [ccw.util.eclipse :as e]))
(defn greet [context]
(e/info-dialog "Hello world"
"This popup provided to you from a user script"))
;; these two def* build the fragment using the provided symbol and the current ns
(defcommand greeter
:command-name "Greetings from CCW"
:category "org.eclipse.ui.category.window")
(defhandler handler-factory :for greeter
[context] (ccw.util.GenericHandler. #'greet))
(defmacro defcommand [name & {:as opts}]
`(do
(def ~name (merge
{:element-id ~(str *ns* "/" (ns-name name))}
~opts))
(set! *fragment*
(update-in [:commands]
(fnil conj []) ~name))))
(defmacro defhandler [name command & body]
`(do
(defn ~name ~@body)
(set! *fragment*
(update-in [:handlers]
(fnil conj [])
{:contribution-URI
~(str "bundleclass://ccw.core/clojure/"
(ns-name *ns*) "/" name)
:command (:element-id ~command)}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment