-
-
Save cgrand/7693118 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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)) |
This file contains hidden or 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
(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