author | Claus Gittinger <cg@exept.de> |
Wed, 17 Jul 2002 17:47:38 +0200 | |
changeset 3736 | 687a0a8de66c |
parent 3722 | 0a1edec5d83b |
child 3752 | 79378c1f0faf |
permissions | -rw-r--r-- |
3154 | 1 |
"{ Package: 'stx:libtool' }" |
2 |
||
3 |
ToolApplicationModel subclass:#WorkspaceApplication |
|
3667 | 4 |
instanceVariableNames:'workspaces tabList selectedWorkspaceIndexHolder workspaceHolder |
5 |
autoDefineWorkspaceVariables' |
|
6 |
classVariableNames:'DefaultAutoDefineWorkspaceVariables' |
|
3222 | 7 |
poolDictionaries:'' |
8 |
category:'Interface-Smalltalk' |
|
3154 | 9 |
! |
10 |
||
3191 | 11 |
!WorkspaceApplication class methodsFor:'documentation'! |
12 |
||
13 |
documentation |
|
14 |
" |
|
15 |
A simple wrapper around a WorkSpace-View, adding a pullDown menu. |
|
16 |
||
17 |
[author:] |
|
18 |
Claus Gittinger |
|
19 |
" |
|
20 |
! ! |
|
3154 | 21 |
|
22 |
!WorkspaceApplication class methodsFor:'interface specs'! |
|
23 |
||
24 |
windowSpec |
|
25 |
"This resource specification was automatically generated |
|
26 |
by the UIPainter of ST/X." |
|
27 |
||
28 |
"Do not manually edit this!! If it is corrupted, |
|
29 |
the UIPainter may not be able to read the specification." |
|
30 |
||
31 |
" |
|
32 |
UIPainter new openOnClass:WorkspaceApplication andSelector:#windowSpec |
|
33 |
WorkspaceApplication new openInterface:#windowSpec |
|
34 |
WorkspaceApplication open |
|
35 |
" |
|
36 |
||
37 |
<resource: #canvas> |
|
38 |
||
39 |
^ |
|
40 |
#(#FullSpec |
|
41 |
#name: #windowSpec |
|
42 |
#window: |
|
43 |
#(#WindowSpec |
|
44 |
#label: 'Workspace' |
|
45 |
#name: 'Workspace' |
|
46 |
#min: #(#Point 10 10) |
|
47 |
#max: #(#Point 1024 768) |
|
3648
77e7128e230f
oops - there was an invisible view in the spec
Claus Gittinger <cg@exept.de>
parents:
3532
diff
changeset
|
48 |
#bounds: #(#Rectangle 177 150 609 391) |
3154 | 49 |
#menu: #mainMenu |
50 |
) |
|
51 |
#component: |
|
52 |
#(#SpecCollection |
|
53 |
#collection: #( |
|
3193 | 54 |
#(#NoteBookViewSpec |
55 |
#name: 'NoteBook1' |
|
56 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
57 |
#model: #selectedWorkspaceIndexHolder |
|
58 |
#menu: #tabList |
|
59 |
#useIndex: true |
|
60 |
#accessTabMenuAction: #tabMenuAt: |
|
61 |
#canvas: #workspaceHolder |
|
62 |
#canvasInset: 0 |
|
63 |
#canvasFrameLevel: 0 |
|
64 |
#keepCanvasAlive: true |
|
65 |
#tabLevel: 2 |
|
66 |
) |
|
3154 | 67 |
) |
68 |
||
69 |
) |
|
70 |
) |
|
71 |
! ! |
|
72 |
||
73 |
!WorkspaceApplication class methodsFor:'menu specs'! |
|
74 |
||
75 |
mainMenu |
|
76 |
"This resource specification was automatically generated |
|
77 |
by the MenuEditor of ST/X." |
|
78 |
||
79 |
"Do not manually edit this!! If it is corrupted, |
|
80 |
the MenuEditor may not be able to read the specification." |
|
81 |
||
82 |
" |
|
83 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#mainMenu |
|
84 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication mainMenu)) startUp |
|
85 |
" |
|
86 |
||
87 |
<resource: #menu> |
|
88 |
||
89 |
^ |
|
90 |
#(#Menu |
|
91 |
#( |
|
92 |
#(#MenuItem |
|
93 |
#label: 'File' |
|
94 |
#translateLabel: true |
|
95 |
#submenu: |
|
96 |
#(#Menu |
|
97 |
#( |
|
98 |
#(#MenuItem |
|
3651 | 99 |
#label: 'New Workspace' |
3154 | 100 |
#translateLabel: true |
3651 | 101 |
#value: #newWorkspace |
102 |
) |
|
103 |
#(#MenuItem |
|
104 |
#label: 'New SystemWorkspace' |
|
105 |
#translateLabel: true |
|
106 |
#value: #newSystemWorkspace |
|
3154 | 107 |
) |
108 |
#(#MenuItem |
|
109 |
#label: '-' |
|
110 |
) |
|
111 |
#(#MenuItem |
|
112 |
#label: 'Load File...' |
|
113 |
#translateLabel: true |
|
114 |
#value: #menuLoad |
|
115 |
) |
|
116 |
#(#MenuItem |
|
117 |
#label: '-' |
|
118 |
) |
|
119 |
#(#MenuItem |
|
120 |
#label: 'Save As...' |
|
121 |
#translateLabel: true |
|
122 |
#value: #menuSaveAs |
|
123 |
) |
|
124 |
#(#MenuItem |
|
125 |
#label: '-' |
|
126 |
) |
|
127 |
#(#MenuItem |
|
128 |
#label: 'Exit' |
|
129 |
#translateLabel: true |
|
130 |
#value: #closeRequest |
|
131 |
) |
|
132 |
) |
|
133 |
nil |
|
134 |
nil |
|
135 |
) |
|
136 |
) |
|
137 |
#(#MenuItem |
|
3736 | 138 |
#label: 'Buffers' |
3193 | 139 |
#translateLabel: true |
3651 | 140 |
#nameKey: #Buffer |
3193 | 141 |
#submenu: |
142 |
#(#Menu |
|
143 |
#( |
|
144 |
#(#MenuItem |
|
3222 | 145 |
#label: 'Add Buffer' |
3193 | 146 |
#translateLabel: true |
147 |
#value: #addWorkspace |
|
148 |
) |
|
149 |
#(#MenuItem |
|
150 |
#label: 'Rename...' |
|
151 |
#translateLabel: true |
|
152 |
#value: #renameWorkspace |
|
153 |
) |
|
154 |
#(#MenuItem |
|
155 |
#label: '-' |
|
156 |
) |
|
157 |
#(#MenuItem |
|
3222 | 158 |
#label: 'Remove Buffer' |
3193 | 159 |
#translateLabel: true |
160 |
#value: #removeWorkspace |
|
161 |
#enabled: #canRemoveWorkspace |
|
162 |
) |
|
163 |
) |
|
164 |
nil |
|
165 |
nil |
|
166 |
) |
|
167 |
) |
|
168 |
#(#MenuItem |
|
3154 | 169 |
#label: 'Edit' |
170 |
#translateLabel: true |
|
171 |
#submenu: |
|
172 |
#(#Menu |
|
173 |
#( |
|
174 |
#(#MenuItem |
|
175 |
#label: 'Copy' |
|
176 |
#translateLabel: true |
|
177 |
#value: #copySelection |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
178 |
#enabled: #hasSelectionInActiveWorkspace |
3154 | 179 |
) |
180 |
#(#MenuItem |
|
181 |
#label: 'Cut' |
|
182 |
#translateLabel: true |
|
183 |
#value: #cutSelection |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
184 |
#enabled: #hasSelectionInActiveWorkspace |
3154 | 185 |
) |
186 |
#(#MenuItem |
|
187 |
#label: 'Paste' |
|
188 |
#translateLabel: true |
|
189 |
#value: #paste |
|
190 |
) |
|
191 |
) |
|
192 |
nil |
|
193 |
nil |
|
194 |
) |
|
195 |
) |
|
196 |
#(#MenuItem |
|
3722 | 197 |
#label: 'Workspace' |
198 |
#translateLabel: true |
|
199 |
#submenu: |
|
200 |
#(#Menu |
|
201 |
#( |
|
202 |
#(#MenuItem |
|
203 |
#label: 'Add Workspace Variable...' |
|
204 |
#translateLabel: true |
|
205 |
#value: #addWorkspaceVariable |
|
206 |
) |
|
207 |
#(#MenuItem |
|
208 |
#label: 'Remove Workspace Variable...' |
|
209 |
#translateLabel: true |
|
210 |
#value: #removeWorkspaceVariable |
|
211 |
) |
|
212 |
#(#MenuItem |
|
213 |
#label: '-' |
|
214 |
) |
|
215 |
#(#MenuItem |
|
216 |
#label: 'Remove all Workspace Variables...' |
|
217 |
#translateLabel: true |
|
218 |
#value: #removeAllWorkspaceVariables |
|
219 |
) |
|
220 |
#(#MenuItem |
|
221 |
#label: 'Settings' |
|
222 |
#translateLabel: true |
|
223 |
#isVisible: false |
|
224 |
#submenu: |
|
225 |
#(#Menu |
|
226 |
#( |
|
227 |
#(#MenuItem |
|
228 |
#label: 'Autodefine Workspace Variables' |
|
229 |
#translateLabel: true |
|
230 |
#indication: #autoDefineWorkspaceVariables |
|
231 |
) |
|
232 |
) |
|
233 |
nil |
|
234 |
nil |
|
235 |
) |
|
236 |
) |
|
237 |
) |
|
238 |
nil |
|
239 |
nil |
|
240 |
) |
|
241 |
) |
|
242 |
#(#MenuItem |
|
3154 | 243 |
#label: 'Smalltalk' |
244 |
#translateLabel: true |
|
245 |
#submenu: |
|
246 |
#(#Menu |
|
247 |
#( |
|
248 |
#(#MenuItem |
|
249 |
#label: 'DoIt' |
|
250 |
#translateLabel: true |
|
251 |
#value: #doIt |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
252 |
#enabled: #hasSelectionInActiveWorkspace |
3154 | 253 |
) |
254 |
#(#MenuItem |
|
255 |
#label: 'PrintIt' |
|
256 |
#translateLabel: true |
|
257 |
#value: #printIt |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
258 |
#enabled: #hasSelectionInActiveWorkspace |
3154 | 259 |
) |
260 |
#(#MenuItem |
|
261 |
#label: 'InspectIt' |
|
262 |
#translateLabel: true |
|
263 |
#value: #inspectIt |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
264 |
#enabled: #hasSelectionInActiveWorkspace |
3154 | 265 |
) |
266 |
#(#MenuItem |
|
267 |
#label: '-' |
|
268 |
) |
|
269 |
#(#MenuItem |
|
3384 | 270 |
#label: 'TimeIt' |
271 |
#translateLabel: true |
|
272 |
#value: #timeIt |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
273 |
#enabled: #hasSelectionInActiveWorkspace |
3384 | 274 |
) |
275 |
#(#MenuItem |
|
276 |
#label: 'SpyOnIt' |
|
277 |
#translateLabel: true |
|
278 |
#value: #spyOnIt |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
279 |
#enabled: #hasSelectionInActiveWorkspace |
3384 | 280 |
) |
281 |
#(#MenuItem |
|
282 |
#label: '-' |
|
283 |
) |
|
284 |
#(#MenuItem |
|
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
285 |
#label: 'Browse Class' |
3154 | 286 |
#translateLabel: true |
287 |
#value: #browseIt |
|
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
288 |
#enabled: #hasSelectionInActiveWorkspace |
3154 | 289 |
) |
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
290 |
#(#MenuItem |
3710 | 291 |
#label: 'Browse Implementors of It' |
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
292 |
#translateLabel: true |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
293 |
#value: #browseImplementorsOfIt |
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
294 |
#enabled: #hasSelectionInActiveWorkspace |
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
295 |
) |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
296 |
#(#MenuItem |
3710 | 297 |
#label: 'Browse References to It' |
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
298 |
#translateLabel: true |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
299 |
#value: #browseReferencesToIt |
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
300 |
#enabled: #hasSelectionInActiveWorkspace |
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
301 |
) |
3154 | 302 |
) |
303 |
nil |
|
304 |
nil |
|
305 |
) |
|
306 |
) |
|
307 |
#(#MenuItem |
|
308 |
#label: 'Help' |
|
309 |
#translateLabel: true |
|
310 |
#startGroup: #right |
|
311 |
#submenu: |
|
312 |
#(#Menu |
|
313 |
#( |
|
314 |
#(#MenuItem |
|
315 |
#label: 'Documentation' |
|
316 |
#translateLabel: true |
|
317 |
#value: #openDocumentation |
|
318 |
) |
|
319 |
#(#MenuItem |
|
320 |
#label: '-' |
|
321 |
) |
|
322 |
#(#MenuItem |
|
3282 | 323 |
#label: 'About this Application...' |
3154 | 324 |
#translateLabel: true |
325 |
#value: #openAboutThisApplication |
|
326 |
) |
|
327 |
) |
|
328 |
nil |
|
329 |
nil |
|
330 |
) |
|
331 |
) |
|
332 |
) |
|
333 |
nil |
|
334 |
nil |
|
335 |
) |
|
3193 | 336 |
! |
337 |
||
338 |
tabMenu |
|
339 |
"This resource specification was automatically generated |
|
340 |
by the MenuEditor of ST/X." |
|
341 |
||
342 |
"Do not manually edit this!! If it is corrupted, |
|
343 |
the MenuEditor may not be able to read the specification." |
|
344 |
||
345 |
" |
|
346 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#tabMenu |
|
347 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication tabMenu)) startUp |
|
348 |
" |
|
349 |
||
350 |
<resource: #menu> |
|
351 |
||
352 |
^ |
|
353 |
#(#Menu |
|
354 |
#( |
|
355 |
#(#MenuItem |
|
3222 | 356 |
#label: 'Add Buffer' |
3193 | 357 |
#translateLabel: true |
3651 | 358 |
"/ #triggerOnDown: true |
3193 | 359 |
#value: #addWorkspace |
360 |
) |
|
361 |
#(#MenuItem |
|
362 |
#label: 'Rename...' |
|
363 |
#translateLabel: true |
|
3651 | 364 |
"/ #triggerOnDown: true |
3193 | 365 |
#value: #renameWorkspace: |
366 |
) |
|
367 |
#(#MenuItem |
|
368 |
#label: '-' |
|
369 |
) |
|
370 |
#(#MenuItem |
|
3222 | 371 |
#label: 'Remove Buffer' |
3193 | 372 |
#translateLabel: true |
3651 | 373 |
"/ #triggerOnDown: true |
3193 | 374 |
#value: #removeWorkspace: |
375 |
#enabled: #canRemoveWorkspace: |
|
376 |
) |
|
377 |
) |
|
378 |
nil |
|
379 |
nil |
|
380 |
) |
|
3154 | 381 |
! ! |
382 |
||
3332 | 383 |
!WorkspaceApplication class methodsFor:'special startup'! |
384 |
||
385 |
openSystemWorkspace |
|
3345 | 386 |
|wsApp licenceView path needRemove| |
387 |
||
388 |
needRemove := true. |
|
3332 | 389 |
|
390 |
wsApp := self new. |
|
391 |
wsApp allButOpen. |
|
3337 | 392 |
wsApp window extent:640@400. |
3332 | 393 |
|
3345 | 394 |
path := (Smalltalk getSystemFileName:'README') ? '../../README'. |
3532
e38c9dd404a2
care for missing workspace files
Claus Gittinger <cg@exept.de>
parents:
3507
diff
changeset
|
395 |
(path notNil and:[path asFilename exists]) ifTrue:[ |
3345 | 396 |
wsApp addWindow:(HVScrollableView for:Workspace) named:'README' asFirst:false. |
397 |
wsApp loadFile:path. |
|
398 |
wsApp removeWorkspace:1. "/ the original Workspace |
|
399 |
needRemove := false. |
|
400 |
]. |
|
3334 | 401 |
|
3346 | 402 |
"/ path := (Smalltalk getSystemFileName:'doc/online/english/LICENCE_STX.html') ? '../../doc/online/english/LICENCE_STX.html'. |
403 |
"/ path asFilename exists ifTrue:[ |
|
404 |
"/ wsApp addWindow:(licenceView := HVScrollableView for:HTMLDocumentView) named:'License' asFirst:false. |
|
405 |
"/ licenceView homeDocument:'../../doc/online/english/LICENCE_STX.html'. |
|
406 |
"/ licenceView updateLabelFlag:false. |
|
407 |
"/ needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
|
408 |
"/ needRemove := false. |
|
409 |
"/ ]. |
|
3332 | 410 |
|
3347 | 411 |
path := (Smalltalk getSystemFileName:'Keyboard.wsp'). |
3532
e38c9dd404a2
care for missing workspace files
Claus Gittinger <cg@exept.de>
parents:
3507
diff
changeset
|
412 |
(path notNil and:[path asFilename exists]) ifTrue:[ |
3345 | 413 |
wsApp addWindow:(HVScrollableView for:Workspace) named:'Keyboard' asFirst:false. |
414 |
wsApp loadFile:path. |
|
415 |
needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
|
416 |
needRemove := false. |
|
417 |
]. |
|
3332 | 418 |
|
3347 | 419 |
path := (Smalltalk getSystemFileName:'Hello.wsp'). |
3532
e38c9dd404a2
care for missing workspace files
Claus Gittinger <cg@exept.de>
parents:
3507
diff
changeset
|
420 |
(path notNil and:[path asFilename exists]) ifTrue:[ |
3345 | 421 |
wsApp addWindow:(HVScrollableView for:Workspace) named:'Welcome' asFirst:false. |
422 |
wsApp loadFile:path. |
|
423 |
needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
|
424 |
needRemove := false. |
|
425 |
]. |
|
3332 | 426 |
|
427 |
wsApp openWindow |
|
428 |
||
429 |
" |
|
430 |
self openSystemWorkspace |
|
431 |
" |
|
432 |
! ! |
|
433 |
||
3154 | 434 |
!WorkspaceApplication methodsFor:'accessing'! |
435 |
||
3193 | 436 |
selectedWorkspace |
437 |
|wsIndex| |
|
438 |
||
439 |
workspaces isNil ifTrue:[ |
|
440 |
workspaces := OrderedCollection new. |
|
441 |
]. |
|
442 |
wsIndex := self selectedWorkspaceIndexHolder value. |
|
443 |
wsIndex == 0 ifTrue:[ |
|
444 |
^ nil |
|
445 |
]. |
|
446 |
||
447 |
workspaces size < wsIndex ifTrue:[ |
|
448 |
workspaces grow:wsIndex. |
|
449 |
workspaces at:wsIndex put:(HVScrollableView for:Workspace). |
|
450 |
]. |
|
451 |
^ workspaces at:wsIndex |
|
452 |
! |
|
453 |
||
454 |
tabMenuAt:index |
|
3196 | 455 |
|m i ws| |
3193 | 456 |
|
457 |
m := self class tabMenu. |
|
458 |
m := m decodeAsLiteralArray. |
|
459 |
i := m detectItem:[:item | item value == #removeWorkspace:] ifNone:nil. |
|
460 |
i notNil ifTrue:[ |
|
461 |
i argument:index. |
|
462 |
index ~~ self selectedWorkspaceIndexHolder value ifTrue:[ |
|
463 |
"/ for now: if that buffer is modified, |
|
464 |
"/ do not allow removing. |
|
465 |
"/ (must be brought to front, in order for check-for-modification to work) |
|
3196 | 466 |
ws := workspaces at:index. |
467 |
(ws isKindOf:ScrollableView) ifTrue:[ |
|
468 |
ws := ws scrolledView |
|
469 |
]. |
|
470 |
((ws isKindOf:TextView) not |
|
471 |
or:[ ws modified ]) |
|
472 |
ifTrue:[ |
|
3193 | 473 |
i disable |
474 |
]. |
|
475 |
]. |
|
476 |
]. |
|
477 |
i := m detectItem:[:item | item value == #renameWorkspace:] ifNone:nil. |
|
478 |
i notNil ifTrue:[ |
|
479 |
i argument:index. |
|
480 |
]. |
|
481 |
||
482 |
m findGuiResourcesIn:self. |
|
483 |
^ m |
|
484 |
! |
|
485 |
||
486 |
workspaceHolder |
|
487 |
workspaceHolder isNil ifTrue:[ |
|
3207 | 488 |
workspaceHolder := ValueHolder with:(self selectedWorkspace). |
3193 | 489 |
]. |
490 |
^ workspaceHolder |
|
491 |
! ! |
|
492 |
||
493 |
!WorkspaceApplication methodsFor:'aspects'! |
|
494 |
||
3667 | 495 |
autoDefineWorkspaceVariables |
496 |
"does not work yet - needs more interaction with parser" |
|
497 |
||
498 |
autoDefineWorkspaceVariables isNil ifTrue:[ |
|
499 |
autoDefineWorkspaceVariables := DefaultAutoDefineWorkspaceVariables asValue. |
|
500 |
autoDefineWorkspaceVariables onChangeSend:#autoDefineWorkspaceVariablesChanged to:self. |
|
501 |
]. |
|
502 |
^ autoDefineWorkspaceVariables. |
|
503 |
! |
|
504 |
||
3193 | 505 |
selectedWorkspaceIndexHolder |
506 |
selectedWorkspaceIndexHolder isNil ifTrue:[ |
|
507 |
selectedWorkspaceIndexHolder := 1 asValue. |
|
508 |
selectedWorkspaceIndexHolder onChangeSend:#workspaceSelectionChanged to:self. |
|
509 |
]. |
|
510 |
^ selectedWorkspaceIndexHolder. |
|
511 |
! |
|
512 |
||
513 |
tabList |
|
514 |
tabList isNil ifTrue:[ |
|
515 |
tabList := List new. |
|
516 |
]. |
|
517 |
^ tabList. |
|
518 |
! ! |
|
519 |
||
520 |
!WorkspaceApplication methodsFor:'aspects - queries'! |
|
521 |
||
522 |
canRemoveWorkspace |
|
3214 | 523 |
^ self canRemoveWorkspace:(self selectedWorkspaceIndexHolder value) |
524 |
! |
|
525 |
||
526 |
canRemoveWorkspace:idx |
|
3193 | 527 |
^ self tabList size > 1 |
3214 | 528 |
"/ and:[ (self workspacesTextViewAt:(self selectedWorkspaceIndexHolder value)) |
3391
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
529 |
! |
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
530 |
|
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
531 |
hasSelectionInActiveWorkspace |
09fd110d1ea4
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
3384
diff
changeset
|
532 |
^ self selectedWorkspacesTextView selectionAsString size > 0 |
3154 | 533 |
! ! |
534 |
||
535 |
!WorkspaceApplication methodsFor:'initialization & release'! |
|
536 |
||
537 |
closeRequest |
|
3193 | 538 |
(self askIfModified:'Text was modified. Close anyway ?' yesButton:'Close') ifFalse:[ |
3154 | 539 |
^ self |
540 |
]. |
|
541 |
||
542 |
^ super closeRequest |
|
543 |
! ! |
|
544 |
||
545 |
!WorkspaceApplication methodsFor:'menu actions'! |
|
546 |
||
3196 | 547 |
addWindow:aWindow named:name |
3334 | 548 |
self addWindow:aWindow named:name asFirst:false |
549 |
! |
|
550 |
||
551 |
addWindow:aWindow named:name asFirst:asFirst |
|
552 |
|tabList wsIndex newSelectedIndex| |
|
3193 | 553 |
|
554 |
tabList := self tabList. |
|
555 |
wsIndex := tabList size + 1. |
|
556 |
wsIndex == 1 ifTrue:[ |
|
557 |
"/ first - add a name for the first tab |
|
558 |
tabList add:(self window label). "/ 'Workspace'. |
|
559 |
wsIndex := wsIndex + 1. |
|
560 |
]. |
|
561 |
||
562 |
workspaces grow:wsIndex. |
|
3334 | 563 |
asFirst ifTrue:[ |
564 |
tabList addFirst:(name bindWith:wsIndex). |
|
565 |
workspaces replaceFrom:2 to:wsIndex with:workspaces startingAt:1. |
|
566 |
newSelectedIndex := 1. |
|
567 |
] ifFalse:[ |
|
568 |
tabList addLast:(name bindWith:wsIndex). |
|
569 |
newSelectedIndex := wsIndex. |
|
570 |
]. |
|
571 |
workspaces at:newSelectedIndex put:aWindow. |
|
572 |
self selectedWorkspaceIndexHolder value:newSelectedIndex. |
|
573 |
"/ workspaceHolder value:aWindow. |
|
3193 | 574 |
! |
575 |
||
3196 | 576 |
addWorkspace |
577 |
self addWindow:(HVScrollableView for:Workspace) named:'Workspace%1' |
|
578 |
! |
|
579 |
||
3722 | 580 |
addWorkspaceVariable |
581 |
|name selection| |
|
582 |
||
583 |
selection := self selectedWorkspacesTextView selection ? ''. |
|
584 |
||
585 |
name := Dialog |
|
586 |
request:'Name of new Workspace Variable:' |
|
587 |
initialAnswer:(selection asString string) |
|
588 |
okLabel:'Add' |
|
589 |
title:'Enter Variable Name'. |
|
590 |
name size == 0 ifTrue:[ |
|
591 |
^ self |
|
592 |
]. |
|
593 |
Workspace addWorkspaceVariable:name. |
|
594 |
! |
|
595 |
||
3667 | 596 |
autoDefineWorkspaceVariablesChanged |
597 |
"does not work yet - needs more interaction with parser" |
|
598 |
||
599 |
|doAutoDefine| |
|
600 |
||
601 |
doAutoDefine := autoDefineWorkspaceVariables value. |
|
602 |
||
603 |
DefaultAutoDefineWorkspaceVariables := doAutoDefine. |
|
604 |
workspaces do:[:each | |
|
605 |
each autoDefineWorkspaceVariables:doAutoDefine |
|
606 |
]. |
|
607 |
! |
|
608 |
||
3198 | 609 |
basicInspectIt |
610 |
self inspectIt:true |
|
611 |
! |
|
612 |
||
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
613 |
browseImplementorsOfIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
614 |
self selectedWorkspacesTextView browseImplementorsOfIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
615 |
! |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
616 |
|
3154 | 617 |
browseIt |
3198 | 618 |
self selectedWorkspacesTextView browseIt |
3154 | 619 |
! |
620 |
||
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
621 |
browseReferencesToIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
622 |
self selectedWorkspacesTextView browseReferencesToIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
623 |
! |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
624 |
|
3154 | 625 |
copySelection |
3198 | 626 |
self selectedWorkspacesTextView copySelection |
3154 | 627 |
! |
628 |
||
629 |
cutSelection |
|
3198 | 630 |
self selectedWorkspacesTextView cutSelection |
3154 | 631 |
! |
632 |
||
633 |
doIt |
|
3198 | 634 |
self selectedWorkspacesTextView doIt |
3154 | 635 |
! |
636 |
||
637 |
inspectIt |
|
3198 | 638 |
self inspectIt:false |
639 |
! |
|
640 |
||
641 |
inspectIt:basic |
|
3196 | 642 |
|ws obj v| |
643 |
||
3198 | 644 |
ws := self selectedWorkspacesTextView. |
3196 | 645 |
ws |
646 |
do:(ws selection) |
|
647 |
withValueDo:[:result | |
|
3208 | 648 |
| cls resultString| |
3196 | 649 |
|
3198 | 650 |
basic ifFalse:[ |
651 |
cls := result inspectorClass. |
|
652 |
]. |
|
3196 | 653 |
cls isNil ifTrue:[ |
654 |
cls := InspectorView |
|
655 |
]. |
|
656 |
v := cls new. |
|
657 |
v inspect:result. |
|
3208 | 658 |
"/ v allowFollow:true. |
659 |
result isBehavior ifTrue:[ |
|
660 |
resultString := result name |
|
661 |
] ifFalse:[ |
|
662 |
resultString := result classNameWithArticle |
|
663 |
]. |
|
664 |
self addWindow:v named:('Inspecting: ' , resultString). |
|
3196 | 665 |
] |
666 |
||
667 |
"/ self selectedWorkspace inspectIt |
|
3154 | 668 |
! |
669 |
||
3332 | 670 |
loadFile:aFileName |
671 |
|file ws lbl| |
|
672 |
||
673 |
file := aFileName asFilename. |
|
3507 | 674 |
(ws := self selectedWorkspacesTextView) contents:file contents. |
3332 | 675 |
ws modified:false. |
676 |
||
677 |
lbl := file withoutSuffix baseName. |
|
678 |
tabList size <= 1 ifTrue:[ |
|
679 |
self window label:lbl. |
|
680 |
] ifFalse:[ |
|
681 |
tabList at:self selectedWorkspaceIndexHolder value put:lbl |
|
682 |
] |
|
683 |
! |
|
684 |
||
3154 | 685 |
menuLoad |
3332 | 686 |
|file| |
3154 | 687 |
|
3193 | 688 |
(self askIfModified:'Text was modified. Load anyway ?' yesButton:'Load') ifFalse:[ ^ self]. |
689 |
||
3469 | 690 |
file := Dialog requestFileName:'Load file:' default:'file.wsp' pattern:'*.wsp'. |
3154 | 691 |
file size > 0 ifTrue:[ |
3332 | 692 |
self loadFile:file |
3154 | 693 |
] |
694 |
! |
|
695 |
||
696 |
menuSaveAs |
|
3473
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
697 |
|file ws doAppend| |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
698 |
|
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
699 |
doAppend := false. |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
700 |
Dialog aboutToOpenBoxNotificationSignal handle:[:n | |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
701 |
|box| |
3154 | 702 |
|
3473
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
703 |
box := n parameter. |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
704 |
box addButton:(Button label:'Append' |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
705 |
action:[doAppend := true. box okPressed]). |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
706 |
n proceed. |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
707 |
] do:[ |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
708 |
file := Dialog requestFileName:'Save file:' default:'file.wsp'. |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
709 |
]. |
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
710 |
|
3154 | 711 |
file size > 0 ifTrue:[ |
3473
1120657c3d2e
added Append-option to saveAs
Claus Gittinger <cg@exept.de>
parents:
3469
diff
changeset
|
712 |
(ws := self selectedWorkspacesTextView) saveAs:file doAppend:doAppend. |
3193 | 713 |
ws modified:false. |
3154 | 714 |
] |
715 |
! |
|
716 |
||
3334 | 717 |
newSystemWorkspace |
718 |
self class openSystemWorkspace |
|
719 |
! |
|
720 |
||
3651 | 721 |
newWorkspace |
722 |
self class open |
|
723 |
! |
|
724 |
||
3154 | 725 |
openDocumentation |
726 |
"opens the documentation file" |
|
727 |
||
728 |
self openHTMLDocument: 'tools/misc/TOP.html#WORKSPACE' |
|
729 |
! |
|
730 |
||
731 |
paste |
|
3198 | 732 |
self selectedWorkspacesTextView paste |
3154 | 733 |
! |
734 |
||
735 |
printIt |
|
3198 | 736 |
self selectedWorkspacesTextView printIt |
3193 | 737 |
! |
738 |
||
3722 | 739 |
removeAllWorkspaceVariables |
740 |
(Dialog confirm:'Do you really want to remove all Workspace Variables ?') |
|
741 |
ifTrue:[ |
|
742 |
Workspace removeAllWorkspaceVariables |
|
743 |
]. |
|
744 |
! |
|
745 |
||
3193 | 746 |
removeWorkspace |
747 |
self removeWorkspace:(self selectedWorkspaceIndexHolder value) |
|
748 |
! |
|
749 |
||
750 |
removeWorkspace:wsIndex |
|
751 |
|tabList newWsIndex| |
|
752 |
||
753 |
wsIndex == self selectedWorkspaceIndexHolder value ifTrue:[ |
|
754 |
(self askIfModified:'Text was modified. Remove anyway ?' yesButton:'Remove') ifFalse:[ |
|
755 |
^ self |
|
756 |
]. |
|
757 |
]. |
|
758 |
||
759 |
tabList := self tabList. |
|
760 |
||
761 |
wsIndex == tabList size ifTrue:[ |
|
762 |
newWsIndex := wsIndex - 1. |
|
763 |
] ifFalse:[ |
|
764 |
newWsIndex := wsIndex. |
|
765 |
]. |
|
766 |
||
767 |
tabList removeIndex:wsIndex. |
|
768 |
(workspaces at:wsIndex) destroy. |
|
769 |
workspaces removeIndex:wsIndex. |
|
770 |
||
771 |
tabList size == 1 ifTrue:[ |
|
772 |
self window label:(tabList at:1). |
|
773 |
tabList removeIndex:1 |
|
774 |
]. |
|
775 |
||
3334 | 776 |
workspaceHolder value:(workspaces at:newWsIndex). |
3193 | 777 |
self selectedWorkspaceIndexHolder value:newWsIndex. |
778 |
"/ to force change (update workspaceHolder - even if same index) |
|
779 |
self selectedWorkspaceIndexHolder changed:#value. |
|
780 |
! |
|
781 |
||
3722 | 782 |
removeWorkspaceVariable |
783 |
|name selection| |
|
784 |
||
785 |
selection := self selectedWorkspacesTextView selection ? ''. |
|
786 |
||
787 |
name := Dialog |
|
788 |
request:'Variable to remove:' |
|
789 |
initialAnswer:(selection asString string) |
|
790 |
okLabel:'Remove' |
|
791 |
title:'Enter Variable Name' |
|
792 |
list:(Workspace workspaceVariables keys asOrderedCollection sort). |
|
793 |
name size == 0 ifTrue:[ |
|
794 |
^ self |
|
795 |
]. |
|
796 |
Workspace removeWorkspaceVariable:name. |
|
797 |
! |
|
798 |
||
3193 | 799 |
renameWorkspace |
800 |
self renameWorkspace:(self selectedWorkspaceIndexHolder value) |
|
801 |
! |
|
802 |
||
803 |
renameWorkspace:wsIndex |
|
804 |
|tabList oldName newName| |
|
805 |
||
806 |
tabList := self tabList. |
|
807 |
tabList isEmpty ifTrue:[ |
|
808 |
oldName := self window label |
|
809 |
] ifFalse:[ |
|
810 |
oldName := tabList at:wsIndex. |
|
811 |
]. |
|
812 |
newName := Dialog request:(resources string:'New Name for %1:' with:oldName) initialAnswer:oldName. |
|
813 |
newName size == 0 ifTrue:[ ^ self]. |
|
814 |
||
815 |
tabList notEmpty ifTrue:[ |
|
816 |
tabList at:wsIndex put:newName. |
|
817 |
]. |
|
818 |
wsIndex == self selectedWorkspaceIndexHolder value ifTrue:[ |
|
819 |
self window label:newName. |
|
820 |
]. |
|
3384 | 821 |
! |
822 |
||
823 |
spyOnIt |
|
824 |
self selectedWorkspacesTextView spyOnIt |
|
825 |
! |
|
826 |
||
827 |
timeIt |
|
828 |
self selectedWorkspacesTextView timeIt |
|
3154 | 829 |
! ! |
830 |
||
831 |
!WorkspaceApplication methodsFor:'private'! |
|
832 |
||
833 |
askIfModified:question yesButton:yesButtonText |
|
834 |
"tell user, that code has been modified - let her confirm" |
|
835 |
||
836 |
|textView| |
|
837 |
||
3193 | 838 |
textView := self selectedWorkspace. |
3196 | 839 |
(textView isKindOf:ScrollableView) ifTrue:[ |
840 |
textView := textView scrolledView |
|
841 |
]. |
|
842 |
(textView isKindOf:TextView) ifFalse:[ |
|
843 |
^ true |
|
844 |
]. |
|
845 |
(textView modified not |
|
846 |
or:[textView contentsWasSaved |
|
847 |
or:[textView contents withoutSeparators isEmpty]]) ifTrue:[ |
|
3154 | 848 |
^ true |
849 |
]. |
|
850 |
(Dialog |
|
851 |
confirm:(resources string:question) withCRs |
|
852 |
yesLabel:(resources at:yesButtonText) |
|
853 |
noLabel:(resources at:'Cancel')) |
|
854 |
ifTrue:[ |
|
855 |
"/ reset modified flag so question is asked only once |
|
856 |
textView modified:false. |
|
857 |
^ true |
|
858 |
]. |
|
859 |
^ false |
|
860 |
||
861 |
"Modified: 2.10.1997 / 14:23:47 / stefan" |
|
3193 | 862 |
! |
863 |
||
3198 | 864 |
selectedWorkspacesTextView |
865 |
|textView| |
|
866 |
||
867 |
textView := self selectedWorkspace. |
|
868 |
(textView isKindOf:ScrollableView) ifTrue:[ |
|
869 |
textView := textView scrolledView |
|
870 |
]. |
|
871 |
(textView isKindOf:TextView) ifTrue:[ |
|
872 |
^ textView |
|
873 |
]. |
|
874 |
^ textView workspace |
|
875 |
! |
|
876 |
||
3193 | 877 |
workspaceSelectionChanged |
3334 | 878 |
|wsIndex windowLabel v| |
3193 | 879 |
|
880 |
"/ self selected |
|
3334 | 881 |
self workspaceHolder value:(v := self selectedWorkspace). |
3193 | 882 |
wsIndex := self selectedWorkspaceIndexHolder value. |
883 |
||
884 |
wsIndex ~~ 0 ifTrue:[ |
|
885 |
windowLabel := tabList at:wsIndex ifAbsent:nil. |
|
886 |
windowLabel notNil ifTrue:[self window label:windowLabel]. |
|
887 |
]. |
|
3154 | 888 |
! ! |
889 |
||
890 |
!WorkspaceApplication class methodsFor:'documentation'! |
|
891 |
||
892 |
version |
|
3736 | 893 |
^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.33 2002-07-17 15:47:38 cg Exp $' |
3154 | 894 |
! ! |