diff --git a/.gitignore b/.gitignore index f22125ec..e6579a71 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ autodoc/** /.classpath /.project /.settings +.lein-env diff --git a/examples/gaidica/src/gaidica/core.clj b/examples/gaidica/src/gaidica/core.clj index 302e3dd7..0b22d685 100644 --- a/examples/gaidica/src/gaidica/core.clj +++ b/examples/gaidica/src/gaidica/core.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -25,9 +25,9 @@ (defn get-webcams [city] (storm/webcams @api-key city)) -(defn get-rad-sat [city] +(defn get-rad-sat [city] { :radar (storm/radar @api-key city) - :satellite (storm/satellite @api-key city)}) + :satellite (storm/satellite @api-key city)}) ;; Widget construction stuff ----------------------------------- ;; No behavior here, just building widgets @@ -37,17 +37,17 @@ (def divider-color "#aaaaaa") (defn make-forecast-entry [f] - (mig-panel + (mig-panel :constraints ["" "[][grow, fill]" "[top][top]"] :border (line-border :bottom 1 :color divider-color) :items [ [(label :icon (:icon_url f)) "span 1 2"] [(label :text (:title f) :font title-font) "wrap"] - [(text - :opaque? false - :multi-line? true - :wrap-lines? true - :editable? false + [(text + :opaque? false + :multi-line? true + :wrap-lines? true + :editable? false :text (:fcttext f) :font normal-font) "wmin 10"]])) @@ -55,23 +55,23 @@ (map #(vector (make-forecast-entry %) "wrap") forecasts)) (defn make-forecast-panel [forecasts] - (mig-panel + (mig-panel :id :forecast - :constraints ["" "[grow, fill]"] + :constraints ["" "[grow, fill]"] :items (make-forecast-entries forecasts))) -(defn make-webcam-table [] - (table - :id :webcam-table - :model - [:columns - [{:key :handle :text "Name" } - :lat :lon +(defn make-webcam-table [] + (table + :id :webcam-table + :model + [:columns + [{:key :handle :text "Name" } + :lat :lon {:key :updated :text "Last Updated"} {:key :CURRENTIMAGEURL :text "Image"}]])) (defn make-webcam-panel [] - (border-panel + (border-panel :id :webcam :border 5 :center (top-bottom-split @@ -83,9 +83,9 @@ (border-panel :id :radar :border 5 - :center - (scrollable - (grid-panel :columns 2 + :center + (scrollable + (grid-panel :columns 2 :items [(label :id :radar-image :text "") (label :id :sat-image :text "") (label :id :sat-ir4-image :text "") @@ -96,7 +96,7 @@ :hgap 5 :border [5 (line-border :bottom 1 :color divider-color)] :west (label :text "City:" :font title-font) - :center (text + :center (text :id :city :class :refresh :text "Ann Arbor,MI"))) @@ -108,7 +108,7 @@ { :title "Radar/Satellite" :content (make-radar-panel) }])) -(defn make-frame +(defn make-frame [] (frame :title "Gaidica" @@ -129,8 +129,8 @@ (def panel-behaviors [{ :name "Forecast" :data-fn get-text-forecasts - :update-fn (fn [root forecasts] - (config! (select root [:#forecast]) + :update-fn (fn [root forecasts] + (config! (select root [:#forecast]) :items (make-forecast-entries forecasts))) } { :name "Webcams" @@ -139,25 +139,25 @@ (let [t (select root [:#webcam-table])] (clear! t) (apply insert-at! t (interleave (iterate identity 0) webcams)))) } - + { :name "Radar/Satellite" - :data-fn get-rad-sat + :data-fn get-rad-sat :update-fn (fn [root {:keys [radar satellite]}] (config! (select root [:#radar-image]) :icon (:image_url radar)) - (config! (select root [:#sat-image]) :icon (:image_url satellite)) - (config! (select root [:#sat-ir4-image]) :icon (:image_url_ir4 satellite)) - (config! (select root [:#sat-vis-image]) :icon (:image_url_vis satellite))) + (config! (select root [:#sat-image]) :icon (:image_url satellite)) + (config! (select root [:#sat-ir4-image]) :icon (:image_url_ir4 satellite)) + (config! (select root [:#sat-vis-image]) :icon (:image_url_vis satellite))) }]) (def active-requests (atom #{})) ; schedule data requests for each panel (:data-fn) and call UI update functions ; (:update-fn) with results, in the UI thread! -(defn refresh-action-handler [e] +(defn refresh-action-handler [e] (let [root (to-frame e) city (text (select root [:#city]))] (doseq [{:keys [name data-fn update-fn]} panel-behaviors] - (future + (future (swap! active-requests conj name) (let [data (data-fn city)] (swap! active-requests disj name) @@ -167,7 +167,7 @@ (def refresh-action (action :name "Refresh" :key "menu R" :handler refresh-action-handler)) -(defn add-behaviors +(defn add-behaviors [root] ; As active requests change, update the status bar (bind/bind @@ -179,12 +179,12 @@ ; displayed image (bind/bind (bind/selection (select root [:#webcam-table])) - (bind/transform + (bind/transform #(-> (select root [:#webcam-table]) - (value-at %) + (value-at %) :CURRENTIMAGEURL)) (bind/property (select root [:#webcam-image]) :icon)) - + ; Use refresh-action as the action for everything marked with class ; :refresh. (config! (select root [:.refresh]) :action refresh-action) @@ -198,8 +198,8 @@ (println "Usage: gaidica ") (System/exit 1)) (reset! api-key (first args)) - (invoke-later - (-> + (invoke-later + (-> (make-frame) add-behaviors show!)) diff --git a/examples/substance/src/substance/core.clj b/examples/substance/src/substance/core.clj index 3f01c2d3..0d626216 100644 --- a/examples/substance/src/substance/core.clj +++ b/examples/substance/src/substance/core.clj @@ -46,7 +46,7 @@ skin in one of the following ways: do this *after* (seesaw.core/native!) since that sets the L&F. See http://insubstantial.github.com/insubstantial/substance/docs/getting-started.html -for more info. There you'll also find much more info about the +for more info. There you'll also find much more info about the skins along with much less crappy looking demos.") (defn -main [& args] diff --git a/examples/window-builder/src/window_builder/core.clj b/examples/window-builder/src/window_builder/core.clj index bab3ed09..b8399fba 100644 --- a/examples/window-builder/src/window_builder/core.clj +++ b/examples/window-builder/src/window_builder/core.clj @@ -15,7 +15,7 @@ (def states ["CA", "GA", "WA"]) -(def defaults +(def defaults { :first-name "Laura" :last-name "Palmer" :street "123 Main St." @@ -25,14 +25,14 @@ ; A helper to create an instance of the form, annotate it for Seesaw and do ; some other initialization. -(defn my-form +(defn my-form [] (let [form (identify (window_builder.MyForm.))] ; initialize the state combobox (config! (select form [:#state]) :model states) form)) -; Now we just create the panel, initialize it to the defaults above with +; Now we just create the panel, initialize it to the defaults above with ; seesaw.core/value! and show it in a dialog. Note how, besides setting the ; names of the widgets, the code in MyForm.java is strictly for layout. All ; behavior, etc is done in Clojure. @@ -43,4 +43,3 @@ (if (= :success result) (println "User entered: " (value form)) (println "User canceled"))))) - diff --git a/jvm/seesaw/ExceptionHandler.java b/jvm/seesaw/ExceptionHandler.java index 8215a279..aae3a5e5 100644 --- a/jvm/seesaw/ExceptionHandler.java +++ b/jvm/seesaw/ExceptionHandler.java @@ -4,7 +4,7 @@ * * The use and distribution terms for this software are covered by the * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) - * which can be found in the file epl-v10.html at the root of this + * which can be found in the file epl-v10.html at the root of this * distribution. * By using this software in any fashion, you are agreeing to be bound by * the terms of this license. diff --git a/lazytest-watch.bat b/lazytest-watch.bat index b1a35207..623515a8 100644 --- a/lazytest-watch.bat +++ b/lazytest-watch.bat @@ -18,7 +18,7 @@ set cmd="%java%" %JAVA_OPTS% -classpath "%leinCP%" lazytest.watch src test echo %cmd% %cmd% -endlocal +endlocal rem pause only when errors? rem if errorlevel 1 pause rem or always pause diff --git a/lazytest.bat b/lazytest.bat index 88bbe3c6..eea8f1ef 100644 --- a/lazytest.bat +++ b/lazytest.bat @@ -17,7 +17,7 @@ set leinCP=%%a set cmd="%java%" %JAVA_OPTS% -classpath "%leinCP%" lazytest.main test echo %cmd% %cmd% -endlocal +endlocal rem pause only when errors? rem if errorlevel 1 pause rem or always pause diff --git a/lazytest.sh b/lazytest.sh index b87eef0a..45f81d71 100755 --- a/lazytest.sh +++ b/lazytest.sh @@ -1,4 +1,4 @@ #!/bin/sh JAVA_OPTS="-XX:MaxPermSize=512m -Xmx512m" -java $JAVA_OPTS -cp `lein2 classpath` lazytest.main test +java $JAVA_OPTS -cp `lein classpath` lazytest.main test diff --git a/project.clj b/project.clj index 2e7eebba..76c9b91b 100644 --- a/project.clj +++ b/project.clj @@ -12,7 +12,8 @@ :distribution :repo :comments "same as Clojure"} - :warn-on-reflection true + :global-vars {*warn-on-reflection* true + *assert* false} ; To run the examples: ; @@ -20,13 +21,13 @@ ; :aliases { "examples" ["run" "-m" "seesaw.test.examples.launcher"] } - :dependencies [[org.clojure/clojure "1.4.0"] + :dependencies [[org.clojure/clojure "1.5.1"] [com.miglayout/miglayout "3.7.4"] [com.jgoodies/forms "1.2.1"] - [org.swinglabs.swingx/swingx-core "1.6.3"] + [org.swinglabs.swingx/swingx-core "1.6.5"] [j18n "1.0.2"] - [org.fife.ui/rsyntaxtextarea "2.0.4.1"]] - :profiles { :dev {:dependencies [[com.stuartsierra/lazytest "1.1.2"] + [org.fife.ui/rsyntaxtextarea "2.0.3"]] + :profiles { :dev {:dependencies [[com.stuartsierra/lazytest "1.2.3"] [lein-autodoc "0.9.0"]]}} :repositories [["stuartsierra-releases" "http://stuartsierra.com/maven2"]] :autodoc { diff --git a/src/seesaw/action.clj b/src/seesaw/action.clj index 310175d1..631d9079 100644 --- a/src/seesaw/action.clj +++ b/src/seesaw/action.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -13,8 +13,8 @@ seesaw.action (:use [seesaw.util :only [resource to-mnemonic-keycode]]) (:use [seesaw icon keystroke meta] - [seesaw.options :only [option-map - default-option bean-option resource-option + [seesaw.options :only [option-map + default-option bean-option resource-option apply-options option-provider]]) (:import [javax.swing Action AbstractAction])) @@ -25,15 +25,15 @@ (defn- action-property-option ([name key set-conv] (action-property-option name key set-conv nil)) ([name key set-conv get-conv] - (default-option name - (fn [^Action target value] + (default-option name + (fn [^Action target value] (.putValue target key ((or set-conv identity) value))) (fn [^Action target] (.getValue target key))))) ; store the handler function in a property on the action. (def ^{:private true} action-handler-property "seesaw-action-handler") -(def ^{:private true} action-options +(def ^{:private true} action-options (option-map (bean-option :enabled? Action boolean) (action-property-option :selected? Action/SELECTED_KEY boolean) @@ -42,12 +42,12 @@ (action-property-option :tip Action/SHORT_DESCRIPTION resource) (action-property-option :icon Action/SMALL_ICON icon) (action-property-option :key Action/ACCELERATOR_KEY keystroke) - (default-option :mnemonic + (default-option :mnemonic (fn [^Action a v] (.putValue a Action/MNEMONIC_KEY (Integer. (to-mnemonic-keycode v)))) (fn [^Action a] - (.getValue a Action/MNEMONIC_KEY))) - (default-option :handler + (.getValue a Action/MNEMONIC_KEY))) + (default-option :handler #(put-meta! %1 action-handler-property %2) #(get-meta %1 action-handler-property)) (resource-option :resource [:name :command :tip :icon :key :mnemonic]))) @@ -55,11 +55,11 @@ (option-provider javax.swing.Action action-options) -(defn action +(defn action "Construct a new Action object. Supports the following properties: :enabled? Whether the action is enabled - :selected? Whether the action is selected (for use with radio buttons, + :selected? Whether the action is selected (for use with radio buttons, toggle buttons, etc. :name The name of the action, i.e. the text that will be displayed in whatever widget it's associated with @@ -85,8 +85,7 @@ http://download.oracle.com/javase/6/docs/api/javax/swing/Action.html " [& opts] - (let [a (proxy [AbstractAction] [] - (actionPerformed [e] + (let [a (proxy [AbstractAction] [] + (actionPerformed [e] (if-let [f (get-meta this action-handler-property)] (f e))))] - (apply-options a opts))) - + (apply-options a opts))) \ No newline at end of file diff --git a/src/seesaw/applet.clj b/src/seesaw/applet.clj index f94c570e..5c5828f4 100644 --- a/src/seesaw/applet.clj +++ b/src/seesaw/applet.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -19,7 +19,7 @@ "Define an applet. This macro does all the gen-class business and takes maps applet lifetime methods to callback functions automatically. Supports the following options: - + :name The name of the generated class. Defaults to the current namespace. :init Function called when the applet is first loaded. Takes a single @@ -34,7 +34,7 @@ :content Function called after :init which should return the content of the applet, for example some kind of panel. It's added to the center of a border pane so it will be resized with the applet. - + Note that the namespace containing a call to (defapplet) must be compiled. In Leiningen, this is easiest to do by adding an :aot option to project.clj: @@ -51,9 +51,9 @@ Then refer to it from your webpage like this: - Examples: @@ -66,8 +66,8 @@ http://download.oracle.com/javase/tutorial/deployment/applet/index.html " [& {:keys [name init start stop content] - :or {init '(fn [applet]) - start '(fn [applet]) + :or {init '(fn [applet]) + start '(fn [applet]) stop '(fn [applet]) content '(fn [applet] (seesaw.core/label "A Seesaw Applet"))}}] (let [applet (gensym "applet")] @@ -78,7 +78,7 @@ :prefix "-seesaw-applet-") (defn ~'-seesaw-applet-init [#^javax.swing.JApplet ~applet] - (seesaw.core/invoke-later + (seesaw.core/invoke-later (do (~init ~applet) (doto ~applet @@ -87,10 +87,9 @@ (.. getContentPane revalidate repaint))))) (defn ~'-seesaw-applet-start [#^JApplet ~applet] - (seesaw.core/invoke-later + (seesaw.core/invoke-later (~start ~applet))) (defn ~'-seesaw-applet-stop [#^JApplet ~applet] - (seesaw.core/invoke-later - (~stop ~applet)))))) - + (seesaw.core/invoke-later + (~stop ~applet)))))) \ No newline at end of file diff --git a/src/seesaw/behave.clj b/src/seesaw/behave.clj index 98df69d1..5a2c7a2b 100644 --- a/src/seesaw/behave.clj +++ b/src/seesaw/behave.clj @@ -76,5 +76,4 @@ (drag e [(- (.x p) (.x last-point)) (- (.y p) (.y last-point))]) (.setLocation last-point (.getPoint e)))) :mouse-released - finish))) - + finish))) \ No newline at end of file diff --git a/src/seesaw/bind.clj b/src/seesaw/bind.clj index db52b1bb..07345c08 100644 --- a/src/seesaw/bind.clj +++ b/src/seesaw/bind.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -37,16 +37,16 @@ target (to-bindable* target))) -(defn composite +(defn composite "Create a composite bindable from the start and end of a binding chain" [start end] (reify Bindable (subscribe [this handler] (subscribe end handler)) (notify [this v] (notify start v)))) -(defn bind +(defn bind "Chains together two or more bindables into a listening chain. - When the value of source changes it is passed along and updates + When the value of source changes it is passed along and updates the value of target and so on. Note that the return value of this function is itself a composite @@ -81,15 +81,15 @@ Circular bindings will usually work. " [first-source target & more] - (loop [source (to-bindable first-source) - target (to-bindable target) + (loop [source (to-bindable first-source) + target (to-bindable target) more (seq more) unsubs []] (let [unsub (subscribe source #(notify target %)) unsubs (conj unsubs unsub)] (if more (recur target (to-bindable (first more)) (next more) unsubs) - (reify + (reify Bindable (subscribe [this handler] (subscribe target handler)) (notify [this v] (notify first-source v)) @@ -141,8 +141,8 @@ clojure.lang.Agent (subscribe [this handler] - (let [key (keyword (gensym "bindable-agent-watcher"))] - (add-watch this key + (let [key (keyword (gensym "bindable-agent-watcher"))] + (add-watch this key (fn bindable-agent-watcher [k r o n] (when-not (= o n) (handler n)))) (fn [] (remove-watch this key)))) @@ -152,7 +152,7 @@ (subscribe [this handler] (ssc/listen this :document (fn [e] (handler (get-document-text this))))) - (notify [this v] + (notify [this v] (when-not (= v (get-document-text this)) (do (.remove this 0 (.getLength this)) @@ -162,77 +162,77 @@ (subscribe [this handler] (ssc/listen this :change (fn [e] (handler (.getValue this))))) - (notify [this v] - (when-not (= v (.getValue this)) - (.setValue this v))) - + (notify [this v] + (when-not (= v (.getValue this)) + (.setValue this v))) + javax.swing.BoundedRangeModel (subscribe [this handler] (ssc/listen this :change (fn [e] (handler (.getValue this))))) - (notify [this v] - (when-not (= (int v) (.getValue this)) + (notify [this v] + (when-not (= (int v) (.getValue this)) (.setValue this v))) - + javax.swing.JComboBox (subscribe [this handler] (ssc/listen this :action (fn [e] (handler (.getSelectedItem this))))) - (notify [this v] - (when-not (= v (.getSelectedItem this)) + (notify [this v] + (when-not (= v (.getSelectedItem this)) (.setSelectedItem this v)))) -(defn b-swap! +(defn b-swap! "Creates a bindable that swaps! an atom's value using the given function each - time its input changes. That is, each time a new value comes in, + time its input changes. That is, each time a new value comes in, (apply swap! atom f new-value args) is called. This bindable's value (the current value of the atom) is subscribable. - + Example: - + ; Accumulate list of selections in a vector (bind (selection my-list) (b-swap! my-atom conj)) " [atom f & args] (reify Bindable - (subscribe [this handler] + (subscribe [this handler] (subscribe atom handler)) - (notify [this v] + (notify [this v] (apply swap! atom f v args)))) (defn- b-send* [send-fn agent f & args] (reify Bindable - (subscribe [this handler] + (subscribe [this handler] (subscribe agent handler)) - (notify [this v] + (notify [this v] (apply send-fn agent f v args)))) (defn b-send "Creates a bindable that (send)s to an agent using the given function each - time its input changes. That is, each time a new value comes in, + time its input changes. That is, each time a new value comes in, (apply send agent f new-value args) is called. This bindable's value (the current value of the atom) is subscribable. - + Example: - + ; Accumulate list of selections in a vector (bind (selection my-list) (b-send my-agent conj)) " [agent f & args] (apply b-send* send agent f args)) -(defn b-send-off +(defn b-send-off "Creates a bindable that (send-off)s to an agent using the given function each - time its input changes. That is, each time a new value comes in, + time its input changes. That is, each time a new value comes in, (apply send agent f new-value args) is called. This bindable's value (the current value of the atom) is subscribable. - + Example: - + ; Accumulate list of selections in a vector (bind (selection my-list) (b-send-off my-agent conj)) " @@ -260,7 +260,7 @@ (.replace "?" "")) #"\-")))) -(defn property +(defn property "Returns a bindable (suitable to pass to seesaw.bind/bind) that connects to a property of a widget, e.g. :foreground, :enabled?, etc. @@ -275,21 +275,21 @@ (bind (.getDocument t) (transform #(try (color %) (catch Exception (color 0 0 0)))) (property lbl :background))) - + See: (seesaw.bind/bind) " [^java.awt.Component target property-name] (reify Bindable - (subscribe [this handler] + (subscribe [this handler] (let [property-name (property-kw->java-name property-name) ; first letter of *some* property-names must be lower-case property-name (property-change-listener-name-overrides property-name - (apply str + (apply str (clojure.string/lower-case (first property-name)) (rest property-name))) - handler (reify java.beans.PropertyChangeListener + handler (reify java.beans.PropertyChangeListener (propertyChange [this e] (handler (.getNewValue e))))] (.addPropertyChangeListener target property-name handler) (fn [] (.removePropertyChangeListener target property-name handler)))) @@ -302,9 +302,9 @@ options corresponds to the option map passed to (seesaw.core/selection) and (seesaw.core/selection) - + Examples: - + ; Bind checkbox state to enabled state of a widget (let [cb (checkbox :text \"Enable\") t (text)] @@ -318,21 +318,21 @@ ([widget options] (reify Bindable (subscribe [this handler] - (ssc/listen widget :selection + (ssc/listen widget :selection (fn [_] (-> widget (ssc/selection options) handler)))) (notify [this v] (ssc/selection! widget options v)))) ([widget] (selection widget {}))) -(defn value +(defn value "Converts the value of a widget into a bindable. Applies to listbox, table, tree, combobox, checkbox, etc, etc. In short, anything to which (seesaw.core/value) applies. This is a \"receive-only\" bindable since there is no good way to detect changes in the values of composites. Examples: - + ; Map the value of an atom (a map) into the value of a panel. (let [a (atom nil) p (border-panel :north (checkbox :id :cb :text \"Enable\") @@ -352,11 +352,11 @@ (notify [this v] (ssc/value! widget v))))) -(defn transform +(defn transform "Creates a bindable that takes an incoming value v, applies (f v args), and passes the result on. f should be side-effect free. - + See: (seesaw.bind/bind)" [f & args] @@ -364,7 +364,7 @@ (reify Bindable (subscribe [this handler] (swap! state update-in [:handlers] conj handler) - (fn [] + (fn [] (swap! state update-in [:handlers] (partial remove-handler handler)))) (notify [this v] (let [new-value (:value (swap! state assoc :value (apply f v args)))] @@ -375,7 +375,7 @@ "Creates a bindable that takes an incoming value v, executes (f v args) and does nothing further. That is, it's the end of the binding chain. - + See: (seesaw.bind/bind) (seesaw.bind/b-do)" @@ -390,26 +390,26 @@ "Macro helper for (seesaw.bind/b-do*). Takes a single-argument fn-style binding vector and a body. When a new value is received it is passed to the binding and the body is executes. The result is discarded. - + See: (seesaw.bind/b-do*) " [bindings & body] `(b-do* (fn ~bindings ~@body))) -(defn filter +(defn filter "Executes a predicate on incoming value. If the predicate returns a truthy - value, the incoming value is passed on to the next bindable in the chain. + value, the incoming value is passed on to the next bindable in the chain. Otherwise, nothing is notified. - + Examples: - + ; Block out of range values (let [input (text) output (slider :min 0 :max 100)] - (bind - input - (filter #(< 0 % 100)) + (bind + input + (filter #(< 0 % 100)) output)) Notes: @@ -427,7 +427,7 @@ (fn [] (swap! state update-in [:handlers] (partial remove-handler handler)))) (notify [this v] - (when (pred v) + (when (pred v) (swap! state assoc :value v) (doseq [h (:handlers @state)] (h v))))))) @@ -436,9 +436,9 @@ "Executes a predicate on incoming value. If the predicate returns a truthy value, that value is passed on to the next bindable in the chain. Otherwise, nothing is notified. - + Examples: - + ; Try to convert a text string to a number. Do nothing if the conversion ; Fails (let [input (text) @@ -467,15 +467,15 @@ (defn tee "Create a tee junction in a bindable chain. - + Examples: - + ; Take the content of a text box and show it as upper and lower ; case in two labels (let [t (text) upper (label) lower (label)] - (bind (property t :text) + (bind (property t :text) (tee (bind (transform #(.toUpperCase %)) (property upper :text)) (bind (transform #(.toLowerCase %)) (property lower :text))))) @@ -499,38 +499,38 @@ (schedule-fn (fn [] (doseq [h @handlers] (h v)))))))) -(defn notify-later +(defn notify-later "Creates a bindable that notifies its subscribers (next in chain) on the swing thread using (seesaw.invoke/invoke-later). You should use this to ensure that things happen on the right thread, e.g. (seesaw.bind/property) and (seesaw.bind/selection). - + See: (seesaw.invoke/invoke-later) " [] (notify-when* invoke/invoke-later*)) -(defn notify-soon +(defn notify-soon "Creates a bindable that notifies its subscribers (next in chain) on the swing thread using (seesaw.invoke/invoke-soon). You should use this to ensure that things happen on the right thread, e.g. (seesaw.bind/property) and (seesaw.bind/selection). - + See: (seesaw.invoke/invoke-soon) " [] (notify-when* invoke/invoke-soon*)) -(defn notify-now +(defn notify-now "Creates a bindable that notifies its subscribers (next in chain) on the swing thread using (seesaw.invoke/invoke-now). You should use this to ensure that things happen on the right thread, e.g. (seesaw.bind/property) and (seesaw.bind/selection). Note that sincel invoke-now is used, you're in danger of deadlocks. Be careful. - + See: (seesaw.invoke/invoke-soon) " @@ -551,4 +551,4 @@ javax.swing.text.JTextComponent (to-bindable* [this] (.getDocument this)) javax.swing.JComboBox - (to-bindable* [this] this)) + (to-bindable* [this] this)) \ No newline at end of file diff --git a/src/seesaw/border.clj b/src/seesaw/border.clj index 322d15b5..3299c4b0 100644 --- a/src/seesaw/border.clj +++ b/src/seesaw/border.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -22,12 +22,12 @@ (declare to-border) -(defn empty-border +(defn empty-border "Create an empty border. The following properties are supported: - + :thickness The thickness of the border (all sides) in pixels. This property is only used if :top, :bottom, etc are omitted. Defaults to 1. - + :top Thickness of the top border in pixels. Defaults to 0. :left Thickness of the left border in pixels. Defaluts to 0. :bottom Thickness of the bottom border in pixels. Defaluts to 0. @@ -47,9 +47,9 @@ (let [t (or thickness 1)] (BorderFactory/createEmptyBorder t t t t)))) -(defn line-border +(defn line-border "Create a colored border with following properties: - + :color The color, passed through (seesaw.color/to-color). Defaults to black. :thickness The thickness of the border in pixels. This property is only used if :top, :bottom, etc are omitted. Defaults to 1. @@ -57,25 +57,25 @@ :left Thickness of the left border in pixels. Defaluts to 0. :bottom Thickness of the bottom border in pixels. Defaluts to 0. :right Thickness of the right border in pixels. Defaluts to 0. - - Examples: - + + Examples: + ; Create a green border, 3 pixels on top, 5 pixels on the botttom (line-border :color \"#0f0\" :top 3 :bottom 5) " [& {:keys [color thickness top left bottom right] :or {thickness 1 color Color/BLACK}}] (if (or top left bottom right) - (BorderFactory/createMatteBorder - (int (or top 0)) (int (or left 0)) (int (or bottom 0)) (int (or right 0)) + (BorderFactory/createMatteBorder + (int (or top 0)) (int (or left 0)) (int (or bottom 0)) (int (or right 0)) ^Color (to-color color)) (BorderFactory/createLineBorder (to-color color) thickness))) (defn compound-border "Create a compount border from the given arguments. Order is from inner to outer. Each argument is passed through (seesaw.border/to-border). - + Examples: - + ; Create an 4 pixel empty border, red line border, and title border. (compound-border 4 (line-border :color :red :thickness 4) \"Title\") @@ -86,9 +86,9 @@ ([b0 b1] (BorderFactory/createCompoundBorder (to-border b1) (to-border b0))) ([b0 b1 & more] (reduce #(compound-border %1 %2) (compound-border b0 b1) more))) -(defn custom-border +(defn custom-border "Define a custom border with the following properties: - + :paint A function that takes the same arguments as Border.paintBorder: java.awt.Component c - The target component java.awt.Graphics g - The graphics context to draw to @@ -96,7 +96,7 @@ int y - y position of border int w - width of border int h - height of border - + :insets Returns the insets of the border. Can be a zero-arg function that returns something that is passed through (seesaw.util/to-insets) or a constant value passed through the same. Defaults to 0. @@ -110,12 +110,12 @@ " [& args] (let [{:keys [insets opaque? paint]} args - insets (cond + insets (cond (fn? insets) insets :else (constantly insets)) opaque? (cond (fn? opaque?) opaque? - :else (constantly opaque?))] + :else (constantly opaque?))] (reify javax.swing.border.Border (getBorderInsets [this c] (to-insets (insets c))) @@ -144,7 +144,7 @@ to-border is used implicitly by the :border option supported by all widgets to it is rarely necessary to call directly. " - ([b] + ([b] (cond (nil? b) nil (instance? Border b) b @@ -153,5 +153,4 @@ (resource-key? b) (to-border (resource b)) :else (BorderFactory/createTitledBorder (str b)))) ([b & args] - (apply compound-border b args))) - + (apply compound-border b args))) \ No newline at end of file diff --git a/src/seesaw/cells.clj b/src/seesaw/cells.clj index 1718e0d3..b7aeb295 100644 --- a/src/seesaw/cells.clj +++ b/src/seesaw/cells.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -17,7 +17,7 @@ (def ^{:private true} nil-fn (constantly nil)) -(defn default-list-cell-renderer +(defn default-list-cell-renderer [render-fn] (if (instance? javax.swing.ListCellRenderer render-fn) render-fn @@ -25,15 +25,15 @@ (getListCellRendererComponent [component value index selected? focus?] (let [^javax.swing.DefaultListCellRenderer this this] (proxy-super getListCellRendererComponent component value index selected? focus?) - (render-fn this { :this this - :component component - :value value - :index index - :selected? selected? - :focus? focus? }) + (render-fn this { :this this + :component component + :value value + :index index + :selected? selected? + :focus? focus? }) this))))) -(defn default-tree-cell-renderer +(defn default-tree-cell-renderer [render-fn] (if (instance? javax.swing.tree.TreeCellRenderer render-fn) render-fn @@ -41,11 +41,11 @@ (getTreeCellRendererComponent [component value selected? expanded? leaf? row focus?] (let [^javax.swing.tree.DefaultTreeCellRenderer this this] (proxy-super getTreeCellRendererComponent component value selected? expanded? leaf? row focus?) - (render-fn this { :this this - :component component - :value value - :selected? selected? - :expaned? expanded? + (render-fn this { :this this + :component component + :value value + :selected? selected? + :expaned? expanded? :leaf? leaf? :row row :focus? focus? }) @@ -54,9 +54,7 @@ (defn to-cell-renderer [target arg] (cond - (or (instance? javax.swing.JList target) + (or (instance? javax.swing.JList target) (instance? javax.swing.JComboBox target)) (default-list-cell-renderer arg) (instance? javax.swing.JTree target) (default-tree-cell-renderer arg) - :else (illegal-argument "Don't know how to make cell renderer for %s" (class arg)))) - - + :else (illegal-argument "Don't know how to make cell renderer for %s" (class arg)))) \ No newline at end of file diff --git a/src/seesaw/chooser.clj b/src/seesaw/chooser.clj index 8baa2d72..5f5c4791 100644 --- a/src/seesaw/chooser.clj +++ b/src/seesaw/chooser.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -12,7 +12,7 @@ :author "Dave Ray"} seesaw.chooser (:use [seesaw.color :only [to-color]] - [seesaw.options :only [default-option bean-option apply-options + [seesaw.options :only [default-option bean-option apply-options option-map option-provider]] [seesaw.util :only [illegal-argument]]) (:import (javax.swing.filechooser FileFilter FileNameExtensionFilter) @@ -20,9 +20,9 @@ (defn file-filter "Create a FileFilter. - + Arguments: - + description - description of this filter, will show up in the filter-selection box when opening a file choosing dialog. @@ -55,7 +55,7 @@ (doseq [f filters] (.addChoosableFileFilter chooser (cond - (instance? FileFilter f) + (instance? FileFilter f) f (and (sequential? f) (sequential? (second f))) @@ -67,11 +67,11 @@ :else (illegal-argument "not a valid filter: %s" f))))) -(def ^{:private true} file-chooser-options +(def ^{:private true} file-chooser-options (option-map (default-option :dir - (fn [^JFileChooser chooser dir] - (.setCurrentDirectory chooser (if (instance? java.io.File dir) dir + (fn [^JFileChooser chooser dir] + (.setCurrentDirectory chooser (if (instance? java.io.File dir) dir (java.io.File. (str dir)))))) (bean-option [:multi? :multi-selection-enabled] JFileChooser boolean) (bean-option [:selection-mode :file-selection-mode] JFileChooser file-selection-modes) @@ -84,7 +84,7 @@ (defn- show-file-chooser [^JFileChooser chooser parent type] (case type - :open (.showOpenDialog chooser parent) + :open (.showOpenDialog chooser parent) :save (.showSaveDialog chooser parent) (.showDialog chooser parent (str type)))) @@ -118,11 +118,11 @@ :selection-mode The file selection mode: :files-only, :dirs-only and :files-and-dirs. Defaults to :files-only :filters A seq of either: - + A seq that contains a filter name and a seq of extensions as strings for that filter. - - A seq that contains a filter name and a function + + A seq that contains a filter name and a function to be used as accept function. (see file-filter) A FileFilter. (see file-filter) @@ -151,7 +151,7 @@ Returns result of SUCCESS-FN (default: either java.io.File or seq of java.io.File iff multi? set to true) in case of the user selecting a file, or result of CANCEL-FN otherwise. - + See http://download.oracle.com/javase/6/docs/api/javax/swing/JFileChooser.html " [& args] @@ -165,7 +165,7 @@ ^JFileChooser chooser (configure-file-chooser (JFileChooser.) (dissoc opts :type :remember-directory? :success-fn :cancel-fn)) multi? (.isMultiSelectionEnabled chooser) result (show-file-chooser chooser parent type)] - (cond + (cond (= result JFileChooser/APPROVE_OPTION) (do (when remember-directory? @@ -175,14 +175,14 @@ (defn choose-color "Choose a color with a color chooser dialog. The optional first argument is the - parent component for the dialog. The rest of the args is a list of key/value + parent component for the dialog. The rest of the args is a list of key/value pairs: - + :color The initial selected color (see seesaw.color/to-color) :title The dialog's title - + Returns the selected color or nil if canceled. - + See: http://download.oracle.com/javase/6/docs/api/javax/swing/JColorChooser.html " diff --git a/src/seesaw/color.clj b/src/seesaw/color.clj index 0e888958..964e06d8 100644 --- a/src/seesaw/color.clj +++ b/src/seesaw/color.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -165,8 +165,8 @@ "yellowgreen" (Color. 154,205,50) }) -(defn get-rgba - [^java.awt.Color c] +(defn get-rgba + [^java.awt.Color c] (vector (.getRed c) (.getGreen c) (.getBlue c) (.getAlpha c))) (defn- decode [s] @@ -234,5 +234,4 @@ (cond (nil? c) nil (instance? Color c) c - :else (color c))) - + :else (color c))) \ No newline at end of file diff --git a/src/seesaw/config.clj b/src/seesaw/config.clj index cb533370..2e412aa4 100644 --- a/src/seesaw/config.clj +++ b/src/seesaw/config.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -17,7 +17,7 @@ "A protocol for configuring and querying properties of an object. Client code should use (seesaw.core/config!) and (seesaw.core/config) rather than calling protocol methods directly. - + See: (seesaw.core/config) (seesaw.core/config!) @@ -27,15 +27,15 @@ (defn config "Retrieve the value of an option from target. For example: - + (config button1 :text) => \"I'm a button!\" - - Target must satisfy the Configurable protocol. In general, it may be a widget, - or convertible to widget with (to-widget). For example, the target can be an event + + Target must satisfy the Configurable protocol. In general, it may be a widget, + or convertible to widget with (to-widget). For example, the target can be an event object. - Returns the option value. + Returns the option value. Throws IllegalArgumentException if an unknown option is requested. See: @@ -52,9 +52,9 @@ or: (config! [button1 button2] :enabled? false :text \"We're disabled\") - - Targets must satisfy the Configurable protocol. In general, they may be widgets, - or convertible to widgets with (to-widget). For example, the target can be an event + + Targets must satisfy the Configurable protocol. In general, they may be widgets, + or convertible to widgets with (to-widget). For example, the target can be an event object. Returns the input targets. @@ -66,5 +66,4 @@ [targets & args] (doseq [target (to-seq targets)] (config!* target args)) - targets) - + targets) \ No newline at end of file diff --git a/src/seesaw/core.clj b/src/seesaw/core.clj index ee4db6a9..942f1776 100644 --- a/src/seesaw/core.clj +++ b/src/seesaw/core.clj @@ -3713,5 +3713,4 @@ This idea is shamelessly borrowed from Clarity https://github.com/stathissideris/clarity " [target v] - (seesaw.value/value!* (or (to-widget target) target) v)) - + (seesaw.value/value!* (or (to-widget target) target) v)) \ No newline at end of file diff --git a/src/seesaw/cursor.clj b/src/seesaw/cursor.clj index cc147eea..0028279d 100644 --- a/src/seesaw/cursor.clj +++ b/src/seesaw/cursor.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -14,18 +14,18 @@ (:use [seesaw.util :only [constant-map illegal-argument]]) (:import [java.awt Cursor Toolkit])) -(def ^{:private true} built-in-cursor-map - (constant-map Cursor {:suffix "_CURSOR"} +(def ^{:private true} built-in-cursor-map + (constant-map Cursor {:suffix "_CURSOR"} :crosshair :custom :default :hand :move :text :wait :e-resize :n-resize :ne-resize :nw-resize :s-resize :se-resize :sw-resize :w-resize)) (defn- custom-cursor [^java.awt.Image image & [point]] (let [[x y] point] - (.. (Toolkit/getDefaultToolkit) (createCustomCursor image - (java.awt.Point. (or x 0) (or y 0)) + (.. (Toolkit/getDefaultToolkit) (createCustomCursor image + (java.awt.Point. (or x 0) (or y 0)) (str (gensym "seesaw-cursor")))))) -(defn cursor +(defn cursor "Create a built-in or custom cursor. Take one of two forms: (cursor :name-of-built-in-cursor) @@ -33,7 +33,7 @@ Creates a built-in cursor of the given type. Valid types are: :crosshair :custom :default :hand :move :text :wait - :e-resize :n-resize :ne-resize :nw-resize + :e-resize :n-resize :ne-resize :nw-resize :s-resize :se-resize :sw-resize :w-resize To create custom cursor: @@ -54,7 +54,7 @@ Notes: This function is used implicitly by the :cursor option on most widget - constructor functions. So + constructor functions. So (label :cursor (cursor :hand)) @@ -69,7 +69,7 @@ See: - http://download.oracle.com/javase/6/docs/api/java/awt/Cursor.html + http://download.oracle.com/javase/6/docs/api/java/awt/Cursor.html http://download.oracle.com/javase/6/docs/api/java/awt/Toolkit.html#createCustomCursor%28java.awt.Image,%20java.awt.Point,%20java.lang.String%29 " ^Cursor @@ -80,6 +80,4 @@ (instance? Cursor type) type (instance? java.awt.Image type) (apply custom-cursor type args) (instance? javax.swing.ImageIcon type) (apply cursor (.getImage ^javax.swing.ImageIcon type) args) - :else (illegal-argument "Don't know how to make cursor from %s" type))) - - + :else (illegal-argument "Don't know how to make cursor from %s" type))) \ No newline at end of file diff --git a/src/seesaw/dev.clj b/src/seesaw/dev.clj index 76f7fabc..cbacef44 100644 --- a/src/seesaw/dev.clj +++ b/src/seesaw/dev.clj @@ -2,14 +2,14 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. ; You must not remove this notice, or any other, from this software. (ns ^{:doc "Functions to aid development of Seesaw apps." - :author "Dave Ray"} + :author "Dave Ray"} seesaw.dev (:require [clojure.string :as string] [seesaw.util :as util] @@ -19,7 +19,7 @@ [clojure.pprint :as pp])) -(defonce ^{:private true} error-frame +(defonce ^{:private true} error-frame (delay (core/frame :title "Seesaw - Unhandled Exception" @@ -30,15 +30,15 @@ :hgap 5 :vgap 5 :border 5 :north (core/label :id :header) - :center + :center (core/top-bottom-split (core/scrollable (core/text :id :event - :editable? false + :editable? false :wrap-lines? true :multi-line? true) :border "Current Event") (core/scrollable (core/text :id :throwable - :editable? false + :editable? false :multi-line? true) :border "Stack Trace") :divider-location 1/3))))) @@ -56,25 +56,25 @@ (core/text! t (let [sw (java.io.StringWriter.) pw (java.io.PrintWriter. sw) _ (.printStackTrace throwable pw) - _ (.flush pw)] + _ (.flush pw)] (.toString sw))) (core/scroll! :to :top))) frame) (defn- show-error-frame [event throwable] (-> - (force error-frame) + (force error-frame) (set-error-frame-content event throwable) core/show! (core/move! :to-front))) (defonce ^{:private true :tag seesaw.ExceptionHandler} handler (seesaw.ExceptionHandler.)) -(defn debug! +(defn debug! "Install a custom exception handler which displays a window with event and stack trace info whenever an unhandled exception occurs in the UI thread. This is usually more friendly than the console, especially in a repl. - + Calling with no args, enables default debugging. Otherwise, pass a two arg function that takes a java.awt.AWTEvent and a java.lang.Throwable. Passing nil disables debugging. @@ -82,7 +82,7 @@ ([] (debug! show-error-frame)) ([f] (core/invoke-now (let [q (.. (java.awt.Toolkit/getDefaultToolkit) getSystemEventQueue) - installed? (identical? q handler)] + installed? (identical? q handler)] (cond (and f installed?) (do (.setHandler handler f) true) (and f (not installed?)) (do (.push q (.setHandler handler f)) true) @@ -101,26 +101,25 @@ (printf " %24s Notes/Examples%n" "Option") (printf "--%24s --------------%n" (apply str (repeat 24 \-))) (doseq [{:keys [name setter examples]} (sort-by :name (vals (opt/get-option-map v)))] - (printf " %24s %s%n" + (printf " %24s %s%n" name (if examples (examples-str examples) "")))) (defn show-events "Given a class or instance, print information about all supported events. From there, you can look up javadocs, etc. - + Examples: - + (show-events javax.swing.JButton) ... lots of output ... - + (show-events (button)) ... lots of output ... " [v] - (doseq [{:keys [name ^Class class events]} (->> (ev/events-for v) + (doseq [{:keys [name ^Class class events]} (->> (ev/events-for v) (sort-by :name))] (printf "%s [%s]%n" name (if class (.getName class) "?")) (doseq [e (sort events)] - (printf " %s%n" e)))) - + (printf " %s%n" e)))) \ No newline at end of file diff --git a/src/seesaw/dnd.clj b/src/seesaw/dnd.clj index c4f0bad4..1f51d788 100644 --- a/src/seesaw/dnd.clj +++ b/src/seesaw/dnd.clj @@ -174,13 +174,13 @@ (defn validate-import-pairs [import-pairs] ;; ensure useful error message for missing :on-drop handler ;; otherwise user will see null pointer exception later - (when-let [error-import-pairs (seq (filter - (fn [[flavor handler]] - (when (and (map? handler) + (when-let [error-import-pairs (seq (filter + (fn [[flavor handler]] + (when (and (map? handler) (not (:on-drop handler))) - [flavor handler])) + [flavor handler])) import-pairs))] - (throw (ex-info + (throw (ex-info "no :on-drop key found in handler-map. :import with handler-map must have (:on-drop handler) => (fn [data] ...)" {:error-import-pairs error-import-pairs})))) @@ -188,7 +188,7 @@ (validate-import-pairs import-pairs) (map (fn [[flavor handler]] (let [handler (if (map? handler) handler {:on-drop handler})] - [flavor handler])) + [flavor handler])) import-pairs)) (defn default-transfer-handler @@ -202,16 +202,16 @@ Data Import The :import option specifies a vector of flavor/handler pairs. A handler is - either + either - a function: (fn [data] ...process drop...) + a function: (fn [data] ...process drop...) or a map : {:on-drop (fn [data] ...process drop...) :can-drop? (fn [data] ...check drop is allowed...)} - if a map is provided :on-drop is mandatory, :can-drop? is optional, + if a map is provided :on-drop is mandatory, :can-drop? is optional, defaulting to (constantly true) - When a drop/paste occurs, the handler for the first matching flavor is + When a drop/paste occurs, the handler for the first matching flavor is called with a map with the following keys: :target The widget that's the target of the drop @@ -299,7 +299,7 @@ (canImport [^TransferHandler$TransferSupport support] (boolean - (some + (some (fn [flavor] (when (.isDataFlavorSupported support flavor) (let [[flavorful handler] (get-import-handler support import-pairs)] @@ -315,9 +315,9 @@ (let [[flavorful handler] (get-import-handler support import-pairs) data (get-import-data support flavorful) drop? (.isDrop support) - on-drop (:on-drop handler) + on-drop (:on-drop handler) ] - (boolean + (boolean (on-drop {:data data :drop? drop? :drop-location (if drop? (unpack-drop-location (.getDropLocation support))) @@ -364,5 +364,4 @@ (getSourceActions [^javax.swing.JComponent c] TransferHandler/NONE) - (exportDone [^javax.swing.JComponent c ^Transferable data action]))) - + (exportDone [^javax.swing.JComponent c ^Transferable data action]))) \ No newline at end of file diff --git a/src/seesaw/dnd_explorer.clj b/src/seesaw/dnd_explorer.clj index aade748f..2cfcbf5f 100644 --- a/src/seesaw/dnd_explorer.clj +++ b/src/seesaw/dnd_explorer.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -13,10 +13,10 @@ (:require [seesaw.table :as table])) (defn drop-handler [t support] - (let [flavors (.getDataFlavors support)] + (let [flavors (.getDataFlavors support)] (table/clear! t) - (apply table/insert-at! t - (mapcat + (apply table/insert-at! t + (mapcat (fn [f i] [0 (assoc (bean f) :N (format "%04d" i))]) flavors (iterate inc 0))))) @@ -29,7 +29,7 @@ :primaryType :subType :humanPresentableName]]) - (.setAutoCreateRowSorter true))] + (.setAutoCreateRowSorter true))] (frame :title "Seesaw Drag-n-Drop Explorer" :size [640 :by 480] @@ -48,5 +48,4 @@ (-> (app) show!))) -;(-main) - +;(-main) \ No newline at end of file diff --git a/src/seesaw/event.clj b/src/seesaw/event.clj index 81b9cb51..a38106e0 100644 --- a/src/seesaw/event.clj +++ b/src/seesaw/event.clj @@ -546,4 +546,4 @@ selection (selection-group-for v)] (if selection (cons selection base) - base))) + base))) \ No newline at end of file diff --git a/src/seesaw/font.clj b/src/seesaw/font.clj index 2a81be5d..4058ac48 100644 --- a/src/seesaw/font.clj +++ b/src/seesaw/font.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -19,13 +19,13 @@ "Returns a seq of strings naming the font families on the system. These are the names that are valid in :name option (seesaw.font/font) as well as in font descriptor strings like \"Arial-BOLD-20\" - + See: (seesaw.core/font) " ([] (font-families nil)) ([locale] - (-> (GraphicsEnvironment/getLocalGraphicsEnvironment) + (-> (GraphicsEnvironment/getLocalGraphicsEnvironment) (.getAvailableFontFamilyNames locale) seq))) @@ -47,7 +47,7 @@ Options are: - :name The name of the font. Besides string values, also possible are + :name The name of the font. Besides string values, also possible are any of :monospaced, :serif, :sans-serif. See (seesaw.font/font-families) to get a system-specific list of all valid values. :style The style. One of :bold, :plain, :italic, or a set of those values @@ -107,5 +107,4 @@ (nil? f) nil (instance? Font f) f (map? f) (apply font (flatten (seq f))) - true (font f))) - + true (font f))) \ No newline at end of file diff --git a/src/seesaw/forms.clj b/src/seesaw/forms.clj index 8ce0455d..8a04ddb5 100644 --- a/src/seesaw/forms.clj +++ b/src/seesaw/forms.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -92,8 +92,8 @@ (def ^{:private true} layout-options (option-map - (default-option - :column-groups + (default-option + :column-groups (fn set-column-groups [c v] (cond (instance? FormLayout c) @@ -150,5 +150,4 @@ (apply-options layout opts) (apply-options builder opts) (doto (.getPanel builder) - (apply-options opts)))) - + (apply-options opts)))) \ No newline at end of file diff --git a/src/seesaw/graphics.clj b/src/seesaw/graphics.clj index cc779351..02fe6261 100644 --- a/src/seesaw/graphics.clj +++ b/src/seesaw/graphics.clj @@ -451,5 +451,4 @@ (let [ret (draw g2d shape style)] (if more (recur ret (first more) (second more) (nnext more)) - ret)))) - + ret)))) \ No newline at end of file diff --git a/src/seesaw/icon.clj b/src/seesaw/icon.clj index 06864895..ff457505 100644 --- a/src/seesaw/icon.clj +++ b/src/seesaw/icon.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -18,9 +18,9 @@ ;******************************************************************************* ; Icons -(defn ^javax.swing.Icon icon +(defn ^javax.swing.Icon icon "Loads an icon. The parameter p can be any of the following: - + nil - returns nil javax.swing.Icon - returns the icon java.awt.Image - returns an ImageIcon around the image @@ -35,7 +35,7 @@ " [p] (cond - (nil? p) nil + (nil? p) nil (instance? javax.swing.Icon p) p (instance? java.awt.Image p) (ImageIcon. ^java.awt.Image p) (instance? java.net.URL p) (ImageIcon. ^java.net.URL p) @@ -44,6 +44,5 @@ :else (if-let [url (jio/resource (str p))] (icon url) - (if-let [url (to-url p)] - (ImageIcon. url))))) - + (if-let [url (to-url p)] + (ImageIcon. url))))) \ No newline at end of file diff --git a/src/seesaw/invoke.clj b/src/seesaw/invoke.clj index 4c88cf1c..6915e679 100644 --- a/src/seesaw/invoke.clj +++ b/src/seesaw/invoke.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -21,13 +21,13 @@ (SwingUtilities/invokeAndWait invoker)) @result))) -(defn invoke-soon* +(defn invoke-soon* [f & args] (if (SwingUtilities/isEventDispatchThread) (apply f args) (apply invoke-later* f args))) -(defmacro invoke-later +(defmacro invoke-later "Equivalent to SwingUtilities/invokeLater. Executes the given body sometime in the future on the Swing UI thread. For example, @@ -39,8 +39,8 @@ (seesaw.core/invoke-later) is an alias of this macro. See: - - http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable) + + http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable) " [& body] `(invoke-later* (fn [] ~@body))) @@ -58,7 +58,7 @@ (seesaw.core/invoke-now) is an alias of this macro. See: - http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeAndWait(java.lang.Runnable) + http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeAndWait(java.lang.Runnable) " [& body] `(invoke-now* (fn [] ~@body))) @@ -74,15 +74,15 @@ See: (seesaw.core/invoke-later) - http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable) + http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable) " [& body] `(invoke-soon* (fn [] ~@body))) -(defn signaller* - "Returns a function that conditionally queues the given function (+ args) on +(defn signaller* + "Returns a function that conditionally queues the given function (+ args) on the UI thread. The call is only queued if there is not already a pending call - queued. - + queued. + Suppose you're performing some computation in the background and want to signal some UI component to update. Normally you'd use (seesaw.core/invoke-later) but that can easily flood the UI thread with unnecessary updates. That is, @@ -114,7 +114,7 @@ You probably want to use the (seesaw.invoke/signaller) convenience form. - + See: (seesaw.invoke/invoke-later) (seesaw.invoke/signaller) @@ -124,25 +124,24 @@ (fn [& args] (let [do-it (compare-and-set! active? false true)] (when do-it - (invoke-later - (apply f args) + (invoke-later + (apply f args) (reset! active? false))) do-it)))) -(defmacro signaller +(defmacro signaller "Convenience form of (seesaw.invoke/signaller*). - + A use of signaller* like this: - + (signaller* (fn [x y z] ... body ...)) - + can be written like this: - + (signaller [x y z] ... body ...) - + See: (seesaw.invoke/signaller*) " [args & body] - `(signaller* (fn ~args ~@body))) - + `(signaller* (fn ~args ~@body))) \ No newline at end of file diff --git a/src/seesaw/keymap.clj b/src/seesaw/keymap.clj index df71acc5..76ca3e99 100644 --- a/src/seesaw/keymap.clj +++ b/src/seesaw/keymap.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -26,7 +26,7 @@ (let [^javax.swing.AbstractButton b act] (action :handler (fn [_] (.doClick b)))) - (fn? act) + (fn? act) (action :handler act) :else (illegal-argument "Don't know how to make key-map action from '%s'" act))) @@ -44,41 +44,41 @@ (def ^{:private true} default-scope (:descendants scope-table)) (defn map-key - "Install a key mapping on a widget. - - Key mappings are hopelessly entwined with keyboard focus and the widget + "Install a key mapping on a widget. + + Key mappings are hopelessly entwined with keyboard focus and the widget hierarchy. When a key is pressed in a widget with focus, each widget up the hierarchy gets a chance to handle it. There three 'scopes' with which a mapping may be registered: - - :self + + :self The mapping only handles key presses when the widget itself has the keyboard focus. Use this, for example, to install custom key mappings in a text box. - + :descendants - + The mapping handles key presses when the widget itself or any - of its descendants has keyboard focus. - + of its descendants has keyboard focus. + :global - + The mapping handles key presses as long as the top-level window containing the widget is active. This is what's used for menu shortcuts and should be used for other app-wide mappings. - + Given this, each mapping is installed on a particular widget along with the desired keystroke and action to perform. The keystroke can be any valid argument to (seesaw.keystroke/keystroke). The action can be one of the following: - + * A javax.swing.Action. See (seesaw.core/action) * A single-argument function. An action will automatically be created around it. * A button, menu, menuitem, or other button-y thing. An action that programmatically clicks the button will be created. - * nil to disable or remove a mapping + * nil to disable or remove a mapping target may be a widget, frame, or something convertible through to-widget. @@ -109,5 +109,4 @@ (.put am id act) (fn [] (.remove im ks) - (.remove am id)))) - + (.remove am id)))) \ No newline at end of file diff --git a/src/seesaw/keystroke.clj b/src/seesaw/keystroke.clj index fad57b22..e59d760c 100644 --- a/src/seesaw/keystroke.clj +++ b/src/seesaw/keystroke.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -26,7 +26,7 @@ (clojure.string/join mask (clojure.string/split s #"menu")))) (defn keystroke - "Convert an argument to a KeyStroke. When the argument is a string, follows + "Convert an argument to a KeyStroke. When the argument is a string, follows the keystroke descriptor syntax for KeyStroke/getKeyStroke (see link below). For example, @@ -42,12 +42,11 @@ See http://download.oracle.com/javase/6/docs/api/javax/swing/KeyStroke.html#getKeyStroke(java.lang.String)" [arg] - (cond + (cond (nil? arg) nil (instance? KeyStroke arg) arg (char? arg) (KeyStroke/getKeyStroke ^Character arg) (resource-key? arg) (keystroke (resource arg)) :else (if-let [ks (KeyStroke/getKeyStroke ^String (preprocess-descriptor (str arg)))] ks - (illegal-argument "Invalid keystroke descriptor: %s" arg)))) - + (illegal-argument "Invalid keystroke descriptor: %s" arg)))) \ No newline at end of file diff --git a/src/seesaw/layout.clj b/src/seesaw/layout.clj index 7f86170c..2a9a64b2 100644 --- a/src/seesaw/layout.clj +++ b/src/seesaw/layout.clj @@ -277,7 +277,7 @@ (add-widget target widget (border-layout-dirs constraint))) (get-constraint* [layout container widget] (.getConstraints layout widget)) - + java.awt.CardLayout (add!* [layout target widget constraint] (add-widget target widget (name constraint))) @@ -321,5 +321,4 @@ (doto container (.remove idx) (.add new-widget constraint idx)))) - container)) - + container)) \ No newline at end of file diff --git a/src/seesaw/make_widget.clj b/src/seesaw/make_widget.clj index 9e68f964..a56cefe8 100644 --- a/src/seesaw/make_widget.clj +++ b/src/seesaw/make_widget.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -17,9 +17,9 @@ (make-widget* [v])) (defmacro ^{:private true} def-make-widget [t b & forms] - `(extend-type + `(extend-type ~t - MakeWidget + MakeWidget (~'make-widget* ~b ~@forms))) (def-make-widget java.awt.Component [c] c) @@ -28,25 +28,24 @@ (def-make-widget javax.swing.Action [v] (JButton. v)) -(def-make-widget clojure.lang.Keyword - [v] +(def-make-widget clojure.lang.Keyword + [v] (condp = v :separator (javax.swing.JSeparator.) :fill-h (Box/createHorizontalGlue) :fill-v (Box/createVerticalGlue))) -(def-make-widget clojure.lang.IPersistentVector +(def-make-widget clojure.lang.IPersistentVector [[v0 v1 v2]] (cond (= :fill-h v0) (Box/createHorizontalStrut v1) (= :fill-v v0) (Box/createVerticalStrut v1) (= :by v1) (Box/createRigidArea (Dimension. v0 v2)))) -(def-make-widget String +(def-make-widget String [v] (JLabel. v)) (def-make-widget java.net.URL [v] - (JLabel. (icon v))) - + (JLabel. (icon v))) \ No newline at end of file diff --git a/src/seesaw/meta.clj b/src/seesaw/meta.clj index 477ef7a2..72ee0e30 100644 --- a/src/seesaw/meta.clj +++ b/src/seesaw/meta.clj @@ -35,6 +35,4 @@ (get-meta [this key] (.getClientProperty this key)) javax.swing.Action (put-meta! [this key value] (doto this (.putValue (str key) value))) - (get-meta [this key] (.getValue this (str key)))) - - + (get-meta [this key] (.getValue this (str key)))) \ No newline at end of file diff --git a/src/seesaw/mig.clj b/src/seesaw/mig.clj index 9a8404f4..e877ef40 100644 --- a/src/seesaw/mig.clj +++ b/src/seesaw/mig.clj @@ -67,5 +67,4 @@ (add!* [layout target widget constraint] (add-widget target widget constraint)) (get-constraint* [layout container widget] - (.getComponentConstraints layout widget))) - + (.getComponentConstraints layout widget))) \ No newline at end of file diff --git a/src/seesaw/mouse.clj b/src/seesaw/mouse.clj index fadf0e53..682f6372 100644 --- a/src/seesaw/mouse.clj +++ b/src/seesaw/mouse.clj @@ -60,5 +60,4 @@ Returns :left, :center, :right, or nil." [^java.awt.event.MouseEvent e] - (mouse-button-table (.getButton e))) - + (mouse-button-table (.getButton e))) \ No newline at end of file diff --git a/src/seesaw/options.clj b/src/seesaw/options.clj index 10aa561f..8bf38248 100644 --- a/src/seesaw/options.clj +++ b/src/seesaw/options.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -21,7 +21,7 @@ (apply merge (get-option-maps* this))) (defmacro option-provider [class options] - `(extend-protocol OptionProvider + `(extend-protocol OptionProvider ~class (~'get-option-maps* [this#] [~options]))) @@ -30,27 +30,27 @@ (declare apply-options) (defn- strip-question-mark - [^String s] + [^String s] (if (.endsWith s "?") (.substring s 0 (dec (count s))) s)) (defn- setter-name [property] - (->> property - name + (->> property + name strip-question-mark - (str "set-") - camelize + (str "set-") + camelize symbol)) (defn- getter-name [property] (let [property (name property) prefix (if (.endsWith property "?") "is-" "get-")] - (->> property - name + (->> property + name strip-question-mark - (str prefix) - camelize + (str prefix) + camelize symbol))) (defn- split-bean-option-name [v] @@ -58,18 +58,18 @@ (vector? v) v :else [v v])) -(defmacro bean-option +(defmacro bean-option [name-arg target-type & [set-conv get-conv examples]] (let [[option-name bean-property-name] (split-bean-option-name name-arg) target (gensym "target")] - `(Option. ~option-name + `(Option. ~option-name (fn [~(with-meta target {:tag target-type}) value#] (. ~target ~(setter-name bean-property-name) (~(or set-conv `identity) value#))) (fn [~(with-meta target {:tag target-type})] (~(or get-conv `identity) (. ~target ~(getter-name bean-property-name)))) ~examples))) -(defn default-option +(defn default-option ([name] (default-option name (fn [_ _] (illegal-argument "No setter defined for option %s" name)))) ([name setter] (default-option name setter (fn [_] (illegal-argument "No getter defined for option %s" name)))) ([name setter getter] (default-option name setter getter nil)) @@ -80,20 +80,20 @@ ([name examples] (default-option name (fn [_ _]) (fn [_ _]) "Internal use.")) ([name] (ignore-option name nil))) -(defn resource-option +(defn resource-option "Defines an option that takes a j18n namespace-qualified keyword as a value. The keyword is used as a prefix for the set of properties in the given key list. This allows subsets of widget options to be configured from a resource bundle. - + Example: - ; The :resource property looks in a resource bundle for + ; The :resource property looks in a resource bundle for ; prefix.text, prefix.foreground, etc. (resource-option :resource [:text :foreground :background]) " [option-name keys] - (default-option - option-name + (default-option + option-name (fn [target value] {:pre [(resource-key? value)]} (let [nspace (namespace value) @@ -105,12 +105,12 @@ [(keyword k) v]))) (map name keys))))) nil - [(str "A i18n prefix for a resource with keys") + [(str "A i18n prefix for a resource with keys") (pr-str keys)])) (defn- apply-option [target ^Option opt v] - (if-let [setter (:setter opt)] + (if-let [setter (:setter opt)] (setter target v) (illegal-argument "No setter found for option %s" (:name opt)))) @@ -123,7 +123,7 @@ (defn- apply-options* [target opts handler-maps] - (let [pairs (if (map? opts) opts (partition 2 opts))] + (let [pairs (if (map? opts) opts (partition 2 opts))] (doseq [[k v] pairs] (let [opt (lookup-option target handler-maps k)] (apply-option target opt v)))) @@ -131,7 +131,7 @@ (defn apply-options [target opts] - (check-args (or (map? opts) (even? (count opts))) + (check-args (or (map? opts) (even? (count opts))) "opts must be a map or have an even number of entries") (apply-options* target opts (get-option-maps* target))) @@ -152,12 +152,12 @@ ([parent-option set-conv get-conv] (around-option parent-option set-conv get-conv nil))) -(defn option-map +(defn option-map "Construct an option map from a list of options." [& opts] (into {} (map (juxt :name identity) opts))) -(defn get-option-value +(defn get-option-value ([target name] (get-option-value target name (get-option-maps* target))) ([target name handlers] (let [^Option option (lookup-option target handlers name) @@ -173,5 +173,4 @@ setter (:setter option)] (if setter (setter target value) - (illegal-argument "Option %s cannot be set on %s" name (class target)))))) - + (illegal-argument "Option %s cannot be set on %s" name (class target)))))) \ No newline at end of file diff --git a/src/seesaw/pref.clj b/src/seesaw/pref.clj index 7b599f4d..b07aadc0 100644 --- a/src/seesaw/pref.clj +++ b/src/seesaw/pref.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -10,7 +10,7 @@ (ns seesaw.pref) -(defn ^java.util.prefs.Preferences +(defn ^java.util.prefs.Preferences preferences-node* "Return the java.util.prefs.Preferences/userRoot for the specified namespace." @@ -44,7 +44,7 @@ namespace." (reset! v) (add-watch (keyword (gensym "pref-atom-watcher")) (fn [k r o n] - (when (not= o n) + (when (not= o n) (.put node key (serialize-value n)))))))) (defmacro bind-preference-to-atom @@ -66,5 +66,4 @@ namespace." (bind-preference-to-atom ~key atom#))) ([key initial-value] `(let [atom# (atom ~initial-value)] - (bind-preference-to-atom ~key atom#)))) - + (bind-preference-to-atom ~key atom#)))) \ No newline at end of file diff --git a/src/seesaw/rsyntax.clj b/src/seesaw/rsyntax.clj index 3597a330..ff1c019b 100644 --- a/src/seesaw/rsyntax.clj +++ b/src/seesaw/rsyntax.clj @@ -63,4 +63,4 @@ http://javadoc.fifesoft.com/rsyntaxtextarea/ " [& opts] - (apply core/config! (org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.) opts)) + (apply core/config! (org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.) opts)) \ No newline at end of file diff --git a/src/seesaw/scroll.clj b/src/seesaw/scroll.clj index 80633d20..1b6cb241 100644 --- a/src/seesaw/scroll.clj +++ b/src/seesaw/scroll.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -20,42 +20,42 @@ (def ^{:private true} default-handlers { ; TODO preserve current x offset for :top and bottom :top - (fn [target] + (fn [target] (scroll-rect-to-visible target (java.awt.Rectangle. 0 0 0 0))) - :bottom - (fn [^java.awt.Component target] + :bottom + (fn [^java.awt.Component target] (scroll-rect-to-visible target (java.awt.Rectangle. 0 (.getHeight target) 0 0))) ; TODO :left and :right - :point - (fn [target ^Integer x ^Integer y] + :point + (fn [target ^Integer x ^Integer y] (scroll-rect-to-visible target (java.awt.Rectangle. x y 0 0))) - :rect - (fn [target ^Integer x ^Integer y ^Integer w ^Integer h] + :rect + (fn [target ^Integer x ^Integer y ^Integer w ^Integer h] (scroll-rect-to-visible target (java.awt.Rectangle. x y w h))) }) (def ^{:private true} list-handlers { - :row + :row (fn [^javax.swing.JList target ^Integer row] - (scroll-rect-to-visible target (.getCellBounds target row row))) + (scroll-rect-to-visible target (.getCellBounds target row row))) }) (def ^{:private true} table-handlers { ; TODO preserve current column - :row + :row (fn [^javax.swing.JTable target ^Integer row] - (scroll-rect-to-visible target (.getCellRect target row 0 false))) + (scroll-rect-to-visible target (.getCellRect target row 0 false))) ; TODO preserve current row - :column + :column (fn [^javax.swing.JTable target ^Integer column] - (scroll-rect-to-visible target (.getCellRect target 0 column false))) - :cell + (scroll-rect-to-visible target (.getCellRect target 0 column false))) + :cell (fn [^javax.swing.JTable target ^Integer row ^Integer column] - (scroll-rect-to-visible target (.getCellRect target row column false))) + (scroll-rect-to-visible target (.getCellRect target row column false))) }) (defn- text-position-to-rect [^javax.swing.text.JTextComponent target ^Integer position] - (try + (try (.modelToView target position) (catch javax.swing.text.BadLocationException e nil))) @@ -70,75 +70,74 @@ ; weird behavior because the caret moves off-screen and will cause a jump ; as soon as the user tabs to the text component and starts moving the cursor. :top - (fn [^javax.swing.text.JTextComponent target] + (fn [^javax.swing.text.JTextComponent target] (set-caret-position target 0)) - :bottom + :bottom (fn [^java.awt.Component target] (set-caret-position target (dec (text-get-end-position target)))) ; TODO :left and :right ; TODO at some point reimplement :point and :rect in terms of caret ; position - :line + :line (fn [^javax.swing.text.JTextComponent target ^Integer line] - (let [root (.. target getDocument getDefaultRootElement)] + (let [root (.. target getDocument getDefaultRootElement)] (if (and (>= line 0) (< line (.getElementCount root))) - (set-caret-position target (.. root (getElement line) getStartOffset))))) + (set-caret-position target (.. root (getElement line) getStartOffset))))) :position (fn [^javax.swing.text.JTextComponent target ^Integer position] - (if (and (>= position 0) (< position (text-get-end-position target))) + (if (and (>= position 0) (< position (text-get-end-position target))) (set-caret-position target position))) }) (defn- lookup-handler [handlers op] - (if-let [h (handlers op)] + (if-let [h (handlers op)] h (illegal-argument "Unknown scroll op %s" op))) -(defn- canoncicalize-arg +(defn- canoncicalize-arg "Take the arg to (scroll!*) and turn it into a vector of the form [op & args]" [arg] (cond - (instance? java.awt.Rectangle arg) - (let [^java.awt.Rectangle r arg] + (instance? java.awt.Rectangle arg) + (let [^java.awt.Rectangle r arg] [:rect (.x r) (.y r) (.width r) (.height r)]) - (instance? java.awt.Point arg) - (let [^java.awt.Point p arg] + (instance? java.awt.Point arg) + (let [^java.awt.Point p arg] [:point (.x p) (.y p)]) (keyword? arg) [arg] (vector? arg) arg - :else (illegal-argument "Unknown scroll arg format %s" arg))) + :else (illegal-argument "Unknown scroll arg format %s" arg))) (defprotocol ^{:private true} Scroll - (scroll-to [this arg])) + (scroll-to [this arg])) (defn- default-scroll-to-impl [target arg handlers] (let [[op & args] arg] (apply (lookup-handler handlers op) target args))) (extend-protocol Scroll - javax.swing.JComponent - (scroll-to [this arg] + javax.swing.JComponent + (scroll-to [this arg] (default-scroll-to-impl this arg default-handlers)) javax.swing.JList - (scroll-to [this arg] + (scroll-to [this arg] (default-scroll-to-impl this arg (merge default-handlers list-handlers))) javax.swing.JTable - (scroll-to [this arg] + (scroll-to [this arg] (default-scroll-to-impl this arg (merge default-handlers table-handlers))) javax.swing.text.JTextComponent - (scroll-to [this arg] + (scroll-to [this arg] (default-scroll-to-impl this arg (merge default-handlers text-handlers))) - + ; TODO implement JTree ops ) (defn scroll!* [target modifier arg] (check-args (not (nil? target)) "target of scroll!* cannot be nil") - (condp = modifier + (condp = modifier :to (scroll-to target (canoncicalize-arg arg))) - target) - + target) \ No newline at end of file diff --git a/src/seesaw/selection.clj b/src/seesaw/selection.clj index a4ee7489..f0d94a2f 100644 --- a/src/seesaw/selection.clj +++ b/src/seesaw/selection.clj @@ -156,7 +156,4 @@ (set-selection target (if (or (nil? values) (:multi? opts)) values [values]) ) - target)) - - - + target)) \ No newline at end of file diff --git a/src/seesaw/selector.clj b/src/seesaw/selector.clj index 8d8af2e2..46b83055 100644 --- a/src/seesaw/selector.clj +++ b/src/seesaw/selector.clj @@ -558,5 +558,4 @@ ;bindings)] ;`(map (fn [~node-or-fragment] ;(let [~@bindings] - ;~@body)) ~nodes-or-fragments))) - + ;~@body)) ~nodes-or-fragments))) \ No newline at end of file diff --git a/src/seesaw/style.clj b/src/seesaw/style.clj index a81949e3..67c7aa3c 100644 --- a/src/seesaw/style.clj +++ b/src/seesaw/style.clj @@ -37,5 +37,4 @@ [root stylesheet] (doseq [[sel style] stylesheet] (apply config! (select root sel) (reduce concat style))) - root) - + root) \ No newline at end of file diff --git a/src/seesaw/swingx.clj b/src/seesaw/swingx.clj index 82a546fa..53414650 100644 --- a/src/seesaw/swingx.clj +++ b/src/seesaw/swingx.clj @@ -751,5 +751,4 @@ (abstract-panel-x (grid-layout rows columns) opts)) (defn card-panel-x [& opts] - (abstract-panel-x (java.awt.CardLayout.) opts)) - + (abstract-panel-x (java.awt.CardLayout.) opts)) \ No newline at end of file diff --git a/src/seesaw/table.clj b/src/seesaw/table.clj index 3c8cdc35..70db36ad 100644 --- a/src/seesaw/table.clj +++ b/src/seesaw/table.clj @@ -302,5 +302,4 @@ (defn column-count "Return number of columns in a table model or JTable." [target] - (.getColumnCount (to-table-model target))) - + (.getColumnCount (to-table-model target))) \ No newline at end of file diff --git a/src/seesaw/timer.clj b/src/seesaw/timer.clj index 7697fe23..1aaea20f 100644 --- a/src/seesaw/timer.clj +++ b/src/seesaw/timer.clj @@ -45,5 +45,4 @@ t (javax.swing.Timer. 0 a)] (apply-options t (dissoc opts :start? :initial-value)) (when start? (.start t)) - t)) - + t)) \ No newline at end of file diff --git a/src/seesaw/to_widget.clj b/src/seesaw/to_widget.clj index 8f9268f2..5ab21c8c 100644 --- a/src/seesaw/to_widget.clj +++ b/src/seesaw/to_widget.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -13,20 +13,19 @@ (:import [java.awt Dimension] [javax.swing Box JLabel JButton])) -(defprotocol ToWidget +(defprotocol ToWidget (to-widget* [v])) (defmacro ^{:private true} def-to-widget [t b & forms] - `(extend-type + `(extend-type ~t - ToWidget + ToWidget (~'to-widget* ~b ~@forms))) (def-to-widget Object [c] nil) (def-to-widget java.awt.Component [c] c) -(def-to-widget java.util.EventObject - [v] - (try-cast java.awt.Component (.getSource v))) - +(def-to-widget java.util.EventObject + [v] + (try-cast java.awt.Component (.getSource v))) \ No newline at end of file diff --git a/src/seesaw/tree.clj b/src/seesaw/tree.clj index 84d28c48..1d6d9809 100644 --- a/src/seesaw/tree.clj +++ b/src/seesaw/tree.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -21,13 +21,13 @@ (defn- ensure-array [v] (if v (to-array v))) -(defn node-structure-changed - "Fire a node structure changed event on a tree model created with +(defn node-structure-changed + "Fire a node structure changed event on a tree model created with (simple-tree-model). node-path is the sequence of nodes from the model root to the node whose structure changed. Call this when the entire structure under a node has changed. - + See: (seesaw.tree/simple-tree-model) " @@ -39,8 +39,8 @@ nil nil))) -(defn nodes-removed - "Fire a node removed event on a tree model created with +(defn nodes-removed + "Fire a node removed event on a tree model created with (simple-tree-model). parent-path is the path to the parent node, indices is a seq of the indices of the removed nodes and children is a seq of the removed nodes. @@ -52,13 +52,13 @@ [tree-model parent-path indices children] (fire-event* tree-model :tree-nodes-removed - (javax.swing.event.TreeModelEvent. tree-model + (javax.swing.event.TreeModelEvent. tree-model (ensure-array parent-path) (int-array indices) (ensure-array children)))) -(defn node-removed - "Fire a node removed event on a tree model created with +(defn node-removed + "Fire a node removed event on a tree model created with (simple-tree-model). parent-path is the path to the parent node, index is the index of the removed node and child is the removed node. @@ -70,30 +70,30 @@ (nodes-removed tree-model parent-path [index] [child])) (defn- build-insert-or-change-event [tree-model parent-path children] - (let [indices (if-let [parent (last parent-path)] + (let [indices (if-let [parent (last parent-path)] (map #(.getIndexOfChild tree-model parent %) children)) ] - (javax.swing.event.TreeModelEvent. tree-model + (javax.swing.event.TreeModelEvent. tree-model (ensure-array parent-path) (if indices (int-array indices)) (ensure-array children)))) -(defn nodes-inserted +(defn nodes-inserted "Fire a node insertion event. parent-path is the path to the parent of the newly inserted children. children is the newly inserted nodes. - + See: (seesaw.tree/node-inserted) (seesaw.tree/simple-tree-model) " [tree-model parent-path children] - (fire-event* tree-model + (fire-event* tree-model :tree-nodes-inserted (build-insert-or-change-event tree-model parent-path children))) -(defn node-inserted +(defn node-inserted "Fire a node insertion event. parent-path is the path to the parent of the newly inserted child. child is the newly inserted node. - + See: (seesaw.tree/nodes-inserted) (seesaw.tree/simple-tree-model) @@ -101,31 +101,31 @@ [tree-model node-path] (let [parent-path (butlast node-path) node (last node-path)] - (nodes-inserted tree-model - (or parent-path [node]) + (nodes-inserted tree-model + (or parent-path [node]) (if parent-path [node])))) -(defn nodes-changed +(defn nodes-changed "Fire a node changed event. parent-path is the path to the parent of the changed children. children is the changed nodes. Fire this event if the appearance of a node has changed in any way. - + See: (seesaw.tree/node-changed) (seesaw.tree/simple-tree-model) " [tree-model parent-path children] - (fire-event* tree-model - :tree-nodes-changed + (fire-event* tree-model + :tree-nodes-changed (build-insert-or-change-event tree-model parent-path children))) -(defn node-changed +(defn node-changed "Fire a node changed event. parent-path is the path to the parent of the changed node. child is the changed node. Fire this event if the appearance of a node has changed in any way. - + See: (seesaw.tree/nodes-changed) (seesaw.tree/simple-tree-model) @@ -133,8 +133,8 @@ [tree-model node-path] (let [parent-path (butlast node-path) node (last node-path)] - (nodes-changed tree-model - (or parent-path [node]) + (nodes-changed tree-model + (or parent-path [node]) (if parent-path [node])))) (defn simple-tree-model @@ -142,7 +142,7 @@ The arguments are the same as clojure.core/tree-seq. Changes to the underlying model can be reported with the various node-xxx event functions in seesaw.tree. - + See: http://docs.oracle.com/javase/6/docs/api/javax/swing/tree/TreeModel.html " @@ -153,7 +153,7 @@ (getRoot [this] root) (getChildCount [this parent] (count (children parent))) (getChild [this parent index] (nth (children parent) index)) - (getIndexOfChild [this parent child] + (getIndexOfChild [this parent child] (first (keep-indexed #(when (= %2 child) %1) (children parent)))) (isLeaf [this node] (not (branch? node))) (addTreeModelListener [this listener] @@ -170,5 +170,4 @@ :tree-nodes-removed #(.treeNodesRemoved %1 %2) :tree-structure-changed #(.treeStructureChanged %1 %2))] (doseq [listener @listeners] - (handler listener event))))))) - + (handler listener event))))))) \ No newline at end of file diff --git a/src/seesaw/util.clj b/src/seesaw/util.clj index f8a93a1d..2981b2cb 100644 --- a/src/seesaw/util.clj +++ b/src/seesaw/util.clj @@ -2,23 +2,23 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. ; You must not remove this notice, or any other, from this software. (ns seesaw.util - (:require clojure.string + (:require clojure.string [j18n.core :as j18n]) (:import [java.net URL URI MalformedURLException URISyntaxException])) -(defn illegal-argument +(defn illegal-argument "Throw an illegal argument exception formatted as with (clojure.core/format)" [fmt & args] (throw (IllegalArgumentException. ^String (apply format fmt args)))) -(defn check-args +(defn check-args [condition message] (if-not condition (throw (IllegalArgumentException. ^String message)) @@ -34,10 +34,10 @@ "Spawn of (cond) and (doto). Works like (doto), but each form has a condition which controls whether it is executed. Returns x. - (doto (new java.util.HashMap) - true (.put \"a\" 1) + (doto (new java.util.HashMap) + true (.put \"a\" 1) (< 2 1) (.put \"b\" 2)) - + Here, only (.put \"a\" 1) is executed. " [x & forms] @@ -52,7 +52,7 @@ (defn to-seq [v] "Stupid helper to turn possibly single values into seqs" - (cond + (cond (nil? v) v (seq? v) v (coll? v) (seq v) @@ -63,13 +63,13 @@ (.. (name k) (toUpperCase) (replace "-" "_"))) (defn constant-map - "Given a class and a list of keywordized constant names returns the + "Given a class and a list of keywordized constant names returns the values of those fields in a map. The name mapping upper-cases and replaces hyphens with underscore, e.g. - + :above-baseline --> ABOVE_BASELINE - Note that the fields must be static and declared *in* the class, not a + Note that the fields must be static and declared *in* the class, not a supertype. " [^Class klass & fields] @@ -78,13 +78,13 @@ (reduce (fn [m [k v]] (assoc m k v)) {} - (map - #(vector %1 (.. klass - (getDeclaredField (str (constantize-keyword %1) suffix)) + (map + #(vector %1 (.. klass + (getDeclaredField (str (constantize-keyword %1) suffix)) (get nil))) fields)))) - - + + (defn camelize "Convert input string to camelCase from hyphen-case" [s] @@ -92,7 +92,7 @@ (defn boolean? [b] "Return true if b is exactly true or false. Useful for handling optional - boolean properties where we want to do nothing if the property isn't + boolean properties where we want to do nothing if the property isn't provided." (or (true? b) (false? b))) @@ -107,7 +107,7 @@ (catch ClassCastException e nil))) (defn ^URL to-url [s] - "Try to parse (str s) as a URL. Returns new java.net.URL on success, nil + "Try to parse (str s) as a URL. Returns new java.net.URL on success, nil otherwise. This is different from clojure.java.io/as-url in that it doesn't throw an exception and it uses (str) on the input." (if (instance? URL s) s @@ -141,8 +141,8 @@ (java.awt.Insets. top left (or bottom top) (or right left))) :else (illegal-argument "Don't know how to create insets from %s" v))) -(defprotocol Children - "A protocol for retrieving the children of a widget as a seq. +(defprotocol Children + "A protocol for retrieving the children of a widget as a seq. This takes care of idiosyncracies of frame vs. menus, etc." (children [c] "Returns a seq of the children of the given widget")) @@ -158,12 +158,12 @@ (defn collect "Given a root widget or frame, returns a depth-fist seq of all the widgets in the hierarchy. For example to disable everything: - + (config (collect (.getContentPane my-frame)) :enabled? false) " [root] - (tree-seq - (constantly true) + (tree-seq + (constantly true) children root)) @@ -180,21 +180,20 @@ (defn ^Integer to-mnemonic-keycode "Convert a character to integer to a mnemonic keycode. In the case of char - input, generates the correct keycode even if it's lower case. Input argument + input, generates the correct keycode even if it's lower case. Input argument can be: * i18n resource keyword - only first char is used * string - only first char is used * char - lower or upper case * int - key event code - + See: java.awt.event.KeyEvent for list of keycodes http://download.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html" [v] - (cond + (cond (resource-key? v) (to-mnemonic-keycode (resource v)) (string? v) (to-mnemonic-keycode (.charAt ^String v 0)) (char? v) (int (Character/toUpperCase ^Character v)) - :else (int v))) - + :else (int v))) \ No newline at end of file diff --git a/src/seesaw/value.clj b/src/seesaw/value.clj index 97564675..ac29ae8b 100644 --- a/src/seesaw/value.clj +++ b/src/seesaw/value.clj @@ -86,5 +86,4 @@ ; TODO Tree? ; TODO Table? - ) - + ) \ No newline at end of file diff --git a/src/seesaw/widget_options.clj b/src/seesaw/widget_options.clj index bc5f5c79..19afda8d 100644 --- a/src/seesaw/widget_options.clj +++ b/src/seesaw/widget_options.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -18,7 +18,7 @@ (get-layout-option-map* [this])) (extend-protocol OptionProvider - javax.swing.JComponent + javax.swing.JComponent (get-option-maps* [this] (concat (get-widget-option-map* this) @@ -28,11 +28,10 @@ (get-option-maps* [this] nil)) (defmacro widget-option-provider [class options & [nil-layout-options]] - `(extend-protocol WidgetOptionProvider + `(extend-protocol WidgetOptionProvider ~class (~'get-widget-option-map* [this#] [~options]) (~'get-layout-option-map* [this#] (if-let [layout# (.getLayout this#)] (get-option-maps* layout#) - [~nil-layout-options])))) - + [~nil-layout-options])))) \ No newline at end of file diff --git a/src/seesaw/widgets/log_window.clj b/src/seesaw/widgets/log_window.clj index 21a23927..acb90aa8 100644 --- a/src/seesaw/widgets/log_window.clj +++ b/src/seesaw/widgets/log_window.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -19,7 +19,7 @@ (defn- log-window-proxy [state] (proxy [javax.swing.JTextArea clojure.lang.IDeref] [] ; Implement IDeref - (deref [] state) + (deref [] state) ; this is how you disable auto-scrolling :( (scrollRectToVisible [rect] @@ -30,18 +30,18 @@ (log [this message] "Log a message to the given log-window") (clear [this] "Clear the contents of the log-window")) -(defn logf +(defn logf "Log a formatted message to the given log-window." [this fmt & args] (log this (apply format fmt args))) (defn log-window "An auto-scrolling log window. - - The returned widget implements the LogWindow protocol with - which you can clear it, or append messages. It is thread-safe, - i.e. messages logged from multiple threads won't be interleaved. - + + The returned widget implements the LogWindow protocol with + which you can clear it, or append messages. It is thread-safe, + i.e. messages logged from multiple threads won't be interleaved. + It must be wrapped in (seesaw.core/scrollable) for scrolling. Includes a context menu with options for clearing the window @@ -62,12 +62,12 @@ " [& opts] (let [state {:buffer (StringBuffer.) ; Buffer text from other threads here - :limit (atom nil) + :limit (atom nil) :auto-scroll? (atom true) ; Efficiently tell the ui thread to grab the buffer ; contents and move it to the text area. :signal (signaller [this] - (let [{:keys [buffer limit]} @this] + (let [{:keys [buffer limit]} @this] (locking buffer (.append this (str buffer)) (.setLength buffer 0)) @@ -77,11 +77,11 @@ (if (> length limit) (.remove doc 0 (- length limit))))))) } - this (log-window-proxy state) + this (log-window-proxy state) scroll-item (checkbox-menu-item :resource ::scroll :selected? true) - + clear-action (action :resource ::clear :handler (fn [_] (clear this)))] @@ -97,7 +97,7 @@ ; Apply default options and whatever options are provided. (apply-options - this + this (concat [:editable? false :font :monospaced @@ -111,11 +111,11 @@ (let [{:keys [buffer signal]} @this] (.append buffer message) (signal this))) - (clear [this] + (clear [this] (invoke-soon (text! this ""))) - WidgetOptionProvider - (get-widget-option-map* [this] + WidgetOptionProvider + (get-widget-option-map* [this] [text-area-options (option-map (default-option :limit @@ -125,5 +125,4 @@ (default-option :auto-scroll? (fn [this v] (reset! (:auto-scroll? @this) v)) (fn [this] @(:auto-scroll? @this))))]) - (get-layout-option-map* [this] nil)) - + (get-layout-option-map* [this] nil)) \ No newline at end of file diff --git a/src/seesaw/widgets/rounded_label.clj b/src/seesaw/widgets/rounded_label.clj index e07c0dac..8f25fd26 100644 --- a/src/seesaw/widgets/rounded_label.clj +++ b/src/seesaw/widgets/rounded_label.clj @@ -53,5 +53,4 @@ (-> (frame :content (rounded-label :border 5 :background :darkgrey :text "I'm a rounded label")) - pack! show!)) - + pack! show!)) \ No newline at end of file diff --git a/test/seesaw/test/action.clj b/test/seesaw/test/action.clj index b2a4c5c3..c257a396 100644 --- a/test/seesaw/test/action.clj +++ b/test/seesaw/test/action.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -26,7 +26,7 @@ (expect (not (.getValue a Action/SELECTED_KEY))) (expect (= "This is a tip" (.getValue a Action/SHORT_DESCRIPTION))))) (it "sets the mnemonic of the action given an integer key code" - (let [m (.getValue (action :mnemonic 99) Action/MNEMONIC_KEY)] + (let [m (.getValue (action :mnemonic 99) Action/MNEMONIC_KEY)] ; For Clojure 1.3, ensure that it's an Integer in there and not a Long (expect (instance? java.lang.Integer m)) (expect (= 99 m)))) @@ -36,7 +36,7 @@ (expect (instance? java.lang.Integer m)) (expect (= (int \T) m)))) (it "sets the mnemonic of the action given a lower-case character" - (let [m (.getValue (action :mnemonic \t) Action/MNEMONIC_KEY)] + (let [m (.getValue (action :mnemonic \t) Action/MNEMONIC_KEY)] ; For Clojure 1.3, ensure that it's an Integer in there and not a Long (expect (instance? java.lang.Integer m)) (expect (= (int \T) m)))) @@ -81,5 +81,4 @@ (it "loads :key from a resource" (expect (= (keystroke "ctrl C") (config (action :key ::my-action.key) :key)))) (it "loads :tip from a resource" - (expect (= "A tip" (config (action :tip ::my-action.tip) :tip))))) - + (expect (= "A tip" (config (action :tip ::my-action.tip) :tip))))) \ No newline at end of file diff --git a/test/seesaw/test/action.properties b/test/seesaw/test/action.properties index a65a7035..68d7335d 100644 --- a/test/seesaw/test/action.properties +++ b/test/seesaw/test/action.properties @@ -6,4 +6,3 @@ my-action.command=A command my-action.key=ctrl C my-action.mnemonic=X my-action.icon=seesaw/test/examples/rss.gif - diff --git a/test/seesaw/test/behave.clj b/test/seesaw/test/behave.clj index cf02c9dc..45926999 100644 --- a/test/seesaw/test/behave.clj +++ b/test/seesaw/test/behave.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -21,5 +21,4 @@ ; Simulate focus gained :( (doseq [l (.getFocusListeners t)] (.focusGained l (java.awt.event.FocusEvent. t java.awt.event.FocusEvent/FOCUS_GAINED))) - (expect (= "Hi there" (.getSelectedText t)))))) - + (expect (= "Hi there" (.getSelectedText t)))))) \ No newline at end of file diff --git a/test/seesaw/test/bind.clj b/test/seesaw/test/bind.clj index 81b1dd7d..5f775e37 100644 --- a/test/seesaw/test/bind.clj +++ b/test/seesaw/test/bind.clj @@ -33,7 +33,7 @@ (cb) (reset! a 6) (expect (= [6 5 5] [@a @b @c])))) - + (it "can chain bindables, including composites, together" (let [a (atom 1) b (atom nil)] @@ -105,7 +105,7 @@ (bind v (.getModel sl)) (reset! v 20) (expect (= (.getValue sl) 20))))) - + (testing "given a toggle button (or any button/menu)" (it "should sync the selection state of the button" (let [v (atom nil) @@ -213,7 +213,7 @@ (reset! b 6) (expect (= [5 6] @end))))) -(describe filter +(describe filter (it "doesn't pass along value when predicate returns falsey" (let [start (atom :foo) end (atom :bar)] @@ -255,7 +255,7 @@ (reset! input :b) (expect (= :b (ssc/selection lb)))))) -(describe value +(describe value (it "maps its input to the value of a widget" (let [input (atom nil) lb (ssc/listbox :id :lb :model [:a :b :c]) @@ -281,8 +281,8 @@ (let [start (atom nil) target (atom []) end (atom nil)] - (bind start - (b-swap! target conj) + (bind start + (b-swap! target conj) end) (reset! start 1) (reset! start 2) @@ -294,7 +294,7 @@ (it "acts like send passing the old value, new value, and additional args to a function" (let [start (atom nil) target (agent [])] - (bind start + (bind start (b-send target conj) ) (reset! start 1) (reset! start 2) @@ -306,7 +306,7 @@ (it "acts like sendoff passing the old value, new value, and additional args to a function" (let [start (atom nil) target (agent [])] - (bind start + (bind start (b-send-off target conj) ) (reset! start 1) (reset! start 2) @@ -372,7 +372,7 @@ (unsubscribe) (await (send target (fn [_] "b"))) (expect (= 1 @calls))))) - + (testing "on a javax.swing.text.Document" (it "should return a function that unsubscribes" (let [calls (atom 0) @@ -394,7 +394,7 @@ (unsub) (.setValue target 2) (expect (= 1 @calls))))) - + (testing "on a funnel" (it "should return a function that unsubscribes" (let [calls (atom 0) @@ -407,7 +407,7 @@ (reset! a "hi") (expect (= 1 @calls)) ))) - + (testing "on a widget property" (it "should return a function that unsubscribes" (let [calls (atom 0) @@ -451,5 +451,4 @@ (unsub) (notify target "bye") (expect (= 1 @calls)) - )))) - + ))) \ No newline at end of file diff --git a/test/seesaw/test/border.clj b/test/seesaw/test/border.clj index 15c8d22a..bc5836e7 100644 --- a/test/seesaw/test/border.clj +++ b/test/seesaw/test/border.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -114,5 +114,4 @@ (let [called (atom false) b (custom-border :paint (fn [c g x y w h] (reset! called true)))] (.paintBorder b nil nil 0 0 0 0) - (expect @called)))) - + (expect @called)))) \ No newline at end of file diff --git a/test/seesaw/test/cells.clj b/test/seesaw/test/cells.clj index 354dd24d..46026efd 100644 --- a/test/seesaw/test/cells.clj +++ b/test/seesaw/test/cells.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -19,7 +19,7 @@ (it "proxies a DefaultListCellRenderer which dispatches to a function" (let [expected-font (font :name "ARIAL-BOLD-18") jlist (javax.swing.JList.) - render-fn (fn [renderer info] + render-fn (fn [renderer info] (config! renderer :foreground java.awt.Color/YELLOW :text "hi" :icon nil @@ -35,7 +35,7 @@ (it "proxies a DefaultTreeCellRenderer which dispatches to a function" (let [expected-font (font :name "ARIAL-BOLD-18") jtree (javax.swing.JTree.) - render-fn (fn [renderer info] + render-fn (fn [renderer info] (config! renderer :foreground java.awt.Color/YELLOW :text "hi" :icon nil @@ -57,6 +57,4 @@ (it "creates a list cell renderer for a JList" (instance? javax.swing.ListCellRenderer (to-cell-renderer (javax.swing.JList.) (fn [r i])))) (it "creates a list cell renderer for a JComboBox" - (instance? javax.swing.ListCellRenderer (to-cell-renderer (javax.swing.JComboBox.) (fn [r i]))))) - - + (instance? javax.swing.ListCellRenderer (to-cell-renderer (javax.swing.JComboBox.) (fn [r i]))))) \ No newline at end of file diff --git a/test/seesaw/test/chooser.clj b/test/seesaw/test/chooser.clj index f4e9d5af..7635d66a 100644 --- a/test/seesaw/test/chooser.clj +++ b/test/seesaw/test/chooser.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. diff --git a/test/seesaw/test/color.clj b/test/seesaw/test/color.clj index 7056197a..e01d3786 100644 --- a/test/seesaw/test/color.clj +++ b/test/seesaw/test/color.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -59,6 +59,4 @@ c (default-color name) expected (.getColor (javax.swing.UIManager/getDefaults) name)] (expect (not (nil? c))) - (expect (= c expected))))) - - + (expect (= c expected))))) \ No newline at end of file diff --git a/test/seesaw/test/config.clj b/test/seesaw/test/config.clj index 28affa1b..59f98922 100644 --- a/test/seesaw/test/config.clj +++ b/test/seesaw/test/config.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -13,5 +13,4 @@ (:use [lazytest.describe :only (describe it testing)] [lazytest.expect :only (expect)])) -; Pretty much tested in core - +; Pretty much tested in core \ No newline at end of file diff --git a/test/seesaw/test/core.clj b/test/seesaw/test/core.clj index 26de2d1b..8312c3b8 100644 --- a/test/seesaw/test/core.clj +++ b/test/seesaw/test/core.clj @@ -1645,4 +1645,3 @@ (expect (visible? b)) (show-card! p "third") (expect (visible? c))))) - diff --git a/test/seesaw/test/cursor.clj b/test/seesaw/test/cursor.clj index c4f7988b..681d769a 100644 --- a/test/seesaw/test/cursor.clj +++ b/test/seesaw/test/cursor.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -40,5 +40,4 @@ (let [icon (javax.swing.ImageIcon. (buffered-image 16 16)) cur (cursor icon [5 5])] ; Can't actually test that the hotspot was set - (= (Cursor/CUSTOM_CURSOR) (.getType cur))))) - + (= (Cursor/CUSTOM_CURSOR) (.getType cur))))) \ No newline at end of file diff --git a/test/seesaw/test/dnd.clj b/test/seesaw/test/dnd.clj index 5ea162e6..6ea7f487 100644 --- a/test/seesaw/test/dnd.clj +++ b/test/seesaw/test/dnd.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -27,8 +27,8 @@ (describe uri-list-flavor (it "implements to-remote to convert list of URIs to uri-list" - (= "http://google.com\r\nhttp://github.com" - (to-remote uri-list-flavor + (= "http://google.com\r\nhttp://github.com" + (to-remote uri-list-flavor [(java.net.URI. "http://google.com") (java.net.URI. "http://github.com")]))) (it "implements to-local to convert uri-list to list of URIs" @@ -42,13 +42,13 @@ t (default-transferable [string-flavor o])] (expect (identical? o (.getTransferData t (to-raw-flavor string-flavor)))))) (it "can hold arbitrary objects or functions" - (let [t (default-transferable [string-flavor "hi" + (let [t (default-transferable [string-flavor "hi" (local-object-flavor Integer) (fn [] 99)])] (expect (= "hi" (.getTransferData t (to-raw-flavor string-flavor)))) (expect (= 99 (.getTransferData t (to-raw-flavor (local-object-flavor Integer))))))) (it "throws UnsupportedFlavorException correctly" (let [t (default-transferable [string-flavor "hi"])] - (try (.getTransferData t (to-raw-flavor file-list-flavor)) false + (try (.getTransferData t (to-raw-flavor file-list-flavor)) false (catch UnsupportedFlavorException e true)))) (it "implements (getTransferDataFlavors)" (let [t (default-transferable [(local-object-flavor []) []]) @@ -63,11 +63,11 @@ (javax.swing.TransferHandler$TransferSupport. (javax.swing.JLabel.) t)) (describe default-transfer-handler - (testing "(default-transfer-handler)" + (testing "(default-transfer-handler)" (it "creates a transfer handler" (instance? javax.swing.TransferHandler (default-transfer-handler))) (it "throws an ex-info if there is a handler-map without an on-drop key" - (try + (try (default-transfer-handler :import [string-flavor {}]) false (catch clojure.lang.ExceptionInfo e true)))) @@ -79,24 +79,24 @@ (let [th (default-transfer-handler :import [string-flavor (fn [info])])] (expect (.canImport th (fake-transfer-support (StringSelection. "hi")))) (expect (not (.canImport th (fake-transfer-support (default-transferable []))))))) - + (let [transfer-handler (default-transfer-handler :import [string-flavor {:on-drop (fn [info]) - :can-drop? (fn [info] + :can-drop? (fn [info] (= info "should match"))}])] (testing ":can-drop?" (it "returns false if the import handler is a map and :can-drop? returns false" - (not (.canImport transfer-handler + (not (.canImport transfer-handler (fake-transfer-support (StringSelection. "should not match"))))) - + (it "returns true if the import handler is a map and :can-drop? returns true" - (.canImport transfer-handler + (.canImport transfer-handler (fake-transfer-support (StringSelection. "should match")))) - + (let [transfer-handler (default-transfer-handler :import [string-flavor {:on-drop (fn [info])}])] (it "returns true if the import handler is a map and :can-drop? is not given" - (.canImport transfer-handler + (.canImport transfer-handler (fake-transfer-support (StringSelection. "should match")))))))) (testing "(importData)" @@ -158,6 +158,4 @@ called (atom nil) th (default-transfer-handler :export { :finish (fn [v] (reset! called v) true) })] (.exportDone th source tr TransferHandler/MOVE) - (expect (= {:source source :data tr :action :move} @called)))))) - - + (expect (= {:source source :data tr :action :move} @called)))))) \ No newline at end of file diff --git a/test/seesaw/test/event.clj b/test/seesaw/test/event.clj index 070bd738..0ba0823f 100644 --- a/test/seesaw/test/event.clj +++ b/test/seesaw/test/event.clj @@ -371,5 +371,4 @@ (reset! called nil) (remove-fn) (.setText b "BYE") - (expect (nil? @called))))) - + (expect (nil? @called))))) \ No newline at end of file diff --git a/test/seesaw/test/examples/behave.clj b/test/seesaw/test/examples/behave.clj index 2d49d5b4..1ec5047e 100644 --- a/test/seesaw/test/examples/behave.clj +++ b/test/seesaw/test/examples/behave.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -12,7 +12,7 @@ (:use [seesaw core behave] seesaw.test.examples.example)) -; Examples of stuff in (seesaw.behave). +; Examples of stuff in (seesaw.behave). (defn focus-select [] (vertical-panel @@ -29,5 +29,4 @@ (defexample [] (frame :title "seesaw.behave examples" :content (focus-select))) -;(run :dispose) - +;(run :dispose) \ No newline at end of file diff --git a/test/seesaw/test/examples/bind.clj b/test/seesaw/test/examples/bind.clj index a3e48e5a..6a658874 100644 --- a/test/seesaw/test/examples/bind.clj +++ b/test/seesaw/test/examples/bind.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -16,7 +16,7 @@ (defn regex-box [& opts] (let [pattern (text :id :search :columns 20 :border [5 (line-border)]) status (label :text "Ready" :h-text-position :left)] - (b/bind + (b/bind ; As the text of the textbox changes ... pattern ; Convert it to a regex, or nil if it's invalid @@ -25,23 +25,23 @@ (b/tee ; The first path sets the color of the text box depending ; on whether the regex was valid - (b/bind - (b/transform #(if % "white" "lightcoral")) + (b/bind + (b/transform #(if % "white" "lightcoral")) (b/property pattern :background)) ; The second path sets the text of the status label - (b/bind - (b/transform #(if % "Ready" "Invalid regex")) + (b/bind + (b/transform #(if % "Ready" "Invalid regex")) status))) - (border-panel - :north "Enter a search string:" + (border-panel + :north "Enter a search string:" :center pattern :south status :vgap 5 :border 5))) (defexample [] - (let [f (frame + (let [f (frame :title "Seesaw (bind) example" - :content (border-panel :north (checkbox :id :enable + :content (border-panel :north (checkbox :id :enable :text "Enable search" :selected? true) :center (regex-box)))] @@ -53,4 +53,3 @@ f)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/button_group.clj b/test/seesaw/test/examples/button_group.clj index 35c67285..488a6734 100644 --- a/test/seesaw/test/examples/button_group.clj +++ b/test/seesaw/test/examples/button_group.clj @@ -55,4 +55,3 @@ :content (content))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/canvas.clj b/test/seesaw/test/examples/canvas.clj index 9a72f6df..72eef81f 100644 --- a/test/seesaw/test/examples/canvas.clj +++ b/test/seesaw/test/examples/canvas.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -47,9 +47,9 @@ (def text-style (style :foreground (color 0 0 0) :font "ARIAL-BOLD-24")) -(def star - (path [] - (move-to 0 20) (line-to 5 5) +(def star + (path [] + (move-to 0 20) (line-to 5 5) (line-to 20 0) (line-to 5 -5) (line-to 0 -20) (line-to -5 -5) (line-to -20 0) (line-to -5 5) @@ -74,16 +74,16 @@ ; Note that we can use (config!) to set the :paint handler just like ; properties on other widgets. (defn switch-paint-action [n paint] - (action :name n + (action :name n :handler #(-> (to-frame %) (select [:#canvas]) (config! :paint paint)))) (defexample [] - (frame - :title "Canvas Example" + (frame + :title "Canvas Example" :width 500 :height 300 - :content + :content (border-panel :hgap 5 :vgap 5 :border 5 ; Create the canvas with initial nil paint function, i.e. just canvas ; will be filled with it's background color and that's it. @@ -96,4 +96,3 @@ (switch-paint-action "Ovals" paint2)])))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/cell_renderers.clj b/test/seesaw/test/examples/cell_renderers.clj index cb6bad03..92291710 100644 --- a/test/seesaw/test/examples/cell_renderers.clj +++ b/test/seesaw/test/examples/cell_renderers.clj @@ -12,16 +12,15 @@ ; properties in the normal way. (defn render-fn [renderer info] (let [v (:value info)] - (apply config! renderer - (if (even? v) + (apply config! renderer + (if (even? v) [:text (str v " is even") :font even-font :foreground "#000033"] [:text (str v " is odd") :font odd-font :foreground "#aaaaee"])))) (defexample [] (frame :title "Cell Renderer Example" - :content (scrollable - (listbox :model (range 5 25) - :renderer render-fn)))) + :content (scrollable + (listbox :model (range 5 25) + :renderer render-fn)))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/clock.clj b/test/seesaw/test/examples/clock.clj index 3b57a6fd..f3e3fe2c 100644 --- a/test/seesaw/test/examples/clock.clj +++ b/test/seesaw/test/examples/clock.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -38,10 +38,10 @@ (def tick-style (style :foreground java.awt.Color/DARK_GRAY :stroke (stroke :width 3 :cap :round))) -(defn second-so-far [] +(defn second-so-far [] (let [d (java.util.Date.)] - (+ - (* (.getHours d) 60 60) + (+ + (* (.getHours d) 60 60) (* (.getMinutes d) 60) (.getSeconds d)))) @@ -78,10 +78,9 @@ (defexample [] (let [cvs (canvas :id :canvas :background "#BBBBBB" :paint paint-clock) t (timer (fn [e] (repaint! cvs)) :delay 1000)] - (frame - :title "Seesaw Canvas Clock" + (frame + :title "Seesaw Canvas Clock" :width 400 :height 400 :content cvs))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/custom_border.clj b/test/seesaw/test/examples/custom_border.clj index 05b8e871..2cab53dd 100644 --- a/test/seesaw/test/examples/custom_border.clj +++ b/test/seesaw/test/examples/custom_border.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -14,14 +14,13 @@ seesaw.test.examples.example)) (defexample [] - (frame + (frame :size [400 :by 400] :content (label :text "I have a custom border" - :border (custom-border :insets 10 + :border (custom-border :insets 10 :paint (fn [c g x y w h] (doto g (.setColor java.awt.Color/RED) (.drawRoundRect (+ 5 x) (+ 5 y) (- w 10) (- h 10) 15 15))))))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/custom_dialog.clj b/test/seesaw/test/examples/custom_dialog.clj index 1b55a48c..0f40ff1c 100644 --- a/test/seesaw/test/examples/custom_dialog.clj +++ b/test/seesaw/test/examples/custom_dialog.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -16,58 +16,57 @@ [] (let [ok-act (action :name "Ok" :handler (fn [e] (return-from-dialog e "OK"))) cancel-act (action :name "Cancel" :handler (fn [e] (return-from-dialog e "Cancel")))] - (-> (custom-dialog + (-> (custom-dialog :modal? true :title "More Options" :content (flow-panel :items [ok-act cancel-act])) - pack! + pack! show!))) (defn open-display-options-dlg [] - (let [ok-act (action + (let [ok-act (action :name "Ok" :handler (fn [e] (return-from-dialog e (value (to-frame e))))) cancel-act (action :name "Cancel" :handler (fn [e] (return-from-dialog e nil))) more-act (action :name "More ..." :handler (fn [e] (alert (str "More Result = " (open-more-options-dlg)))))] - (-> (custom-dialog + (-> (custom-dialog :title "Display Options" :modal? true :resizable? false - :content (mig-panel + :content (mig-panel :border (line-border) :items [[(label :font (font :from (default-font "Label.font") :style :bold) - :text "Display options for new geometry") + :text "Display options for new geometry") "gaptop 10, wrap"] - + [:separator "growx, wrap, gaptop 10, spanx 2"] - + ["Display mode:"] - - [(combobox :id :mode - :model ["Triangulated Mesh" "Lines"]) + + [(combobox :id :mode + :model ["Triangulated Mesh" "Lines"]) "wrap"] - + ["Angle"] - - [(slider :id :angle - :min 0 :max 20 - :minor-tick-spacing 1 :major-tick-spacing 20 + + [(slider :id :angle + :min 0 :max 20 + :minor-tick-spacing 1 :major-tick-spacing 20 :paint-labels? true) "wrap"] - - [(flow-panel :align :right :items [more-act ok-act cancel-act]) - "spanx 2" "alignx right"]])) - pack! + + [(flow-panel :align :right :items [more-act ok-act cancel-act]) + "spanx 2" "alignx right"]])) + pack! show!))) (defexample [] (frame :title "Custom Dialog Example" - :content (action :name "Show Dialog" - :handler (fn [e] + :content (action :name "Show Dialog" + :handler (fn [e] (alert (str "Result = " (open-display-options-dlg))))))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/dialog.clj b/test/seesaw/test/examples/dialog.clj index cb1720bf..8b6cddc9 100644 --- a/test/seesaw/test/examples/dialog.clj +++ b/test/seesaw/test/examples/dialog.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -53,10 +53,10 @@ common-opts)) pack! show!)) (defn open-display-options-remembered-dlg [] - (-> (dialog :id :dlg + (-> (dialog :id :dlg ;;:options [ok-act cancel-act] :success-fn (fn [p] - (let [knn (selection (select (to-frame p) [:#knn]))] + (let [knn (selection (select (to-frame p) [:#knn]))] [[(selection (select (to-frame p) [:#mesh-p])) (selection (select (to-frame p) [:#plot-p]))] (selection (select (to-frame p) [:#angle])) (selection (select (to-frame p) [:#mode])) @@ -79,7 +79,7 @@ ["KNN"] [(bound-slider "LAST_KNN" 150 :id :knn :min 0 :max 300 :minor-tick-spacing 10 :major-tick-spacing 100 :paint-labels? true) - "wrap"] + "wrap"] ["Color"] [(let [lbl (label :id :colorbtn :text " " :background (color 255 255 0) :listen [:mouse-clicked @@ -96,11 +96,10 @@ (defexample [] (frame :title "Custom Dialog Example" :resizable? false - :content (vertical-panel :items [(action :name "Show Dialog with custom :success-fn" + :content (vertical-panel :items [(action :name "Show Dialog with custom :success-fn" :handler (fn [e] (alert (str "Result = " (open-display-options-dlg))))) - (action :name "Show Dialog with custom option buttons" + (action :name "Show Dialog with custom option buttons" :handler (fn [e] (alert (str "Result = " (open-display-options-custom-dlg))))) - (action :name "Show Dialog with remembered values" + (action :name "Show Dialog with remembered values" :handler (fn [e] (alert (str "Result = " (open-display-options-remembered-dlg)))))]))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/dnd.clj b/test/seesaw/test/examples/dnd.clj index c98b92bd..b3188bf6 100644 --- a/test/seesaw/test/examples/dnd.clj +++ b/test/seesaw/test/examples/dnd.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -21,7 +21,7 @@ :model ["A String"] :drag-enabled? true :drop-mode :insert - :transfer-handler + :transfer-handler [:import [dnd/string-flavor (fn [{:keys [target data]}] (.. target getModel (addElement data)))] :export { @@ -37,16 +37,16 @@ :model [] :drag-enabled? true :drop-mode :insert - :transfer-handler - (dnd/default-transfer-handler + :transfer-handler + (dnd/default-transfer-handler :import [dnd/file-list-flavor (fn [{:keys [target data]}] ; data is always List - (doseq [file data] + (doseq [file data] (.. target getModel (addElement file))))] :export { :actions (constantly :copy) - :start (fn [c] - (let [file (selection c)] + :start (fn [c] + (let [file (selection c)] [dnd/file-list-flavor [file]])) ; No :finish needed }))) @@ -57,23 +57,23 @@ :model [(java.net.URI. "http://github.com/daveray/seesaw")] :drag-enabled? true :drop-mode :insert - :transfer-handler - (dnd/default-transfer-handler + :transfer-handler + (dnd/default-transfer-handler :import [dnd/uri-list-flavor (fn [{:keys [target data]}] ; data is seq of java.net.URI - (doseq [url data] + (doseq [url data] (.. target getModel (addElement url))))] :export { :actions (constantly :copy) - :start (fn [c] - (let [url (selection c)] + :start (fn [c] + (let [url (selection c)] [dnd/uri-list-flavor [url] ])) ; No :finish needed }))) ; A list box that imports and exports images, like with a browser (defn image-target [] - (let [icon-label (label)] + (let [icon-label (label)] (left-right-split (scrollable (listbox @@ -82,8 +82,8 @@ :model [] :drag-enabled? true :drop-mode :insert - :transfer-handler - (dnd/default-transfer-handler + :transfer-handler + (dnd/default-transfer-handler :import [dnd/image-flavor (fn [{:keys [target data]}] (.. target getModel (addElement data)))]))) (scrollable icon-label) @@ -94,7 +94,7 @@ :title "Seesaw Drag-n-Drop Example" :content (vertical-panel - :items [ + :items [ (border-panel :border "Drag and Drop Text here" :center (scrollable (string-target))) (border-panel :border "Drag and Drop Files here" :center (scrollable (file-target))) (border-panel :border "Drag and Drop URIs here" :center (scrollable (url-target))) @@ -102,4 +102,3 @@ ]))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/dynamic_layout.clj b/test/seesaw/test/examples/dynamic_layout.clj index d7e8501b..31386af1 100644 --- a/test/seesaw/test/examples/dynamic_layout.clj +++ b/test/seesaw/test/examples/dynamic_layout.clj @@ -11,7 +11,7 @@ ; get the same space. Otherwise modifying what's shown would trigger ; a recursive layout cascade (probably?) ; * A card panel could be used to rather than :visible? to swap between -; alternative layouts. +; alternative layouts. (defn make-dynamic-panel [i] @@ -52,4 +52,3 @@ show!)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/editor_pane_hyperlink.clj b/test/seesaw/test/examples/editor_pane_hyperlink.clj index 1c9dbacd..b2190c73 100644 --- a/test/seesaw/test/examples/editor_pane_hyperlink.clj +++ b/test/seesaw/test/examples/editor_pane_hyperlink.clj @@ -48,5 +48,3 @@ add-behaviors)) ;(run :dispose) - - diff --git a/test/seesaw/test/examples/example.clj b/test/seesaw/test/examples/example.clj index da295768..762780df 100644 --- a/test/seesaw/test/examples/example.clj +++ b/test/seesaw/test/examples/example.clj @@ -1,21 +1,21 @@ (ns seesaw.test.examples.example (:use [seesaw.core :only [config! pack! show! invoke-now]])) -(defmacro defexample - "Does the boilerplate for an example. +(defmacro defexample + "Does the boilerplate for an example. arg-vec is a binding vector of arguments for the example, usually command-line args. body is code which must return an instance of javax.swing.JFrame. If the frame's size has not been set at all, pack! is called. Then show! is called. - + Defines two functions: - + run : takes an on-close keyword and trailing args and runs the example. -main : calls (run :exit & args). i.e. runs the example and exits when closed - - See the plethora of examples in this directory for usage examples. + + See the plethora of examples in this directory for usage examples. " [arg-vec & body] `(do diff --git a/test/seesaw/test/examples/explorer.clj b/test/seesaw/test/examples/explorer.clj index eeba18d5..7a78ba7b 100644 --- a/test/seesaw/test/examples/explorer.clj +++ b/test/seesaw/test/examples/explorer.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -31,7 +31,7 @@ (defn make-frame [] ; Put all the widgets together - (frame :title "File Explorer" :width 500 :height 500 + (frame :title "File Explorer" :width 500 :height 500 :content (border-panel :border 5 :hgap 5 :vgap 5 :north (label :id :current-dir :text "Location") @@ -56,4 +56,3 @@ f)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/form.clj b/test/seesaw/test/examples/form.clj index e0e7d9a7..e50019eb 100644 --- a/test/seesaw/test/examples/form.clj +++ b/test/seesaw/test/examples/form.clj @@ -2,10 +2,10 @@ (:use seesaw.core seesaw.test.examples.example)) -;http://www.leepoint.net/notes-java/GUI/layouts/gridbag-example.html +;http://www.leepoint.net/notes-java/GUI/layouts/gridbag-example.html (defexample [] - (frame :title "Find/Replace" :content + (frame :title "Find/Replace" :content (form-panel :items [ [nil :fill :both :insets (java.awt.Insets. 5 5 5 5) :gridx 0 :gridy 0] @@ -24,9 +24,9 @@ [[5 :by 5] :grid :wrap] - [(grid-panel :columns 2 - :items (map #(checkbox :text %) - ["Match Case" "Wrap Around" + [(grid-panel :columns 2 + :items (map #(checkbox :text %) + ["Match Case" "Wrap Around" "Whole Words" "Search Solution" "Regular Expressions" "Search Backwards" "Highlight Results" "Incremental Search"])) @@ -34,4 +34,3 @@ ))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/forms.clj b/test/seesaw/test/examples/forms.clj index bd6cb130..dd58bc56 100644 --- a/test/seesaw/test/examples/forms.clj +++ b/test/seesaw/test/examples/forms.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -33,4 +33,3 @@ :content (frame-content))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/full_screen.clj b/test/seesaw/test/examples/full_screen.clj index bb6ca700..da8a8f64 100644 --- a/test/seesaw/test/examples/full_screen.clj +++ b/test/seesaw/test/examples/full_screen.clj @@ -20,7 +20,7 @@ :width 400 :height 400 ;:undecorated? true - :content (vertical-panel + :content (vertical-panel :items ["A demo of (seesaw.core/toggle-full-screen!)." (button :id :toggle :text "Toggle full screen") (button :id :close :text "Close")]))) @@ -36,4 +36,3 @@ show!)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/game_of_life.clj b/test/seesaw/test/examples/game_of_life.clj index 90a5c14d..e66653a3 100644 --- a/test/seesaw/test/examples/game_of_life.clj +++ b/test/seesaw/test/examples/game_of_life.clj @@ -37,9 +37,9 @@ (iterate step initial-world)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Cell file reading +;; Cell file reading -(defn load-cell-file +(defn load-cell-file "Parse a cell file from http://www.bitstorm.org/gameoflife/lexicon/cells/ !Name: T-nosed_p4 @@ -59,13 +59,13 @@ " [readerable] (with-open [r (jio/reader readerable)] - (let [lines (line-seq r) + (let [lines (line-seq r) name (first lines) grid (drop 2 lines)] (->> grid - (map-indexed (fn [y s] - (map-indexed (fn [x c] - (if (= \O c) [x y])) + (map-indexed (fn [y s] + (map-indexed (fn [x c] + (if (= \O c) [x y])) s))) (apply concat) (filter identity) @@ -95,46 +95,46 @@ (not= (even? x) (even? y)) "#323232")))))) (defn make-ui [] - (frame - :title "Game of Life" + (frame + :title "Game of Life" :size [300 :by 300] :content (border-panel :border 5 :hgap 5 :vgap 5 :north "Drag and Drop .cell file URLs on this window" - :center (canvas :id :canvas + :center (canvas :id :canvas :background :black :border (line-border :thickness 2 :color :black)) - :east (slider :id :size - :min 8 - :max 256 - :value 32 + :east (slider :id :size + :min 8 + :max 256 + :value 32 :orientation :vertical :tip "Adjust grid size") - :south (toolbar :floatable? false + :south (toolbar :floatable? false :items [(label :id :link :tip "Open cell file library in browser" :text "Cell file library" :foreground :blue :cursor :hand) :separator - "Period (ms) " (spinner - :id :period + "Period (ms) " (spinner + :id :period :model (spinner-model 250 :from 50 :to 1000 :by 25))])))) (defn add-behaviors [root] (let [c (select root [:#canvas]) - t (timer (fn [_] - (swap! worlds #(drop 1 %)) + t (timer (fn [_] + (swap! worlds #(drop 1 %)) (repaint! c)) :delay 250 :start? true) bounds (atom [0 0 32 32]) - drop-fn (fn [{:keys [data]}] (reset (load-cell-file (first data))))] + drop-fn (fn [{:keys [data]}] (reset (load-cell-file (first data))))] ; Handle dropped uris and files (config! root :transfer-handler [:import [dnd/uri-list-flavor drop-fn dnd/file-list-flavor drop-fn]]) - + ; Draw the grid using current bounds (config! c :paint #(draw-grid %1 %2 @bounds (first @worlds))) @@ -148,17 +148,17 @@ ; Make a fake link (listen (select root [:#link]) - :mouse-clicked (fn [_] + :mouse-clicked (fn [_] (.. (java.awt.Desktop/getDesktop) (browse (java.net.URI. "http://www.bitstorm.org/gameoflife/lexicon/cells/"))))) ; When the period changes, adjust the timer - (listen (select root [:#period]) :selection - (fn [e] (.setDelay t (selection e)))) + (listen (select root [:#period]) :selection + (fn [e] (.setDelay t (selection e)))) ; When mouse is dragged, pan the grid (kinda crappy due to scaling) (when-mouse-dragged c :drag (fn [e [dx dy]] - (swap! bounds (fn [[x0 y0 x1 y1]] + (swap! bounds (fn [[x0 y0 x1 y1]] [(- x0 dx) (- y0 dy) (- x1 dx) (- y1 dy)]))))) root) @@ -167,4 +167,3 @@ (-> (make-ui) add-behaviors)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/hotpotatoes.clj b/test/seesaw/test/examples/hotpotatoes.clj index cbc5fd24..f5d34090 100644 --- a/test/seesaw/test/examples/hotpotatoes.clj +++ b/test/seesaw/test/examples/hotpotatoes.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -13,16 +13,16 @@ seesaw.test.examples.example) (:require [clojure.java.io :only reader])) -; A simple HTTP request app. Enter a URL and click "Go". It does the request in +; A simple HTTP request app. Enter a URL and click "Go". It does the request in ; the background and displays the response. (defn do-request [url-str f] - (future + (future (let [result (if-let [url (to-url url-str)] (slurp url) ("Invalid URL"))] (invoke-later (f result))))) - + (defexample [] (let [exit-action (action :handler dispose! :name "Exit") url-text (text "http://google.com") @@ -31,32 +31,31 @@ result-handler (fn [s] (text! result-text s) (text! status "Ready")) - go-handler (fn [e] + go-handler (fn [e] (text! status "Busy") - (do-request + (do-request (text url-text) result-handler))] - (frame + (frame :id :frame :title "Hot Potatoes!" :menubar (menubar :items [(menu :text "File" :items [exit-action])]) :width 500 :height 600 - :content + :content (border-panel :border 5 :north (toolbar :items [exit-action]) - :center + :center (border-panel - :north - (horizontal-panel + :north + (horizontal-panel :border [5 "Configure Request"] - :items ["URL" url-text + :items ["URL" url-text (action :handler go-handler :name "Go")]) :center - (horizontal-panel + (horizontal-panel :border [5 "Request Result"] :items [(scrollable result-text)])) :south status)))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/j18n.clj b/test/seesaw/test/examples/j18n.clj index b969e678..4801e785 100644 --- a/test/seesaw/test/examples/j18n.clj +++ b/test/seesaw/test/examples/j18n.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -13,18 +13,18 @@ seesaw.test.examples.example)) (defexample [] - (let [a (action + (let [a (action ; Use a set of properties for the action, all with prefix "action" :resource ::my-action - :handler (fn [_] + :handler (fn [_] ; Alert and other dialog functions know about resources - (alert ::my-action.click-message)))] - - (frame + (alert ::my-action.click-message)))] + + (frame ; Most Seesaw properties (title, text, icon) will look in the resource ; bundle when a namespace-qualified keyword is given :title ::title - :menubar (menubar :items [(menu + :menubar (menubar :items [(menu :text ::menu.tools.text :items [a])]) :content (vertical-panel @@ -39,4 +39,3 @@ a])))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/j18n.properties b/test/seesaw/test/examples/j18n.properties index 3848440e..3230f561 100644 --- a/test/seesaw/test/examples/j18n.properties +++ b/test/seesaw/test/examples/j18n.properties @@ -27,4 +27,3 @@ my-action.click-message=Click! label.text=I'm a label label.font=Courier-Italic-15 label.foreground=#FF5500 - diff --git a/test/seesaw/test/examples/kitchensink.clj b/test/seesaw/test/examples/kitchensink.clj index 6c52fae2..f6f0d136 100644 --- a/test/seesaw/test/examples/kitchensink.clj +++ b/test/seesaw/test/examples/kitchensink.clj @@ -154,4 +154,3 @@ f)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/kotka_bind.clj b/test/seesaw/test/examples/kotka_bind.clj index b90ec309..70f7bdae 100644 --- a/test/seesaw/test/examples/kotka_bind.clj +++ b/test/seesaw/test/examples/kotka_bind.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -42,26 +42,25 @@ ; Wire up the done button (listen done :action-performed dispose!) ; Toggle buttons on done - (bind/bind - done? + (bind/bind + done? (bind/some identity) ; (when done?) (bind/notify-later) ; cross to swing thread (bind/tee (bind/property done :enabled?) - (bind/bind - (bind/transform not) + (bind/bind + (bind/transform not) (bind/property cancel :enabled?)))) ; Wire up cancel button. - (listen cancel :action-performed - (fn [_] + (listen cancel :action-performed + (fn [_] (reset! canceled? true))) ; Wire up progress bar. - (bind/bind - progress - (bind/notify-later) + (bind/bind + progress + (bind/notify-later) pbar) (-> #(processing items done? canceled? progress) Thread. .start) (frame :title "Example GUI" :on-close :dispose :content panel))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/launcher.clj b/test/seesaw/test/examples/launcher.clj index 595a4e62..79a86d77 100644 --- a/test/seesaw/test/examples/launcher.clj +++ b/test/seesaw/test/examples/launcher.clj @@ -108,5 +108,4 @@ (-> (make-frame) add-behaviors)) -;(run :dispose) - +;(run :dispose) \ No newline at end of file diff --git a/test/seesaw/test/examples/log_window.clj b/test/seesaw/test/examples/log_window.clj index 1c36d69f..de4fc480 100644 --- a/test/seesaw/test/examples/log_window.clj +++ b/test/seesaw/test/examples/log_window.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -27,16 +27,16 @@ :content (border-panel :center (scrollable (log-window :id :log-window :limit nil)) - :south (horizontal-panel + :south (horizontal-panel :items [(button :id :start :text "Start Spammer") (button :id :stop :text "Stop") (checkbox :id :limit? :text "Limit to") - (spinner :id :limit + (spinner :id :limit :model (spinner-model 500 :from 1 :to nil :by 1)) "chars"])))) (defn spammer [lw prefix go] - (loop [i 0] + (loop [i 0] (log lw (str prefix " - " i " asdf asdf asdf asdf asdf asdf\n")) (Thread/sleep 100) (if @go @@ -47,14 +47,14 @@ go (atom false)] (listen limit? - :selection (fn [_] (config! log-window :limit (if (value limit?) + :selection (fn [_] (config! log-window :limit (if (value limit?) (value limit))))) (listen stop :action (fn [_] (reset! go false))) - (listen - start - :action (fn [_] + (listen + start + :action (fn [_] (reset! go true) (future (spammer log-window (System/currentTimeMillis) go))))) f) diff --git a/test/seesaw/test/examples/make_widget.clj b/test/seesaw/test/examples/make_widget.clj index eb021117..6ec361d7 100644 --- a/test/seesaw/test/examples/make_widget.clj +++ b/test/seesaw/test/examples/make_widget.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -48,4 +48,3 @@ :content (scrollable (vertical-panel :items people)))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/mig.clj b/test/seesaw/test/examples/mig.clj index 51a190f9..d1389c70 100644 --- a/test/seesaw/test/examples/mig.clj +++ b/test/seesaw/test/examples/mig.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -23,7 +23,7 @@ [ (text) "span, growx"] [ "Contact" "gap 10"] [ (text) "span, growx, wrap"] - + [ "Propeller" "split, span, gaptop 10"] [ :separator "growx, wrap, gaptop 10"] @@ -39,5 +39,4 @@ (defexample [] (frame :title "MigLayout Example" :resizable? false :content (frame-content))) -;(run :dispose) - +;(run :dispose) diff --git a/test/seesaw/test/examples/multi_dialog.clj b/test/seesaw/test/examples/multi_dialog.clj index cd13d255..02cec3fb 100644 --- a/test/seesaw/test/examples/multi_dialog.clj +++ b/test/seesaw/test/examples/multi_dialog.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -14,8 +14,8 @@ ; Tiny test for showing multiple "document modal" dialogs at the same time. (defn do-dialog [title] - (-> (dialog - :title title + (-> (dialog + :title title :modal? :document :options [(button :text "CLICK!" :listen [:action (fn [e] (return-from-dialog e title))])]) pack! show!)) @@ -30,4 +30,3 @@ (invoke-later (-> [(make-frame "FIRST") (make-frame "SECOND")] pack! show!))) ;(-main) - diff --git a/test/seesaw/test/examples/paintable.clj b/test/seesaw/test/examples/paintable.clj index c320b97f..9da11b96 100644 --- a/test/seesaw/test/examples/paintable.clj +++ b/test/seesaw/test/examples/paintable.clj @@ -36,4 +36,3 @@ :content (content))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/pan_on_drag.clj b/test/seesaw/test/examples/pan_on_drag.clj index 14d1932c..5650e0aa 100644 --- a/test/seesaw/test/examples/pan_on_drag.clj +++ b/test/seesaw/test/examples/pan_on_drag.clj @@ -5,7 +5,7 @@ (defn scrollable-image [id] (sc/scrollable - (sc/label :id id + (sc/label :id id ;:icon "file:///Users/dave/Desktop/IMG_0058.JPG" ))) @@ -22,17 +22,17 @@ [(/ (.getWidth view-to-pan) (.getWidth panner)) (/ (.getHeight view-to-pan) (.getHeight panner))]) -(defn pan-on-drag +(defn pan-on-drag ([view-to-pan & {:keys [panner speed] :or {panner view-to-pan speed 1.0}}] - (behave/when-mouse-dragged panner - :drag (fn [e [dx dy]] - (let [[sx sy] (calculate-scales panner view-to-pan)] + (behave/when-mouse-dragged panner + :drag (fn [e [dx dy]] + (let [[sx sy] (calculate-scales panner view-to-pan)] (pan view-to-pan (* dx sx speed) (* dy sy speed))))))) (defn add-behaviors [root] (pan-on-drag (sc/select root [:#image])) - (pan-on-drag (sc/select root [:#image]) - :panner (sc/select root [:#panner]) + (pan-on-drag (sc/select root [:#image]) + :panner (sc/select root [:#panner]) :scale 5.0) root) @@ -40,13 +40,13 @@ (sc/frame :title "Pan on drag" :size [480 :by 480] - :content - (sc/border-panel + :content + (sc/border-panel :north "Click and drag to pan the image" :center (scrollable-image :image) - :south (sc/flow-panel + :south (sc/flow-panel :items ["Or drag on the blue field to pan the image" - (sc/label + (sc/label :id :panner :size [50 :by 50] :background :blue)])))) @@ -55,4 +55,3 @@ (-> (app) add-behaviors)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/pi.clj b/test/seesaw/test/examples/pi.clj index 9d9b0c17..d656800d 100644 --- a/test/seesaw/test/examples/pi.clj +++ b/test/seesaw/test/examples/pi.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -14,10 +14,10 @@ (:require seesaw.invoke) (:import [java.util.concurrent LinkedBlockingQueue TimeUnit])) -(defn calculate-pi-for +(defn calculate-pi-for "Calculate a sliver of pi" [start step-size] - (reduce + (reduce (fn [acc i] (+ acc (/ (* 4.0 (- 1 (* (mod i 2) 2))) (+ (* 2 i) 1)))) 0.0 @@ -31,17 +31,17 @@ (if-let [{:keys [start step-size]} (.poll queue 1 TimeUnit/SECONDS)] (swap! result (fn [{:keys [value count]} new-value] - {:value (+ value new-value) + {:value (+ value new-value) :count (inc count)}) (calculate-pi-for start step-size))) (send *agent* agent-calculate)) state) -(defn agent-start [state] - (send *agent* agent-calculate) +(defn agent-start [state] + (send *agent* agent-calculate) (assoc state :running true)) -(defn agent-stop [state] +(defn agent-stop [state] (assoc state :running false)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -52,7 +52,7 @@ queue (LinkedBlockingQueue. (for [i (range steps)] {:start i :step-size step-size})) agents (for [i (range num-agents)] (agent {:running false - :queue queue + :queue queue :result result}))] { :agents agents :queue queue @@ -75,7 +75,7 @@ progress (config! (select root [:#progress]) :max steps :value 0) task (init-task 4 step-size steps)] (add-watch (:result task) (gensym) - (seesaw.invoke/signaller [k r o {:keys [value count]}] + (seesaw.invoke/signaller [k r o {:keys [value count]}] (config! progress :value count) (text! result-label (format "\u03C0 = %.20f" value)))) (reset! current-task (start-task task)))) @@ -116,7 +116,7 @@ :vgap 5 :hgap 5 } - [:JToolBar] { + [:JToolBar] { :border 5 :floatable? false :opaque? false } @@ -125,14 +125,14 @@ [:#step-size] { :text 10000 } - [:JButton] { + [:JButton] { :foreground "#0022DD" :background "#ffefd5" } [:#go] { :text "Go!" } [:#cancel] { :text "Cancel" } - [:#progress] { + [:#progress] { :border 10 } [:#result] { @@ -158,9 +158,8 @@ root) (defexample [] - (-> (make-frame) - (apply-stylesheet stylesheet) + (-> (make-frame) + (apply-stylesheet stylesheet) (apply-behaviors behaviors))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/piano.clj b/test/seesaw/test/examples/piano.clj index 0fe47366..74585660 100644 --- a/test/seesaw/test/examples/piano.clj +++ b/test/seesaw/test/examples/piano.clj @@ -81,4 +81,3 @@ add-behaviors)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/popup.clj b/test/seesaw/test/examples/popup.clj index 8aaa9c1e..27c4f66d 100644 --- a/test/seesaw/test/examples/popup.clj +++ b/test/seesaw/test/examples/popup.clj @@ -38,4 +38,3 @@ :divider-location 1/2))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/reorderable_listbox.clj b/test/seesaw/test/examples/reorderable_listbox.clj index 07d3ff4d..965ac330 100644 --- a/test/seesaw/test/examples/reorderable_listbox.clj +++ b/test/seesaw/test/examples/reorderable_listbox.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. diff --git a/test/seesaw/test/examples/rpn.clj b/test/seesaw/test/examples/rpn.clj index 512187c6..6e2efec0 100644 --- a/test/seesaw/test/examples/rpn.clj +++ b/test/seesaw/test/examples/rpn.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -16,22 +16,22 @@ ;; A simple RPN calculator -(defn operator +(defn operator "make a function that takes the stack, pops arity args, applies f to them and returns the new stack with the result on top. If f returns nil, does nothing." [f arity] - (fn [stack] + (fn [stack] (let [[args more] (split-at arity stack)] - (if-let [result (apply f args)] + (if-let [result (apply f args)] (cons result more) more)))) -(defn push-op +(defn push-op "Return an operator that pushes v" [v] (operator (constantly v) 0)) -(defn calculate +(defn calculate "Start with the given stack and apply each of the given op functions to it and return the resulting stack." [stack & ops] @@ -41,7 +41,7 @@ ops)) ; A declarative version of our operators with fn, arity, and display -(def operators +(def operators { :+ { :op + :arity 2 :text "+" } :- { :op - :arity 2 :text "-" } :* { :op * :arity 2 :text "x" } @@ -51,40 +51,40 @@ ; Making push a noop here simplifies things below. :push { :op (constantly nil) :arity 0 :text "Push"}}) -; Define the layout of the UI. +; Define the layout of the UI. (defn layout [] (frame :title "RPN Calculator" - :content + :content (border-panel :border 5 - :hgap 5 + :hgap 5 :vgap 5 :north (text :id :value) - :center (grid-panel :columns 3 + :center (grid-panel :columns 3 :items (concat - (map #(button :class :digit :text %) [7 8 9 - 4 5 6 - 1 2 3 + (map #(button :class :digit :text %) [7 8 9 + 4 5 6 + 1 2 3 0]) [(button :id :point :class :digit :text ".")])) :west (scrollable (listbox :id :stack) :preferred-size [150 :by 0]) :east (grid-panel :columns 1 - :items (map #(button :id (key %) - :class :operator + :items (map #(button :id (key %) + :class :operator :text (:text (val %))) operators))))) ; Install behaviors on the UI. -(defn behave +(defn behave [root] (let [stack (atom []) ; Holds the current stack state value (select root [:#value]) ; The value text box current-value (atom nil)] ; The current displayed value as double or nil ; As the text box changes, convert to double, or nil for empty. - (bind/bind - value - (bind/transform #(if (empty? %) nil (Double/valueOf %))) + (bind/bind + value + (bind/transform #(if (empty? %) nil (Double/valueOf %))) current-value) ; As text box changes, enable/disable decimal point button @@ -95,15 +95,15 @@ ; The digit buttons just append their number (or decimal point) to the text box (listen (select root [:.digit]) - :action (fn [e] - (let [c (text e)] + :action (fn [e] + (let [c (text e)] (text! value (str (text value) c))))) ; The operator buttons look up their operator in the table, apply it ; to the current stack and clear the text box (listen (select root [:.operator]) :action (fn [e] - (let [{:keys [op arity]} (operators (id-of e))] + (let [{:keys [op arity]} (operators (id-of e))] (swap! stack calculate (push-op @current-value) (operator op arity)) (text! value "")))) @@ -112,18 +112,17 @@ root) ; Set styles. NOTE this uses an alpha API and will most likely change -(def style - { [:#value] {:halign :right - :font "ARIAL-PLAIN-20" +(def style + { [:#value] {:halign :right + :font "ARIAL-PLAIN-20" :editable? false} [:#stack] {:font "ARIAL-PLAIN-20"} }) -(defexample [] +(defexample [] (-> (layout) behave (apply-stylesheet style) ; <- NOTE use of experimental/alpha function )) -;(run :dispose) - +;(run :dispose) \ No newline at end of file diff --git a/test/seesaw/test/examples/rsyntax.clj b/test/seesaw/test/examples/rsyntax.clj index db354df6..b99a04d6 100644 --- a/test/seesaw/test/examples/rsyntax.clj +++ b/test/seesaw/test/examples/rsyntax.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -15,9 +15,9 @@ [clojure.java.io :as io])) (defn make-frame [] - (frame :title "RSyntax Example" :width 500 :height 400 - :content (scrollable - (rsyntax/text-area + (frame :title "RSyntax Example" :width 500 :height 400 + :content (scrollable + (rsyntax/text-area :text (io/resource "seesaw/test/examples/rsyntax.clj") :syntax :clojure)))) @@ -25,4 +25,3 @@ (make-frame) ) ;(run :dispose) - diff --git a/test/seesaw/test/examples/scribble.clj b/test/seesaw/test/examples/scribble.clj index 1bbeb515..e77584ef 100644 --- a/test/seesaw/test/examples/scribble.clj +++ b/test/seesaw/test/examples/scribble.clj @@ -139,4 +139,3 @@ (-> (make-ui) add-behaviors)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/scroll.clj b/test/seesaw/test/examples/scroll.clj index ed26204a..62c6001f 100644 --- a/test/seesaw/test/examples/scroll.clj +++ b/test/seesaw/test/examples/scroll.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -14,11 +14,11 @@ seesaw.scroll)) (defn top [target] - (action :name "(scroll! v :to :top)" + (action :name "(scroll! v :to :top)" :handler (fn [e] (scroll! target :to :top)))) (defn bottom [target] - (action :name "(scroll! v :to :bottom)" + (action :name "(scroll! v :to :bottom)" :handler (fn [e] (scroll! target :to :bottom)))) (defn point [target & [x y]] @@ -30,8 +30,8 @@ :handler (fn [e] (scroll! target :to [:rect x y w h])))) (defn test-panel [target items] - (border-panel :center (scrollable target) - :south (grid-panel :columns 2 + (border-panel :center (scrollable target) + :south (grid-panel :columns 2 :items items))) (defn general [] (let [t (text :multi-line? true :text "Paste a lot of text here so there's scroll bars")] @@ -55,12 +55,12 @@ arg1 (text :columns 10) go-action (action :name "Scroll!" :handler (fn [e] - (scroll! target :to [op-name + (scroll! target :to [op-name (Integer/valueOf (text arg0)) (Integer/valueOf (text arg1))]))) go-button (button :action go-action)] - (listen #{arg0 arg1} :document - (fn [e] + (listen #{arg0 arg1} :document + (fn [e] (text! go-button (format "(scroll! v :to [%s %s %s])" op-name (text arg0) (text arg1))))) (text! [arg0 arg1] "20") (horizontal-panel :items [arg0 arg1 go-button]))) @@ -71,26 +71,26 @@ (defn jtable [] (let [columns (map #(-> ( format "c%09d" %) keyword) (range 26)) - jtable (table :auto-resize :off + jtable (table :auto-resize :off :model [:columns columns :rows (repeat 500 (into {} (for [c columns] [c 100])))])] - (test-panel - jtable - [(top jtable) (bottom jtable) + (test-panel + jtable + [(top jtable) (bottom jtable) (test-op-int jtable :row) (test-op-int jtable :column) (test-op-int-int jtable :cell)]))) (defn jtext[] - (let [t (text :multi-line? true + (let [t (text :multi-line? true :text (apply str (interpose "\n" (range 0 1000))))] - (test-panel t [(top t) - (bottom t) - (test-op-int t :line) + (test-panel t [(top t) + (bottom t) + (test-op-int t :line) (test-op-int t :position)]))) (defn app-panel [] - (tabbed-panel + (tabbed-panel :tabs [{:title "general" :content (general)} {:title "listbox" :content (jlist)} {:title "table" :content (jtable)} @@ -101,4 +101,3 @@ (frame :title "Seesaw Scroll Demo" :size [800 :by 400] :content (app-panel))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/slider.clj b/test/seesaw/test/examples/slider.clj index aff1faf2..3f6cbd97 100644 --- a/test/seesaw/test/examples/slider.clj +++ b/test/seesaw/test/examples/slider.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -13,7 +13,7 @@ seesaw.test.examples.example)) (defn make-frame [] - (frame + (frame :title "Slider Example" :content (horizontal-panel :items [ @@ -28,7 +28,7 @@ (defn update-color [root] (let [{:keys [red green blue]} (value root)] ; <- Use (value) to get map of values - (config! (select root [:#canvas]) + (config! (select root [:#canvas]) :background (color red green blue)))) (defexample [] @@ -39,4 +39,3 @@ root)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/spinner.clj b/test/seesaw/test/examples/spinner.clj index c0703a20..c142d160 100644 --- a/test/seesaw/test/examples/spinner.clj +++ b/test/seesaw/test/examples/spinner.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -12,12 +12,12 @@ seesaw.test.examples.example)) (defexample [] - (frame + (frame :title "Spinner Example" :content (vertical-panel :items ["A default spinner (print value change to stdout)" - (spinner :listen [:selection (fn [e] (println (selection e)))]) + (spinner :listen [:selection (fn [e] (println (selection e)))]) "A spinner over a sequence of values" (spinner :model (map #(str "Value" %) (range 0 100 5))) "An unbounded spinner starting at a particular date" @@ -29,11 +29,10 @@ "A date spinner with explicit start and end" (spinner :model (let [s (java.util.Date. (long (* 1000 24 3600 1000))) v (java.util.Date. (long (* 2000 24 3600 1000))) - e (java.util.Date. (long (* 3000 24 3600 1000))) + e (java.util.Date. (long (* 3000 24 3600 1000))) m (spinner-model v :from s :to e :by :day-of-month)] m)) ]))) ;(run :dispose) - diff --git a/test/seesaw/test/examples/swingx.clj b/test/seesaw/test/examples/swingx.clj index 168b8c9d..b77848a8 100644 --- a/test/seesaw/test/examples/swingx.clj +++ b/test/seesaw/test/examples/swingx.clj @@ -123,4 +123,3 @@ (-> (make-ui) add-behaviors)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/table.clj b/test/seesaw/test/examples/table.clj index a740d31c..a0210d23 100644 --- a/test/seesaw/test/examples/table.clj +++ b/test/seesaw/test/examples/table.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -17,8 +17,8 @@ (defn make-table [] (table :id :table :model [ - :columns [ { :key :name :text "Name" } - { :key :town :text "Town" } + :columns [ { :key :name :text "Name" } + { :key :town :text "Town" } { :key :interest :text "Interest" }] :rows [{ :name "Kupzog" :town "Cologne" :interest "programming" :id 1234} { :name "Hansson" :town "Ystadt" :interest "Hunting" :id 2234} @@ -38,14 +38,13 @@ (let [f (show! (make-frame)) t (select f [:#table])] ; Listen for selection changes and show them in the label - (listen t :selection - (fn [e] - (config! (select f [:#sel]) - :text (str "Selection: " + (listen t :selection + (fn [e] + (config! (select f [:#sel]) + :text (str "Selection: " ; (selection t) returns the selected row index ; (value-at t row) returns the record at row (value-at t (selection t)))))) f)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/temp.clj b/test/seesaw/test/examples/temp.clj index 69152b9d..255d40fa 100644 --- a/test/seesaw/test/examples/temp.clj +++ b/test/seesaw/test/examples/temp.clj @@ -2,18 +2,18 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. ; You must not remove this notice, or any other, from this software. (ns seesaw.test.examples.temp - (:use seesaw.core + (:use seesaw.core seesaw.font seesaw.test.examples.example)) -; See http://stuartsierra.com/2010/01/06/heating-up-clojure-swing +; See http://stuartsierra.com/2010/01/06/heating-up-clojure-swing (defn f-to-c [f] (* (- f 32) 5/9)) @@ -34,27 +34,26 @@ (text! target (display (convert n))) (text! target "")))) -(defn listen-temp [source target f] +(defn listen-temp [source target f] (listen source :document (fn [e] (update-temp source target f))) source) (defexample [] - (let [c (text :tip "Enter Celsius temperature") + (let [c (text :tip "Enter Celsius temperature") f (text :tip "Enter Fahrenheit temperature")] - (frame - :title "Temp Converter" + (frame + :title "Temp Converter" :content - (grid-panel + (grid-panel :hgap 10 :vgap 10 :columns 2 :border 10 - :items - [(label :text "Degrees Celsius" - :halign :right + :items + [(label :text "Degrees Celsius" + :halign :right :font "ARIAL-BOLD-20" ) (listen-temp c f c-to-f) - (label :text "Degrees Fahrenheit" - :halign :right + (label :text "Degrees Fahrenheit" + :halign :right :font {:style :italic :size 20 :name "Arial"}) (listen-temp f c f-to-c)])))) -;(run :dispose) - +;(run :dispose) diff --git a/test/seesaw/test/examples/text_editor.clj b/test/seesaw/test/examples/text_editor.clj index e6af5462..7af1da40 100644 --- a/test/seesaw/test/examples/text_editor.clj +++ b/test/seesaw/test/examples/text_editor.clj @@ -32,7 +32,7 @@ (defn select-file [type] (choose-file main-panel :type type)) (defn a-new [e] - (let [selected (select-file :save)] + (let [selected (select-file :save)] (if (.exists @current-file) (alert "File already exists.") (do (set-current-file selected) @@ -84,4 +84,3 @@ :menubar menus)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/text_ref.clj b/test/seesaw/test/examples/text_ref.clj index 83766cb9..307d6e04 100644 --- a/test/seesaw/test/examples/text_ref.clj +++ b/test/seesaw/test/examples/text_ref.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -22,15 +22,15 @@ ; Set up our binding chain (bind/bind input ; Take changes to input (bind/transform #(.toUpperCase %)) ; Pass through upper case transform - value ; Put the value in the atom + value ; Put the value in the atom output) ; Show the final value in the output text doc (text! input "Initial Value") - (frame - :content - (vertical-panel + (frame + :content + (vertical-panel :border 5 - :items ["Enter text here:" - input + :items ["Enter text here:" + input :separator "Changed atom is reflected here:" output @@ -38,5 +38,4 @@ (action :name "Print atom value to console" :handler (fn [e] (println "Current atom value is: " @value)))])))) -;(run :dispose) - +;(run :dispose) \ No newline at end of file diff --git a/test/seesaw/test/examples/toggle_listbox.clj b/test/seesaw/test/examples/toggle_listbox.clj index 70730aa2..a0bd2a8f 100644 --- a/test/seesaw/test/examples/toggle_listbox.clj +++ b/test/seesaw/test/examples/toggle_listbox.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. diff --git a/test/seesaw/test/examples/tree.clj b/test/seesaw/test/examples/tree.clj index 91fed68c..8e1d4092 100644 --- a/test/seesaw/test/examples/tree.clj +++ b/test/seesaw/test/examples/tree.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -15,19 +15,19 @@ (def source "http://www.4clojure.com/problems/rss") -; Make a tree model for some XML using same arguments (branch? and childnre) +; Make a tree model for some XML using same arguments (branch? and childnre) ; as (clojure.core/tree-seq) (defn load-model [] - (simple-tree-model - (complement string?) + (simple-tree-model + (complement string?) (comp seq :content) (clojure.xml/parse source))) ; A custom renderer so that XML elements are displayed nicely (defn render-fn [renderer info] (let [v (:value info)] - (config! renderer - :text (if (map? v) + (config! renderer + :text (if (map? v) (format "<%s>" (name (:tag v))) v)))) @@ -44,16 +44,15 @@ (defexample [] (let [f (make-frame)] ; Listen for selection changes and show them in the label - (listen (select f [:#tree]) + (listen (select f [:#tree]) :tree-will-expand #(println (str "Tree will expand\n" %)) :tree-will-collapse #(println (str "Tree will collapse\n" %)) :tree-expanded #(println (str "Tree expanded\n" %)) :tree-collapsed #(println (str "Tree collapsed\n" %)) - :selection - (fn [e] - (config! (select f [:#sel]) + :selection + (fn [e] + (config! (select f [:#sel]) :text (str "Selection: " (-> e selection first last))))) f)) ;(run :dispose) - diff --git a/test/seesaw/test/examples/xyz_panel.clj b/test/seesaw/test/examples/xyz_panel.clj index 24bd6ef5..367c236e 100644 --- a/test/seesaw/test/examples/xyz_panel.clj +++ b/test/seesaw/test/examples/xyz_panel.clj @@ -28,7 +28,7 @@ ; manually. :drag (fn [e _] (let [p (.getPoint e)] - (move! e :by [(- (.x p) (.x start-point)) + (move! e :by [(- (.x p) (.x start-point)) (- (.y p) (.y start-point))]))))) w) @@ -83,4 +83,3 @@ :size [600 :by 600])) ;(run :dispose) - diff --git a/test/seesaw/test/font.clj b/test/seesaw/test/font.clj index 1f7eff17..24416e73 100644 --- a/test/seesaw/test/font.clj +++ b/test/seesaw/test/font.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -74,5 +74,4 @@ (let [f (default-font "Label.font") expected (.getFont (javax.swing.UIManager/getDefaults) "Label.font")] (expect (not (nil? f))) - (expect (= expected f))))) - + (expect (= expected f))))) \ No newline at end of file diff --git a/test/seesaw/test/forms.clj b/test/seesaw/test/forms.clj index de7f7c0e..0842814e 100644 --- a/test/seesaw/test/forms.clj +++ b/test/seesaw/test/forms.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -32,5 +32,4 @@ "R/mm" (text :columns 10) "D/mm" (text :columns 10) (separator)] :default-dialog-border? true)] - (expect (instance? javax.swing.JPanel p))))) - + (expect (instance? javax.swing.JPanel p))))) \ No newline at end of file diff --git a/test/seesaw/test/graphics.clj b/test/seesaw/test/graphics.clj index 0fe7bc03..80ce98e1 100644 --- a/test/seesaw/test/graphics.clj +++ b/test/seesaw/test/graphics.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -165,8 +165,8 @@ ; make a stub shape to grab args... (defrecord TestShape [received-args] Draw - (draw* - [shape g2d style] + (draw* + [shape g2d style] ; Note that "this" is used instead of shape. Otherwise, on failure, lazytest ; tries to print a cyclical structure when there's a failure. (swap! received-args conj [g2d "this" style]))) @@ -187,7 +187,7 @@ final-args @args] (expect (= "graphics" result)) (expect (= [["graphics" "this" "style"]["graphics" "this" "style2"]] final-args))))) - + (describe style (it "creates a new style object" (let [strk (stroke :width 5) @@ -224,8 +224,8 @@ (expect (= java.awt.MultipleGradientPaint$CycleMethod/NO_CYCLE (.getCycleMethod g))))) (it "creates a linear gradient" - (let [g (linear-gradient - :start [1 2] + (let [g (linear-gradient + :start [1 2] :end [3.5 4.6] :fractions [0.0 0.8 1.0] :colors [:black :blue java.awt.Color/ORANGE] @@ -256,8 +256,8 @@ (expect (= java.awt.MultipleGradientPaint$CycleMethod/NO_CYCLE (.getCycleMethod g))))) (it "creates a radial gradient" - (let [g (radial-gradient - :center [1 2] + (let [g (radial-gradient + :center [1 2] :focus [3.5 4.6] :fractions [0.0 0.8 1.0] :colors [:black :blue java.awt.Color/ORANGE] @@ -271,5 +271,4 @@ (expect (= [java.awt.Color/BLACK java.awt.Color/BLUE java.awt.Color/ORANGE] (vec (.getColors g)))) (expect (= java.awt.MultipleGradientPaint$CycleMethod/REFLECT - (.getCycleMethod g)))))) - + (.getCycleMethod g)))))) \ No newline at end of file diff --git a/test/seesaw/test/icon.clj b/test/seesaw/test/icon.clj index 0d391dee..f1c5d09d 100644 --- a/test/seesaw/test/icon.clj +++ b/test/seesaw/test/icon.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -37,5 +37,4 @@ (expect (instance? javax.swing.ImageIcon i)))) (it "returns an icon given a i18n keyword" (let [i (icon ::test-icon)] - (expect (instance? javax.swing.ImageIcon i))))) - + (expect (instance? javax.swing.ImageIcon i))))) \ No newline at end of file diff --git a/test/seesaw/test/invoke.clj b/test/seesaw/test/invoke.clj index c71aeaa2..13fb4056 100644 --- a/test/seesaw/test/invoke.clj +++ b/test/seesaw/test/invoke.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -19,14 +19,14 @@ (describe invoke-soon (it "should execute code and return the result immediately if executed on the swing thread" - (= {:foo :hi :edt? true} - (invoke-now + (= {:foo :hi :edt? true} + (invoke-now (invoke-soon {:foo :hi :edt? (javax.swing.SwingUtilities/isEventDispatchThread)})))) (it "should send code to the swing thread for later execution and return nil immediately if not called on the swing thread" - (let [p (promise)] - (expect (nil? (invoke-soon + (let [p (promise)] + (expect (nil? (invoke-soon (deliver p {:edt? (javax.swing.SwingUtilities/isEventDispatchThread)})))) (expect (= {:edt? true} @p))))) @@ -39,5 +39,4 @@ ; Now check the call count and make sure only one function was queued ; Use invoke-now so we know the deref is executed *after* the functions ; are processed. - (expect (= 1 (invoke-now @call-count)))))) - + (expect (= 1 (invoke-now @call-count)))))) \ No newline at end of file diff --git a/test/seesaw/test/keymap.clj b/test/seesaw/test/keymap.clj index 03c3c1d5..a363443f 100644 --- a/test/seesaw/test/keymap.clj +++ b/test/seesaw/test/keymap.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -68,5 +68,4 @@ b (button) _ (map-key b k b :id :foo :scope :global) id (.. b (getInputMap javax.swing.JComponent/WHEN_IN_FOCUSED_WINDOW) (get k))] - (expect (= id :foo))))) - + (expect (= id :foo))))) \ No newline at end of file diff --git a/test/seesaw/test/keystroke.clj b/test/seesaw/test/keystroke.clj index 51f3e140..dec0bc41 100644 --- a/test/seesaw/test/keystroke.clj +++ b/test/seesaw/test/keystroke.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -36,5 +36,4 @@ (expect (= (.. (Toolkit/getDefaultToolkit) getMenuShortcutKeyMask) (bit-and 7 (.getModifiers ks)))))) (it "returns a keystroke for a char" (let [ks (keystroke \A)] - (expect (= \A (.getKeyChar ks)))))) - + (expect (= \A (.getKeyChar ks)))))) \ No newline at end of file diff --git a/test/seesaw/test/make_widget.clj b/test/seesaw/test/make_widget.clj index 25d48687..bdea572e 100644 --- a/test/seesaw/test/make_widget.clj +++ b/test/seesaw/test/make_widget.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -11,5 +11,4 @@ (ns seesaw.test.make-widget (:use seesaw.make-widget) (:use [lazytest.describe :only (describe it testing)] - [lazytest.expect :only (expect)])) - + [lazytest.expect :only (expect)])) \ No newline at end of file diff --git a/test/seesaw/test/meta.clj b/test/seesaw/test/meta.clj index 41b4b212..f52d25ea 100644 --- a/test/seesaw/test/meta.clj +++ b/test/seesaw/test/meta.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -43,5 +43,4 @@ (let [f (javax.swing.JFrame.) result (put-meta! f :some-key 10000)] (expect (= f result)) - (expect (= 10000 (get-meta f :some-key))))))) - + (expect (= 10000 (get-meta f :some-key))))))) \ No newline at end of file diff --git a/test/seesaw/test/mig.clj b/test/seesaw/test/mig.clj index 6775f02b..d1debb51 100644 --- a/test/seesaw/test/mig.clj +++ b/test/seesaw/test/mig.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -23,8 +23,8 @@ (expect (= "[fill]" (.getColumnConstraints l))) (expect (= "[nogrid]" (.getRowConstraints l))))) (it "should support the usual default options" - (mig-panel :id :mig - :class :classy + (mig-panel :id :mig + :class :classy :opaque? false :listen [:mouse-clicked (fn [_])] :foreground :red @@ -44,5 +44,4 @@ result (replace! p l1 l3)] (expect (= p result)) (expect (= [l0 l3 l2] (vec (.getComponents p)))) - (expect (= "wrap" (-> p .getLayout (.getComponentConstraints l3)))))))) - + (expect (= "wrap" (-> p .getLayout (.getComponentConstraints l3)))))))) \ No newline at end of file diff --git a/test/seesaw/test/options.clj b/test/seesaw/test/options.clj index 84549d08..3bee22e7 100644 --- a/test/seesaw/test/options.clj +++ b/test/seesaw/test/options.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -25,8 +25,8 @@ (catch IllegalArgumentException e true))) (it "throws IllegalArgumentException for a property with no setter" (try - (do - (apply-options (javax.swing.JPanel.) + (do + (apply-options (javax.swing.JPanel.) [:no-setter "no-setter"]) false) (catch IllegalArgumentException e true)))) @@ -40,15 +40,15 @@ (get-option-value (javax.swing.JPanel.) :text [{:text (default-option :text nil nil)}]) false (catch IllegalArgumentException e true))) (it "uses the getter of an option to retrieve a value" - (= "hi" (get-option-value - (javax.swing.JPanel.) - :text + (= "hi" (get-option-value + (javax.swing.JPanel.) + :text [{:text (default-option :text nil (constantly "hi"))}])))) ;(describe resource-option ;(it "has a setter that applies options using values from resource bundle" - ;(let [l (apply-options (javax.swing.JLabel.) - ;[:resource ::resource-option] + ;(let [l (apply-options (javax.swing.JLabel.) + ;[:resource ::resource-option] ;{:resource (resource-option :resource [:text :name]) ;:text (bean-option :text javax.swing.JLabel) ;:name (bean-option :name javax.swing.JLabel) })] @@ -57,20 +57,19 @@ (describe around-option (it "calls the provided converter after calling the getter from the wrapped option" - (= 100 (get-option-value nil - :foo - [{:foo (around-option + (= 100 (get-option-value nil + :foo + [{:foo (around-option (default-option :foo identity (constantly 99)) - identity + identity inc)}]))) (it "calls the provided converter before calling the setter of the wrapped option" (let [result (atom nil)] - (set-option-value nil - :bar + (set-option-value nil + :bar 100 [{:bar (around-option (default-option :foo #(reset! result %2)) inc identity)}]) - (expect (= 101 @result))))) - + (expect (= 101 @result))))) \ No newline at end of file diff --git a/test/seesaw/test/pref.clj b/test/seesaw/test/pref.clj index 669b3e83..eb0a8704 100644 --- a/test/seesaw/test/pref.clj +++ b/test/seesaw/test/pref.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. diff --git a/test/seesaw/test/rsyntax.clj b/test/seesaw/test/rsyntax.clj index 330a7e06..70853469 100644 --- a/test/seesaw/test/rsyntax.clj +++ b/test/seesaw/test/rsyntax.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -19,4 +19,3 @@ (let [ta (rsyntax/text-area :syntax :clojure)] (expect (instance? org.fife.ui.rsyntaxtextarea.RSyntaxTextArea ta)) (expect (= "text/clojure" (core/config ta :syntax)))))) - diff --git a/test/seesaw/test/scroll.clj b/test/seesaw/test/scroll.clj index 8b9c68aa..e4f099ba 100644 --- a/test/seesaw/test/scroll.clj +++ b/test/seesaw/test/scroll.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -74,7 +74,4 @@ (let [t (text :multi-line? true :text "\n\n\n\n") s (scrollable t)] (scroll!* t :to [:position 4]) - (expect (= 4 (.getCaretPosition t))))))) - - - + (expect (= 4 (.getCaretPosition t))))))) \ No newline at end of file diff --git a/test/seesaw/test/selection.clj b/test/seesaw/test/selection.clj index a9a39d2a..5a88f54a 100644 --- a/test/seesaw/test/selection.clj +++ b/test/seesaw/test/selection.clj @@ -187,7 +187,7 @@ (testing "when given a JTabbedPane" (it "selects a tab by title when given a string" (let [tp (sc/tabbed-panel :tabs [{:title "A" :content "A"} - {:title "B" :content "B"}])] + {:title "B" :content "B"}])] (expect (= 0 (.getSelectedIndex tp))) (selection! tp "B") (expect (= 1 (.getSelectedIndex tp))))) @@ -226,5 +226,4 @@ (let [jtable (javax.swing.JTable. 10 2)] (expect (= jtable (selection! jtable {:multi? true } [0 2 4 6 8 9]))) (expect (= [0 2 4 6 8 9] (selection jtable {:multi? true}))) - (expect (= 0 (selection jtable))))))) - + (expect (= 0 (selection jtable)))))) \ No newline at end of file diff --git a/test/seesaw/test/selector.clj b/test/seesaw/test/selector.clj index 212f4500..ca76860b 100644 --- a/test/seesaw/test/selector.clj +++ b/test/seesaw/test/selector.clj @@ -89,5 +89,4 @@ (it "should select all of the components in a tree with :*" (let [a (core/label) b (core/text) c (core/label) p (core/flow-panel :items [a b c])] - (expect (= [p a b c] (select p [:*])))))) - + (expect (= [p a b c] (select p [:*])))))) \ No newline at end of file diff --git a/test/seesaw/test/timer.clj b/test/seesaw/test/timer.clj index 09e582f3..e935e73f 100644 --- a/test/seesaw/test/timer.clj +++ b/test/seesaw/test/timer.clj @@ -28,5 +28,4 @@ (expect (= 123 (.getInitialDelay t))) (expect (= 456 (.getDelay t))) (expect (not (.isRunning t))) - (expect (not (.isRepeats t)))))) - + (expect (not (.isRepeats t)))))) \ No newline at end of file diff --git a/test/seesaw/test/to_widget.clj b/test/seesaw/test/to_widget.clj index fc4d7543..0736724b 100644 --- a/test/seesaw/test/to_widget.clj +++ b/test/seesaw/test/to_widget.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -11,5 +11,4 @@ (ns seesaw.test.to-widget (:use seesaw.to-widget) (:use [lazytest.describe :only (describe it testing)] - [lazytest.expect :only (expect)])) - + [lazytest.expect :only (expect)])) \ No newline at end of file diff --git a/test/seesaw/test/tree.clj b/test/seesaw/test/tree.clj index 7cef0d95..6e98da58 100644 --- a/test/seesaw/test/tree.clj +++ b/test/seesaw/test/tree.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -113,5 +113,4 @@ root (.getRoot m)] (listen m :tree-nodes-removed #(reset! e %)) (node-removed m [root] 2 (.getChild m root 2)) - (expect (not (nil? @e)))))) - + (expect (not (nil? @e)))))) \ No newline at end of file diff --git a/test/seesaw/test/util.clj b/test/seesaw/test/util.clj index bb0c4294..9b40cb90 100644 --- a/test/seesaw/test/util.clj +++ b/test/seesaw/test/util.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -24,14 +24,14 @@ (it "returns true if the condition is true" (check-args true "yes!")) (it "returns throws IllegalArgumentException if condition is false" - (try + (try (do (check-args false "no!") false) (catch IllegalArgumentException e true)))) (describe cond-doto (it "only executes forms with true conditions" - (= "firstsecondfifth" (str (cond-doto (StringBuilder.) - true (.append "first") + (= "firstsecondfifth" (str (cond-doto (StringBuilder.) + true (.append "first") (> 2 1) (.append "second") (< 2 1) (.append "third") false (.append "fourth") @@ -132,5 +132,4 @@ (it "returns true for resource keywords" (resource-key? ::hello)) (it "returns false for non-resource keywords" - (not (resource-key? :hello)))) - + (not (resource-key? :hello)))) \ No newline at end of file diff --git a/test/seesaw/test/value.clj b/test/seesaw/test/value.clj index 48e78089..822e6199 100644 --- a/test/seesaw/test/value.clj +++ b/test/seesaw/test/value.clj @@ -134,4 +134,3 @@ (= "" (-> (text "foo") (value!* nil) text))) (it "sets the text of a label" (= "bar" (-> (label) (value!* "bar") text)))) - diff --git a/test/seesaw/test/widgets/log_window.clj b/test/seesaw/test/widgets/log_window.clj index 7519194e..2d4b9476 100644 --- a/test/seesaw/test/widgets/log_window.clj +++ b/test/seesaw/test/widgets/log_window.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -14,7 +14,7 @@ [lazytest.describe :only (describe it testing)] [lazytest.expect :only (expect)])) -(describe log-window +(describe log-window (it "creates a JTextArea" (instance? javax.swing.JTextArea (log-window))) (it "has :limit option" @@ -22,5 +22,4 @@ (it "has :auto-scroll? option" (not (config (log-window :auto-scroll? false) :auto-scroll?))) (it "satisfies LogWindow protocol" - (satisfies? LogWindow (log-window)))) - + (satisfies? LogWindow (log-window)))) \ No newline at end of file diff --git a/test/seesaw/test/widgets/rounded_label.clj b/test/seesaw/test/widgets/rounded_label.clj index 24c2d1b3..7b516bca 100644 --- a/test/seesaw/test/widgets/rounded_label.clj +++ b/test/seesaw/test/widgets/rounded_label.clj @@ -2,7 +2,7 @@ ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this +; which can be found in the file epl-v10.html at the root of this ; distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. @@ -19,5 +19,4 @@ (it "honors label options" (let [rl (rounded-label :text "hi" :background :blue)] (expect (= "hi" (.getText rl))) - (expect (= java.awt.Color/BLUE (.getBackground rl)))))) - + (expect (= java.awt.Color/BLUE (.getBackground rl)))))) \ No newline at end of file