Permalink
Browse files

WIP : generic lein + scriptable ccw

  • Loading branch information...
1 parent a9020e8 commit e2a24c86aa55da74506b31de82b1d4c56cf3c690 @laurentpetit laurentpetit committed Dec 13, 2012
View
@@ -0,0 +1,37 @@
+(ccw.util.bundle/set-bundle-classloader! "ccw.core")
+(require '[ccw.util.eclipse :as e])
+;(require '[ccw.leiningen.launch :as launch])
+
+(defn hello-world [ _ ]
+ (e/info-dialog "Test" "Hello, world 7"))
+
+#_(e/define-command! {
+ :id :hello1
+ :name "hello1"
+ :handler #'hello-world})
+
+(require '[ccw.util.bundle :as b])
+(b/add-command!
+ (b/bundle "ccw.core")
+ {"id" "hello7" "name" "HELLO 7"})
+
+(e/define-handler! {
+ :command-id :hello7
+ :fn #'hello-world})
+
+(e/ui
+ (e/save-key-binding!
+ (e/key-binding {
+ :key-sequence "COMMAND+D"
+ :command :hello7
+ :context-id :ccw.ui.clojureEditorScope})))
+
+#_(defn launch-lein [e]
+ (e/info-dialog "Launching leiningen" "Launching lein2")
+ #_(launch/lein "paredit.clj" "classpath"))
+
+#_(e/define-command! {
+ :id :lein,
+ :name "Run arbitrary Leiningen command"
+ :handler #'launch-lein})
+
@@ -0,0 +1,24 @@
+(ns ccw.leiningen.launch
+ ;(:require [ccw.util.launch :as launch])
+ (require [ccw.util.eclipse :as e]))
+
+(alias 'launch 'ccw.util.launch)
+
+(defn lein [project command]
+ (let [launch {
+ :private true
+ :java/project-name (e/project-name project)
+ :java/classpath [{:entry-type :archive
+ :path "/Users/laurentpetit/.lein/self-installs/leiningen-2.0.0-preview10-standalone.jar"}
+ {:entry-type :jre-container
+ :name launch/default-jre-container-name}]
+ :java/default-classpath false
+ :java/vm-arguments (str " -Dfile.encoding=UTF-8"
+ " -Dmaven.wagon.http.ssl.easy=false"
+ " -Dleiningen.original.pwd=\"/Users/laurentpetit/tmp\"")
+ :java/main-type-name "clojure.main"
+ :java/program-arguments (str "-m leiningen.core.main " command)
+ }]
+ (launch/run launch)))
+
+
@@ -7,7 +7,8 @@
org.osgi.framework.Bundle
org.osgi.framework.Version
org.osgi.framework.BundleException
- clojure.osgi.ClojureOSGi))
+ clojure.osgi.ClojureOSGi)
+ (:require [clojure.xml :as xml]))
;(defn require-and-get-var)
; public static Var requireAndGetVar(String bundleSymbolicName, String varName) throws CoreException {
@@ -109,14 +110,33 @@
(run [this] (f)))))
;; http://www.ibm.com/developerworks/opensource/library/os-ecl-dynext/
-(defn add-contribution [s bundle]
+(defn add-contribution! [s bundle]
(let [registry (org.eclipse.core.runtime.RegistryFactory/getRegistry)
key (.getTemporaryUserToken registry)
contributor (org.eclipse.core.runtime.ContributorFactoryOSGi/createContributor bundle)
is (java.io.ByteArrayInputStream. (.getBytes s))]
(.addContribution registry is contributor false nil nil key)))
-;(ccw.util.bundle-utils/add-contribution
+(defn xml-map->extension [ext-map]
+ (let [m {:tag "plugin" :content [ext-map]}]
+ (with-out-str (xml/emit-element m))))
+
+(defn add-command! [bundle command-attrs]
+ (let [ext-str (xml-map->extension
+ {:tag "extension"
+ :attrs {:point "org.eclipse.ui.commands"}
+ :content [{:tag "command"
+ :attrs command-attrs}]})]
+ (add-contribution! ext-str bundle)))
+
+(defn add-menu! [bundle menu-contribution]
+ (let [ext-str (xml-map->extension
+ {:tag "extension"
+ :attrs {:point "org.eclipse.ui.menus"}
+ :content [menu-contribution]})]
+ (add-contribution! ext-str bundle)))
+
+;(ccw.util.bundle/add-contribution!
; "
; <plugin>
; <extension
@@ -134,7 +154,7 @@
; "
; b)
-;(ccw.util.bundle-utils/add-contribution
+;(ccw.util.bundle/add-contribution!
; "
; <plugin>
; <extension
@@ -150,7 +170,9 @@
; "
; b)
-;(ccw.util.bundle-utils/add-contribution
+
+
+;(ccw.util.bundle/add-contribution!
; "
; <plugin>
; <extension
@@ -188,7 +210,7 @@
-;(ccw.util.bundle-utils/add-contribution
+;(ccw.util.bundle/add-contribution!
; "
;<plugin>
;<extension
Oops, something went wrong.

0 comments on commit e2a24c8

Please sign in to comment.