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