#|

Tables Example

Note: This is an example file showing concepts of the Integration Kit. The code itself is not supported and will never be supported.
|#


(in-package :EXAMPLES)
(use-package :OLI)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Logical Table

(sd-create-logical-table "Workplanes"
  :columns '(:name)
  :columnNames '("Name")
  :types '(:string))


;; Display Table 

(sd-create-display-table "WORKPLANES"
  :tableTitle "Workplanes"
  :logicalTable "Workplanes"
  :columns '(:name)
  :applyColumns '(:name)
  :applyAction :default)


;; Dialog

(sd-defdialog 'CURRENT_WP2
  :variables
  '((WPS :initial-value
	 (let
	  ((tree (jb-inq-obj-tree-list (sd-pathname-to-obj "/"))))
	  (sd-remove-logical-table-row "Workplanes" :row :all)
	  (dolist
	   (i (remove-if #'(lambda (obj)
			    (not (equal (sel_item-type obj)
					*sd-workplane-seltype*)))
			 tree))
	   (sd-insert-logical-table-row
	    "Workplanes" :contents (list (sd-inq-obj-pathname i) )))))
(WP :value-type :string
	:show-input-tool
	(sd-show-display-table "WORKPLANES"
			       :position '("CURRENT_WP2-OPTIONS-OPT-CONT-WP-TB"
					   :leftCenter -10 0))
	:hide-input-tool (sd-hide-display-table "WORKPLANES")))
  :start-variable 'wp
  :local-functions
  '((doit ()
     (sd-call-cmds (current_wp wp))))
  :ok-action '(doit))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defun jb-inq-obj-tree-list (obj)
  (cons obj
   (apply #'nconc (mapcar #'jb-inq-obj-tree-list (sd-inq-obj-children obj)))))


;;