AmberRack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +74 -0
- data/.rvmrc +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +62 -0
- data/README.md +17 -0
- data/Rakefile +24 -0
- data/amber-rack.gemspec +33 -0
- data/app/amber_app.rb +35 -0
- data/app/javascripts/Benchfib.deploy.js +159 -0
- data/app/javascripts/Benchfib.js +159 -0
- data/app/javascripts/Canvas.deploy.js +1464 -0
- data/app/javascripts/Canvas.js +1464 -0
- data/app/javascripts/Compiler.deploy.js +1587 -0
- data/app/javascripts/Compiler.js +1587 -0
- data/app/javascripts/Examples.deploy.js +800 -0
- data/app/javascripts/Examples.js +800 -0
- data/app/javascripts/IDE.deploy.js +3457 -0
- data/app/javascripts/IDE.js +3457 -0
- data/app/javascripts/IDE.js.bak +3420 -0
- data/app/javascripts/JQuery.deploy.js +898 -0
- data/app/javascripts/JQuery.js +898 -0
- data/app/javascripts/Kernel.deploy.js +6761 -0
- data/app/javascripts/Kernel.js +6761 -0
- data/app/javascripts/Parser.deploy.js +1655 -0
- data/app/javascripts/Parser.js +1655 -0
- data/app/javascripts/Raphael-Core.js +0 -0
- data/app/javascripts/Raphael-Graph.js +0 -0
- data/app/javascripts/SUnit.deploy.js +1059 -0
- data/app/javascripts/SUnit.js +1059 -0
- data/app/javascripts/application.js +2 -0
- data/app/javascripts/boot.js +466 -0
- data/app/javascripts/init.js +2 -0
- data/app/javascripts/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/jquery.textarea.js +267 -0
- data/app/javascripts/jtalk.js +78 -0
- data/app/javascripts/lib/CodeMirror/LICENSE +19 -0
- data/app/javascripts/lib/CodeMirror/README.md +6 -0
- data/app/javascripts/lib/CodeMirror/compress.html +92 -0
- data/app/javascripts/lib/CodeMirror/css/baboon.png +0 -0
- data/app/javascripts/lib/CodeMirror/css/baboon_vector.svg +153 -0
- data/app/javascripts/lib/CodeMirror/css/docs.css +154 -0
- data/app/javascripts/lib/CodeMirror/demo/activeline.html +72 -0
- data/app/javascripts/lib/CodeMirror/demo/changemode.html +51 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.html +79 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.js +151 -0
- data/app/javascripts/lib/CodeMirror/demo/fullscreen.html +158 -0
- data/app/javascripts/lib/CodeMirror/demo/marker.html +53 -0
- data/app/javascripts/lib/CodeMirror/demo/mustache.html +57 -0
- data/app/javascripts/lib/CodeMirror/demo/preview.html +75 -0
- data/app/javascripts/lib/CodeMirror/demo/resize.html +44 -0
- data/app/javascripts/lib/CodeMirror/demo/runmode.html +50 -0
- data/app/javascripts/lib/CodeMirror/demo/search.html +106 -0
- data/app/javascripts/lib/CodeMirror/demo/theme.html +53 -0
- data/app/javascripts/lib/CodeMirror/index.html +239 -0
- data/app/javascripts/lib/CodeMirror/internals.html +389 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.css +67 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.js +2144 -0
- data/app/javascripts/lib/CodeMirror/lib/overlay.js +51 -0
- data/app/javascripts/lib/CodeMirror/lib/runmode.js +27 -0
- data/app/javascripts/lib/CodeMirror/manual.html +854 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/clike.js +247 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/index.html +102 -0
- data/app/javascripts/lib/CodeMirror/mode/css/css.js +124 -0
- data/app/javascripts/lib/CodeMirror/mode/css/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.css +3 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.js +13 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/index.html +99 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/haskell.js +242 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/index.html +60 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/index.html +78 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/javascript.js +348 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/index.html +72 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/lua.js +138 -0
- data/app/javascripts/lib/CodeMirror/mode/php/index.html +49 -0
- data/app/javascripts/lib/CodeMirror/mode/php/php.js +110 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/index.html +63 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/plsql.js +217 -0
- data/app/javascripts/lib/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/app/javascripts/lib/CodeMirror/mode/python/index.html +123 -0
- data/app/javascripts/lib/CodeMirror/mode/python/python.js +321 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/index.html +526 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.css +75 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.js +333 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/index.html +65 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/scheme.js +181 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/index.html +41 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/sparql.js +143 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/index.html +96 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/stex.js +167 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/index.html +42 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/xml.js +231 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/index.html +68 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/yaml.js +95 -0
- data/app/javascripts/lib/CodeMirror/oldrelease.html +178 -0
- data/app/javascripts/lib/CodeMirror/test/index.html +29 -0
- data/app/javascripts/lib/CodeMirror/test/test.js +249 -0
- data/app/javascripts/lib/CodeMirror/theme/default.css +18 -0
- data/app/javascripts/lib/CodeMirror/theme/elegant.css +9 -0
- data/app/javascripts/lib/CodeMirror/theme/jtalk.css +21 -0
- data/app/javascripts/lib/CodeMirror/theme/neat.css +8 -0
- data/app/javascripts/lib/CodeMirror/theme/night.css +20 -0
- data/app/javascripts/lib/jQuery/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/lib/jQuery/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/lib/jQuery/jquery.textarea.js +267 -0
- data/app/smalltalk/Canvas.st +481 -0
- data/app/smalltalk/IDE.st +1752 -0
- data/config.ru +2 -0
- data/lib/amber-rack.rb +4 -0
- data/lib/amber-rack/version.rb +3 -0
- data/public/CodeMirror/LICENSE +19 -0
- data/public/CodeMirror/README.md +6 -0
- data/public/CodeMirror/compress.html +92 -0
- data/public/CodeMirror/css/baboon.png +0 -0
- data/public/CodeMirror/css/baboon_vector.svg +153 -0
- data/public/CodeMirror/css/docs.css +154 -0
- data/public/CodeMirror/demo/activeline.html +72 -0
- data/public/CodeMirror/demo/changemode.html +51 -0
- data/public/CodeMirror/demo/complete.html +79 -0
- data/public/CodeMirror/demo/complete.js +151 -0
- data/public/CodeMirror/demo/fullscreen.html +158 -0
- data/public/CodeMirror/demo/marker.html +53 -0
- data/public/CodeMirror/demo/mustache.html +57 -0
- data/public/CodeMirror/demo/preview.html +75 -0
- data/public/CodeMirror/demo/resize.html +44 -0
- data/public/CodeMirror/demo/runmode.html +50 -0
- data/public/CodeMirror/demo/search.html +106 -0
- data/public/CodeMirror/demo/theme.html +53 -0
- data/public/CodeMirror/index.html +239 -0
- data/public/CodeMirror/internals.html +389 -0
- data/public/CodeMirror/lib/codemirror.css +67 -0
- data/public/CodeMirror/lib/codemirror.js +2144 -0
- data/public/CodeMirror/lib/overlay.js +51 -0
- data/public/CodeMirror/lib/runmode.js +27 -0
- data/public/CodeMirror/manual.html +854 -0
- data/public/CodeMirror/mode/clike/clike.js +247 -0
- data/public/CodeMirror/mode/clike/index.html +102 -0
- data/public/CodeMirror/mode/css/css.js +124 -0
- data/public/CodeMirror/mode/css/index.html +56 -0
- data/public/CodeMirror/mode/diff/diff.css +3 -0
- data/public/CodeMirror/mode/diff/diff.js +13 -0
- data/public/CodeMirror/mode/diff/index.html +99 -0
- data/public/CodeMirror/mode/haskell/haskell.js +242 -0
- data/public/CodeMirror/mode/haskell/index.html +60 -0
- data/public/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/public/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/public/CodeMirror/mode/javascript/index.html +78 -0
- data/public/CodeMirror/mode/javascript/javascript.js +348 -0
- data/public/CodeMirror/mode/lua/index.html +72 -0
- data/public/CodeMirror/mode/lua/lua.js +138 -0
- data/public/CodeMirror/mode/php/index.html +49 -0
- data/public/CodeMirror/mode/php/php.js +110 -0
- data/public/CodeMirror/mode/plsql/index.html +63 -0
- data/public/CodeMirror/mode/plsql/plsql.js +217 -0
- data/public/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/public/CodeMirror/mode/python/index.html +123 -0
- data/public/CodeMirror/mode/python/python.js +321 -0
- data/public/CodeMirror/mode/rst/index.html +526 -0
- data/public/CodeMirror/mode/rst/rst.css +75 -0
- data/public/CodeMirror/mode/rst/rst.js +333 -0
- data/public/CodeMirror/mode/scheme/index.html +65 -0
- data/public/CodeMirror/mode/scheme/scheme.js +181 -0
- data/public/CodeMirror/mode/smalltalk/index.html +56 -0
- data/public/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/public/CodeMirror/mode/sparql/index.html +41 -0
- data/public/CodeMirror/mode/sparql/sparql.js +143 -0
- data/public/CodeMirror/mode/stex/index.html +96 -0
- data/public/CodeMirror/mode/stex/stex.js +167 -0
- data/public/CodeMirror/mode/xml/index.html +42 -0
- data/public/CodeMirror/mode/xml/xml.js +231 -0
- data/public/CodeMirror/mode/yaml/index.html +68 -0
- data/public/CodeMirror/mode/yaml/yaml.js +95 -0
- data/public/CodeMirror/oldrelease.html +178 -0
- data/public/CodeMirror/test/index.html +29 -0
- data/public/CodeMirror/test/test.js +249 -0
- data/public/CodeMirror/theme/default.css +18 -0
- data/public/CodeMirror/theme/elegant.css +9 -0
- data/public/CodeMirror/theme/jtalk.css +21 -0
- data/public/CodeMirror/theme/neat.css +8 -0
- data/public/CodeMirror/theme/night.css +20 -0
- data/public/css/jtalk.css +362 -0
- data/public/css/style.css +456 -0
- data/public/css/sunit.css +66 -0
- data/public/ide/fork_me.png +0 -0
- data/public/ide/screen2.png +0 -0
- data/public/ide/style.css +456 -0
- data/public/ide/syntax.css +61 -0
- data/public/ide/text_header.png +0 -0
- data/public/ide/title_container1.png +0 -0
- data/public/images/background_box.png +0 -0
- data/public/images/background_header.png +0 -0
- data/public/images/balloon_header.png +0 -0
- data/views/index.haml +66 -0
- metadata +341 -0
@@ -0,0 +1,1752 @@
|
|
1
|
+
Widget subclass: #TabManager
|
2
|
+
instanceVariableNames: 'selectedTab tabs opened ul'
|
3
|
+
category: 'IDE'!
|
4
|
+
|
5
|
+
!TabManager methodsFor: 'accessing'!
|
6
|
+
|
7
|
+
tabs
|
8
|
+
^tabs ifNil: [tabs := Array new]
|
9
|
+
! !
|
10
|
+
|
11
|
+
!TabManager methodsFor: 'actions'!
|
12
|
+
|
13
|
+
updateBodyMargin
|
14
|
+
self setBodyMargin: '#jtalk' asJQuery height + 27
|
15
|
+
!
|
16
|
+
|
17
|
+
updatePosition
|
18
|
+
<jQuery('#jtalk').css('top', '').css('bottom', '27px')>
|
19
|
+
!
|
20
|
+
|
21
|
+
removeBodyMargin
|
22
|
+
self setBodyMargin: 0
|
23
|
+
!
|
24
|
+
|
25
|
+
setBodyMargin: anInteger
|
26
|
+
'.jtalkBody' asJQuery cssAt: 'margin-bottom' put: anInteger asString, 'px'
|
27
|
+
!
|
28
|
+
|
29
|
+
onResize: aBlock
|
30
|
+
<jQuery('#jtalk').resizable({
|
31
|
+
handles: 'n',
|
32
|
+
resize: aBlock,
|
33
|
+
minHeight: 230
|
34
|
+
})>
|
35
|
+
!
|
36
|
+
|
37
|
+
onWindowResize: aBlock
|
38
|
+
<jQuery(window).resize(aBlock)>
|
39
|
+
!
|
40
|
+
|
41
|
+
open
|
42
|
+
opened ifFalse: [
|
43
|
+
'body' asJQuery addClass: 'jtalkBody'.
|
44
|
+
'#jtalk' asJQuery show.
|
45
|
+
ul asJQuery show.
|
46
|
+
self updateBodyMargin.
|
47
|
+
selectedTab show.
|
48
|
+
opened := true]
|
49
|
+
!
|
50
|
+
|
51
|
+
close
|
52
|
+
opened ifTrue: [
|
53
|
+
'#jtalk' asJQuery hide.
|
54
|
+
ul asJQuery hide.
|
55
|
+
selectedTab hide.
|
56
|
+
self removeBodyMargin.
|
57
|
+
'body' asJQuery removeClass: 'jtalkBody'.
|
58
|
+
opened := false]
|
59
|
+
!
|
60
|
+
|
61
|
+
newBrowserTab
|
62
|
+
Browser open
|
63
|
+
!
|
64
|
+
|
65
|
+
selectTab: aWidget
|
66
|
+
self open.
|
67
|
+
selectedTab := aWidget.
|
68
|
+
self tabs do: [:each |
|
69
|
+
each hide].
|
70
|
+
aWidget show.
|
71
|
+
|
72
|
+
self update
|
73
|
+
!
|
74
|
+
|
75
|
+
closeTab: aWidget
|
76
|
+
self removeTab: aWidget.
|
77
|
+
self selectTab: self tabs last.
|
78
|
+
aWidget remove.
|
79
|
+
self update
|
80
|
+
! !
|
81
|
+
|
82
|
+
!TabManager methodsFor: 'adding/Removing'!
|
83
|
+
|
84
|
+
addTab: aWidget
|
85
|
+
self tabs add: aWidget.
|
86
|
+
'#jtalk' asJQuery append: aWidget.
|
87
|
+
aWidget hide
|
88
|
+
!
|
89
|
+
|
90
|
+
removeTab: aWidget
|
91
|
+
self tabs remove: aWidget.
|
92
|
+
self update
|
93
|
+
! !
|
94
|
+
|
95
|
+
!TabManager methodsFor: 'initialization'!
|
96
|
+
|
97
|
+
initialize
|
98
|
+
super initialize.
|
99
|
+
opened := true.
|
100
|
+
'body' asJQuery
|
101
|
+
append: self;
|
102
|
+
append: [:html | html div id: 'jtalk'];
|
103
|
+
addClass: 'jtalkBody'.
|
104
|
+
self
|
105
|
+
addTab: Transcript current;
|
106
|
+
addTab: Workspace new.
|
107
|
+
self selectTab: self tabs last.
|
108
|
+
self
|
109
|
+
onResize: [self updateBodyMargin; updatePosition];
|
110
|
+
onWindowResize: [self updatePosition]
|
111
|
+
! !
|
112
|
+
|
113
|
+
!TabManager methodsFor: 'rendering'!
|
114
|
+
|
115
|
+
renderOn: html
|
116
|
+
ul := html ul
|
117
|
+
id: 'jtalkTabs';
|
118
|
+
yourself.
|
119
|
+
self renderTabs
|
120
|
+
!
|
121
|
+
|
122
|
+
renderTabFor: aWidget on: html
|
123
|
+
| li |
|
124
|
+
li := html li.
|
125
|
+
selectedTab = aWidget ifTrue: [
|
126
|
+
li class: 'selected'].
|
127
|
+
li with: [
|
128
|
+
aWidget canBeClosed ifTrue: [
|
129
|
+
html span
|
130
|
+
class: 'close';
|
131
|
+
with: 'x';
|
132
|
+
onClick: [self closeTab: aWidget]].
|
133
|
+
html span
|
134
|
+
with: aWidget label;
|
135
|
+
onClick: [self selectTab: aWidget]]
|
136
|
+
!
|
137
|
+
|
138
|
+
renderTabs
|
139
|
+
ul contents: [:html |
|
140
|
+
html li
|
141
|
+
class: 'closeAll';
|
142
|
+
with: 'x';
|
143
|
+
onClick: [self close].
|
144
|
+
self tabs do: [:each |
|
145
|
+
self renderTabFor: each on: html].
|
146
|
+
html li
|
147
|
+
class: 'newtab';
|
148
|
+
with: ' + ';
|
149
|
+
onClick: [self newBrowserTab]]
|
150
|
+
! !
|
151
|
+
|
152
|
+
!TabManager methodsFor: 'updating'!
|
153
|
+
|
154
|
+
update
|
155
|
+
self renderTabs
|
156
|
+
! !
|
157
|
+
|
158
|
+
TabManager class instanceVariableNames: 'current'!
|
159
|
+
|
160
|
+
!TabManager class methodsFor: 'instance creation'!
|
161
|
+
|
162
|
+
current
|
163
|
+
^current ifNil: [current := super new]
|
164
|
+
!
|
165
|
+
|
166
|
+
new
|
167
|
+
self shouldNotImplement
|
168
|
+
! !
|
169
|
+
|
170
|
+
Widget subclass: #TabWidget
|
171
|
+
instanceVariableNames: 'div'
|
172
|
+
category: 'IDE'!
|
173
|
+
|
174
|
+
!TabWidget methodsFor: 'accessing'!
|
175
|
+
|
176
|
+
label
|
177
|
+
self subclassResponsibility
|
178
|
+
! !
|
179
|
+
|
180
|
+
!TabWidget methodsFor: 'actions'!
|
181
|
+
|
182
|
+
open
|
183
|
+
TabManager current addTab: self.
|
184
|
+
TabManager current selectTab: self
|
185
|
+
!
|
186
|
+
|
187
|
+
show
|
188
|
+
div asJQuery show
|
189
|
+
!
|
190
|
+
|
191
|
+
hide
|
192
|
+
div asJQuery hide
|
193
|
+
!
|
194
|
+
|
195
|
+
remove
|
196
|
+
div asJQuery remove
|
197
|
+
! !
|
198
|
+
|
199
|
+
!TabWidget methodsFor: 'rendering'!
|
200
|
+
|
201
|
+
renderOn: html
|
202
|
+
div := html div
|
203
|
+
class: 'jtalkTool';
|
204
|
+
yourself.
|
205
|
+
self renderTab
|
206
|
+
!
|
207
|
+
|
208
|
+
renderBoxOn: html
|
209
|
+
!
|
210
|
+
|
211
|
+
renderButtonsOn: html
|
212
|
+
!
|
213
|
+
|
214
|
+
update
|
215
|
+
self renderTab
|
216
|
+
!
|
217
|
+
|
218
|
+
renderTab
|
219
|
+
div contents: [:html |
|
220
|
+
html div
|
221
|
+
class: 'jt_box';
|
222
|
+
with: [self renderBoxOn: html].
|
223
|
+
html div
|
224
|
+
class: 'jt_buttons';
|
225
|
+
with: [self renderButtonsOn: html]]
|
226
|
+
! !
|
227
|
+
|
228
|
+
!TabWidget methodsFor: 'testing'!
|
229
|
+
|
230
|
+
canBeClosed
|
231
|
+
^false
|
232
|
+
! !
|
233
|
+
|
234
|
+
!TabWidget class methodsFor: 'instance creation'!
|
235
|
+
|
236
|
+
open
|
237
|
+
^self new open
|
238
|
+
! !
|
239
|
+
|
240
|
+
TabWidget subclass: #Workspace
|
241
|
+
instanceVariableNames: 'sourceArea'
|
242
|
+
category: 'IDE'!
|
243
|
+
|
244
|
+
!Workspace methodsFor: 'accessing'!
|
245
|
+
|
246
|
+
label
|
247
|
+
^'[Workspace]'
|
248
|
+
! !
|
249
|
+
|
250
|
+
!Workspace methodsFor: 'actions'!
|
251
|
+
|
252
|
+
clearWorkspace
|
253
|
+
sourceArea clear
|
254
|
+
!
|
255
|
+
|
256
|
+
doIt
|
257
|
+
sourceArea doIt
|
258
|
+
!
|
259
|
+
|
260
|
+
printIt
|
261
|
+
sourceArea printIt
|
262
|
+
!
|
263
|
+
|
264
|
+
inspectIt
|
265
|
+
sourceArea inspectIt
|
266
|
+
! !
|
267
|
+
|
268
|
+
!Workspace methodsFor: 'rendering'!
|
269
|
+
|
270
|
+
renderBoxOn: html
|
271
|
+
sourceArea := SourceArea new.
|
272
|
+
sourceArea renderOn: html
|
273
|
+
!
|
274
|
+
|
275
|
+
renderButtonsOn: html
|
276
|
+
html button
|
277
|
+
with: 'DoIt';
|
278
|
+
title: 'ctrl+d';
|
279
|
+
onClick: [self doIt].
|
280
|
+
html button
|
281
|
+
with: 'PrintIt';
|
282
|
+
title: 'ctrl+p';
|
283
|
+
onClick: [self printIt].
|
284
|
+
html button
|
285
|
+
with: 'InspectIt';
|
286
|
+
title: 'ctrl+i';
|
287
|
+
onClick: [self inspectIt].
|
288
|
+
html button
|
289
|
+
with: 'Clear workspace';
|
290
|
+
onClick: [self clearWorkspace]
|
291
|
+
! !
|
292
|
+
|
293
|
+
TabWidget subclass: #Transcript
|
294
|
+
instanceVariableNames: 'textarea'
|
295
|
+
category: 'IDE'!
|
296
|
+
|
297
|
+
!Transcript methodsFor: 'accessing'!
|
298
|
+
|
299
|
+
label
|
300
|
+
^'[Transcript]'
|
301
|
+
! !
|
302
|
+
|
303
|
+
!Transcript methodsFor: 'actions'!
|
304
|
+
|
305
|
+
show: anObject
|
306
|
+
textarea asJQuery val: textarea asJQuery val, anObject asString.
|
307
|
+
!
|
308
|
+
|
309
|
+
cr
|
310
|
+
textarea asJQuery val: textarea asJQuery val, String cr.
|
311
|
+
!
|
312
|
+
|
313
|
+
clear
|
314
|
+
textarea asJQuery val: ''
|
315
|
+
! !
|
316
|
+
|
317
|
+
!Transcript methodsFor: 'rendering'!
|
318
|
+
|
319
|
+
renderBoxOn: html
|
320
|
+
textarea := html textarea.
|
321
|
+
textarea asJQuery call: 'tabby'.
|
322
|
+
textarea
|
323
|
+
class: 'jt_transcript';
|
324
|
+
at: 'spellcheck' put: 'false'
|
325
|
+
!
|
326
|
+
|
327
|
+
renderButtonsOn: html
|
328
|
+
html button
|
329
|
+
with: 'Clear transcript';
|
330
|
+
onClick: [self clear]
|
331
|
+
! !
|
332
|
+
|
333
|
+
Transcript class instanceVariableNames: 'current'!
|
334
|
+
|
335
|
+
!Transcript class methodsFor: 'instance creation'!
|
336
|
+
|
337
|
+
open
|
338
|
+
self current open
|
339
|
+
!
|
340
|
+
|
341
|
+
new
|
342
|
+
self shouldNotImplement
|
343
|
+
!
|
344
|
+
|
345
|
+
current
|
346
|
+
^current ifNil: [current := super new]
|
347
|
+
! !
|
348
|
+
|
349
|
+
!Transcript class methodsFor: 'printing'!
|
350
|
+
|
351
|
+
show: anObject
|
352
|
+
self current show: anObject
|
353
|
+
!
|
354
|
+
|
355
|
+
cr
|
356
|
+
self current show: String cr
|
357
|
+
!
|
358
|
+
|
359
|
+
clear
|
360
|
+
self current clear
|
361
|
+
! !
|
362
|
+
|
363
|
+
TabWidget subclass: #Browser
|
364
|
+
instanceVariableNames: 'selectedCategory selectedClass selectedProtocol selectedMethod commitButton categoriesList classesList protocolsList methodsList sourceArea tabsList selectedTab saveButton classButtons methodButtons unsavedChanges input'
|
365
|
+
category: 'IDE'!
|
366
|
+
|
367
|
+
!Browser methodsFor: 'accessing'!
|
368
|
+
|
369
|
+
label
|
370
|
+
^selectedClass
|
371
|
+
ifNil: ['Browser (nil)']
|
372
|
+
ifNotNil: [selectedClass name]
|
373
|
+
!
|
374
|
+
|
375
|
+
categories
|
376
|
+
| categories |
|
377
|
+
categories := Array new.
|
378
|
+
Smalltalk current classes do: [:each |
|
379
|
+
(categories includes: each category) ifFalse: [
|
380
|
+
categories add: each category]].
|
381
|
+
^categories sort
|
382
|
+
!
|
383
|
+
|
384
|
+
classes
|
385
|
+
^(Smalltalk current classes
|
386
|
+
select: [:each | each category = selectedCategory])
|
387
|
+
sort: [:a :b | a name > b name]
|
388
|
+
!
|
389
|
+
|
390
|
+
protocols
|
391
|
+
| klass |
|
392
|
+
selectedClass ifNotNil: [
|
393
|
+
selectedTab = #comment ifTrue: [^#()].
|
394
|
+
klass := selectedTab = #instance
|
395
|
+
ifTrue: [selectedClass]
|
396
|
+
ifFalse: [selectedClass class].
|
397
|
+
klass methodDictionary isEmpty ifTrue: [
|
398
|
+
^Array with: 'not yet classified'].
|
399
|
+
^klass protocols].
|
400
|
+
^Array new
|
401
|
+
!
|
402
|
+
|
403
|
+
methods
|
404
|
+
| klass |
|
405
|
+
selectedTab = #comment ifTrue: [^#()].
|
406
|
+
selectedClass ifNotNil: [
|
407
|
+
klass := selectedTab = #instance
|
408
|
+
ifTrue: [selectedClass]
|
409
|
+
ifFalse: [selectedClass class]].
|
410
|
+
^(selectedProtocol
|
411
|
+
ifNil: [
|
412
|
+
klass
|
413
|
+
ifNil: [#()]
|
414
|
+
ifNotNil: [klass methodDictionary values]]
|
415
|
+
ifNotNil: [
|
416
|
+
klass methodDictionary values select: [:each |
|
417
|
+
each category = selectedProtocol]]) sort: [:a :b | a selector > b selector]
|
418
|
+
!
|
419
|
+
|
420
|
+
source
|
421
|
+
selectedTab = #comment ifFalse: [
|
422
|
+
^(selectedProtocol notNil or: [selectedMethod notNil])
|
423
|
+
ifFalse: [self declarationSource]
|
424
|
+
ifTrue: [self methodSource]].
|
425
|
+
^selectedClass
|
426
|
+
ifNil: ['']
|
427
|
+
ifNotNil: [self classCommentSource]
|
428
|
+
!
|
429
|
+
|
430
|
+
methodSource
|
431
|
+
^selectedMethod
|
432
|
+
ifNil: [self dummyMethodSource]
|
433
|
+
ifNotNil: [selectedMethod source]
|
434
|
+
!
|
435
|
+
|
436
|
+
dummyMethodSource
|
437
|
+
^'messageSelectorAndArgumentNames
|
438
|
+
"comment stating purpose of message"
|
439
|
+
|
440
|
+
| temporary variable names |
|
441
|
+
statements'
|
442
|
+
!
|
443
|
+
|
444
|
+
declarationSource
|
445
|
+
^selectedTab = #instance
|
446
|
+
ifTrue: [self classDeclarationSource]
|
447
|
+
ifFalse: [self metaclassDeclarationSource]
|
448
|
+
!
|
449
|
+
|
450
|
+
classDeclarationSource
|
451
|
+
| stream |
|
452
|
+
stream := '' writeStream.
|
453
|
+
selectedClass ifNotNil: [
|
454
|
+
stream
|
455
|
+
nextPutAll: selectedClass superclass asString;
|
456
|
+
nextPutAll: ' subclass: #';
|
457
|
+
nextPutAll: selectedClass name;
|
458
|
+
nextPutAll: String lf, String tab;
|
459
|
+
nextPutAll: 'instanceVariableNames: '''.
|
460
|
+
selectedClass instanceVariableNames
|
461
|
+
do: [:each | stream nextPutAll: each]
|
462
|
+
separatedBy: [stream nextPutAll: ' '].
|
463
|
+
stream
|
464
|
+
nextPutAll: '''', String lf, String tab;
|
465
|
+
nextPutAll: 'category: ''';
|
466
|
+
nextPutAll: selectedClass category;
|
467
|
+
nextPutAll: ''''].
|
468
|
+
^stream contents
|
469
|
+
!
|
470
|
+
|
471
|
+
metaclassDeclarationSource
|
472
|
+
| stream |
|
473
|
+
stream := '' writeStream.
|
474
|
+
selectedClass ifNotNil: [
|
475
|
+
stream
|
476
|
+
nextPutAll: selectedClass asString;
|
477
|
+
nextPutAll: ' class ';
|
478
|
+
nextPutAll: 'instanceVariableNames: '''.
|
479
|
+
selectedClass class instanceVariableNames
|
480
|
+
do: [:each | stream nextPutAll: each]
|
481
|
+
separatedBy: [stream nextPutAll: ' '].
|
482
|
+
stream nextPutAll: ''''].
|
483
|
+
^stream contents
|
484
|
+
!
|
485
|
+
|
486
|
+
classCommentSource
|
487
|
+
^selectedClass comment
|
488
|
+
!
|
489
|
+
|
490
|
+
selectedClass
|
491
|
+
^selectedClass
|
492
|
+
! !
|
493
|
+
|
494
|
+
!Browser methodsFor: 'actions'!
|
495
|
+
|
496
|
+
disableSaveButton
|
497
|
+
saveButton ifNotNil: [
|
498
|
+
saveButton at: 'disabled' put: true].
|
499
|
+
unsavedChanges := false
|
500
|
+
!
|
501
|
+
|
502
|
+
hideClassButtons
|
503
|
+
classButtons asJQuery hide
|
504
|
+
!
|
505
|
+
|
506
|
+
showClassButtons
|
507
|
+
classButtons asJQuery show
|
508
|
+
!
|
509
|
+
|
510
|
+
hideMethodButtons
|
511
|
+
methodButtons asJQuery hide
|
512
|
+
!
|
513
|
+
|
514
|
+
showMethodButtons
|
515
|
+
methodButtons asJQuery show
|
516
|
+
!
|
517
|
+
|
518
|
+
compile
|
519
|
+
self disableSaveButton.
|
520
|
+
selectedTab = #comment ifTrue: [
|
521
|
+
selectedClass ifNotNil: [
|
522
|
+
self compileClassComment]].
|
523
|
+
(selectedProtocol notNil or: [selectedMethod notNil])
|
524
|
+
ifFalse: [self compileDefinition]
|
525
|
+
ifTrue: [self compileMethodDefinition]
|
526
|
+
!
|
527
|
+
|
528
|
+
compileClassComment
|
529
|
+
selectedClass comment: sourceArea val
|
530
|
+
!
|
531
|
+
|
532
|
+
compileMethodDefinition
|
533
|
+
selectedTab = #instance
|
534
|
+
ifTrue: [self compileMethodDefinitionFor: selectedClass]
|
535
|
+
ifFalse: [self compileMethodDefinitionFor: selectedClass class]
|
536
|
+
!
|
537
|
+
|
538
|
+
compileMethodDefinitionFor: aClass
|
539
|
+
| compiler method source node |
|
540
|
+
source := sourceArea val.
|
541
|
+
selectedProtocol ifNil: [selectedProtocol := selectedMethod category].
|
542
|
+
compiler := Compiler new.
|
543
|
+
node := compiler parse: source.
|
544
|
+
node isParseFailure ifTrue: [
|
545
|
+
^self alert: 'PARSE ERROR: ', node reason, ', position: ', node position asString].
|
546
|
+
compiler currentClass: aClass.
|
547
|
+
method := compiler eval: (compiler compileNode: node).
|
548
|
+
method category: selectedProtocol.
|
549
|
+
compiler unknownVariables do: [:each |
|
550
|
+
(self confirm: 'Declare ''', each, ''' as instance variable?') ifTrue: [
|
551
|
+
self addInstanceVariableNamed: each toClass: aClass.
|
552
|
+
^self compileMethodDefinitionFor: aClass]].
|
553
|
+
aClass addCompiledMethod: method.
|
554
|
+
compiler setupClass: aClass.
|
555
|
+
self updateMethodsList.
|
556
|
+
self selectMethod: method
|
557
|
+
!
|
558
|
+
|
559
|
+
compileDefinition
|
560
|
+
| newClass |
|
561
|
+
newClass := Compiler new loadExpression: sourceArea val.
|
562
|
+
self
|
563
|
+
resetClassesList;
|
564
|
+
updateCategoriesList;
|
565
|
+
updateClassesList
|
566
|
+
!
|
567
|
+
|
568
|
+
commitCategory
|
569
|
+
selectedCategory ifNotNil: [
|
570
|
+
(Ajax url: self class commitPathJs, '/', selectedCategory, '.js')
|
571
|
+
at: 'type' put: 'PUT';
|
572
|
+
at: 'data' put: (Exporter new exportCategory: selectedCategory);
|
573
|
+
at: 'error' put: [self alert: 'Commit failed!!'];
|
574
|
+
send.
|
575
|
+
(Ajax url: self class commitPathJs, '/', selectedCategory, '.deploy.js')
|
576
|
+
at: 'type' put: 'PUT';
|
577
|
+
at: 'data' put: (Exporter new exportCategory: selectedCategory);
|
578
|
+
at: 'error' put: [self alert: 'Commit failed!!'];
|
579
|
+
send.
|
580
|
+
(Ajax url: self class commitPathSt, '/', selectedCategory, '.st')
|
581
|
+
at: 'type' put: 'PUT';
|
582
|
+
at: 'data' put: (ChunkExporter new exportCategory: selectedCategory);
|
583
|
+
at: 'error' put: [self alert: 'Commit failed!!'];
|
584
|
+
send]
|
585
|
+
!
|
586
|
+
|
587
|
+
cancelChanges
|
588
|
+
^unsavedChanges
|
589
|
+
ifTrue: [self confirm: 'Cancel changes?']
|
590
|
+
ifFalse: [true]
|
591
|
+
!
|
592
|
+
|
593
|
+
removeClass
|
594
|
+
(self confirm: 'Do you really want to remove ', selectedClass name, '?')
|
595
|
+
ifTrue: [
|
596
|
+
Smalltalk current removeClass: selectedClass.
|
597
|
+
self resetClassesList.
|
598
|
+
self selectClass: nil]
|
599
|
+
!
|
600
|
+
|
601
|
+
removeMethod
|
602
|
+
self cancelChanges ifTrue: [
|
603
|
+
(self confirm: 'Do you really want to remove #', selectedMethod selector, '?')
|
604
|
+
ifTrue: [
|
605
|
+
selectedTab = #instance
|
606
|
+
ifTrue: [selectedClass removeCompiledMethod: selectedMethod]
|
607
|
+
ifFalse: [selectedClass class removeCompiledMethod: selectedMethod].
|
608
|
+
self selectMethod: nil]]
|
609
|
+
!
|
610
|
+
|
611
|
+
setMethodProtocol: aString
|
612
|
+
self cancelChanges ifTrue: [
|
613
|
+
(self protocols includes: aString)
|
614
|
+
ifFalse: [self addNewProtocol]
|
615
|
+
ifTrue: [
|
616
|
+
selectedMethod category: aString.
|
617
|
+
selectedProtocol := aString.
|
618
|
+
selectedMethod := selectedMethod.
|
619
|
+
self
|
620
|
+
updateProtocolsList;
|
621
|
+
updateMethodsList;
|
622
|
+
updateSourceAndButtons]]
|
623
|
+
!
|
624
|
+
|
625
|
+
addNewProtocol
|
626
|
+
| newProtocol |
|
627
|
+
newProtocol := self prompt: 'New method protocol'.
|
628
|
+
newProtocol notEmpty ifTrue: [
|
629
|
+
selectedMethod category: newProtocol.
|
630
|
+
self setMethodProtocol: newProtocol]
|
631
|
+
!
|
632
|
+
|
633
|
+
selectCategory: aCategory
|
634
|
+
self cancelChanges ifTrue: [
|
635
|
+
selectedCategory := aCategory.
|
636
|
+
selectedClass := selectedProtocol := selectedMethod := nil.
|
637
|
+
self resetClassesList.
|
638
|
+
self
|
639
|
+
updateCategoriesList;
|
640
|
+
updateClassesList;
|
641
|
+
updateProtocolsList;
|
642
|
+
updateMethodsList;
|
643
|
+
updateSourceAndButtons]
|
644
|
+
!
|
645
|
+
|
646
|
+
selectClass: aClass
|
647
|
+
self cancelChanges ifTrue: [
|
648
|
+
selectedClass := aClass.
|
649
|
+
selectedProtocol := selectedMethod := nil.
|
650
|
+
self
|
651
|
+
updateClassesList;
|
652
|
+
updateProtocolsList;
|
653
|
+
updateMethodsList;
|
654
|
+
updateSourceAndButtons]
|
655
|
+
!
|
656
|
+
|
657
|
+
selectProtocol: aString
|
658
|
+
self cancelChanges ifTrue: [
|
659
|
+
selectedProtocol := aString.
|
660
|
+
selectedMethod := nil.
|
661
|
+
self
|
662
|
+
updateProtocolsList;
|
663
|
+
updateMethodsList;
|
664
|
+
updateSourceAndButtons]
|
665
|
+
!
|
666
|
+
|
667
|
+
selectMethod: aMethod
|
668
|
+
self cancelChanges ifTrue: [
|
669
|
+
selectedMethod := aMethod.
|
670
|
+
self
|
671
|
+
updateProtocolsList;
|
672
|
+
updateMethodsList;
|
673
|
+
updateSourceAndButtons]
|
674
|
+
!
|
675
|
+
|
676
|
+
selectTab: aString
|
677
|
+
self cancelChanges ifTrue: [
|
678
|
+
selectedTab := aString.
|
679
|
+
self selectProtocol: nil.
|
680
|
+
self updateTabsList]
|
681
|
+
!
|
682
|
+
|
683
|
+
renameClass
|
684
|
+
| newName |
|
685
|
+
newName := self prompt: 'Rename class ', selectedClass name.
|
686
|
+
newName notEmpty ifTrue: [
|
687
|
+
selectedClass rename: newName.
|
688
|
+
self
|
689
|
+
updateClassesList;
|
690
|
+
updateSourceAndButtons]
|
691
|
+
!
|
692
|
+
|
693
|
+
addInstanceVariableNamed: aString toClass: aClass
|
694
|
+
ClassBuilder new
|
695
|
+
addSubclassOf: aClass superclass named: aClass name instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)
|
696
|
+
!
|
697
|
+
|
698
|
+
searchReferencesOf: aString
|
699
|
+
ReferencesBrowser search: aString
|
700
|
+
!
|
701
|
+
|
702
|
+
searchClassReferences
|
703
|
+
ReferencesBrowser search: selectedClass name
|
704
|
+
!
|
705
|
+
|
706
|
+
search: aString
|
707
|
+
self cancelChanges ifTrue: [| searchedClass |
|
708
|
+
searchedClass := Smalltalk current at: aString.
|
709
|
+
searchedClass isClass
|
710
|
+
ifTrue: [self class openOn: searchedClass]
|
711
|
+
ifFalse: [self searchReferencesOf: aString]]
|
712
|
+
! !
|
713
|
+
|
714
|
+
!Browser methodsFor: 'initialization'!
|
715
|
+
|
716
|
+
initialize
|
717
|
+
super initialize.
|
718
|
+
selectedTab := #instance.
|
719
|
+
unsavedChanges := false
|
720
|
+
! !
|
721
|
+
|
722
|
+
!Browser methodsFor: 'rendering'!
|
723
|
+
|
724
|
+
renderBoxOn: html
|
725
|
+
self
|
726
|
+
renderTopPanelOn: html;
|
727
|
+
renderTabsOn: html;
|
728
|
+
renderBottomPanelOn: html
|
729
|
+
!
|
730
|
+
|
731
|
+
renderTopPanelOn: html
|
732
|
+
html div
|
733
|
+
class: 'top';
|
734
|
+
with: [
|
735
|
+
self renderInputOn: html.
|
736
|
+
categoriesList := html ul class: 'jt_column browser categories'.
|
737
|
+
commitButton := html button
|
738
|
+
class: 'jt_commit';
|
739
|
+
title: 'Commit classes in this category to disk';
|
740
|
+
onClick: [self commitCategory];
|
741
|
+
with: 'Commit category'.
|
742
|
+
classesList := ClassesList on: self.
|
743
|
+
classesList renderOn: html.
|
744
|
+
protocolsList := html ul class: 'jt_column browser protocols'.
|
745
|
+
methodsList := html ul class: 'jt_column browser methods'.
|
746
|
+
self
|
747
|
+
updateCategoriesList;
|
748
|
+
updateClassesList;
|
749
|
+
updateProtocolsList;
|
750
|
+
updateMethodsList.
|
751
|
+
html div class: 'jt_clear']
|
752
|
+
!
|
753
|
+
|
754
|
+
renderTabsOn: html
|
755
|
+
tabsList := html ul class: 'jt_tabs'.
|
756
|
+
self updateTabsList.
|
757
|
+
!
|
758
|
+
|
759
|
+
renderBottomPanelOn: html
|
760
|
+
html div
|
761
|
+
class: 'jt_sourceCode';
|
762
|
+
with: [
|
763
|
+
sourceArea := SourceArea new.
|
764
|
+
sourceArea renderOn: html.
|
765
|
+
sourceArea
|
766
|
+
onKeyUp: [self updateStatus]]
|
767
|
+
!
|
768
|
+
|
769
|
+
renderButtonsOn: html
|
770
|
+
saveButton := html button.
|
771
|
+
saveButton
|
772
|
+
with: 'Save';
|
773
|
+
onClick: [self compile].
|
774
|
+
methodButtons := html span.
|
775
|
+
classButtons := html span.
|
776
|
+
html div
|
777
|
+
class: 'right';
|
778
|
+
with: [
|
779
|
+
html button
|
780
|
+
with: 'DoIt';
|
781
|
+
onClick: [sourceArea doIt].
|
782
|
+
html button
|
783
|
+
with: 'PrintIt';
|
784
|
+
onClick: [sourceArea printIt].
|
785
|
+
html button with: 'InspectIt';
|
786
|
+
onClick: [sourceArea inspectit]].
|
787
|
+
self updateSourceAndButtons
|
788
|
+
!
|
789
|
+
|
790
|
+
renderInputOn: html
|
791
|
+
input := html input
|
792
|
+
class: 'implementors';
|
793
|
+
yourself.
|
794
|
+
input onKeyPress: [:event |
|
795
|
+
event keyCode = 13 ifTrue: [
|
796
|
+
self search: input asJQuery val]]
|
797
|
+
! !
|
798
|
+
|
799
|
+
!Browser methodsFor: 'testing'!
|
800
|
+
|
801
|
+
canBeClosed
|
802
|
+
^true
|
803
|
+
! !
|
804
|
+
|
805
|
+
!Browser methodsFor: 'updating'!
|
806
|
+
|
807
|
+
updateCategoriesList
|
808
|
+
categoriesList contents: [:html |
|
809
|
+
self categories do: [:each || li label |
|
810
|
+
each isEmpty
|
811
|
+
ifTrue: [label := 'Unclassified']
|
812
|
+
ifFalse: [label := each].
|
813
|
+
li := html li.
|
814
|
+
selectedCategory = each ifTrue: [
|
815
|
+
li class: 'selected'].
|
816
|
+
li
|
817
|
+
with: label;
|
818
|
+
onClick: [self selectCategory: each]]]
|
819
|
+
!
|
820
|
+
|
821
|
+
updateClassesList
|
822
|
+
TabManager current update.
|
823
|
+
classesList updateNodes.
|
824
|
+
"classesList contents: [:html |
|
825
|
+
self classes do: [:each || li |
|
826
|
+
li := html li.
|
827
|
+
selectedClass = each ifTrue: [
|
828
|
+
li class: 'selected'].
|
829
|
+
li
|
830
|
+
with: each name;
|
831
|
+
onClick: [self selectClass: each]]]"
|
832
|
+
!
|
833
|
+
|
834
|
+
updateProtocolsList
|
835
|
+
protocolsList contents: [:html |
|
836
|
+
self protocols do: [:each || li |
|
837
|
+
li := html li.
|
838
|
+
selectedProtocol = each ifTrue: [
|
839
|
+
li class: 'selected'].
|
840
|
+
li
|
841
|
+
with: each;
|
842
|
+
onClick: [self selectProtocol: each]]]
|
843
|
+
!
|
844
|
+
|
845
|
+
updateMethodsList
|
846
|
+
methodsList contents: [:html |
|
847
|
+
self methods do: [:each || li |
|
848
|
+
li := html li.
|
849
|
+
selectedMethod = each ifTrue: [
|
850
|
+
li class: 'selected'].
|
851
|
+
li
|
852
|
+
with: each selector;
|
853
|
+
onClick: [self selectMethod: each]]]
|
854
|
+
!
|
855
|
+
|
856
|
+
updateTabsList
|
857
|
+
tabsList contents: [:html || li |
|
858
|
+
li := html li.
|
859
|
+
selectedTab = #instance ifTrue: [li class: 'selected'].
|
860
|
+
li
|
861
|
+
with: 'Instance';
|
862
|
+
onClick: [self selectTab: #instance].
|
863
|
+
li := html li.
|
864
|
+
selectedTab = #class ifTrue: [li class: 'selected'].
|
865
|
+
li
|
866
|
+
with: 'Class';
|
867
|
+
onClick: [self selectTab: #class].
|
868
|
+
li := html li.
|
869
|
+
selectedTab = #comment ifTrue: [li class: 'selected'].
|
870
|
+
li
|
871
|
+
with: 'Comment';
|
872
|
+
onClick: [self selectTab: #comment]]
|
873
|
+
!
|
874
|
+
|
875
|
+
updateSourceAndButtons
|
876
|
+
self disableSaveButton.
|
877
|
+
classButtons contents: [:html |
|
878
|
+
html button
|
879
|
+
with: 'Rename class';
|
880
|
+
onClick: [self renameClass].
|
881
|
+
html button
|
882
|
+
with: 'Remove class';
|
883
|
+
onClick: [self removeClass].
|
884
|
+
html button
|
885
|
+
with: 'References';
|
886
|
+
onClick: [self searchClassReferences]].
|
887
|
+
methodButtons contents: [:html |
|
888
|
+
html button
|
889
|
+
with: 'Remove method';
|
890
|
+
onClick: [self removeMethod].
|
891
|
+
html select
|
892
|
+
onChange: [:e :select | self setMethodProtocol: select val];
|
893
|
+
with: [
|
894
|
+
html option
|
895
|
+
with: 'Method protocol';
|
896
|
+
at: 'disabled' put: 'disabled'.
|
897
|
+
html option
|
898
|
+
class: 'important';
|
899
|
+
with: 'New...'.
|
900
|
+
self protocols do: [:each |
|
901
|
+
html option with: each]].
|
902
|
+
selectedMethod isNil ifFalse: [
|
903
|
+
html select
|
904
|
+
onChange: [:e :select | self searchReferencesOf: select val];
|
905
|
+
with: [
|
906
|
+
html option
|
907
|
+
with: 'References';
|
908
|
+
at: 'disabled' put: 'disabled'.
|
909
|
+
html option
|
910
|
+
class: 'important';
|
911
|
+
with: selectedMethod selector.
|
912
|
+
selectedMethod messageSends sorted do: [:each |
|
913
|
+
html option with: each]]]].
|
914
|
+
selectedMethod isNil
|
915
|
+
ifTrue: [
|
916
|
+
self hideMethodButtons.
|
917
|
+
(selectedClass isNil or: [selectedProtocol notNil])
|
918
|
+
ifTrue: [self hideClassButtons]
|
919
|
+
ifFalse: [self showClassButtons]]
|
920
|
+
ifFalse: [
|
921
|
+
self hideClassButtons.
|
922
|
+
self showMethodButtons].
|
923
|
+
sourceArea val: self source
|
924
|
+
!
|
925
|
+
|
926
|
+
updateStatus
|
927
|
+
sourceArea val = self source
|
928
|
+
ifTrue: [
|
929
|
+
saveButton ifNotNil: [
|
930
|
+
saveButton at: 'disabled' put: true].
|
931
|
+
unsavedChanges := false]
|
932
|
+
ifFalse: [
|
933
|
+
saveButton ifNotNil: [
|
934
|
+
saveButton removeAt: 'disabled'].
|
935
|
+
unsavedChanges := true]
|
936
|
+
!
|
937
|
+
|
938
|
+
resetClassesList
|
939
|
+
classesList resetNodes
|
940
|
+
! !
|
941
|
+
|
942
|
+
!Browser class methodsFor: 'accessing'!
|
943
|
+
|
944
|
+
commitPathJs
|
945
|
+
^'js'
|
946
|
+
!
|
947
|
+
|
948
|
+
commitPathSt
|
949
|
+
^'st'
|
950
|
+
! !
|
951
|
+
|
952
|
+
!Browser class methodsFor: 'convenience'!
|
953
|
+
|
954
|
+
openOn: aClass
|
955
|
+
^self new
|
956
|
+
open;
|
957
|
+
selectCategory: aClass category;
|
958
|
+
selectClass: aClass
|
959
|
+
!
|
960
|
+
|
961
|
+
open
|
962
|
+
self new open
|
963
|
+
! !
|
964
|
+
|
965
|
+
TabWidget subclass: #Inspector
|
966
|
+
instanceVariableNames: 'label variables object selectedVariable variablesList valueTextarea workspaceTextarea diveButton'
|
967
|
+
category: 'IDE'!
|
968
|
+
|
969
|
+
!Inspector methodsFor: 'accessing'!
|
970
|
+
|
971
|
+
label
|
972
|
+
^label ifNil: ['Inspector (nil)']
|
973
|
+
!
|
974
|
+
|
975
|
+
variables
|
976
|
+
^variables
|
977
|
+
!
|
978
|
+
|
979
|
+
setVariables: aCollection
|
980
|
+
variables := aCollection
|
981
|
+
!
|
982
|
+
|
983
|
+
setLabel: aString
|
984
|
+
label := aString
|
985
|
+
!
|
986
|
+
|
987
|
+
selectedVariable
|
988
|
+
^selectedVariable
|
989
|
+
!
|
990
|
+
|
991
|
+
selectedVariable: aString
|
992
|
+
selectedVariable := aString
|
993
|
+
! !
|
994
|
+
|
995
|
+
!Inspector methodsFor: 'actions'!
|
996
|
+
|
997
|
+
inspect: anObject
|
998
|
+
object := anObject.
|
999
|
+
variables := #().
|
1000
|
+
object inspectOn: self
|
1001
|
+
!
|
1002
|
+
|
1003
|
+
dive
|
1004
|
+
(self variables at: self selectedVariable) inspect
|
1005
|
+
!
|
1006
|
+
|
1007
|
+
refresh
|
1008
|
+
self
|
1009
|
+
inspect: object;
|
1010
|
+
updateVariablesList;
|
1011
|
+
updateValueTextarea
|
1012
|
+
! !
|
1013
|
+
|
1014
|
+
!Inspector methodsFor: 'rendering'!
|
1015
|
+
|
1016
|
+
renderBoxOn: html
|
1017
|
+
self
|
1018
|
+
renderTopPanelOn: html;
|
1019
|
+
renderBottomPanelOn: html
|
1020
|
+
!
|
1021
|
+
|
1022
|
+
renderTopPanelOn: html
|
1023
|
+
html div
|
1024
|
+
class: 'top';
|
1025
|
+
with: [
|
1026
|
+
variablesList := html ul class: 'jt_column variables'.
|
1027
|
+
valueTextarea := html textarea class: 'jt_column value'; at: 'readonly' put: 'readonly'.
|
1028
|
+
self
|
1029
|
+
updateVariablesList;
|
1030
|
+
updateValueTextarea.
|
1031
|
+
html div class: 'jt_clear']
|
1032
|
+
!
|
1033
|
+
|
1034
|
+
renderBottomPanelOn: html
|
1035
|
+
html div
|
1036
|
+
class: 'jt_sourceCode';
|
1037
|
+
with: [
|
1038
|
+
workspaceTextarea := html textarea
|
1039
|
+
class: 'source';
|
1040
|
+
at: 'spellcheck' put: 'false'.
|
1041
|
+
workspaceTextarea asJQuery call: 'tabby']
|
1042
|
+
!
|
1043
|
+
|
1044
|
+
renderButtonsOn: html
|
1045
|
+
html button
|
1046
|
+
with: 'Refresh';
|
1047
|
+
onClick: [self refresh].
|
1048
|
+
diveButton := html button
|
1049
|
+
with: 'Dive';
|
1050
|
+
onClick: [self dive].
|
1051
|
+
self updateButtons
|
1052
|
+
! !
|
1053
|
+
|
1054
|
+
!Inspector methodsFor: 'testing'!
|
1055
|
+
|
1056
|
+
canBeClosed
|
1057
|
+
^true
|
1058
|
+
! !
|
1059
|
+
|
1060
|
+
!Inspector methodsFor: 'updating'!
|
1061
|
+
|
1062
|
+
updateVariablesList
|
1063
|
+
variablesList contents: [:html |
|
1064
|
+
self variables keys do: [:each || li |
|
1065
|
+
li := html li.
|
1066
|
+
li
|
1067
|
+
with: each;
|
1068
|
+
onClick: [self selectVariable: each].
|
1069
|
+
self selectedVariable = each ifTrue: [
|
1070
|
+
li class: 'selected']]]
|
1071
|
+
!
|
1072
|
+
|
1073
|
+
selectVariable: aString
|
1074
|
+
self selectedVariable: aString.
|
1075
|
+
self
|
1076
|
+
updateVariablesList;
|
1077
|
+
updateValueTextarea;
|
1078
|
+
updateButtons
|
1079
|
+
!
|
1080
|
+
|
1081
|
+
updateValueTextarea
|
1082
|
+
valueTextarea asJQuery val: (self selectedVariable isNil
|
1083
|
+
ifTrue: ['']
|
1084
|
+
ifFalse: [(self variables at: self selectedVariable) printString])
|
1085
|
+
!
|
1086
|
+
|
1087
|
+
updateButtons
|
1088
|
+
(self selectedVariable notNil and: [(self variables at: self selectedVariable) notNil])
|
1089
|
+
ifFalse: [diveButton at: 'disabled' put: true]
|
1090
|
+
ifTrue: [diveButton removeAt: 'disabled']
|
1091
|
+
! !
|
1092
|
+
|
1093
|
+
!Inspector class methodsFor: 'instance creation'!
|
1094
|
+
|
1095
|
+
on: anObject
|
1096
|
+
^self new
|
1097
|
+
inspect: anObject;
|
1098
|
+
yourself
|
1099
|
+
! !
|
1100
|
+
|
1101
|
+
TabWidget subclass: #ReferencesBrowser
|
1102
|
+
instanceVariableNames: 'implementors senders implementorsList input timer selector sendersList referencedClasses referencedClassesList'
|
1103
|
+
category: 'IDE'!
|
1104
|
+
|
1105
|
+
!ReferencesBrowser methodsFor: 'accessing'!
|
1106
|
+
|
1107
|
+
implementors
|
1108
|
+
^implementors ifNil: [implementors := Array new]
|
1109
|
+
!
|
1110
|
+
|
1111
|
+
label
|
1112
|
+
^'[ReferencesBrowser]'
|
1113
|
+
!
|
1114
|
+
|
1115
|
+
selector
|
1116
|
+
^selector
|
1117
|
+
!
|
1118
|
+
|
1119
|
+
senders
|
1120
|
+
^senders ifNil: [senders := Array new]
|
1121
|
+
!
|
1122
|
+
|
1123
|
+
classesAndMetaclasses
|
1124
|
+
^Smalltalk current classes, (Smalltalk current classes collect: [:each | each class])
|
1125
|
+
!
|
1126
|
+
|
1127
|
+
referencedClasses
|
1128
|
+
^referencedClasses ifNil: [referencedClasses := Array new]
|
1129
|
+
! !
|
1130
|
+
|
1131
|
+
!ReferencesBrowser methodsFor: 'actions'!
|
1132
|
+
|
1133
|
+
openBrowserOn: aMethod
|
1134
|
+
| browser |
|
1135
|
+
browser := Browser openOn: (aMethod class isMetaclass
|
1136
|
+
ifTrue: [aMethod methodClass instanceClass] ifFalse: [aMethod methodClass]).
|
1137
|
+
aMethod methodClass isMetaclass ifTrue: [browser selectTab: #class].
|
1138
|
+
browser
|
1139
|
+
selectProtocol: aMethod category;
|
1140
|
+
selectMethod: aMethod
|
1141
|
+
!
|
1142
|
+
|
1143
|
+
searchReferencesFor: aString
|
1144
|
+
selector := aString.
|
1145
|
+
implementors := Array new.
|
1146
|
+
senders := Array new.
|
1147
|
+
referencedClasses := Array new.
|
1148
|
+
(selector match: '^[A-Z]')
|
1149
|
+
ifFalse: [self searchSelectorReferencesFor: selector]
|
1150
|
+
ifTrue: [self searchReferencedClassesFor: selector]
|
1151
|
+
!
|
1152
|
+
|
1153
|
+
search: aString
|
1154
|
+
self
|
1155
|
+
searchReferencesFor: aString;
|
1156
|
+
updateImplementorsList;
|
1157
|
+
updateSendersList;
|
1158
|
+
updateReferencedClassesList
|
1159
|
+
!
|
1160
|
+
|
1161
|
+
searchReferencedClassesFor: aString
|
1162
|
+
self classesAndMetaclasses do: [:each |
|
1163
|
+
each methodDictionary values do: [:value |
|
1164
|
+
(((value referencedClasses select: [:each | each notNil])collect: [:each | each name]) includes: selector) ifTrue: [
|
1165
|
+
self referencedClasses add: value]]]
|
1166
|
+
!
|
1167
|
+
|
1168
|
+
searchSelectorReferencesFor: aString
|
1169
|
+
self classesAndMetaclasses do: [:each |
|
1170
|
+
each methodDictionary keysAndValuesDo: [:key :value |
|
1171
|
+
key = selector ifTrue: [self implementors add: value]].
|
1172
|
+
each methodDictionary keysAndValuesDo: [:key :value |
|
1173
|
+
(value messageSends includes: selector) ifTrue: [
|
1174
|
+
self senders add: value]]]
|
1175
|
+
! !
|
1176
|
+
|
1177
|
+
!ReferencesBrowser methodsFor: 'initialization'!
|
1178
|
+
|
1179
|
+
initialize
|
1180
|
+
super initialize.
|
1181
|
+
selector := ''
|
1182
|
+
! !
|
1183
|
+
|
1184
|
+
!ReferencesBrowser methodsFor: 'private'!
|
1185
|
+
|
1186
|
+
setInputEvents
|
1187
|
+
input
|
1188
|
+
onKeyUp: [timer := [self search: input asJQuery val] valueWithTimeout: 100];
|
1189
|
+
onKeyDown: [timer ifNotNil: [timer clearTimeout]]
|
1190
|
+
! !
|
1191
|
+
|
1192
|
+
!ReferencesBrowser methodsFor: 'rendering'!
|
1193
|
+
|
1194
|
+
renderBoxOn: html
|
1195
|
+
self
|
1196
|
+
renderInputOn: html;
|
1197
|
+
renderImplementorsOn: html;
|
1198
|
+
renderSendersOn: html;
|
1199
|
+
renderReferencedClassesOn: html
|
1200
|
+
!
|
1201
|
+
|
1202
|
+
renderInputOn: html
|
1203
|
+
input := html input
|
1204
|
+
class: 'implementors';
|
1205
|
+
yourself.
|
1206
|
+
input asJQuery val: selector.
|
1207
|
+
self setInputEvents
|
1208
|
+
!
|
1209
|
+
|
1210
|
+
renderImplementorsOn: html
|
1211
|
+
implementorsList := html ul class: 'jt_column implementors'.
|
1212
|
+
self updateImplementorsList
|
1213
|
+
!
|
1214
|
+
|
1215
|
+
renderSendersOn: html
|
1216
|
+
sendersList := html ul class: 'jt_column senders'.
|
1217
|
+
self updateSendersList
|
1218
|
+
!
|
1219
|
+
|
1220
|
+
renderReferencedClassesOn: html
|
1221
|
+
referencedClassesList := html ul class: 'jt_column referenced_classes'.
|
1222
|
+
self updateReferencedClassesList
|
1223
|
+
! !
|
1224
|
+
|
1225
|
+
!ReferencesBrowser methodsFor: 'testing'!
|
1226
|
+
|
1227
|
+
canBeClosed
|
1228
|
+
^true
|
1229
|
+
! !
|
1230
|
+
|
1231
|
+
!ReferencesBrowser methodsFor: 'updating'!
|
1232
|
+
|
1233
|
+
updateImplementorsList
|
1234
|
+
implementorsList contents: [:html |
|
1235
|
+
html li
|
1236
|
+
class: 'column_label';
|
1237
|
+
with: 'Implementors (', self implementors size asString, ')';
|
1238
|
+
style: 'font-weight: bold'.
|
1239
|
+
self implementors do: [:each || li |
|
1240
|
+
li := html li.
|
1241
|
+
li
|
1242
|
+
with: (each methodClass asString, ' >> ', self selector);
|
1243
|
+
onClick: [self openBrowserOn: each]]]
|
1244
|
+
!
|
1245
|
+
|
1246
|
+
updateSendersList
|
1247
|
+
sendersList contents: [:html |
|
1248
|
+
html li
|
1249
|
+
class: 'column_label';
|
1250
|
+
with: 'Senders (', self senders size asString, ')';
|
1251
|
+
style: 'font-weight: bold'.
|
1252
|
+
self senders do: [:each |
|
1253
|
+
html li
|
1254
|
+
with: (each methodClass asString, ' >> ', each selector);
|
1255
|
+
onClick: [self openBrowserOn: each]]]
|
1256
|
+
!
|
1257
|
+
|
1258
|
+
updateReferencedClassesList
|
1259
|
+
referencedClassesList contents: [:html |
|
1260
|
+
html li
|
1261
|
+
class: 'column_label';
|
1262
|
+
with: 'Class references (', self referencedClasses size asString, ')';
|
1263
|
+
style: 'font-weight: bold'.
|
1264
|
+
self referencedClasses do: [:each |
|
1265
|
+
html li
|
1266
|
+
with: (each methodClass asString, ' >> ', each selector);
|
1267
|
+
onClick: [self openBrowserOn: each]]]
|
1268
|
+
! !
|
1269
|
+
|
1270
|
+
!ReferencesBrowser class methodsFor: 'instance creation'!
|
1271
|
+
|
1272
|
+
search: aString
|
1273
|
+
^self new
|
1274
|
+
searchReferencesFor: aString;
|
1275
|
+
open
|
1276
|
+
! !
|
1277
|
+
|
1278
|
+
Widget subclass: #SourceArea
|
1279
|
+
instanceVariableNames: 'editor div'
|
1280
|
+
category: 'IDE'!
|
1281
|
+
|
1282
|
+
!SourceArea methodsFor: 'accessing'!
|
1283
|
+
|
1284
|
+
val
|
1285
|
+
^editor getValue
|
1286
|
+
!
|
1287
|
+
|
1288
|
+
val: aString
|
1289
|
+
editor setValue: aString
|
1290
|
+
!
|
1291
|
+
|
1292
|
+
currentLine
|
1293
|
+
^editor getLine: (editor getCursor line)
|
1294
|
+
!
|
1295
|
+
|
1296
|
+
selection
|
1297
|
+
^editor getSelection
|
1298
|
+
!
|
1299
|
+
|
1300
|
+
selectionEnd
|
1301
|
+
^textarea element selectionEnd
|
1302
|
+
!
|
1303
|
+
|
1304
|
+
selectionStart
|
1305
|
+
^textarea element selectionStart
|
1306
|
+
!
|
1307
|
+
|
1308
|
+
selectionStart: anInteger
|
1309
|
+
textarea element selectionStart: anInteger
|
1310
|
+
!
|
1311
|
+
|
1312
|
+
selectionEnd: anInteger
|
1313
|
+
textarea element selectionEnd: anInteger
|
1314
|
+
!
|
1315
|
+
|
1316
|
+
setEditorOn: aTextarea
|
1317
|
+
<self['@editor'] = CodeMirror.fromTextArea(aTextarea, {
|
1318
|
+
theme: 'jtalk',
|
1319
|
+
lineNumbers: true,
|
1320
|
+
enterMode: 'classic',
|
1321
|
+
matchBrackets: true,
|
1322
|
+
electricChars: false,
|
1323
|
+
})>
|
1324
|
+
!
|
1325
|
+
|
1326
|
+
editor
|
1327
|
+
^editor
|
1328
|
+
! !
|
1329
|
+
|
1330
|
+
!SourceArea methodsFor: 'actions'!
|
1331
|
+
|
1332
|
+
clear
|
1333
|
+
textarea asJQuery val: ''
|
1334
|
+
!
|
1335
|
+
|
1336
|
+
doIt
|
1337
|
+
| selection |
|
1338
|
+
editor somethingSelected
|
1339
|
+
ifFalse: [selection := self currentLine]
|
1340
|
+
ifTrue: [selection := self selection].
|
1341
|
+
^self eval: selection
|
1342
|
+
!
|
1343
|
+
|
1344
|
+
eval: aString
|
1345
|
+
| compiler node |
|
1346
|
+
compiler := Compiler new.
|
1347
|
+
node := compiler parseExpression: aString.
|
1348
|
+
node isParseFailure ifTrue: [
|
1349
|
+
^self alert: node reason, ', position: ', node position].
|
1350
|
+
^compiler loadExpression: aString
|
1351
|
+
!
|
1352
|
+
|
1353
|
+
handleKeyDown: anEvent
|
1354
|
+
<if(anEvent.ctrlKey) {
|
1355
|
+
if(anEvent.keyCode === 80) { //ctrl+p
|
1356
|
+
self._printIt();
|
1357
|
+
anEvent.preventDefault();
|
1358
|
+
return false;
|
1359
|
+
}
|
1360
|
+
if(anEvent.keyCode === 68) { //ctrl+d
|
1361
|
+
self._doIt();
|
1362
|
+
anEvent.preventDefault();
|
1363
|
+
return false;
|
1364
|
+
}
|
1365
|
+
if(anEvent.keyCode === 73) { //ctrl+i
|
1366
|
+
self._inspectIt();
|
1367
|
+
anEvent.preventDefault();
|
1368
|
+
return false;
|
1369
|
+
}
|
1370
|
+
}>
|
1371
|
+
!
|
1372
|
+
|
1373
|
+
inspectIt
|
1374
|
+
self doIt inspect
|
1375
|
+
!
|
1376
|
+
|
1377
|
+
print: aString
|
1378
|
+
| start stop |
|
1379
|
+
start := Dictionary new.
|
1380
|
+
stop := Dictionary new.
|
1381
|
+
start at: 'line' put: (editor getCursor: false) line.
|
1382
|
+
start at: 'ch' put: (editor getCursor: false) ch.
|
1383
|
+
stop at: 'line' put: (start at: 'line').
|
1384
|
+
stop at: 'ch' put: ((start at: 'ch') + aString size + 2).
|
1385
|
+
editor replaceSelection: (editor getSelection, ' ', aString, ' ').
|
1386
|
+
editor setCursor: (editor getCursor: true).
|
1387
|
+
editor setSelection: stop end: start.
|
1388
|
+
console log: start; log: stop
|
1389
|
+
!
|
1390
|
+
|
1391
|
+
printIt
|
1392
|
+
self print: self doIt printString
|
1393
|
+
! !
|
1394
|
+
|
1395
|
+
!SourceArea methodsFor: 'events'!
|
1396
|
+
|
1397
|
+
onKeyUp: aBlock
|
1398
|
+
div onKeyUp: aBlock
|
1399
|
+
!
|
1400
|
+
|
1401
|
+
onKeyDown: aBlock
|
1402
|
+
div onKeyDown: aBlock
|
1403
|
+
! !
|
1404
|
+
|
1405
|
+
!SourceArea methodsFor: 'rendering'!
|
1406
|
+
|
1407
|
+
renderOn: html
|
1408
|
+
| textarea |
|
1409
|
+
div := html div class: 'source'.
|
1410
|
+
div with: [textarea := html textarea].
|
1411
|
+
self setEditorOn: textarea element.
|
1412
|
+
div onKeyDown: [:e | self handleKeyDown: e]
|
1413
|
+
! !
|
1414
|
+
|
1415
|
+
Widget subclass: #ClassesList
|
1416
|
+
instanceVariableNames: 'browser ul nodes'
|
1417
|
+
category: 'IDE'!
|
1418
|
+
|
1419
|
+
!ClassesList methodsFor: 'accessing'!
|
1420
|
+
|
1421
|
+
category
|
1422
|
+
^self browser selectedCategory
|
1423
|
+
!
|
1424
|
+
|
1425
|
+
nodes
|
1426
|
+
nodes ifNil: [nodes := self getNodes].
|
1427
|
+
^nodes
|
1428
|
+
!
|
1429
|
+
|
1430
|
+
browser
|
1431
|
+
^browser
|
1432
|
+
!
|
1433
|
+
|
1434
|
+
browser: aBrowser
|
1435
|
+
|
1436
|
+
browser := aBrowser
|
1437
|
+
!
|
1438
|
+
|
1439
|
+
getNodes
|
1440
|
+
| classes children others |
|
1441
|
+
classes := self browser classes.
|
1442
|
+
children := #().
|
1443
|
+
others := #().
|
1444
|
+
classes do: [:each |
|
1445
|
+
(classes includes: each superclass)
|
1446
|
+
ifFalse: [children add: each]
|
1447
|
+
ifTrue: [others add: each]].
|
1448
|
+
^children collect: [:each |
|
1449
|
+
ClassesListNode on: each browser: self browser classes: others level: 0]
|
1450
|
+
!
|
1451
|
+
|
1452
|
+
resetNodes
|
1453
|
+
nodes := nil
|
1454
|
+
! !
|
1455
|
+
|
1456
|
+
!ClassesList methodsFor: 'rendering'!
|
1457
|
+
|
1458
|
+
renderOn: html
|
1459
|
+
ul := html ul
|
1460
|
+
class: 'jt_column browser classes';
|
1461
|
+
yourself.
|
1462
|
+
self updateNodes
|
1463
|
+
!
|
1464
|
+
|
1465
|
+
updateNodes
|
1466
|
+
ul contents: [:html |
|
1467
|
+
self nodes do: [:each |
|
1468
|
+
each renderOn: html]]
|
1469
|
+
! !
|
1470
|
+
|
1471
|
+
!ClassesList class methodsFor: 'instance creation'!
|
1472
|
+
|
1473
|
+
on: aBrowser
|
1474
|
+
^self new
|
1475
|
+
browser: aBrowser;
|
1476
|
+
yourself
|
1477
|
+
! !
|
1478
|
+
|
1479
|
+
Widget subclass: #ClassesListNode
|
1480
|
+
instanceVariableNames: 'browser theClass level nodes'
|
1481
|
+
category: 'IDE'!
|
1482
|
+
|
1483
|
+
!ClassesListNode methodsFor: 'accessing'!
|
1484
|
+
|
1485
|
+
nodes
|
1486
|
+
^nodes
|
1487
|
+
!
|
1488
|
+
|
1489
|
+
theClass
|
1490
|
+
^theClass
|
1491
|
+
!
|
1492
|
+
|
1493
|
+
theClass: aClass
|
1494
|
+
theClass := aClass
|
1495
|
+
!
|
1496
|
+
|
1497
|
+
browser
|
1498
|
+
^browser
|
1499
|
+
!
|
1500
|
+
|
1501
|
+
browser: aBrowser
|
1502
|
+
browser := aBrowser
|
1503
|
+
!
|
1504
|
+
|
1505
|
+
level
|
1506
|
+
^level
|
1507
|
+
!
|
1508
|
+
|
1509
|
+
level: anInteger
|
1510
|
+
level := anInteger
|
1511
|
+
!
|
1512
|
+
|
1513
|
+
label
|
1514
|
+
| str |
|
1515
|
+
str := String new writeStream.
|
1516
|
+
self level timesRepeat: [
|
1517
|
+
str nextPutAll: ' '].
|
1518
|
+
str nextPutAll: self theClass name.
|
1519
|
+
^str contents
|
1520
|
+
!
|
1521
|
+
|
1522
|
+
getNodesFrom: aCollection
|
1523
|
+
| children others |
|
1524
|
+
children := #().
|
1525
|
+
others := #().
|
1526
|
+
aCollection do: [:each |
|
1527
|
+
(each superclass = self theClass)
|
1528
|
+
ifTrue: [children add: each]
|
1529
|
+
ifFalse: [others add: each]].
|
1530
|
+
nodes:= children collect: [:each |
|
1531
|
+
ClassesListNode on: each browser: self browser classes: others level: self level + 1]
|
1532
|
+
! !
|
1533
|
+
|
1534
|
+
!ClassesListNode methodsFor: 'rendering'!
|
1535
|
+
|
1536
|
+
renderOn: html
|
1537
|
+
| li |
|
1538
|
+
li := html li
|
1539
|
+
onClick: [self browser selectClass: self theClass].
|
1540
|
+
li asJQuery contents: self label.
|
1541
|
+
self browser selectedClass = self theClass ifTrue: [
|
1542
|
+
li class: 'selected'].
|
1543
|
+
self nodes do: [:each |
|
1544
|
+
each renderOn: html]
|
1545
|
+
! !
|
1546
|
+
|
1547
|
+
!ClassesListNode class methodsFor: 'instance creation'!
|
1548
|
+
|
1549
|
+
on: aClass browser: aBrowser classes: aCollection level: anInteger
|
1550
|
+
^self new
|
1551
|
+
theClass: aClass;
|
1552
|
+
browser: aBrowser;
|
1553
|
+
level: anInteger;
|
1554
|
+
getNodesFrom: aCollection;
|
1555
|
+
yourself
|
1556
|
+
! !
|
1557
|
+
|
1558
|
+
TabWidget subclass: #Debugger
|
1559
|
+
instanceVariableNames: 'error selectedContext sourceArea ul'
|
1560
|
+
category: 'IDE'!
|
1561
|
+
|
1562
|
+
!Debugger methodsFor: 'accessing'!
|
1563
|
+
|
1564
|
+
error
|
1565
|
+
^error
|
1566
|
+
!
|
1567
|
+
|
1568
|
+
error: anError
|
1569
|
+
error := anError
|
1570
|
+
!
|
1571
|
+
|
1572
|
+
label
|
1573
|
+
^'[Debugger]'
|
1574
|
+
! !
|
1575
|
+
|
1576
|
+
!Debugger methodsFor: 'actions'!
|
1577
|
+
|
1578
|
+
selectContext: aContext
|
1579
|
+
selectedContext := aContext.
|
1580
|
+
self updateContextsList.
|
1581
|
+
self updateSourceArea
|
1582
|
+
! !
|
1583
|
+
|
1584
|
+
!Debugger methodsFor: 'rendering'!
|
1585
|
+
|
1586
|
+
renderBoxOn: html
|
1587
|
+
self
|
1588
|
+
renderTopPanelOn: html;
|
1589
|
+
renderBottomPanelOn: html
|
1590
|
+
!
|
1591
|
+
|
1592
|
+
renderTopPanelOn: html
|
1593
|
+
selectedContext := self error context.
|
1594
|
+
html div
|
1595
|
+
class: 'top';
|
1596
|
+
with: [
|
1597
|
+
html div
|
1598
|
+
class: 'label';
|
1599
|
+
with: self error messageText.
|
1600
|
+
ul := html ul
|
1601
|
+
class: 'jt_column debugger contexts';
|
1602
|
+
with: [self renderContext: self error context on: html]]
|
1603
|
+
!
|
1604
|
+
|
1605
|
+
renderContext: aContext on: html
|
1606
|
+
| li |
|
1607
|
+
li := html li.
|
1608
|
+
selectedContext = aContext ifTrue: [
|
1609
|
+
li class: 'selected'].
|
1610
|
+
li
|
1611
|
+
with: aContext asString;
|
1612
|
+
onClick: [self selectContext: aContext].
|
1613
|
+
aContext home ifNotNil: [self renderContext: aContext home on: html]
|
1614
|
+
!
|
1615
|
+
|
1616
|
+
renderBottomPanelOn: html
|
1617
|
+
html div
|
1618
|
+
class: 'jt_sourceCode';
|
1619
|
+
with: [
|
1620
|
+
sourceArea := SourceArea new.
|
1621
|
+
sourceArea renderOn: html].
|
1622
|
+
self updateSourceArea
|
1623
|
+
! !
|
1624
|
+
|
1625
|
+
!Debugger methodsFor: 'testing'!
|
1626
|
+
|
1627
|
+
canBeClosed
|
1628
|
+
^true
|
1629
|
+
! !
|
1630
|
+
|
1631
|
+
!Debugger methodsFor: 'updating'!
|
1632
|
+
|
1633
|
+
updateContextsList
|
1634
|
+
ul contents: [:html |
|
1635
|
+
self renderContext: self error context on: html]
|
1636
|
+
!
|
1637
|
+
|
1638
|
+
updateSourceArea
|
1639
|
+
sourceArea val: (selectedContext receiver class methodAt: selectedContext selector) source
|
1640
|
+
! !
|
1641
|
+
|
1642
|
+
ErrorHandler subclass: #DebugErrorHandler
|
1643
|
+
instanceVariableNames: ''
|
1644
|
+
category: 'IDE'!
|
1645
|
+
|
1646
|
+
!DebugErrorHandler methodsFor: 'error handling'!
|
1647
|
+
|
1648
|
+
handleError: anError
|
1649
|
+
[Debugger new
|
1650
|
+
error: anError;
|
1651
|
+
open] on: Error do: [:error |
|
1652
|
+
ErrorHandler new handleError: error]
|
1653
|
+
! !
|
1654
|
+
|
1655
|
+
!DebugErrorHandler class methodsFor: 'initialization'!
|
1656
|
+
|
1657
|
+
initialize
|
1658
|
+
self register
|
1659
|
+
! !
|
1660
|
+
|
1661
|
+
!Object methodsFor: '*IDE'!
|
1662
|
+
|
1663
|
+
inspect
|
1664
|
+
Inspector new
|
1665
|
+
inspect: self;
|
1666
|
+
open
|
1667
|
+
!
|
1668
|
+
|
1669
|
+
inspectOn: anInspector
|
1670
|
+
| variables |
|
1671
|
+
variables := Dictionary new.
|
1672
|
+
variables at: '#self' put: self.
|
1673
|
+
self class allInstanceVariableNames do: [:each |
|
1674
|
+
variables at: each put: (self instVarAt: each)].
|
1675
|
+
anInspector
|
1676
|
+
setLabel: self printString;
|
1677
|
+
setVariables: variables
|
1678
|
+
! !
|
1679
|
+
|
1680
|
+
!Date methodsFor: '*IDE'!
|
1681
|
+
|
1682
|
+
inspectOn: anInspector
|
1683
|
+
| variables |
|
1684
|
+
variables := Dictionary new.
|
1685
|
+
variables at: '#self' put: self.
|
1686
|
+
variables at: '#year' put: self year.
|
1687
|
+
variables at: '#month' put: self month.
|
1688
|
+
variables at: '#day' put: self day.
|
1689
|
+
variables at: '#hours' put: self hours.
|
1690
|
+
variables at: '#minutes' put: self minutes.
|
1691
|
+
variables at: '#seconds' put: self seconds.
|
1692
|
+
variables at: '#milliseconds' put: self milliseconds.
|
1693
|
+
anInspector
|
1694
|
+
setLabel: self printString;
|
1695
|
+
setVariables: variables
|
1696
|
+
! !
|
1697
|
+
|
1698
|
+
!Collection methodsFor: '*IDE'!
|
1699
|
+
|
1700
|
+
inspectOn: anInspector
|
1701
|
+
| variables |
|
1702
|
+
variables := Dictionary new.
|
1703
|
+
variables at: '#self' put: self.
|
1704
|
+
self withIndexDo: [:each :i |
|
1705
|
+
variables at: i put: each].
|
1706
|
+
anInspector
|
1707
|
+
setLabel: self printString;
|
1708
|
+
setVariables: variables
|
1709
|
+
! !
|
1710
|
+
|
1711
|
+
!String methodsFor: '*IDE'!
|
1712
|
+
|
1713
|
+
inspectOn: anInspector
|
1714
|
+
| label |
|
1715
|
+
super inspectOn: anInspector.
|
1716
|
+
self printString size > 30
|
1717
|
+
ifTrue: [label := (self printString copyFrom: 1 to: 30), '...''']
|
1718
|
+
ifFalse: [label := self printString].
|
1719
|
+
anInspector setLabel: label
|
1720
|
+
! !
|
1721
|
+
|
1722
|
+
!MethodContext methodsFor: '*IDE'!
|
1723
|
+
|
1724
|
+
inspectOn: anInspector
|
1725
|
+
| variables |
|
1726
|
+
variables := Dictionary new.
|
1727
|
+
variables at: '#self' put: self.
|
1728
|
+
variables at: '#home' put: self home.
|
1729
|
+
variables at: '#receiver' put: self receiver.
|
1730
|
+
variables at: '#selector' put: self selector.
|
1731
|
+
variables at: '#temps' put: self temps.
|
1732
|
+
self class instanceVariableNames do: [:each |
|
1733
|
+
variables at: each put: (self instVarAt: each)].
|
1734
|
+
anInspector
|
1735
|
+
setLabel: self printString;
|
1736
|
+
setVariables: variables
|
1737
|
+
! !
|
1738
|
+
|
1739
|
+
!Dictionary methodsFor: '*IDE'!
|
1740
|
+
|
1741
|
+
inspectOn: anInspector
|
1742
|
+
| variables |
|
1743
|
+
variables := Dictionary new.
|
1744
|
+
variables at: '#self' put: self.
|
1745
|
+
variables at: '#keys' put: self keys.
|
1746
|
+
self keysAndValuesDo: [:key :value |
|
1747
|
+
variables at: key put: value].
|
1748
|
+
anInspector
|
1749
|
+
setLabel: self printString;
|
1750
|
+
setVariables: variables
|
1751
|
+
! !
|
1752
|
+
|