Begin of new Controller Generator.
This commit is contained in:
parent
cd5d092ed3
commit
733dad8048
3 changed files with 28 additions and 14 deletions
|
@ -4,6 +4,7 @@
|
|||
:url "https://www.bitbucket.org/zilti/clojurefx"
|
||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
||||
[swiss-arrows "1.0.0"]
|
||||
[org.controlsfx/controlsfx "8.40.13"]
|
||||
[com.taoensso/timbre "4.7.4" :exclusions [com.taoensso/carmine]]
|
||||
[clojure-jsr-223 "0.1.0"]]
|
||||
;; :profiles {:uberjar {:aot :all}}
|
||||
|
|
|
@ -35,26 +35,23 @@
|
|||
~@code))))
|
||||
|
||||
(defn branch? [obj]
|
||||
(or (instance? javafx.scene.Parent obj)
|
||||
(or (and (instance? javafx.scene.Parent obj)
|
||||
(not (instance? org.controlsfx.control.StatusBar obj)))
|
||||
(instance? javafx.scene.control.MenuBar obj)
|
||||
(instance? javafx.scene.control.Menu obj)))
|
||||
|
||||
(defn make-node [node children]
|
||||
nil)
|
||||
|
||||
(defmulti down (fn [x] (class x)))
|
||||
(defmethod down javafx.scene.Parent [obj]
|
||||
(.getChildren obj))
|
||||
(defmethod down javafx.scene.control.MenuBar [obj]
|
||||
(.getMenus obj))
|
||||
(defmethod down javafx.scene.control.Menu [obj]
|
||||
(.getItems obj))
|
||||
(defmethod down javafx.scene.control.Label [obj]
|
||||
[(.getGraphic obj)])
|
||||
(defmethod down javafx.scene.control.ProgressIndicator [obj]
|
||||
[(.getContextMenu obj)])
|
||||
(defmethod down :default [obj]
|
||||
nil)
|
||||
(defn down [x]
|
||||
(cond
|
||||
(instance? javafx.scene.control.Label x) (.getGraphic x)
|
||||
(instance? javafx.scene.control.ProgressIndicator x) (.getContextMenu x)
|
||||
(instance? javafx.scene.control.ScrollPane x) (.getContent x)
|
||||
(instance? javafx.scene.control.MenuBar x) (.getMenus x)
|
||||
(instance? javafx.scene.control.Menu x) (.getItems x)
|
||||
(instance? javafx.scene.Parent x) (.getChildren x)
|
||||
:else nil))
|
||||
|
||||
(defn sgzipper [root]
|
||||
(zip/zipper branch? down make-node root))
|
||||
|
|
16
src/clojurefx/controllergen.clj
Normal file
16
src/clojurefx/controllergen.clj
Normal file
|
@ -0,0 +1,16 @@
|
|||
(ns clojurefx.controllergen
|
||||
(:require [clojure.xml :as xml]
|
||||
[clojure.zip :as zip]
|
||||
[taoensso.timbre :as timbre]))
|
||||
(timbre/refer-timbre)
|
||||
|
||||
(def xmlzip (zip/xml-zip (xml/parse "/Users/danielziltener/projects/lizenztool/resources/fxml/mainwindow.fxml")))
|
||||
|
||||
(defn get-fxid-elems
|
||||
([ziptree] (get-fxid-elems ziptree []))
|
||||
([ziptree elems]
|
||||
(cond
|
||||
(zip/end? ziptree) (do (debug "End reached, returning.") elems)
|
||||
(contains? (:attrs (zip/node ziptree)) :fx:id) (do (debug "Found a match!\n" (zip/node ziptree))
|
||||
(recur (zip/next ziptree) (conj elems (zip/node ziptree))))
|
||||
:else (do (debug "No match, continuing:" (zip/node ziptree)) (recur (zip/next ziptree) elems)))))
|
Loading…
Reference in a new issue