                      (make-button "Paste" 
                        (get-ui-icon "OptionPane.informationIcon")
                        [set-handler (fn [] (paste-from-clipboard table))] ) ])
-         e-ctx (make-editable-context)
-         widget (context-editor-widget root table toolbar e-ctx) ]
+         ectx (ref (make-editable-context))
+         e-ctx @ectx
+         widget (context-editor-widget root table toolbar ectx) ]
     (.. root getContentPane 
       (add (get-widget toolbar) BorderLayout/LINE_START))
     (.. root getContentPane
       (add (get-widget table)))
     (apply-exprs widget setup)
+    (dosync-wait (commute (:widgets e-ctx) add widget))
     (add-widget e-ctx widget)
     widget))
+
+(inherit-multimethod get-ectx ::context-editor-widget
+  "Returns the editable-context that is currently associated with the
+   context-editor-widget.
+
+  Parameters:
+    widget  _context-editor-widget")
+
+(defmethod get-ectx ::context-editor-widget
+  [widget] @(:e-ctx widget))
+
+(inherit-multimethod set-ectx ::context-editor-widget
+  "Sets the editable-context that is currently associated with the
+   context-editor-widget to the second parameter.
+
+  Parameters:
+    widget  _context-editor-widget
+    e-ctx   _new editable-context")
+
+(defmethod set-ectx ::context-editor-widget
+  [widget e-ctx] (dosync-wait (ref-set (:e-ctx widget) e-ctx)))
+
 
 (inherit-multimethod get-table ::context-editor-widget
   "Returns the table-control that is associated with the context-editor-widget.

         obj (objects ctx)
         inc (incidence ctx)
         get-cross (fn [obj att] (if (contains? inc [obj att]) "X" " "))
         table (get-table editor)]   

    (set-hook table "cell-value" (fn [_ _ x] x))
    (set-column-count table (+ 1 (count att)))
    (set-row-count table (+ 1 (count obj)))

      widget )))


(defn- ectx-cell-value-hook ;;TODO!!! ...
  [ectx editor row column contents]
  (let [ good-value
         (cond (= column row 0) "⇊objects⇊"
           (= row 0) 
           (let [attrib-cols @(:attr-cols ectx)
                  current-name (attrib-cols column)] 
             (if (= contents current-name) current-name
               current-name
                                        ;(change-attribute-name column contents)
               ))
           (= column 0)
           (let [object-rows @(:obj-rows ectx)
                  current-name (object-rows row)]
             (if (= contents current-name) current-name
                                        ;(change-object-name row contents)
               current-name
               ))
           true ;else
           (let [ cross (string-to-cross contents)
                  obj-name (@(:obj-rows ectx) row)
                  attr-name (@(:attr-cols ectx) column)
                  fca-ctx (get-context ectx)
                  inc (incidence fca-ctx)
                  current-state (contains? inc [obj-name attr-name])]

             (if (not= current-state cross)
                               ;(update-incidence obj-name attr-name cross)
               nil
               )
             (if cross "X" " "))
           )
         other-widgets (del @(:widgets ectx) editor)]

    (call-many other-widgets (fn [x] (update-value-at-index (get-table x) 
                                       row column good-value)))
    good-value))



;;
;;
;; Editable contexts
