Last active
December 29, 2015 15:48
-
-
Save laurentpetit/7692696 to your computer and use it in GitHub Desktop.
place script.clj in ~/.ccw
This file contains 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")) | |
(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"}]}} |
This file contains 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")) | |
(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"}]}} |
This file contains 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
(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 |
This file contains 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] | |
[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