Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(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}]
(def ~name (merge
{:element-id ~(str *ns* "/" (ns-name name))}
(set! *fragment*
(update-in [:commands]
(fnil conj []) ~name))))
(defmacro defhandler [name command & body]
(defn ~name ~@body)
(set! *fragment*
(update-in [:handlers]
(fnil conj [])
~(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