Skip to content

Commit

Permalink
Clicking on previously selected article selects it again and displays…
Browse files Browse the repository at this point in the history
… it in the article window.
  • Loading branch information
unclebob committed Jul 7, 2023
1 parent e89b9dc commit f0454ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/more_speech/ui/swing/tabs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
renderer (.getCellRenderer header-tree)
_ (.setBackgroundSelectionColor renderer (color :azure))]
(listen header-tree :selection (partial node-selected tab-index))
(listen header-tree :mouse-pressed article-click)
(listen header-tree :mouse-pressed (partial article-click tab-index))
(set-mem [:tab-tree-map tab-name] header-tree)
header-tree))

Expand Down Expand Up @@ -274,8 +274,9 @@

;------DECLARED

(defn article-click [e]
(when (.isPopupTrigger e)
(defn article-click [tab-index e]
(if-not (.isPopupTrigger e)
(node-selected tab-index e)
(let [tree (.getComponent e)
path (.getPathForLocation tree (.getX e) (.getY e))
node (.getLastPathComponent path)
Expand Down
26 changes: 16 additions & 10 deletions src/more_speech/ui/swing/users_window.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,31 @@
(.setSelectedValue trusted-listbox
new-trusted-item true)))))))

(defn untrust-items [listbox-items]
(loop [items listbox-items]
(when-let [item (first items)]
(let [untrusted-user (second item)]
(trust-updater/untrust untrusted-user)
(recur (rest items))))))

(defn add-items-to-recent-users [listbox-items]
(loop [items listbox-items]
(when-let [item (first items)]
(let [user-id (second item)]
(update-mem [:user-window :recent-users] conj user-id)
(recur (rest items))))))

(defn untrust-selection [frame _e]
(let [trusted-listbox (select frame [:#trusted-users-listbox])
recent-button (select frame [:#recent-button])
selected-listbox (select frame [:#selected-users])
selected-items (selection trusted-listbox {:multi? true})]
(loop [selected-items selected-items]
(when-let [selected-item (first selected-items)]
(let [untrusted-user (second selected-item)]
(trust-updater/untrust untrusted-user)
(recur (rest selected-items)))))
(untrust-items selected-items)
(load-trusted-users)
(config! trusted-listbox :model (get-mem [:user-window :trusted-user-items]))
(config! recent-button :selected? true)
(load-recent-users)
(loop [selected-items selected-items]
(when-let [selected-item (first selected-items)]
(let [untrusted-user (second selected-item)]
(update-mem [:user-window :recent-users] conj untrusted-user)
(recur (rest selected-items)))))
(add-items-to-recent-users selected-items)
(set-mem [:user-window :recent-user-items]
(make-sorted-listbox-items
(get-mem [:user-window :recent-users])))
Expand Down

0 comments on commit f0454ce

Please sign in to comment.