Summary

(let* ((name "Noé")
(email "n@algo.be")
(salary 0.0)
(year 2000) ;; property list
(data (list 'name name 'email email 'salary salary 'year year))
(compound (loop for pname in data by #'cddr
collect
`(;; must be a property name in plist, see :accessor documentation however :name ,pname ;; just to allow Dialogue to define input validation functions
:value-type ,(case pname
(salary 'float)
(year 'fixnum)
(t 'string))
:prompt ,(string-capitalize pname)))))
(dialogue compound
:main t
:data data
:edit :plist ; !
:title "Plist")
(setf name (getf data 'name)
email (getf data 'email)
salary (getf data 'salary)
year (getf data 'year))
(values name email salary year))

(dialogue
`(:grid
(((:sashform
:name :sash1
:style :vertical
:layout-data (:height 200 :width 400
:horizontalalignment ,*swt.fill*
:grabexcesshorizontalspace t
:verticalalignment ,*swt.fill*
:grabexcessverticalspace t)
((:type :text :style (:multi :border)
:initial-value "1st text control in Sash#1")
(:type :text :style (:multi :border)
:initial-value "2nd text control in Sash#1")
(:sashform
:name :sash2
:style :horizontal
((:type :text :style (:multi :border :wrap)
:initial-value "1st text control in Sash#2")
(:type :text :style (:multi :border) :initial-value "2nd in Sash#2")
(:type :text :style (:multi :border) :initial-value "3rd in Sash#2")))
)))))
:creation-init-function
(lambda (shell) shell
;; Setting the weights of :sash1
(set-sash-weights (find-control :sash1 :test-di) (list 1 1 2)))
:exit-controls nil :name :test-di
:title "2 nested sashforms")
;;; the array to edit
(setf *alpha-array
(let* ((rows-number 5)
(columns-number 4)
(array (make-array (list rows-number columns-number))))
(loop for i from 0 below rows-number do
(loop for j from 0 below columns-number do
(setf (aref array i j)
(if (= i j)
:empty-cell
(+ (* i columns-number) j)))))
array))
(cells-editor
*alpha-array
:row-headers '("A" "B" "CCC")
;; to format each cell value
:set-cell-fn
(lambda (table array ri ci table-item) ; RowIndice ColumnIndice
(declare (ignore table))
(CED-settext table-item ci (format nil "~a" (aref array ri ci))))
:on-cell-mouse-down
;; cell-indices: (RowIndice ColumnIndice)
(lambda (event table array cell-indices table-item)
(declare (ignore event table))
(let ((ri (first cell-indices))
(ci (second cell-indices)))
(ok-di
(format nil
"row indice: ~d~%column indice: ~d~%array value: ~a~%SWT table value: ~a"
ri ci
(aref array ri ci)
(CED-gettext table-item ci))))))

(let ((cells-ed-name :cells-editor-test))
(cells-editor
*alpha-array
:name cells-ed-name
:on-cell-mouse-down
(lambda (event table array cell-indices table-item)
(let ((ci (second cell-indices))
(new-content "Visited"))
;; CED-settext-and-pack: set text of cell CI in table-item if New-Content
;; is different from the current content
(unless (CED-settext-and-pack new-content cells-ed-name ci table-item)
(beep))))))
Viewing alpha values:

Viewing omega values:

(defclass test-data ()
((alpha-value :accessor alpha-value :initarg :alpha-value)
(beta-value :accessor beta-value :initarg :beta-value)
(omega-value :accessor omega-value :initarg :omega-value)
(what-to-view :accessor what-to-view :initform "Alpha values"
:allocation :class)))
(let ((cells-editor-name :cells-editor-test))
(cells-editor
*array
:name cells-editor-name
;; set alignement in the 3 first columns
:alignement '(:right :left :center)
:multi-view-combo-range `("Alpha values" "Beta values" "Omega values")
:multi-view-combo-selection-fn
(lambda (event control-data) event
(setf (class-slot-value 'test-data 'what-to-view)
(get-control-value control-data)))
:set-cell-fn
(lambda (table array ri ci table-item)
(let* ((instance (aref array ri ci))
(what-to-view (class-slot-value 'test-data 'what-to-view))
(reader (cond ((string= what-to-view "Alpha values")
#'alpha-value)
((string= what-to-view "Beta values")
#'beta-value)
(t #'omega-value))))
(CED-settext table-item ci
(format nil "~a" (funcall reader instance)))))))