               (fn [r c s]
                 (ectx-cell-value-hook e-ctx r c s)))))
 
-(defn-typecheck set-context-keep-order ::editable-context
+(defn- set-context-keep-order
   "Sets the bound fca-context of an editable context object to ctx."
   [ectx ctx keep-order]
+  (assert (instance? editable-context ectx))
   (let [new     (make-editable-context ctx keep-order),
         widgets @(:widgets ectx)]
     (dosync

    (class-to-keyword (type (first x))))
  :default nil)

(defn-typecheck get-selected-objects ::context-editor-widget
  "Returns the set of selected objects in the context-editor-widget."
  [widget]
  (let [table (get-table widget),
        view  (get-row-index-permutator table),
        sel   (seq (.getSelectedRows (get-control table))),

       (ref-set (:attr-cols e-ctx) new-attr-cols))
      e-ctx)))

(defn- get-order
  "Returns the current order of the objects and attributes of the context."
  [ectx]
  (assert (instance? editable-context ectx))
  {:attr-cols (deref (:attr-cols ectx)),
   :obj-rows (deref (:obj-rows ectx))})

(defn- get-dual-order
  "Returns the current order of the objects and attributes of the dual of the
   context."
  [ectx]
  (assert (instance? editable-context ectx))
  {:obj-rows (deref (:attr-cols ectx)),
   :attr-cols (deref (:obj-rows ectx))})

(defn- add-widget
  "Adds a context-editor-widget to an editable context, and sets the
   editor windows table to represent the new context."
  [e-ctx editor]
  (assert (instance? editable-context e-ctx))
  (let [ctx (get-context e-ctx),
        att-cols (:attr-cols e-ctx),
        obj-rows (:obj-rows e-ctx),
