author | Claus Gittinger <cg@exept.de> |
Fri, 09 Nov 2001 12:20:13 +0100 | |
changeset 3383 | fb3b6909bd1a |
parent 3347 | ee907655178a |
child 3384 | 2be2f7e2a417 |
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 |
|
194 |
) |
|
195 |
#(#MenuItem |
|
196 |
#label: 'Cut' |
|
197 |
#translateLabel: true |
|
198 |
#value: #cutSelection |
|
199 |
) |
|
200 |
#(#MenuItem |
|
201 |
#label: 'Paste' |
|
202 |
#translateLabel: true |
|
203 |
#value: #paste |
|
204 |
) |
|
205 |
) |
|
206 |
nil |
|
207 |
nil |
|
208 |
) |
|
209 |
) |
|
210 |
#(#MenuItem |
|
211 |
#label: 'Smalltalk' |
|
212 |
#translateLabel: true |
|
213 |
#submenu: |
|
214 |
#(#Menu |
|
215 |
#( |
|
216 |
#(#MenuItem |
|
217 |
#label: 'DoIt' |
|
218 |
#translateLabel: true |
|
219 |
#value: #doIt |
|
220 |
) |
|
221 |
#(#MenuItem |
|
222 |
#label: 'PrintIt' |
|
223 |
#translateLabel: true |
|
224 |
#value: #printIt |
|
225 |
) |
|
226 |
#(#MenuItem |
|
227 |
#label: 'InspectIt' |
|
228 |
#translateLabel: true |
|
229 |
#value: #inspectIt |
|
230 |
) |
|
231 |
#(#MenuItem |
|
232 |
#label: '-' |
|
233 |
) |
|
234 |
#(#MenuItem |
|
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
235 |
#label: 'Browse Class' |
3154 | 236 |
#translateLabel: true |
237 |
#value: #browseIt |
|
238 |
) |
|
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
239 |
#(#MenuItem |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
240 |
#label: 'Browse Implementors of it' |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
241 |
#translateLabel: true |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
242 |
#value: #browseImplementorsOfIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
243 |
) |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
244 |
#(#MenuItem |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
245 |
#label: 'Browse References to it' |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
246 |
#translateLabel: true |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
247 |
#value: #browseReferencesToIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
248 |
) |
3154 | 249 |
) |
250 |
nil |
|
251 |
nil |
|
252 |
) |
|
253 |
) |
|
254 |
#(#MenuItem |
|
255 |
#label: 'Help' |
|
256 |
#translateLabel: true |
|
257 |
#startGroup: #right |
|
258 |
#submenu: |
|
259 |
#(#Menu |
|
260 |
#( |
|
261 |
#(#MenuItem |
|
262 |
#label: 'Documentation' |
|
263 |
#translateLabel: true |
|
264 |
#value: #openDocumentation |
|
265 |
) |
|
266 |
#(#MenuItem |
|
267 |
#label: '-' |
|
268 |
) |
|
269 |
#(#MenuItem |
|
3282 | 270 |
#label: 'About this Application...' |
3154 | 271 |
#translateLabel: true |
272 |
#value: #openAboutThisApplication |
|
273 |
) |
|
274 |
) |
|
275 |
nil |
|
276 |
nil |
|
277 |
) |
|
278 |
) |
|
279 |
) |
|
280 |
nil |
|
281 |
nil |
|
282 |
) |
|
3193 | 283 |
! |
284 |
||
285 |
tabMenu |
|
286 |
"This resource specification was automatically generated |
|
287 |
by the MenuEditor of ST/X." |
|
288 |
||
289 |
"Do not manually edit this!! If it is corrupted, |
|
290 |
the MenuEditor may not be able to read the specification." |
|
291 |
||
292 |
" |
|
293 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#tabMenu |
|
294 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication tabMenu)) startUp |
|
295 |
" |
|
296 |
||
297 |
<resource: #menu> |
|
298 |
||
299 |
^ |
|
300 |
#(#Menu |
|
301 |
#( |
|
302 |
#(#MenuItem |
|
3222 | 303 |
#label: 'Add Buffer' |
3193 | 304 |
#translateLabel: true |
305 |
#triggerOnDown: true |
|
306 |
#value: #addWorkspace |
|
307 |
) |
|
308 |
#(#MenuItem |
|
309 |
#label: 'Rename...' |
|
310 |
#translateLabel: true |
|
311 |
#triggerOnDown: true |
|
312 |
#value: #renameWorkspace: |
|
313 |
) |
|
314 |
#(#MenuItem |
|
315 |
#label: '-' |
|
316 |
) |
|
317 |
#(#MenuItem |
|
3222 | 318 |
#label: 'Remove Buffer' |
3193 | 319 |
#translateLabel: true |
320 |
#triggerOnDown: true |
|
321 |
#value: #removeWorkspace: |
|
322 |
#enabled: #canRemoveWorkspace: |
|
323 |
) |
|
324 |
) |
|
325 |
nil |
|
326 |
nil |
|
327 |
) |
|
3154 | 328 |
! ! |
329 |
||
3332 | 330 |
!WorkspaceApplication class methodsFor:'special startup'! |
331 |
||
332 |
openSystemWorkspace |
|
3345 | 333 |
|wsApp licenceView path needRemove| |
334 |
||
335 |
needRemove := true. |
|
3332 | 336 |
|
337 |
wsApp := self new. |
|
338 |
wsApp allButOpen. |
|
3337 | 339 |
wsApp window extent:640@400. |
3332 | 340 |
|
3345 | 341 |
path := (Smalltalk getSystemFileName:'README') ? '../../README'. |
342 |
path asFilename exists ifTrue:[ |
|
343 |
wsApp addWindow:(HVScrollableView for:Workspace) named:'README' asFirst:false. |
|
344 |
wsApp loadFile:path. |
|
345 |
wsApp removeWorkspace:1. "/ the original Workspace |
|
346 |
needRemove := false. |
|
347 |
]. |
|
3334 | 348 |
|
3346 | 349 |
"/ path := (Smalltalk getSystemFileName:'doc/online/english/LICENCE_STX.html') ? '../../doc/online/english/LICENCE_STX.html'. |
350 |
"/ path asFilename exists ifTrue:[ |
|
351 |
"/ wsApp addWindow:(licenceView := HVScrollableView for:HTMLDocumentView) named:'License' asFirst:false. |
|
352 |
"/ licenceView homeDocument:'../../doc/online/english/LICENCE_STX.html'. |
|
353 |
"/ licenceView updateLabelFlag:false. |
|
354 |
"/ needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
|
355 |
"/ needRemove := false. |
|
356 |
"/ ]. |
|
3332 | 357 |
|
3347 | 358 |
path := (Smalltalk getSystemFileName:'Keyboard.wsp'). |
3345 | 359 |
path asFilename exists ifTrue:[ |
360 |
wsApp addWindow:(HVScrollableView for:Workspace) named:'Keyboard' asFirst:false. |
|
361 |
wsApp loadFile:path. |
|
362 |
needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
|
363 |
needRemove := false. |
|
364 |
]. |
|
3332 | 365 |
|
3347 | 366 |
path := (Smalltalk getSystemFileName:'Hello.wsp'). |
3345 | 367 |
path asFilename exists ifTrue:[ |
368 |
wsApp addWindow:(HVScrollableView for:Workspace) named:'Welcome' asFirst:false. |
|
369 |
wsApp loadFile:path. |
|
370 |
needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
|
371 |
needRemove := false. |
|
372 |
]. |
|
3332 | 373 |
|
374 |
wsApp openWindow |
|
375 |
||
376 |
" |
|
377 |
self openSystemWorkspace |
|
378 |
" |
|
379 |
! ! |
|
380 |
||
3154 | 381 |
!WorkspaceApplication methodsFor:'accessing'! |
382 |
||
3193 | 383 |
selectedWorkspace |
384 |
|wsIndex| |
|
385 |
||
386 |
workspaces isNil ifTrue:[ |
|
387 |
workspaces := OrderedCollection new. |
|
388 |
]. |
|
389 |
wsIndex := self selectedWorkspaceIndexHolder value. |
|
390 |
wsIndex == 0 ifTrue:[ |
|
391 |
^ nil |
|
392 |
]. |
|
393 |
||
394 |
workspaces size < wsIndex ifTrue:[ |
|
395 |
workspaces grow:wsIndex. |
|
396 |
workspaces at:wsIndex put:(HVScrollableView for:Workspace). |
|
397 |
]. |
|
398 |
^ workspaces at:wsIndex |
|
399 |
! |
|
400 |
||
401 |
tabMenuAt:index |
|
3196 | 402 |
|m i ws| |
3193 | 403 |
|
404 |
m := self class tabMenu. |
|
405 |
m := m decodeAsLiteralArray. |
|
406 |
i := m detectItem:[:item | item value == #removeWorkspace:] ifNone:nil. |
|
407 |
i notNil ifTrue:[ |
|
408 |
i argument:index. |
|
409 |
index ~~ self selectedWorkspaceIndexHolder value ifTrue:[ |
|
410 |
"/ for now: if that buffer is modified, |
|
411 |
"/ do not allow removing. |
|
412 |
"/ (must be brought to front, in order for check-for-modification to work) |
|
3196 | 413 |
ws := workspaces at:index. |
414 |
(ws isKindOf:ScrollableView) ifTrue:[ |
|
415 |
ws := ws scrolledView |
|
416 |
]. |
|
417 |
((ws isKindOf:TextView) not |
|
418 |
or:[ ws modified ]) |
|
419 |
ifTrue:[ |
|
3193 | 420 |
i disable |
421 |
]. |
|
422 |
]. |
|
423 |
]. |
|
424 |
i := m detectItem:[:item | item value == #renameWorkspace:] ifNone:nil. |
|
425 |
i notNil ifTrue:[ |
|
426 |
i argument:index. |
|
427 |
]. |
|
428 |
||
429 |
m findGuiResourcesIn:self. |
|
430 |
^ m |
|
431 |
! |
|
432 |
||
433 |
workspaceHolder |
|
434 |
workspaceHolder isNil ifTrue:[ |
|
3207 | 435 |
workspaceHolder := ValueHolder with:(self selectedWorkspace). |
3193 | 436 |
]. |
437 |
^ workspaceHolder |
|
438 |
! ! |
|
439 |
||
440 |
!WorkspaceApplication methodsFor:'aspects'! |
|
441 |
||
442 |
selectedWorkspaceIndexHolder |
|
443 |
selectedWorkspaceIndexHolder isNil ifTrue:[ |
|
444 |
selectedWorkspaceIndexHolder := 1 asValue. |
|
445 |
selectedWorkspaceIndexHolder onChangeSend:#workspaceSelectionChanged to:self. |
|
446 |
]. |
|
447 |
^ selectedWorkspaceIndexHolder. |
|
448 |
! |
|
449 |
||
450 |
tabList |
|
451 |
tabList isNil ifTrue:[ |
|
452 |
tabList := List new. |
|
453 |
]. |
|
454 |
^ tabList. |
|
455 |
! ! |
|
456 |
||
457 |
!WorkspaceApplication methodsFor:'aspects - queries'! |
|
458 |
||
459 |
canRemoveWorkspace |
|
3214 | 460 |
^ self canRemoveWorkspace:(self selectedWorkspaceIndexHolder value) |
461 |
! |
|
462 |
||
463 |
canRemoveWorkspace:idx |
|
3193 | 464 |
^ self tabList size > 1 |
3214 | 465 |
"/ and:[ (self workspacesTextViewAt:(self selectedWorkspaceIndexHolder value)) |
3154 | 466 |
! ! |
467 |
||
468 |
!WorkspaceApplication methodsFor:'initialization & release'! |
|
469 |
||
470 |
closeRequest |
|
3193 | 471 |
(self askIfModified:'Text was modified. Close anyway ?' yesButton:'Close') ifFalse:[ |
3154 | 472 |
^ self |
473 |
]. |
|
474 |
||
475 |
^ super closeRequest |
|
476 |
! ! |
|
477 |
||
478 |
!WorkspaceApplication methodsFor:'menu actions'! |
|
479 |
||
3196 | 480 |
addWindow:aWindow named:name |
3334 | 481 |
self addWindow:aWindow named:name asFirst:false |
482 |
! |
|
483 |
||
484 |
addWindow:aWindow named:name asFirst:asFirst |
|
485 |
|tabList wsIndex newSelectedIndex| |
|
3193 | 486 |
|
487 |
tabList := self tabList. |
|
488 |
wsIndex := tabList size + 1. |
|
489 |
wsIndex == 1 ifTrue:[ |
|
490 |
"/ first - add a name for the first tab |
|
491 |
tabList add:(self window label). "/ 'Workspace'. |
|
492 |
wsIndex := wsIndex + 1. |
|
493 |
]. |
|
494 |
||
495 |
workspaces grow:wsIndex. |
|
3334 | 496 |
asFirst ifTrue:[ |
497 |
tabList addFirst:(name bindWith:wsIndex). |
|
498 |
workspaces replaceFrom:2 to:wsIndex with:workspaces startingAt:1. |
|
499 |
newSelectedIndex := 1. |
|
500 |
] ifFalse:[ |
|
501 |
tabList addLast:(name bindWith:wsIndex). |
|
502 |
newSelectedIndex := wsIndex. |
|
503 |
]. |
|
504 |
workspaces at:newSelectedIndex put:aWindow. |
|
505 |
self selectedWorkspaceIndexHolder value:newSelectedIndex. |
|
506 |
"/ workspaceHolder value:aWindow. |
|
3193 | 507 |
! |
508 |
||
3196 | 509 |
addWorkspace |
510 |
self addWindow:(HVScrollableView for:Workspace) named:'Workspace%1' |
|
511 |
! |
|
512 |
||
3198 | 513 |
basicInspectIt |
514 |
self inspectIt:true |
|
515 |
! |
|
516 |
||
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
517 |
browseImplementorsOfIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
518 |
self selectedWorkspacesTextView browseImplementorsOfIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
519 |
! |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
520 |
|
3154 | 521 |
browseIt |
3198 | 522 |
self selectedWorkspacesTextView browseIt |
3154 | 523 |
! |
524 |
||
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
525 |
browseReferencesToIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
526 |
self selectedWorkspacesTextView browseReferencesToIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
527 |
! |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
528 |
|
3154 | 529 |
copySelection |
3198 | 530 |
self selectedWorkspacesTextView copySelection |
3154 | 531 |
! |
532 |
||
533 |
cutSelection |
|
3198 | 534 |
self selectedWorkspacesTextView cutSelection |
3154 | 535 |
! |
536 |
||
537 |
doIt |
|
3198 | 538 |
self selectedWorkspacesTextView doIt |
3154 | 539 |
! |
540 |
||
541 |
inspectIt |
|
3198 | 542 |
self inspectIt:false |
543 |
! |
|
544 |
||
545 |
inspectIt:basic |
|
3196 | 546 |
|ws obj v| |
547 |
||
3198 | 548 |
ws := self selectedWorkspacesTextView. |
3196 | 549 |
ws |
550 |
do:(ws selection) |
|
551 |
withValueDo:[:result | |
|
3208 | 552 |
| cls resultString| |
3196 | 553 |
|
3198 | 554 |
basic ifFalse:[ |
555 |
cls := result inspectorClass. |
|
556 |
]. |
|
3196 | 557 |
cls isNil ifTrue:[ |
558 |
cls := InspectorView |
|
559 |
]. |
|
560 |
v := cls new. |
|
561 |
v inspect:result. |
|
3208 | 562 |
"/ v allowFollow:true. |
563 |
result isBehavior ifTrue:[ |
|
564 |
resultString := result name |
|
565 |
] ifFalse:[ |
|
566 |
resultString := result classNameWithArticle |
|
567 |
]. |
|
568 |
self addWindow:v named:('Inspecting: ' , resultString). |
|
3196 | 569 |
] |
570 |
||
571 |
"/ self selectedWorkspace inspectIt |
|
3154 | 572 |
! |
573 |
||
3332 | 574 |
loadFile:aFileName |
575 |
|file ws lbl| |
|
576 |
||
577 |
file := aFileName asFilename. |
|
578 |
(ws := self selectedWorkspacesTextView) contents:file contentsOfEntireFile. |
|
579 |
ws modified:false. |
|
580 |
||
581 |
lbl := file withoutSuffix baseName. |
|
582 |
tabList size <= 1 ifTrue:[ |
|
583 |
self window label:lbl. |
|
584 |
] ifFalse:[ |
|
585 |
tabList at:self selectedWorkspaceIndexHolder value put:lbl |
|
586 |
] |
|
587 |
! |
|
588 |
||
3154 | 589 |
menuLoad |
3332 | 590 |
|file| |
3154 | 591 |
|
3193 | 592 |
(self askIfModified:'Text was modified. Load anyway ?' yesButton:'Load') ifFalse:[ ^ self]. |
593 |
||
3236 | 594 |
file := Dialog requestFileName:'Load file:' default:'file.wsp'. |
3154 | 595 |
file size > 0 ifTrue:[ |
3332 | 596 |
self loadFile:file |
3154 | 597 |
] |
598 |
! |
|
599 |
||
600 |
menuSaveAs |
|
3193 | 601 |
|file ws| |
3154 | 602 |
|
3193 | 603 |
file := Dialog requestFileName:'Save file:' default:'file.wsp'. |
3154 | 604 |
file size > 0 ifTrue:[ |
3198 | 605 |
(ws := self selectedWorkspacesTextView) saveAs:file. |
3193 | 606 |
ws modified:false. |
3154 | 607 |
] |
608 |
! |
|
609 |
||
3334 | 610 |
newSystemWorkspace |
611 |
self class openSystemWorkspace |
|
612 |
! |
|
613 |
||
3154 | 614 |
openDocumentation |
615 |
"opens the documentation file" |
|
616 |
||
617 |
self openHTMLDocument: 'tools/misc/TOP.html#WORKSPACE' |
|
618 |
! |
|
619 |
||
620 |
paste |
|
3198 | 621 |
self selectedWorkspacesTextView paste |
3154 | 622 |
! |
623 |
||
624 |
printIt |
|
3198 | 625 |
self selectedWorkspacesTextView printIt |
3193 | 626 |
! |
627 |
||
628 |
removeWorkspace |
|
629 |
self removeWorkspace:(self selectedWorkspaceIndexHolder value) |
|
630 |
! |
|
631 |
||
632 |
removeWorkspace:wsIndex |
|
633 |
|tabList newWsIndex| |
|
634 |
||
635 |
wsIndex == self selectedWorkspaceIndexHolder value ifTrue:[ |
|
636 |
(self askIfModified:'Text was modified. Remove anyway ?' yesButton:'Remove') ifFalse:[ |
|
637 |
^ self |
|
638 |
]. |
|
639 |
]. |
|
640 |
||
641 |
tabList := self tabList. |
|
642 |
||
643 |
wsIndex == tabList size ifTrue:[ |
|
644 |
newWsIndex := wsIndex - 1. |
|
645 |
] ifFalse:[ |
|
646 |
newWsIndex := wsIndex. |
|
647 |
]. |
|
648 |
||
649 |
tabList removeIndex:wsIndex. |
|
650 |
(workspaces at:wsIndex) destroy. |
|
651 |
workspaces removeIndex:wsIndex. |
|
652 |
||
653 |
tabList size == 1 ifTrue:[ |
|
654 |
self window label:(tabList at:1). |
|
655 |
tabList removeIndex:1 |
|
656 |
]. |
|
657 |
||
3334 | 658 |
workspaceHolder value:(workspaces at:newWsIndex). |
3193 | 659 |
self selectedWorkspaceIndexHolder value:newWsIndex. |
660 |
"/ to force change (update workspaceHolder - even if same index) |
|
661 |
self selectedWorkspaceIndexHolder changed:#value. |
|
662 |
! |
|
663 |
||
664 |
renameWorkspace |
|
665 |
self renameWorkspace:(self selectedWorkspaceIndexHolder value) |
|
666 |
! |
|
667 |
||
668 |
renameWorkspace:wsIndex |
|
669 |
|tabList oldName newName| |
|
670 |
||
671 |
tabList := self tabList. |
|
672 |
tabList isEmpty ifTrue:[ |
|
673 |
oldName := self window label |
|
674 |
] ifFalse:[ |
|
675 |
oldName := tabList at:wsIndex. |
|
676 |
]. |
|
677 |
newName := Dialog request:(resources string:'New Name for %1:' with:oldName) initialAnswer:oldName. |
|
678 |
newName size == 0 ifTrue:[ ^ self]. |
|
679 |
||
680 |
tabList notEmpty ifTrue:[ |
|
681 |
tabList at:wsIndex put:newName. |
|
682 |
]. |
|
683 |
wsIndex == self selectedWorkspaceIndexHolder value ifTrue:[ |
|
684 |
self window label:newName. |
|
685 |
]. |
|
3154 | 686 |
! ! |
687 |
||
688 |
!WorkspaceApplication methodsFor:'private'! |
|
689 |
||
690 |
askIfModified:question yesButton:yesButtonText |
|
691 |
"tell user, that code has been modified - let her confirm" |
|
692 |
||
693 |
|textView| |
|
694 |
||
3193 | 695 |
textView := self selectedWorkspace. |
3196 | 696 |
(textView isKindOf:ScrollableView) ifTrue:[ |
697 |
textView := textView scrolledView |
|
698 |
]. |
|
699 |
(textView isKindOf:TextView) ifFalse:[ |
|
700 |
^ true |
|
701 |
]. |
|
702 |
(textView modified not |
|
703 |
or:[textView contentsWasSaved |
|
704 |
or:[textView contents withoutSeparators isEmpty]]) ifTrue:[ |
|
3154 | 705 |
^ true |
706 |
]. |
|
707 |
(Dialog |
|
708 |
confirm:(resources string:question) withCRs |
|
709 |
yesLabel:(resources at:yesButtonText) |
|
710 |
noLabel:(resources at:'Cancel')) |
|
711 |
ifTrue:[ |
|
712 |
"/ reset modified flag so question is asked only once |
|
713 |
textView modified:false. |
|
714 |
^ true |
|
715 |
]. |
|
716 |
^ false |
|
717 |
||
718 |
"Modified: 2.10.1997 / 14:23:47 / stefan" |
|
3193 | 719 |
! |
720 |
||
3198 | 721 |
selectedWorkspacesTextView |
722 |
|textView| |
|
723 |
||
724 |
textView := self selectedWorkspace. |
|
725 |
(textView isKindOf:ScrollableView) ifTrue:[ |
|
726 |
textView := textView scrolledView |
|
727 |
]. |
|
728 |
(textView isKindOf:TextView) ifTrue:[ |
|
729 |
^ textView |
|
730 |
]. |
|
731 |
^ textView workspace |
|
732 |
! |
|
733 |
||
3193 | 734 |
workspaceSelectionChanged |
3334 | 735 |
|wsIndex windowLabel v| |
3193 | 736 |
|
737 |
"/ self selected |
|
3334 | 738 |
self workspaceHolder value:(v := self selectedWorkspace). |
3193 | 739 |
wsIndex := self selectedWorkspaceIndexHolder value. |
740 |
||
741 |
wsIndex ~~ 0 ifTrue:[ |
|
742 |
windowLabel := tabList at:wsIndex ifAbsent:nil. |
|
743 |
windowLabel notNil ifTrue:[self window label:windowLabel]. |
|
744 |
]. |
|
3154 | 745 |
! ! |
746 |
||
747 |
!WorkspaceApplication class methodsFor:'documentation'! |
|
748 |
||
749 |
version |
|
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
750 |
^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.21 2001-11-09 11:20:13 cg Exp $' |
3154 | 751 |
! ! |