        (map #(.setPreferredWidth % 125)) dorun))
 
 (defn activate-groups-table [components]
-  (attach-selection-listener
-    (components :groups-table)
+  (let [{:keys [groups-table preset-names-table presets-table]} components]
+    (attach-selection-listener
+      groups-table
     (fn [_] (update-group-data)
-         (.fireTableDataChanged (.getModel (components :preset-names-table)))
-         (.fireTableStructureChanged (.getModel (components :presets-table)))
-         (set-preferred-column-width (components :presets-table)))))
+         (.fireTableDataChanged (.getModel preset-names-table))
+         (cancel-cell-editing preset-names-table)
+         (cancel-cell-editing presets-table)
+         (.fireTableStructureChanged (.getModel presets-table))
+         (set-preferred-column-width (components :presets-table))))))
 
 ;; test/run
 

        (when (> y (+ (.y r) (.height r)))
          (f))))))

(defn show []
  (let [f (JFrame. "Micro-Manager Configuration Preset Editor")
        cp (.getContentPane f)

(ns org.micromanager.config-editor
  (:import [javax.swing DefaultListModel JFrame JList JPanel JTable
                        DefaultListSelectionModel JScrollPane JViewport
                        ListSelectionModel SpringLayout JPopupMenu]
           [javax.swing.event CellEditorListener ListSelectionListener]
           [java.awt.event MouseAdapter]
           [javax.swing.table AbstractTableModel]
           [java.awt Color Dimension])
  (:use [org.micromanager.mm :only [load-mm gui core edt get-config]]))

(load-mm)

;; utils

(defn slow-update [reference update-fn]
  (let [a (agent nil)
        update-fn-sender
        (fn [_ ref _ _]
          (send-off a
            #(if (not= % @ref)
               (update-fn @ref))
               @ref))]                                
    (add-watch reference (gensym "slow_update")
               update-fn-sender)))
           

;; swing layout 

