   (:use [clojure.xml :only [parse]])
   (:use [clojure.pprint]))
 
-(def fmtstr "%-8s %-16s %-8s %-8s %-1s %-8s %-9s %s")
+(def fmtstr "%-8s %-16s %-8s %-8s %-5s %-5s %-1s %-8s %-9s %s")
 
-(declare tags tree xml xtime)
+(declare tags tree xml xprocs xres xtime)
 
 (defn contents [job]  (map #(:content %) job))
 (defn d        [n]    (apply str (repeat n "-")))

(defn jobs     []     (map :content (filter #(= (:tag %) :Job) (tree))))
(defn re       [user] (re-pattern (str user "@.*")))
(defn tags     [job]  (map #(:tag %) job))
(defn tree     []     (:content (parse (java.io.StringBufferInputStream. (xml)))))
(defn xattr    [j,k]  (first (k j)))
(defn xjobid   [j]    (xattr j :Job_Id))
(defn xml      []     (:out (sh "qstat" "-x")))
(defn xname    [j]    (xattr j :Job_Name))
(defn xowner   [j]    (xattr j :Job_Owner))
(defn xqueue   [j]    (xattr j :queue))
(defn xrtime   [j]    (xtime j :Resource_List))
(defn xstate   [j]    (xattr j :job_state))
(defn xtime    [j,k]  (first (:content (first (filter #(= (:tag %) :walltime) (k j))))))
(defn xutime   [j]    (let [t (xtime j :resources_used)] (if (nil? t) "-" t)))

(defn xpart [j]
  (let [p (first (:content (first (filter #(= (:tag %) :partition) (:Resource_List j)))))]

  (do
    (.setFont ta (Font. "Monospaced" (Font/PLAIN) 12))
    (doto fr
      (.setSize 800 600)
      (.setLayout (BorderLayout.))
      (.add ta BorderLayout/CENTER)
      (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
