 
 (load-mm)
 
-(def groups (atom nil))
-
-(defn update-groups []
-  (reset! groups (seq (core getAvailableConfigGroups)))
-  (.refreshGUI gui))
 
 (defn presets [group]
   (when-not (empty? group)
     (sort (seq (core getAvailableConfigs group)))))
 
-(defn group-data [group]
-  (into (sorted-map) (map #(vector % (get-config group %)) (presets group))))
+(def group-data (atom nil))
+
+(defn update-tables []
+  (doall (map #(.. % getModel fireTableDataChanged) (vals @widgets))))
+
+(defn update-group-data []
+    (reset! group-data 
+            (when-let [group (get-selected-group)]
+              (into (sorted-map)
+                    (map #(vector % (get-config group %))
+                         (presets group))))))
+
+(def groups (atom nil))
+
+(defn update-groups []
+  (reset! groups (seq (core getAvailableConfigGroups)))
+  (update-group-data))
 
 (defn properties [group-data]
   (sort (set (apply concat (map keys (vals group-data))))))

        (reify CellEditorListener 
          (editingStopped [this e]
            (handle-group-text-changed e))))))
  
(defn group-table-model []
  (proxy [AbstractTableModel] []
    (getColumnName [_] "Groups")

     :presets-table presets-table
     :preset-names-table preset-names-table}))

(defn set-preferred-column-width [table]
  (->> table
       .getColumnModel .getColumns enumeration-seq
       (map #(.setPreferredWidth % 125)) dorun))

(defn activate-groups-table [components]
  (attach-selection-listener
    (components :groups-table)
    (fn [_] (update-group-data)
         (.fireTableDataChanged (.getModel (components :preset-names-table)))
         (.fireTableStructureChanged (.getModel (components :presets-table)))
         (set-preferred-column-width (components :presets-table)))))


;; test/run
