Skip to content

Commit 80f9fde

Browse files
committed
完善table界面
1 parent 298e1cc commit 80f9fde

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[camel-snake-kebab "0.4.1"]
1616
[org.clojure/tools.gitlibs "1.0.83"] ;; git download
1717
[cheshire "5.10.0"] ;; json
18-
[ntestoc/seesaw "0.1.4"]
18+
[ntestoc/seesaw "0.1.5"]
1919
[version-clj "0.1.2"]
2020
[camel-snake-kebab "0.4.2"]
2121
[me.raynes/fs "1.4.6"] ;; fs utils

src/burp_clj/collaborator.clj

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@
141141
(gui/invoke-later
142142
(table/add! tbl ia))
143143
(when callback
144-
(callback ia))))
144+
(try (callback ia)
145+
(catch Exception e
146+
(log/error "collaborator callback error:" e))))))
145147
(catch Exception e
146148
(log/error "get collaborator interactions." e))))
147149
window-showing (atom true)

src/burp_clj/message_viewer.clj

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@
149149
^java.lang.Boolean has-focus
150150
^java.lang.Integer row
151151
^java.lang.Integer column]
152-
(let [v (table/value-at tbl row)]
152+
(let [v (->> (.convertRowIndexToModel tbl row)
153+
(table/value-at tbl))]
153154
;; table中的cellrenderer是共用的同一个对象,
154155
;; 因此每次都要根据不同的值来设置,否则后面会一直使用之前设置过的color
155156
(.setBackground this (if-some [bg (:background v)]

src/burp_clj/table_util.clj

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
(ns burp-clj.table-util
22
"table辅助函数"
33
(:require [seesaw.table :as table]
4-
[seesaw.core :as gui]))
4+
[seesaw.core :as gui]
5+
[taoensso.timbre :as log]))
56

67
(defn- filter-table-by
78
"返回[[row-index row-value]...]格式的序列"
@@ -19,32 +20,35 @@
1920
after 是否在查找的行之后插入,默认为false"
2021
([tbl filter-pred value] (insert-by! tbl filter-pred value false))
2122
([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)))))
2931

3032
(defn update-by!
3133
"根据条件查找并更新行
3234
filter-pred 过滤函数,参数为table row数据
3335
update-fn 更新函数,参数为table row数据
3436
"
3537
[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))))
4043

4144
(defn remove-by!
4245
"根据条件查找并删除行
4346
filter-pred 过滤函数,参数为table row数据
4447
"
4548
[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))))
4953

5054

0 commit comments

Comments
 (0)