   (:use seesaw.core)
   (:use seesaw.chooser)
   (:use mtg-pairings.watcher)
+  (:use mtg-pairings.uploader)
   (:require [cheshire.core :refer :all])
   (:import (java.io File FileNotFoundException)))
 
 (native!)
 
-
-(def database-location (text :editable? false :text "%AppData%\\Wizards of the Coast\\Event Reporter\\TournamentData.dat"))
-
-(def server-address  (text :editable? false :text "http://mtgsuomi.fi/pairings/api"))
-
-(def address-checkbox (checkbox :text "Edit address" :selected? false 
-                        :listen [:action (fn [event] (config! server-address :editable? (config address-checkbox :selected?)))]))
-
-
-(defn select-file [event]
-  (if @watcher (stop!))
-  (text! database-location 
-         (choose-file :success-fn (fn [fc file] (.getAbsolutePath file))
-                    :cancel-fn (fn [fc] (text database-location) )))
-  (if (.exists (File. (text database-location)))
-   (start! (text database-location) )
-   (-> (dialog :content "Error opening file") pack! show!)))
-
-
-(def database-button (button :text "..."
-                       :listen [:action select-file]))
-
-(defn upload-results []
-  ())
-
-(def upload-button (button :text "Upload"
-                     :listen [:action upload-results]))
-
 (def tournament-label (text :text "" :editable? false))
 
 (def tournament-listbox (listbox :model "none" :selection-mode :multi-interval))
-  
+
 (def tournament-selector
   (frame
     :on-close :dispose

 (-> main-window pack! show!)
 (if @watcher (stop!))
 (if (.exists (File. (text database-location))) 
   (start! (text database-location) )
   (-> (dialog :content "Database not found at default location, please set database location.") pack! show!)))


(def exit-action (menu-item :text "Exit" :listen [:action exit-handler]))


(def main-window
  (frame
