          obj (objects ctx)
          inc (incidence ctx)
          get-cross (fn [obj att] (if (contains? inc [obj att]) "X" " "))
-         table (get-table editor)]   
-
+         table (get-table editor)
+         current-ectx (get-ectx editor) ]   
+
+    (dosync-wait (commute (:widgets current-ectx) del editor)
+      (set-ectx editor e-ctx)
+      (commute (:widgets e-ctx) add editor))
     (set-hook table "cell-value" (fn [_ _ x] x))
     (set-column-count table (+ 1 (count att)))
     (set-row-count table (+ 1 (count obj)))

(defmethod get-table ::context-editor-widget
  [widget]
  (:table widget))

(defn-swing do-mk-context-editor-widget
  "Creates a control for editing contexts.

                     (make-button "Paste" 
                       (get-ui-icon "OptionPane.informationIcon")
                       [set-handler (fn [] (paste-from-clipboard table))] ) ])
         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.
