 
 ;; collection files
 
-(defn create-default-path []
-  (str (System/getProperty "user.name") ".mmdb.txt"))
-
-(defn new-collection []
-  (File. (create-default-path)))
-
-(defn read-collection-list []
-  (read-value-from-prefs prefs "collection-files"))
+(defn read-collection-map []
+  (or (read-value-from-prefs prefs "collection-files")
+      (let [name (System/getProperty "user.name")]
+        {name (.getAbsolutePath (File. (str name ".mmdb.txt")))})))
+
+(defn save-collection-map [collection-map]
+  (write-value-to-prefs prefs "collection-files" collection-map))
 
 (defn get-current-data-and-settings []
   (let [table (@browser :table)

       (->> @settings-window :locations :table .getModel .getDataVector
            seq (map seq) flatten)
     :sorted-column
       (let [sort-key (->> table .getRowSorter .getSortKeys seq first)]
         {:order ({SortOrder/ASCENDING 1 SortOrder/DESCENDING -1}
                   (.getSortOrder sort-key))
          :model-column (.getColumnName model (.getColumn sort-key))})}))

(defn update-collection-menu [items]
  (let [menu (@browser :collection-menu)]
    (.removeAllItems menu)
    (dorun (map #(.addItem menu %) (sort items)))
    (.addItem menu "New...")))

;; windows


    (.setLayout panel (SpringLayout.))
    (constrain-to-parent scroll-pane :n 32 :w 5 :s -5 :e -5
                         search-field :n 5 :w 25 :n 28 :w 200
                         settings-button :n 5 :w 405 :n 28 :w 510
                         search-label :n 5 :w 5 :n 28 :w 25
                         collection-label :n 5 :w 205 :n 28 :w 275
                         collection-menu :n 5 :w 275 :n 28 :w 405)
    (connect-search search-field table)
    (.setSortsOnUpdates (.getRowSorter table) true)
    (listen-to-open table)
