     (set-hook table "cell-value" 
       (fn [r c s] (ectx-cell-value-hook e-ctx r c s)))))
 
+(inherit-multimethod set-context ::editable-context
+  "Sets the bound fca-context of an editable context object to ctx.
+
+   Parameters:
+    ectx   _editable-context object
+    ctx    _new context")
+
+(defmethod
+  set-context ::editable-context
+  [ectx ctx]
+  (let [ new (make-editable-context ctx)
+         widgets @(:widgets ectx) ]
+    (dosync-wait
+      (ref-set (:widgets ectx) @(:widgets new))
+      (ref-set (:context ectx) @(:context new))
+      (ref-set (:attr-cols ectx) @(:attr-cols new))
+      (ref-set (:obj-rows ectx) @(:obj-rows new)))
+    (call-many widgets (rho add-widget ectx))))
+
+
                    
 (declare change-attribute-name change-object-name change-incidence-cross)
 

(defmethod get-table :conexp.gui.editors.util/table-control
  [x] x)


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

  Parameters:
     & setup     _an optional number of vectors that may contain additional
                  tweaks that are called after widget creation"
  [& setup]
  (let [ self (promise)
         root (JRootPane.)
         table (make-table-control
                 [set-row-count 10]
                 [set-column-count 10])

         toolbar (make-toolbar-control :vert
                   [add-button 
                     (make-button "Copy" 
                       (get-ui-icon "OptionPane.informationIcon")
                       [set-handler (fn [] (copy-to-clipboard table))] )]
                   [add-button
                     (make-button "Paste" 
                       (get-ui-icon "OptionPane.informationIcon")
                       [set-handler (fn [] (paste-from-clipboard table))] ) ])

                   
         widget {:managed-by-conexp-gui-editors-util "context-editor-widget"

         :widget root
         :table table
         :control (get-control table)
         :context (ref nil)

         :associate-context
         (fn-doc "Associates a context with the widget object and implicitly
  updates the control

  Parameters:
    ectx      _editable context"
           [ectx]
           (let [ ctx (if (editable-context? ectx) ectx 
                       (make-editable-context ectx))
                  ctx-ref (@self :context)
                  old-ctx @ctx-ref]
             (do
               (dosync-wait (ref-set ctx-ref nil))
               (if (not (nil? old-ctx)) (!! old-ctx :remove-widget- @self))
               (!! ctx :add-widget- @self))
               (dosync-wait (ref-set ctx-ref ctx))))


         }

         defaults []]
    (do
      (deliver self widget)
      (.. root getContentPane 
        (add (get-widget toolbar) BorderLayout/LINE_START))
      (.. root getContentPane
        (add (get-widget table)))
      (doseq [x defaults] (unroll-parameters-fn-map widget x))
      (doseq [x setup] (unroll-parameters-fn-map widget x))
      widget )))

(declare change-attribute-name change-object-name change-incidence-cross)


                          given 0 new-name)))))
          new-name)))))

(def ctx (conexp.fca/make-context ["a" "b" "c"] [1 2 3] [["a" 1] ["c" 3]]))
(def ctx2 (make-context #{"Apfel" "Birne" "Möhre" "Gurke"} 
            #{"lecker" "geht so" "iieh"} 
