Permalink
Browse files

Merge branch 'release/1.0.9'

  • Loading branch information...
2 parents f5eddf5 + e5e5d96 commit 156e6aea8879c5d4fc7140ae6bbe01a7f99146fc @daveray committed Jul 17, 2011
Submodule autodoc updated from e75d8f to ccd4b5
View
@@ -1,4 +1,4 @@
-(defproject seesaw "1.0.8"
+(defproject seesaw "1.0.9"
:description "A Swing wrapper/DSL for Clojure. You want seesaw.core, FYI. See http://seesaw-clj.org for more info."
:url "http://seesaw-clj.org"
:mailing-list {:name "seesaw-clj"
View
@@ -2421,7 +2421,7 @@
(def ^{:private true} progress-bar-options {
:orientation #(.setOrientation ^javax.swing.JProgressBar %1 (or (orientation-table %2)
(throw (IllegalArgumentException. (str ":orientation must be either :horizontal or :vertical. Got " %2 " instead.")))))
- :value #(do (check-args (number? %2)) (.setValue ^javax.swing.JProgressBar %1 %2))
+ :value #(do (check-args (number? %2) ":value must be a number") (.setValue ^javax.swing.JProgressBar %1 %2))
:min #(do (check-args (number? %2) ":min must be a number.")
(.setMinimum ^javax.swing.JProgressBar %1 %2))
:max #(do (check-args (number? %2) ":max must be a number.")
@@ -11,7 +11,7 @@
(ns seesaw.examples.dialog
(:use [seesaw core font border util color pref mig]
[clojure.pprint :only (cl-format)])
- (:require [seesaw.bind :as bind])
+ (:require [seesaw.bind :as bind]))
(defmethod print-dup java.awt.Color [x writer]
(binding [*print-dup* false]
@@ -87,7 +87,7 @@
(config! e :background clr)))])
color-atom (atom (color 255 255 0))]
(bind-preference-to-atom "LAST_BACKGROUND" color-atom)
- (bind/bind (property lbl :background) color-atom)
+ (bind/bind (bind/property lbl :background) color-atom)
(config! lbl :background @color-atom)
lbl) "growx, wrap"]
])) pack! show!)))
@@ -33,3 +33,5 @@
(defn -main [& args]
(invoke-later (-> (app) pack! show!)))
+
+;(-main)
@@ -0,0 +1,67 @@
+; Copyright (c) Dave Ray, 2011. All rights reserved.
+
+; 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
+; 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.examples.kotka-bind
+ (:require [seesaw.bind :as bind])
+ (:use [seesaw.core]))
+
+; seesaw.bind applied to http://kotka.de/blog/2010/05/Decoupling_Logic_and_GUI.html
+;
+; shows how to bind atom values to widge properties to decouple logic from
+; display.
+
+(defn processing
+ [items done? canceled? progress]
+ (doseq [item (take-while (fn [_] (not @canceled?)) items)]
+ (println item)
+ (Thread/sleep 50)
+ (swap! progress inc))
+ (reset! done? true))
+
+(defn startup
+ []
+ (let [items (take 500 (iterate inc 0))
+ progress (atom 0)
+ done? (atom false)
+ canceled? (atom false)
+ pbar (progress-bar :value 0 :max (count items))
+ done (button :text "Done" :enabled? false)
+ cancel (button :text "Cancel")
+ panel (border-panel
+ :border 5 :hgap 5 :vgap 5
+ :north "The progress bar updates 20 times per second"
+ :center pbar
+ :south (grid-panel :rows 1 :items [done cancel]))]
+ ; Wire up the done button
+ (listen done :action-performed (fn [e] (dispose! (to-root e))))
+ ; Toggle buttons on done
+ (bind/bind done?
+ (bind/some identity) ; (when done?)
+ (bind/tee
+ (bind/property done :enabled?)
+ (bind/bind (bind/transform not) (bind/property cancel :enabled?))))
+ ; Wire up cancel button.
+ (listen cancel :action-performed
+ (fn [_]
+ (reset! canceled? true)))
+ ; Wire up progress bar.
+ (bind/bind progress pbar)
+ (->
+ (frame :title "Example GUI" :on-close :dispose :content panel)
+ pack!
+ show!)
+ (-> #(processing items done? canceled? progress) Thread. .start)))
+
+(defn -main
+ []
+ (invoke-now (startup)))
+
+;(-main)
+
@@ -10,7 +10,7 @@
(ns seesaw.examples.text-ref
(:use [seesaw.core])
- (:require [seesaw.bind :as bind])
+ (:require [seesaw.bind :as bind]))
; Very basic example of connecting a text field to an atom.
@@ -967,7 +967,12 @@
(describe progress-bar
(it "should create a JProgressBar"
- (expect (= javax.swing.JProgressBar (class (progress-bar))))))
+ (expect (= javax.swing.JProgressBar (class (progress-bar)))))
+ (it "should set the progress bars min, max and initial value"
+ (let [pb (progress-bar :value 5 :min 1 :max 6)]
+ (expect (= 5 (.getValue pb)))
+ (expect (= 1 (.getMinimum pb)))
+ (expect (= 6 (.getMaximum pb))))))
(describe select
(it "should throw an exception if selector is not a vector"

0 comments on commit 156e6ae

Please sign in to comment.