-
-
Save cgrand/7638887 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
(require '[ccw.util.e4 :as e4]) | |
;; e is anything that can reach an IEclipseContext. Extend protocol e4/HasContext | |
;; to your type: | |
;(defprotocol HasContext | |
; "Protocol for retrieving the associated IEclipseContext for objects | |
; for which this makes sense." | |
; (-context [o] "Return the context for o, or nil")) | |
(def cmd-id "hello-6") | |
; create a Command model object | |
(def command (e4/make-command | |
e | |
{:element-id cmd-id | |
:name "Run Generic Leiningen task" | |
:category "org.eclipse.ui.category.window"})) | |
; add the command to the Application model | |
(e4/add-command e command) | |
; create a Handler model object | |
; e4/make-handler takes care of resolving cmd-id into the application command | |
; object (the command must have been added to the application model first) | |
; contribution-URI protocol has been extended to clojure via the org.eclipse.languages extension point | |
(def handler (e4/make-handler | |
e | |
{:command cmd-id | |
:contribution-URI "bundleclass://ccw.core/clojure/ccw.leiningen.generic-launcher/prompt"})) | |
; add the handler to the Application model | |
(e4/add-handler e handler) | |
; execute the command | |
(e4/execute-command e cmd-id) | |
;; | |
;; Rough ideas of ways to create Application model additions declaratively | |
;; | |
;; here we declare additional parts of the model only | |
{:app {:commands [{:element-id cmd-id | |
:name "Run Generic Leiningen task" | |
:category "org.eclipse.ui.category.window"}] | |
:handlers [{:command cmd-id | |
:contribution-URI "bundleclass://ccw.core/clojure/ccw.leiningen.generic-launcher/prompt"}]}} | |
;; here an idea to handle additions or deletions | |
{:app {:commands {:+ [{:element-id cmd-id | |
:name "Run Generic Leiningen task" | |
:category "org.eclipse.ui.category.window"}]} | |
:handlers {:+ [{:command cmd-id | |
:contribution-URI "bundleclass://ccw.core/clojure/ccw.leiningen.generic-launcher/prompt"}]}}} | |
;; proposal to remove eclipse-linguo when you don't need/want it: | |
{:app [; declare a command | |
{:cmd cmd-id | |
:name "Run Generic Leiningen task" | |
:category "org.eclipse.ui.category.window"} | |
; declare a handler | |
{:cmd cmd-id | |
:contribution-URI "bundleclass://ccw.core/clojure/ccw.leiningen.generic-launcher/prompt"} | |
; do both at once | |
{:cmd cmd-id ; optional, when optional you can retrieve it from the return value of add... | |
:name "Run Generic Leiningen task" | |
:category "org.eclipse.ui.category.window" | |
:contribution-URI "bundleclass://ccw.core/clojure/ccw.leiningen.generic-launcher/prompt"}]) | |
;; TODO: create a higher-level functions using make-xxx/add-xxx that do either | |
;; add or update according on the identifiers | |
;; TODO: low-level functions to remove things from the model | |
;; TODO: higher-level functions to "cleanup" the model after messings from the | |
;; REPL : idea = use the ability to Tag the model elements: tag them with | |
;; ccw.util.e4 for instance | |
;; TODO: use ASM to generate Behavioral / Dependency Injection classes on the fly | |
;; TODO: experiment with creating Parts / Views as well, leveraging all the above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment