Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ autodoc/**
/.classpath
/.project
/.settings
.lein-env
78 changes: 39 additions & 39 deletions examples/gaidica/src/gaidica/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -37,41 +37,41 @@
(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"]]))

(defn make-forecast-entries [forecasts]
(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
Expand All @@ -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 "")
Expand All @@ -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")))
Expand All @@ -108,7 +108,7 @@
{ :title "Radar/Satellite" :content (make-radar-panel) }]))


(defn make-frame
(defn make-frame
[]
(frame
:title "Gaidica"
Expand All @@ -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"
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -198,8 +198,8 @@
(println "Usage: gaidica <wunderground-api-key>")
(System/exit 1))
(reset! api-key (first args))
(invoke-later
(->
(invoke-later
(->
(make-frame)
add-behaviors
show!))
Expand Down
2 changes: 1 addition & 1 deletion examples/substance/src/substance/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 3 additions & 4 deletions examples/window-builder/src/window_builder/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

(def states ["CA", "GA", "WA"])

(def defaults
(def defaults
{ :first-name "Laura"
:last-name "Palmer"
:street "123 Main St."
Expand All @@ -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.
Expand All @@ -43,4 +43,3 @@
(if (= :success result)
(println "User entered: " (value form))
(println "User canceled")))))

2 changes: 1 addition & 1 deletion jvm/seesaw/ExceptionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lazytest-watch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lazytest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lazytest.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 6 additions & 5 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
:distribution :repo
:comments "same as Clojure"}

:warn-on-reflection true
:global-vars {*warn-on-reflection* true
*assert* false}

; To run the examples:
;
; $ lein examples
;
: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 {
Expand Down
29 changes: 14 additions & 15 deletions src/seesaw/action.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]))
Expand All @@ -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)
Expand All @@ -42,24 +42,24 @@
(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])))


(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
Expand All @@ -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)))
Loading