Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
place script.clj in ~/.ccw
(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"))
(defn handler-factory [context] (ccw.util.GenericHandler. #'greet))
;; last form of the script is an application model fragment to be merged into the Application Model
{:fragment-id "lein-script-test"
:commands [{:element-id "lein-script-test/commands/greeter"
:command-name "Greetings from CCW"
:category "org.eclipse.ui.category.window"}]
:handlers [{:command "lein-script-test/commands/greeter"
:contribution-URI "bundleclass://ccw.core/clojure/lein-script-test/handler-factory"}]}}
(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"))
(defn handler-factory [context] (ccw.util.GenericHandler. #'greet))
(defn run []
{:fragment-id "lein-script-test"
:commands [{:element-id "lein-script-test/commands/greeter"
:command-name "Greetings from CCW"
:category "org.eclipse.ui.category.window"}]
:handlers [{:command "lein-script-test/commands/greeter"
:contribution-URI "bundleclass://ccw.core/clojure/lein-script-test/handler-factory"}]}}
(require '[ccw.util.eclipse :as e])
(defn greet [context]
(e/info-dialog "Hello world"
"This popup provided to you from a user script"))
{:commands [{:command-name "Greetings from CCW"
:handler #'greet}]}
; fragment-id is derived from script path: will be stable for a given installation
; commands with a single general handler have simplified :handler key
; :handler key instead of contributor-URI which will be automatically created "bundleclass://ccw.core/clojure/lein-script-test/handler-factory"
; command element-id can be omitted in which case it will be a random GUID
; :category will be "org.eclipse.ui.category.window" by default
(ns lein-script-test
(:require [ccw.util.eclipse :as e]
[ccw.util.e4.model :as m]))
(defn greet [context]
(e/info-dialog "Hello world"
"This popup provided to you from a user script"))
(defn handler-factory [context] (ccw.util.GenericHandler. #'greet))
(let [app @m/app
cmd-id "c9"
command (m/make-command
app
{:element-id "lein-script-test/commands/greeter"
:command-name "Greetings from CCW"
:category "org.eclipse.ui.category.window"})
handler (m/make-handler
app
{:command command
:contribution-URI "bundleclass://ccw.core/clojure/lein-script-test/handler-factory"})]
(-> app (m/add-command! command) (m/add-handler! handler)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.