                   (actions :as act)
                   (input :as inp)]
     [fm.simrunner.gui (core :as gui) 
-                      (view :as view) 
+                      (view :as viw) 
                       (wiring :as wrg)
                       (rendering :as rdg)
                       (task-buffer :as tbf)]

  (fn [& args]
    (apply on-event app args)))

(defn start [{:keys [stand-alone? app-title working-directory] :as config}]
  @(gui/gui-do
    (let [frame    (view/simrunner-frame)
          view     (-> frame :contents :simrunner-view)
          frame    (:widget frame)
          on-close (if stand-alone? 
                     JFrame/EXIT_ON_CLOSE 
                     JFrame/DISPOSE_ON_CLOSE)
          wrkdir   (-> working-directory
                       (or ".")
                       File.
                       .getAbsolutePath)
          config   (assoc config :working-directory wrkdir)
          app      (app config view)]
      (wrg/wire-up! view (event-handler app))
      (rdg/render! app 
                   rdg/render-ui 
                   (rdg/console-logger (format "%s started." 
                                               app-title)
                                       (format "(Working directory: '%s')" 
                                               wrkdir)))
      (doto frame
        (.setDefaultCloseOperation on-close)
        (.setTitle app-title)
        .show)
      app)))


(defmethod on-event :input-changed [app _ & args]
  (inp/dispatch (-> args first meta :id) app args))

(defn- app [config]
  {:config config
   :worker (agent nil)
   :state  (atom {:ui    {:model        {:actions #{:open-config} 
                                         :values  {}}
                          :render-tasks (tbf/task-buffer)
                          :rendering?   false
