commited new validation system.
[clinton/lisp-on-lines.git] / src / standard-display.lisp
CommitLineData
dee565d0
DC
1(in-package :lisp-on-lines)
2
2b0fd9c8 3;;;; The Standard Layers
dee565d0 4(deflayer viewer)
2b0fd9c8 5(deflayer editor)
a4e6154d 6
e1645f63 7(define-layered-method label (anything)
8 nil)
9
a4e6154d
DC
10(defdisplay
11 :in-layer editor :around (description object)
e1645f63 12 "It is useful to remove the viewer layer when in the editing layer.
a4e6154d 13This allows us to dispatch to a subclasses editor."
e1645f63 14 (with-inactive-layers (viewer)
15 (call-next-method)))
a4e6154d 16
e1645f63 17;;;; These layers affect the layout of the object
dee565d0 18(deflayer one-line)
14a7e1bc 19(deflayer as-table)
2b0fd9c8 20(deflayer as-string)
14a7e1bc 21
2b0fd9c8
DC
22(defdisplay
23 :in-layer as-string (d o)
e1645f63 24 (with-inactive-layers (editor viewer one-line as-table show-attribute-labels)
a4e6154d
DC
25 (do-attributes (a d)
26 (display-attribute a o)
27 (<:as-is " "))))
dee565d0 28
2b0fd9c8
DC
29(defmethod list-slots (thing)
30 (list 'identity))
d1b0ed7c 31
87e47dd6
DC
32;;;; * Object displays.
33
a4e6154d 34
dee565d0 35
2b0fd9c8 36;;;; TODO: all lisp types should have occurences and attributes defined for them.
dee565d0 37
2b0fd9c8
DC
38(defdisplay ((description t) lisp-value)
39 (<:as-html lisp-value))
14a7e1bc 40
2b0fd9c8 41(defdisplay (description (object string))
dee565d0
DC
42 (<:as-html object))
43
ff1e971a 44(defdisplay (description (object symbol))
45 (<:as-html object))
46
2b0fd9c8
DC
47(defdisplay (description object (component t))
48 "The default display for CLOS objects"
49 (print (class-name (class-of object)))
50 (dolist* (slot-name (list-slots object))
51
52 (let ((boundp (slot-boundp object slot-name)))
53 (format t "~A~A : ~A" (strcat slot-name)
54 (if boundp
55 ""
56 "(unbound)")
57 (if boundp
58 (slot-value object slot-name) "")))))
59
60(defdisplay ((description t) object)
61 "The default display for CLOS objects in UCW components"
62 (dolist* (slot-name (list-slots object))
63
64 (let ((boundp (slot-boundp object slot-name)))
65 (<:label :class "lol-label"
66 (display-attribute 'label (strcat slot-name))
67 (if boundp
68 ""
69 "(unbound)"))
70 (<:as-html
71 (if boundp
72 (slot-value object slot-name) "")))))
73
74;;;; ** The default displays for objects with a MEWA occurence
75
76(defdisplay (description object)
77 (<:div
a4e6154d
DC
78 :class "lol-display"
79 (when (label description)
80 (<:span
81 :class "title"
82 (<:as-html (label description))))
2b0fd9c8
DC
83 (do-attributes (attribute description)
84 (<:div
a4e6154d 85 :class "attribute"
2b0fd9c8 86 (display-attribute attribute object)))))
60a24293 87
14a7e1bc 88;;;; ** One line
2b0fd9c8 89(defdisplay
e1645f63 90 :in-layer one-line (description object)
91 "The one line presentation just displays the attributes with a #\Space between them"
92 (do-attributes (attribute description)
93 (display-attribute attribute object)
94 (<:as-html " ")))
14a7e1bc
DC
95
96;;;; ** as-table
97
2b0fd9c8
DC
98(defdisplay :in-layer as-table (description object)
99 (<:table
100 (do-attributes (a description)
14a7e1bc 101 (<:tr
2b0fd9c8
DC
102 (<:td :class "lol-label" (<:as-html (label a)))
103 (<:td (display-attribute a object))))))
14a7e1bc
DC
104
105;;;; List Displays
e1645f63 106
107(deflayer list-display-layer)
108
109(define-layered-class description
110 :in-layer list-display-layer ()
111 ((list-item :initarg :list-item :initform nil :special t :accessor list-item)))
112
2b0fd9c8 113(defdisplay (desc (list list))
e1645f63 114 (with-active-layers (list-display-layer)
e1645f63 115 (<:ul
116 (dolist* (item list)
117 (<:li (apply #'display* item (list-item desc)))))))
dee565d0 118
14a7e1bc 119;;;; Attributes
2b0fd9c8
DC
120(defdisplay
121 :in-layer editor
122 ((attribute standard-attribute) object)
91b9f259 123 (call-next-method))
dee565d0 124
14a7e1bc 125(define-layered-method display-using-description
2b0fd9c8
DC
126 ((attribute standard-attribute) object component)
127 (with-component (component)
128 (<ucw:a :action (call 'info-message :message (strcat (symbol-package (description.type attribute))":/::" (description.type attribute)))
129 (<:as-html "*" )))
87e47dd6
DC
130 (<:as-html (attribute-value object attribute)))
131
dee565d0 132
14a7e1bc 133
dee565d0 134
dee565d0 135
dee565d0
DC
136
137
138
139
140
141