0.1.0-SNAPSHOT permalink Arrow_down_16x16

seq-ref-list-model

clj-swing.list

  • (seq-ref-list-model seq-ref)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clj_swing/list.clj:33 top

(defn seq-ref-list-model [seq-ref]
  (let [listeners (atom #{})
	key (gensym "seq-ref-list-model-watch")
	m (list-model
	   :size ([] (count @seq-ref))
	   :add-listener ([l] (swap! listeners conj l))
	   :remove-listener ([l] (swap! listeners disj l))
	   :get ([i] (if (has-index? @seq-ref i) (nth @seq-ref i) nil))
	   )]
    (add-watch seq-ref key 
	       (fn [_ _ _ state]
		 (do-swing
		  (let [m (ListDataEvent. m (ListDataEvent/CONTENTS_CHANGED) 0 (count state))]
		    (doseq [l @listeners]
		      (.contentsChanged l m))))))
    m))
Vars in clj-swing.list/seq-ref-list-model: add-watch defn doseq fn key let
Used in 0 other vars

Comments top

No comments for seq-ref-list-model. Log in to add a comment.