From 8445c0d07a1e59fd7886d0c4a4610d841f136d17 Mon Sep 17 00:00:00 2001 From: "dziltener@lyrion.ch" Date: Wed, 28 Aug 2013 18:15:12 +0000 Subject: [PATCH] first commit --- .gitignore | 2 + .lein-repl-history | 12 ++ doc/intro.md | 3 + project.clj | 7 ++ src/clojurefx/core.clj | 116 ++++++++++++++++++ target/repl/repl-port | 1 + target/repl/stale/extract-native.dependencies | 1 + test/clojurefx/core_test.clj | 7 ++ 8 files changed, 149 insertions(+) create mode 100644 .lein-repl-history create mode 100644 doc/intro.md create mode 100644 project.clj create mode 100644 src/clojurefx/core.clj create mode 100644 target/repl/repl-port create mode 100644 target/repl/stale/extract-native.dependencies create mode 100644 test/clojurefx/core_test.clj diff --git a/.gitignore b/.gitignore index 40fbb28..ecfc575 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ pom.xml /classes/ /targets/ .lein-deps-sum +*~ +*class diff --git a/.lein-repl-history b/.lein-repl-history new file mode 100644 index 0000000..f62a770 --- /dev/null +++ b/.lein-repl-history @@ -0,0 +1,12 @@ +(def blahref '{a 1 b 2}) +(get blahref 'a) +(def x (symbol "abc")) +(def y (symbol "abc")) +(= x y) +(split "abc-def" #"-") +(use 'clojure.string) +(split "abc-def" #"-") +(first "bvc") +(apply str (list "abc" "Def")) +(cons (list 1 2 3) 4) +(quit) diff --git a/doc/intro.md b/doc/intro.md new file mode 100644 index 0000000..e968df1 --- /dev/null +++ b/doc/intro.md @@ -0,0 +1,3 @@ +# Introduction to clojurefx + +TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/) diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..8de286e --- /dev/null +++ b/project.clj @@ -0,0 +1,7 @@ +(defproject clojurefx "0.1.0-SNAPSHOT" + :description "FIXME: write description" + :url "http://example.com/FIXME" + :license {:name "Eclipse Public License" + :url "http://www.eclipse.org/legal/epl-v10.html"} + :dependencies [[org.clojure/clojure "1.5.1"] + [com.oracle/javafx-runtime "2.2.0"]]) diff --git a/src/clojurefx/core.clj b/src/clojurefx/core.clj new file mode 100644 index 0000000..87a9525 --- /dev/null +++ b/src/clojurefx/core.clj @@ -0,0 +1,116 @@ +(ns clojurefx.core + (:require [clojure.string :as str])) + +(defn run-later* + [f] + (javafx.application.Platform/runLater f)) + +(defmacro run-later + [& body] + `(run-later* (fn [] ~@body))) + +(defn run-now* + [f] + (let [result (promise)] + (run-later + (deliver result (try (f) (catch Throwable e e)))) + @result)) + +(defmacro run-now + [& body] + `(run-now* (fn [] ~@body))) + +(defn event-handler* + [f] + (reify javafx.event.EventHandler + (handle [this e] (f e)))) + +(defmacro event-handler [arg & body] + `(event-handler* (fn ~arg ~@body))) + +(def build-reference + '{accordion "javafx.scene.control" + + affine "javafx.scene.transform" + + anchor "javafx.scene.layout" + border-pane "javafx.scene.layout" + + arc "javafx.scene.shape" + arc-to "javafx.scene.shape" + + blend "javafx.scene.effect" + bloom "javafx.scene.effect" + box-blur "javafx.scene.effect" + + area-chart "javafx.scene.chart" + bar-chart "javafx.scene.chart" + bubble-chart "javafx.scene.chart" + axis "javafx.scene.chart" + + audio-clip "javafx.scene.media" + + bounding-box "javafx.geometry"}) + +(defn- camel [in] + (let [in (name in) + in (str/split in #"-") + in (map #(if (= (str (first %)) (str/upper-case (first %))) + % (str/capitalize %)) in) + in (conj (into [] in) "Builder")] + (apply str in))) + +(defn- get-qualified [builder] + (let [pkgs {"javafx.scene.control" '[accordion button cell check-box check-box-tree-item check-menu-item choice-box + color-picker combo-box context-menu custom-menu-item hyperlink + indexed-cell index-range label list-cell list-view menu-bar menu menu-button menu-item + pagination password-field popup-control progress-bar progress-indicator + radio-button radio-button-menu-item scroll-bar scroll-pane separator + separator-menu-item slider split-menu-button split-pane tab table-cell table-column + table-position table-row table-view tab-pane text-area text-field tree-cell + titled-pane toggle-button toggle-group tool-bar tooltip tree-item tree-view] + "javafx.scene.control.cell" '[check-box-list-cell check-box-table-cell check-box-tree-cell + choice-box-list-cell choice-box-table-cell choice-box-tree-cell + combo-box-list-cell combo-box-table-cell combo-box-tree-cell + text-field-list-cell text-field-table-cell text-field-tree-cell + property-value-factory] + "javafx.scene.layout" '[anchor border-pane column-constraints flow-pane grid-pane h-box pane region + row-constraints stack-pane tile-pane v-box] + "javafx.scene.text" '[text font] + "javafx.scene.shape" '[arc arc-to circle close-path cubic-curve cubic-curve-to ellipse + h-line-to line line-to move-to path polygon polyline quad-curve quad-curve-to + rectangle SVG-path b-line-to] + "javafx.scene.canvas" '[canvas] + "javafx.scene.image" '[image-view] + "javafx.scene.input" '[clipboard-content key-character-combination key-code-combination mnemonic] + "javafx.scene.effect" '[blend bloom box-blur color-adjust color-input displacement-map dropshadow float-map + gaussian-blur glow image-input inner-shadow lighting motion-blur perspective-transform + reflection sepia-tone shadow] + "javafx.scene.paint" '[color image-pattern linear-gradient radial-gradient stop] + "javafx.scene.chart" '[chart area-chart bar-chart line-chart bubble-chart pie-chart scatter-chart + stacked-area-chart stacked-bar-chart x-y-chart + axis category-axis number-axis value-axis] + "javafx.scene.media" '[audio-clip media media-player media-view] + "javafx.scene.transform" '[affine rotate scale shear translate] + "javafx.scene.web" '[HTML-editor prompt-data web-engine web-view] + "javafx.scene" '[scene group image-cursor perspective-camera snapshot-parameters] + "javafx.animation" '[fade-transition fill-transition parallel-transition path-transition pause-transition + rotate-transition scale-transition sequential-transition stroke-transition timeline + translate-transition] + "javafx.stage" '[stage directory-chooser file-chooser popup] + "javafx.geometry" '[bounding-box dimension-2D insets point-2D point-3D rectangle-2D] + "javafx.embed.swt" '[custom-transfer] + "javafx.embed.swing" '[JFX-panel-builder]} + builder (symbol builder)] + (first (filter (comp not nil?) (for [k (keys pkgs)] + (if (not (empty? (filter #(= % builder) (get pkgs k)))) + (symbol (str k "." (camel (name builder)))))))))) + +(defmacro build [what & args] + `(.. ~(get-qualified what) create + ~@args + build)) + +(defmacro deffx [name what & args] + `(def ~name + (build ~what ~@args))) diff --git a/target/repl/repl-port b/target/repl/repl-port new file mode 100644 index 0000000..b834b41 --- /dev/null +++ b/target/repl/repl-port @@ -0,0 +1 @@ +38760 \ No newline at end of file diff --git a/target/repl/stale/extract-native.dependencies b/target/repl/stale/extract-native.dependencies new file mode 100644 index 0000000..73974ba --- /dev/null +++ b/target/repl/stale/extract-native.dependencies @@ -0,0 +1 @@ +([:dependencies ([org.clojure/clojure "1.5.1"] [com.oracle/javafx-runtime "2.2.0"] [org.clojure/tools.nrepl "0.2.3"] [clojure-complete/clojure-complete "0.2.3"])]) \ No newline at end of file diff --git a/test/clojurefx/core_test.clj b/test/clojurefx/core_test.clj new file mode 100644 index 0000000..54c4716 --- /dev/null +++ b/test/clojurefx/core_test.clj @@ -0,0 +1,7 @@ +(ns clojurefx.core-test + (:require [clojure.test :refer :all] + [clojurefx.core :refer :all])) + +(deftest a-test + (testing "FIXME, I fail." + (is (= 0 1))))