File tree 4 files changed +25
-18
lines changed
4 files changed +25
-18
lines changed Original file line number Diff line number Diff line change 15
15
[camel-snake-kebab " 0.4.1" ]
16
16
[org.clojure/tools.gitlibs " 1.0.83" ] ; ; git download
17
17
[cheshire " 5.10.0" ] ; ; json
18
- [ntestoc/seesaw " 0.1.4 " ]
18
+ [ntestoc/seesaw " 0.1.5 " ]
19
19
[version-clj " 0.1.2" ]
20
20
[camel-snake-kebab " 0.4.2" ]
21
21
[me.raynes/fs " 1.4.6" ] ; ; fs utils
Original file line number Diff line number Diff line change 141
141
(gui/invoke-later
142
142
(table/add! tbl ia))
143
143
(when callback
144
- (callback ia))))
144
+ (try (callback ia)
145
+ (catch Exception e
146
+ (log/error " collaborator callback error:" e))))))
145
147
(catch Exception e
146
148
(log/error " get collaborator interactions." e))))
147
149
window-showing (atom true )
Original file line number Diff line number Diff line change 149
149
^java.lang.Boolean has-focus
150
150
^java.lang.Integer row
151
151
^java.lang.Integer column]
152
- (let [v (table/value-at tbl row)]
152
+ (let [v (->> (.convertRowIndexToModel tbl row)
153
+ (table/value-at tbl))]
153
154
; ; table中的cellrenderer是共用的同一个对象,
154
155
; ; 因此每次都要根据不同的值来设置,否则后面会一直使用之前设置过的color
155
156
(.setBackground this (if-some [bg (:background v)]
Original file line number Diff line number Diff line change 1
1
(ns burp-clj.table-util
2
2
" table辅助函数"
3
3
(:require [seesaw.table :as table]
4
- [seesaw.core :as gui]))
4
+ [seesaw.core :as gui]
5
+ [taoensso.timbre :as log]))
5
6
6
7
(defn- filter-table-by
7
8
" 返回[[row-index row-value]...]格式的序列"
19
20
after 是否在查找的行之后插入,默认为false"
20
21
([tbl filter-pred value] (insert-by! tbl filter-pred value false ))
21
22
([tbl filter-pred value after]
22
- (->> (filter-table-by tbl filter-pred)
23
- (mapcat (fn [[idx v]]
24
- [(if after
25
- (inc idx)
26
- idx)
27
- value]))
28
- (apply table/insert-at! tbl))))
23
+ (let [kvs (->> (filter-table-by tbl filter-pred)
24
+ (mapcat (fn [[idx v]]
25
+ [(if after
26
+ (inc idx)
27
+ idx)
28
+ value])))]
29
+ (when-not (empty? kvs)
30
+ (apply table/insert-at! tbl kvs)))))
29
31
30
32
(defn update-by!
31
33
" 根据条件查找并更新行
32
34
filter-pred 过滤函数,参数为table row数据
33
35
update-fn 更新函数,参数为table row数据
34
36
"
35
37
[tbl filter-pred update-fn]
36
- (->> (filter-table-by tbl filter-pred)
37
- (mapcat (fn [[idx v]]
38
- [idx (update-fn v)]))
39
- (apply table/update-at! tbl)))
38
+ (let [kvs (->> (filter-table-by tbl filter-pred)
39
+ (mapcat (fn [[idx v]]
40
+ [idx (update-fn v)])))]
41
+ (when-not (empty? kvs)
42
+ (apply table/update-at! tbl kvs))))
40
43
41
44
(defn remove-by!
42
45
" 根据条件查找并删除行
43
46
filter-pred 过滤函数,参数为table row数据
44
47
"
45
48
[tbl filter-pred]
46
- (->> (filter-table-by tbl filter-pred)
47
- (map first)
48
- (apply table/remove-at! tbl)))
49
+ (let [ks (->> (filter-table-by tbl filter-pred)
50
+ (map first))]
51
+ (when-not (empty? ks)
52
+ (apply table/remove-at! tbl ks))))
49
53
50
54
You can’t perform that action at this time.
0 commit comments