Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Update to recent lazytest
  • Loading branch information
NoahTheDuke committed Sep 19, 2024
commit f51030af36cab936314a3e204a089dfbca275923
4 changes: 4 additions & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:lint-as {seesaw.test.examples.example/defexample clojure.core/defn}
:linters {:clojure-lsp/unused-public-var {:level :off}
:refer-all {:level :off}
:unused-binding {:level :off}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:lint-as {lazytest.core/defdescribe clojure.core/def
lazytest.core/given clojure.core/let}}
2 changes: 2 additions & 0 deletions .clj-kondo/imports/metosin/malli/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:lint-as {malli.experimental/defn schema.core/defn}
:linters {:unresolved-symbol {:exclude [(malli.core/=>)]}}}
4 changes: 4 additions & 0 deletions .clj-kondo/imports/nubank/matcher-combinators/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:linters
{:unresolved-symbol
{:exclude [(cljs.test/is [match? thrown-match?])
(clojure.test/is [match? thrown-match?])]}}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ autodoc/**
.clj-kondo/.cache
.lsp/.cache
.portal/vs-code.edn
.nrepl-port
11 changes: 5 additions & 6 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@
:distribution :repo
:comments "same as Clojure"}

:warn-on-reflection true

; To run the examples:
;
; $ lein examples
;
:aliases { "examples" ["run" "-m" "seesaw.test.examples.launcher"] }
:aliases {"test" ["run" "-m" "lazytest.main"]
"examples" ["run" "-m" "seesaw.test.examples.launcher"]}

:dependencies [[org.clojure/clojure "1.4.0"]
:dependencies [[org.clojure/clojure "1.11.1"]
[com.miglayout/miglayout "3.7.4"]
[com.jgoodies/forms "1.2.1"]
[org.swinglabs.swingx/swingx-core "1.6.3"]
[j18n "1.0.2"]
[com.fifesoft/rsyntaxtextarea "2.5.6"]]
:profiles { :dev {:dependencies [[com.stuartsierra/lazytest "1.1.2"]
[lein-autodoc "0.9.0"]]}}
:profiles { :dev {:dependencies [[io.github.noahtheduke/lazytest "0.4.2"]
[lein-autodoc "0.9.0"]]}}
:repositories [["stuartsierra-releases" "https://stuartsierra.com/maven2"]]
:autodoc {
:name "Seesaw",
Expand Down
2 changes: 1 addition & 1 deletion src/seesaw/action.clj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
See:
http://download.oracle.com/javase/6/docs/api/javax/swing/Action.html
"
[& opts]
^Action [& opts]
(let [a (proxy [AbstractAction] []
(actionPerformed [e]
(if-let [f (get-meta this action-handler-property)] (f e))))]
Expand Down
7 changes: 3 additions & 4 deletions src/seesaw/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@
See:
http://download.oracle.com/javase/6/docs/api/javax/swing/JLabel.html
"
[& args]
^JLabel [& args]
(case (count args)
0 (label :text "")
1 (label :text (first args))
Expand Down Expand Up @@ -1532,8 +1532,7 @@
(seesaw.core/style-text!)
http://download.oracle.com/javase/6/docs/api/javax/swing/JTextPane.html
"
{ :arglists '([& args]) }
[& {:as opts}]
^JTextPane [& {:as opts}]
(let [pane (proxy [JTextPane] []
(getScrollableTracksViewportWidth []
(boolean (get-meta this :wrap-lines?))))]
Expand All @@ -1548,7 +1547,7 @@
(seesaw.core/text)
http://download.oracle.com/javase/tutorial/uiswing/components/editorpane.html
"
[^JTextPane target id ^Integer start ^Integer length]
^JTextPane [^JTextPane target id ^Integer start ^Integer length]
(check-args (instance? JTextPane target) "style-text! only applied to styled-text widgets")
(.setCharacterAttributes (.getStyledDocument target)
start length (.getStyle target (name id)) true)
Expand Down
6 changes: 4 additions & 2 deletions src/seesaw/graphics.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
(.setRenderingHint RenderingHints/KEY_ANTIALIASING RenderingHints/VALUE_ANTIALIAS_ON)))

(defn buffered-image
([width height] (buffered-image width height BufferedImage/TYPE_INT_ARGB))
([width height t] (BufferedImage. width height t)))
(^BufferedImage [width height] (buffered-image width height BufferedImage/TYPE_INT_ARGB))
(^BufferedImage [width height t] (BufferedImage. width height t)))

(defn- to-image [v]
(cond
Expand Down Expand Up @@ -137,6 +137,8 @@
(.addPoint p x y))
p))

(declare line-to move-to curve-to quad-to)

(def ^{:private true} path-ops {
'line-to '.lineTo
'move-to '.moveTo
Expand Down
4 changes: 2 additions & 2 deletions src/seesaw/icon.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;*******************************************************************************
; Icons

(defn ^javax.swing.Icon icon
(defn icon
"Loads an icon. The parameter p can be any of the following:

nil - returns nil
Expand All @@ -33,7 +33,7 @@
This is the function used to process the :icon property on most widgets
and windows. Thus, any of these values may be used for the :icon property.
"
[p]
^javax.swing.ImageIcon [p]
(cond
(nil? p) nil
(instance? javax.swing.Icon p) p
Expand Down
2 changes: 1 addition & 1 deletion src/seesaw/keystroke.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
arg can also be an i18n resource keyword.

See http://download.oracle.com/javase/6/docs/api/javax/swing/KeyStroke.html#getKeyStroke(java.lang.String)"
[arg]
^KeyStroke [arg]
(cond
(nil? arg) nil
(instance? KeyStroke arg) arg
Expand Down
2 changes: 1 addition & 1 deletion src/seesaw/mig.clj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(seesaw.core/default-options)
"
{ :seesaw {:class 'javax.swing.JPanel }}
[& opts]
^javax.swing.JPanel [& opts]
(abstract-panel (net.miginfocom.swing.MigLayout.) opts))

(extend-protocol LayoutManipulation
Expand Down
28 changes: 14 additions & 14 deletions src/seesaw/swingx.clj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
(declare p-pattern)
(declare p-fn)

(defn- ^HighlightPredicate to-p [v]
(defn- to-p ^HighlightPredicate [v]
(cond
(instance? HighlightPredicate v) v
(instance? java.util.regex.Pattern v) (p-pattern v)
Expand Down Expand Up @@ -159,7 +159,7 @@
:else
(HighlighterFactory/createSimpleStriping)))

(defn ^Highlighter to-highlighter [v]
(defn to-highlighter ^Highlighter [v]
(cond
(instance? Highlighter v) v
(= :shade v) (hl-shade)
Expand Down Expand Up @@ -529,7 +529,7 @@
;*******************************************************************************
; JXList

(def ^ {:private true} sort-order-table
(def ^:private sort-order-table
{ :ascending javax.swing.SortOrder/ASCENDING
:descending javax.swing.SortOrder/DESCENDING})

Expand Down Expand Up @@ -585,7 +585,7 @@
See:
(seesaw.core/listbox)
"
[& args]
^org.jdesktop.swingx.JXList [& args]
(apply-options
(doto (construct org.jdesktop.swingx.JXList)
(.setAutoCreateRowSorter true)
Expand Down Expand Up @@ -633,7 +633,7 @@
See:
(seesaw.core/listbox)
"
[& args]
^org.jdesktop.swingx.JXTitledPanel [& args]
(apply-options
(construct org.jdesktop.swingx.JXTitledPanel)
args))
Expand Down Expand Up @@ -666,7 +666,7 @@
(seesaw.core/tree-options)
(seesaw.core/tree)
"
[& args]
^org.jdesktop.swingx.JXTree [& args]
(apply-options
(doto (construct org.jdesktop.swingx.JXTree)
(.setRolloverEnabled true))
Expand Down Expand Up @@ -707,7 +707,7 @@
(seesaw.core/table-options)
(seesaw.core/table)
"
[& args]
^org.jdesktop.swingx.JXTable [& args]
(apply-options
(doto (construct org.jdesktop.swingx.JXTable)
(.setRolloverEnabled true)
Expand All @@ -731,25 +731,25 @@
(defn- abstract-panel-x [layout opts]
(abstract-panel (construct org.jdesktop.swingx.JXPanel) layout opts))

(defn xyz-panel-x [& opts]
(defn xyz-panel-x ^org.jdesktop.swingx.JXPanel [& opts]
(abstract-panel-x nil opts))

(defn border-panel-x [& opts]
(defn border-panel-x ^org.jdesktop.swingx.JXPanel [& opts]
(abstract-panel-x (java.awt.BorderLayout.) opts))

(defn flow-panel-x [& opts]
(defn flow-panel-x ^org.jdesktop.swingx.JXPanel [& opts]
(abstract-panel-x (java.awt.FlowLayout.) opts))

(defn horizontal-panel-x [& opts]
(defn horizontal-panel-x ^org.jdesktop.swingx.JXPanel [& opts]
(abstract-panel-x (box-layout :horizontal) opts))

(defn vertical-panel-x [& opts]
(defn vertical-panel-x ^org.jdesktop.swingx.JXPanel [& opts]
(abstract-panel-x (box-layout :vertical) opts))

(defn grid-panel-x
[& {:keys [rows columns] :as opts}]
^org.jdesktop.swingx.JXPanel [& {:keys [rows columns] :as opts}]
(abstract-panel-x (grid-layout rows columns) opts))

(defn card-panel-x [& opts]
(defn card-panel-x ^org.jdesktop.swingx.JXPanel [& opts]
(abstract-panel-x (java.awt.CardLayout.) opts))

6 changes: 3 additions & 3 deletions src/seesaw/table.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
(let [[head [_ & tail]] (split-at pos row-vec)]
(vec (concat head tail))))

(defn- ^javax.swing.table.DefaultTableModel proxy-table-model
[column-names column-key-map column-classes]
(defn- proxy-table-model
^javax.swing.table.DefaultTableModel [column-names column-key-map column-classes]
(let [full-values (atom [])]
(proxy [javax.swing.table.DefaultTableModel] [(object-array column-names) 0]
(isCellEditable [row col] false)
Expand Down Expand Up @@ -131,7 +131,7 @@
(seesaw.core/table)
http://download.oracle.com/javase/6/docs/api/javax/swing/table/TableModel.html
"
[& {:keys [columns rows] :as opts}]
^javax.swing.table.DefaultTableModel [& {:keys [columns rows] :as opts}]
(let [norm-cols (map normalize-column columns)
col-names (map :text norm-cols)
col-classes (map :class norm-cols)
Expand Down
2 changes: 1 addition & 1 deletion src/seesaw/timer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

See http://download.oracle.com/javase/6/docs/api/javax/swing/Timer.html
"
[f & {:keys [start? initial-value] :or {start? true} :as opts}]
^javax.swing.Timer [f & {:keys [start? initial-value] :or {start? true} :as opts}]
(let [a (action :handler (timer-handler f initial-value))
t (javax.swing.Timer. 0 a)]
(.setDelay t 1000)
Expand Down
10 changes: 5 additions & 5 deletions src/seesaw/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@
(cast c x)
(catch ClassCastException e nil)))

(defn ^URL to-url
(defn to-url
"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."
[s]
^URL [s]
(if (instance? URL s) s
(try
(URL. (str s))
(catch MalformedURLException e nil))))

(defn ^URI to-uri
(defn to-uri
"Try to make a java.net.URI from s"
[s]
^URI [s]
(cond
(instance? URI s) s
(instance? URL s) (.toURI ^URL s)
Expand All @@ -132,7 +132,7 @@
(catch URISyntaxException e nil))))

(defn to-dimension
[v]
^java.awt.Dimension [v]
(cond
(instance? java.awt.Dimension v) v
(and (vector? v) (= 3 (count v)) (= :by (second v)))
Expand Down
4 changes: 2 additions & 2 deletions src/seesaw/widgets/rounded_label.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
See:
(seesaw.core/label)
"
[& opts]
^javax.swing.JLabel [& opts]
(let [radius 15
paint (fn [^javax.swing.JLabel c ^java.awt.Graphics g]
(doto g
(.setColor (.getBackground c))
(.fillRoundRect
0 0 (dec (.getWidth c)) (dec (.getHeight c))
@radius @radius)))
radius radius)))
widget (rounded-label-proxy paint)]
(apply-options widget opts)))

Expand Down
41 changes: 21 additions & 20 deletions test/seesaw/test/action.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
; You must not remove this notice, or any other, from this software.

(ns seesaw.test.action
(:use [seesaw.action]
[seesaw.core :only [config]]
[seesaw.keystroke :only [keystroke]])
(:use [lazytest.describe :only (describe it testing)]
[lazytest.expect :only (expect)])
(:import [javax.swing Action]))
(:require
[lazytest.core :refer [defdescribe describe expect expect-it it]]
[seesaw.action :refer [action]]
[seesaw.core :refer [config]]
[seesaw.keystroke :refer [keystroke]])
(:import
[javax.swing Action]))

(describe action
(defdescribe action-test
(it "sets the name, tooltip, and command"
(let [a (action :name "Test" :tip "This is a tip" :command "Go!")]
(expect (instance? Action a))
Expand All @@ -42,7 +43,7 @@
(expect (= (int \T) m))))
(it "calls the handler when actionPerformed is called"
(let [called (atom false)
f (fn [e] (reset! called true))
f (fn [_] (reset! called true))
a (action :handler f)]
(.actionPerformed a nil)
(expect @called)))
Expand Down Expand Up @@ -70,16 +71,16 @@
(expect (= "A tip" (config a :tip)))
(expect (= (keystroke "ctrl C") (config a :key)))))

(it "loads :icon from a resource"
(expect (instance? javax.swing.Icon (config (action :icon ::my-action.icon) :icon))))
(it "loads :mnemonic from a resource"
(expect (= (int \X) (config (action :mnemonic ::my-action.mnemonic) :mnemonic))))
(it "loads :command from a resource"
(expect (= "A command" (config (action :command ::my-action.command) :command))))
(it "loads :name from a resource"
(expect (= "A name" (config (action :name ::my-action.name) :name))))
(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-it "loads :icon from a resource"
(instance? javax.swing.Icon (config (action :icon ::my-action.icon) :icon)))
(expect-it "loads :mnemonic from a resource"
(= (int \X) (config (action :mnemonic ::my-action.mnemonic) :mnemonic)))
(expect-it "loads :command from a resource"
(= "A command" (config (action :command ::my-action.command) :command)))
(expect-it "loads :name from a resource"
(= "A name" (config (action :name ::my-action.name) :name)))
(expect-it "loads :key from a resource"
(= (keystroke "ctrl C") (config (action :key ::my-action.key) :key)))
(expect-it "loads :tip from a resource"
(= "A tip" (config (action :tip ::my-action.tip) :tip))))

10 changes: 5 additions & 5 deletions test/seesaw/test/behave.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
; You must not remove this notice, or any other, from this software.

(ns seesaw.test.behave
(:use seesaw.behave)
(:use seesaw.core)
(:use [lazytest.describe :only (describe it testing)]
[lazytest.expect :only (expect)]))
(:require
[lazytest.core :refer [defdescribe expect it]]
[seesaw.behave :refer [when-focused-select-all]]
[seesaw.core :refer [text]]))

(describe when-focused-select-all
(defdescribe when-focused-select-all-test
(it "causes all text in a text field to be selected when it gains focus"
(let [t (text "Hi there")
remove-fn (when-focused-select-all t)]
Expand Down
Loading