author | Claus Gittinger <cg@exept.de> |
Mon, 17 May 2004 21:20:54 +0200 | |
changeset 5855 | a91fbf8b707c |
parent 5852 | 729c4b42a98e |
child 5983 | 2e05d5fa48e4 |
permissions | -rw-r--r-- |
5140 | 1 |
" |
2 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
3154 | 13 |
"{ Package: 'stx:libtool' }" |
14 |
||
5303 | 15 |
MultiViewToolApplication subclass:#WorkspaceApplication |
5852 | 16 |
instanceVariableNames:'autoDefineVariables syntaxHolder' |
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
17 |
classVariableNames:'LastFilterBlockString LastProcessingBlockString' |
3222 | 18 |
poolDictionaries:'' |
19 |
category:'Interface-Smalltalk' |
|
3154 | 20 |
! |
21 |
||
3191 | 22 |
!WorkspaceApplication class methodsFor:'documentation'! |
23 |
||
5140 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
3191 | 38 |
documentation |
39 |
" |
|
40 |
A simple wrapper around a WorkSpace-View, adding a pullDown menu. |
|
41 |
||
42 |
[author:] |
|
43 |
Claus Gittinger |
|
44 |
" |
|
45 |
! ! |
|
3154 | 46 |
|
47 |
!WorkspaceApplication class methodsFor:'interface specs'! |
|
48 |
||
49 |
windowSpec |
|
50 |
"This resource specification was automatically generated |
|
51 |
by the UIPainter of ST/X." |
|
52 |
||
53 |
"Do not manually edit this!! If it is corrupted, |
|
54 |
the UIPainter may not be able to read the specification." |
|
55 |
||
56 |
" |
|
57 |
UIPainter new openOnClass:WorkspaceApplication andSelector:#windowSpec |
|
58 |
WorkspaceApplication new openInterface:#windowSpec |
|
59 |
WorkspaceApplication open |
|
60 |
" |
|
61 |
||
62 |
<resource: #canvas> |
|
63 |
||
64 |
^ |
|
65 |
#(#FullSpec |
|
66 |
#name: #windowSpec |
|
67 |
#window: |
|
68 |
#(#WindowSpec |
|
69 |
#label: 'Workspace' |
|
70 |
#name: 'Workspace' |
|
71 |
#min: #(#Point 10 10) |
|
3845 | 72 |
#bounds: #(#Rectangle 13 23 445 264) |
3154 | 73 |
#menu: #mainMenu |
74 |
) |
|
75 |
#component: |
|
76 |
#(#SpecCollection |
|
77 |
#collection: #( |
|
3193 | 78 |
#(#NoteBookViewSpec |
79 |
#name: 'NoteBook1' |
|
80 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
81 |
#model: #selectedWorkspaceIndexHolder |
|
82 |
#menu: #tabList |
|
83 |
#useIndex: true |
|
84 |
#accessTabMenuAction: #tabMenuAt: |
|
85 |
#canvas: #workspaceHolder |
|
86 |
#canvasInset: 0 |
|
87 |
#canvasFrameLevel: 0 |
|
88 |
#keepCanvasAlive: true |
|
4369 | 89 |
#tabLevel: 1 |
3193 | 90 |
) |
3154 | 91 |
) |
92 |
||
93 |
) |
|
94 |
) |
|
95 |
! ! |
|
96 |
||
97 |
!WorkspaceApplication class methodsFor:'menu specs'! |
|
98 |
||
99 |
mainMenu |
|
100 |
"This resource specification was automatically generated |
|
101 |
by the MenuEditor of ST/X." |
|
102 |
||
103 |
"Do not manually edit this!! If it is corrupted, |
|
104 |
the MenuEditor may not be able to read the specification." |
|
105 |
||
106 |
" |
|
107 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#mainMenu |
|
108 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication mainMenu)) startUp |
|
109 |
" |
|
110 |
||
111 |
<resource: #menu> |
|
112 |
||
113 |
^ |
|
5852 | 114 |
#(Menu |
115 |
( |
|
116 |
(MenuItem |
|
117 |
label: 'File' |
|
118 |
translateLabel: true |
|
119 |
submenu: |
|
120 |
(Menu |
|
121 |
( |
|
122 |
(MenuItem |
|
123 |
label: 'New Workspace' |
|
124 |
itemValue: newWorkspace |
|
125 |
translateLabel: true |
|
3651 | 126 |
) |
5852 | 127 |
(MenuItem |
128 |
label: 'New SystemWorkspace' |
|
129 |
itemValue: newSystemWorkspace |
|
130 |
translateLabel: true |
|
3154 | 131 |
) |
5852 | 132 |
(MenuItem |
133 |
label: '-' |
|
3154 | 134 |
) |
5852 | 135 |
(MenuItem |
136 |
label: 'Load File...' |
|
137 |
itemValue: menuLoad |
|
138 |
translateLabel: true |
|
3154 | 139 |
) |
5852 | 140 |
(MenuItem |
141 |
label: '-' |
|
3154 | 142 |
) |
5852 | 143 |
(MenuItem |
144 |
label: 'Save As...' |
|
145 |
itemValue: menuSaveAs |
|
146 |
translateLabel: true |
|
3154 | 147 |
) |
5852 | 148 |
(MenuItem |
149 |
enabled: hasMultipleBuffersHolder |
|
150 |
label: 'Save all As...' |
|
151 |
itemValue: menuSaveAllAs |
|
152 |
translateLabel: true |
|
4267 | 153 |
) |
5852 | 154 |
(MenuItem |
155 |
label: '-' |
|
3154 | 156 |
) |
5852 | 157 |
(MenuItem |
158 |
label: 'Exit' |
|
159 |
itemValue: closeRequest |
|
160 |
translateLabel: true |
|
3154 | 161 |
) |
162 |
) |
|
163 |
nil |
|
164 |
nil |
|
165 |
) |
|
166 |
) |
|
5852 | 167 |
(MenuItem |
168 |
label: 'Buffers' |
|
169 |
nameKey: Buffer |
|
170 |
translateLabel: true |
|
171 |
submenu: |
|
172 |
(Menu |
|
173 |
( |
|
174 |
(MenuItem |
|
175 |
label: 'Add Buffer' |
|
176 |
itemValue: addWorkspace |
|
177 |
translateLabel: true |
|
3193 | 178 |
) |
5852 | 179 |
(MenuItem |
180 |
enabled: anyWorkspaceVariableIsDefined |
|
181 |
label: 'Add Buffer on Workspace Variables' |
|
182 |
itemValue: addWorkspaceVariableInspector |
|
183 |
translateLabel: true |
|
4098 | 184 |
) |
5852 | 185 |
(MenuItem |
186 |
label: 'Add Buffer on Global Variables' |
|
187 |
itemValue: addGlobalVariableInspector |
|
188 |
translateLabel: true |
|
4099 | 189 |
) |
5852 | 190 |
(MenuItem |
191 |
label: 'Rename...' |
|
192 |
itemValue: renameWorkspace |
|
193 |
translateLabel: true |
|
3193 | 194 |
) |
5852 | 195 |
(MenuItem |
196 |
label: '-' |
|
3193 | 197 |
) |
5852 | 198 |
(MenuItem |
199 |
enabled: canRemoveWorkspace |
|
200 |
label: 'Remove Buffer' |
|
201 |
itemValue: removeWorkspace |
|
202 |
translateLabel: true |
|
3193 | 203 |
) |
204 |
) |
|
205 |
nil |
|
206 |
nil |
|
207 |
) |
|
208 |
) |
|
5852 | 209 |
(MenuItem |
210 |
label: 'Edit' |
|
211 |
translateLabel: true |
|
212 |
submenu: |
|
213 |
(Menu |
|
214 |
( |
|
215 |
(MenuItem |
|
216 |
enabled: hasSelectionInActiveWorkspace |
|
217 |
label: 'Cut' |
|
218 |
itemValue: cutSelection |
|
219 |
translateLabel: true |
|
3154 | 220 |
) |
5852 | 221 |
(MenuItem |
222 |
enabled: hasSelectionInActiveWorkspace |
|
223 |
label: 'Copy' |
|
224 |
itemValue: copySelection |
|
225 |
translateLabel: true |
|
3154 | 226 |
) |
5852 | 227 |
(MenuItem |
228 |
label: 'Paste' |
|
229 |
itemValue: paste |
|
230 |
translateLabel: true |
|
3154 | 231 |
) |
5852 | 232 |
(MenuItem |
233 |
enabled: hasHistory |
|
234 |
label: 'Paste Last' |
|
235 |
itemValue: pasteLastDoIt |
|
236 |
translateLabel: true |
|
237 |
submenuChannel: pasteRecentDoItMenu |
|
238 |
keepLinkedMenu: true |
|
239 |
horizontalLayout: true |
|
4790 | 240 |
) |
5852 | 241 |
(MenuItem |
242 |
label: '-' |
|
243 |
) |
|
244 |
(MenuItem |
|
245 |
label: 'Select All' |
|
246 |
itemValue: selectAll |
|
247 |
translateLabel: true |
|
4790 | 248 |
) |
5852 | 249 |
(MenuItem |
250 |
label: '-' |
|
3752 | 251 |
) |
5852 | 252 |
(MenuItem |
253 |
label: 'Filter Text...' |
|
254 |
itemValue: filterText |
|
255 |
translateLabel: true |
|
3752 | 256 |
) |
5852 | 257 |
(MenuItem |
258 |
label: 'Process Text...' |
|
259 |
itemValue: processText |
|
260 |
translateLabel: true |
|
3752 | 261 |
) |
5852 | 262 |
(MenuItem |
263 |
label: '-' |
|
5261 | 264 |
) |
5852 | 265 |
(MenuItem |
266 |
label: 'Web Services' |
|
267 |
translateLabel: true |
|
268 |
submenu: |
|
269 |
(Menu |
|
270 |
( |
|
271 |
(MenuItem |
|
272 |
enabled: hasSelectionInActiveWorkspace |
|
273 |
label: 'Google Spell' |
|
274 |
itemValue: googleSpellingSuggestion |
|
275 |
translateLabel: true |
|
4480 | 276 |
) |
5852 | 277 |
(MenuItem |
278 |
label: 'Translate' |
|
279 |
translateLabel: true |
|
280 |
submenu: |
|
281 |
(Menu |
|
282 |
( |
|
283 |
(MenuItem |
|
284 |
enabled: hasSelectionInActiveWorkspace |
|
285 |
label: 'English -> German' |
|
286 |
itemValue: babelFishTranslate: |
|
287 |
translateLabel: true |
|
288 |
argument: 'en_de' |
|
4480 | 289 |
) |
5852 | 290 |
(MenuItem |
291 |
enabled: hasSelectionInActiveWorkspace |
|
292 |
label: 'English -> French' |
|
293 |
itemValue: babelFishTranslate: |
|
294 |
translateLabel: true |
|
295 |
argument: 'en_fr' |
|
4480 | 296 |
) |
5852 | 297 |
(MenuItem |
298 |
enabled: hasSelectionInActiveWorkspace |
|
299 |
label: 'English -> Spanish' |
|
300 |
itemValue: babelFishTranslate: |
|
301 |
translateLabel: true |
|
302 |
argument: 'en_es' |
|
4480 | 303 |
) |
5852 | 304 |
(MenuItem |
305 |
enabled: hasSelectionInActiveWorkspace |
|
306 |
label: 'English -> Portuguese' |
|
307 |
itemValue: babelFishTranslate: |
|
308 |
translateLabel: true |
|
309 |
argument: 'en_pt' |
|
4480 | 310 |
) |
5852 | 311 |
(MenuItem |
312 |
label: '-' |
|
4480 | 313 |
) |
5852 | 314 |
(MenuItem |
315 |
enabled: hasSelectionInActiveWorkspace |
|
316 |
label: 'German -> English' |
|
317 |
itemValue: babelFishTranslate: |
|
318 |
translateLabel: true |
|
319 |
argument: 'de_en' |
|
4480 | 320 |
) |
5852 | 321 |
(MenuItem |
322 |
enabled: hasSelectionInActiveWorkspace |
|
323 |
label: 'French -> English' |
|
324 |
itemValue: babelFishTranslate: |
|
325 |
translateLabel: true |
|
326 |
argument: 'fr_en' |
|
4480 | 327 |
) |
5852 | 328 |
(MenuItem |
329 |
enabled: hasSelectionInActiveWorkspace |
|
330 |
label: 'Spanish -> English' |
|
331 |
itemValue: babelFishTranslate: |
|
332 |
translateLabel: true |
|
333 |
argument: 'es_en' |
|
4480 | 334 |
) |
5852 | 335 |
(MenuItem |
336 |
enabled: hasSelectionInActiveWorkspace |
|
337 |
label: 'Portuguese -> English' |
|
338 |
itemValue: babelFishTranslate: |
|
339 |
translateLabel: true |
|
340 |
argument: 'pt_en' |
|
4480 | 341 |
) |
5852 | 342 |
(MenuItem |
343 |
enabled: hasSelectionInActiveWorkspace |
|
344 |
label: 'Russian -> English' |
|
345 |
itemValue: babelFishTranslate: |
|
346 |
translateLabel: true |
|
347 |
argument: 'ru_en' |
|
4480 | 348 |
) |
349 |
) |
|
350 |
nil |
|
351 |
nil |
|
352 |
) |
|
353 |
) |
|
354 |
) |
|
355 |
nil |
|
356 |
nil |
|
357 |
) |
|
358 |
) |
|
3154 | 359 |
) |
360 |
nil |
|
361 |
nil |
|
362 |
) |
|
363 |
) |
|
5852 | 364 |
(MenuItem |
365 |
label: 'Workspace' |
|
366 |
translateLabel: true |
|
367 |
submenu: |
|
368 |
(Menu |
|
369 |
( |
|
370 |
(MenuItem |
|
371 |
label: 'Add Workspace Variable...' |
|
372 |
itemValue: addWorkspaceVariable |
|
373 |
translateLabel: true |
|
374 |
) |
|
375 |
(MenuItem |
|
376 |
enabled: anyWorkspaceVariableIsDefined |
|
377 |
label: 'Remove Workspace Variable...' |
|
378 |
itemValue: removeWorkspaceVariable |
|
379 |
translateLabel: true |
|
3722 | 380 |
) |
5852 | 381 |
(MenuItem |
382 |
enabled: anyWorkspaceVariableIsDefined |
|
383 |
label: 'Remove all Workspace Variables...' |
|
384 |
itemValue: removeAllWorkspaceVariables |
|
385 |
translateLabel: true |
|
386 |
) |
|
387 |
(MenuItem |
|
388 |
label: '-' |
|
3722 | 389 |
) |
5852 | 390 |
(MenuItem |
391 |
enabled: anyWorkspaceVariableIsDefined |
|
392 |
label: 'Inspect Workspace Variables' |
|
393 |
itemValue: inspectWorkspaceVariables |
|
394 |
translateLabel: true |
|
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
395 |
) |
5852 | 396 |
(MenuItem |
397 |
label: '-' |
|
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
398 |
) |
5852 | 399 |
(MenuItem |
400 |
label: 'Settings' |
|
401 |
translateLabel: true |
|
402 |
submenu: |
|
403 |
(Menu |
|
404 |
( |
|
405 |
(MenuItem |
|
406 |
label: 'Autodefine as Workspace Variable' |
|
407 |
translateLabel: true |
|
408 |
hideMenuOnActivated: false |
|
409 |
choice: autoDefineVariables |
|
410 |
choiceValue: workspace |
|
411 |
) |
|
412 |
(MenuItem |
|
413 |
label: 'Autodefine as DoIt Variable' |
|
414 |
translateLabel: true |
|
415 |
hideMenuOnActivated: false |
|
416 |
choice: autoDefineVariables |
|
417 |
choiceValue: doIt |
|
418 |
) |
|
419 |
(MenuItem |
|
420 |
label: 'Autodefine off' |
|
421 |
translateLabel: true |
|
422 |
hideMenuOnActivated: false |
|
423 |
choice: autoDefineVariables |
|
4474 | 424 |
) |
5852 | 425 |
(MenuItem |
426 |
label: '-' |
|
4474 | 427 |
) |
5852 | 428 |
(MenuItem |
429 |
label: 'Syntax' |
|
430 |
translateLabel: true |
|
431 |
submenu: |
|
432 |
(Menu |
|
433 |
( |
|
434 |
(MenuItem |
|
435 |
label: 'Smalltalk' |
|
436 |
translateLabel: true |
|
437 |
choice: syntaxHolder |
|
438 |
choiceValue: #Smalltalk |
|
439 |
) |
|
440 |
(MenuItem |
|
441 |
label: 'JavaScript' |
|
442 |
translateLabel: true |
|
443 |
choice: syntaxHolder |
|
444 |
choiceValue: #JavaScript |
|
445 |
) |
|
446 |
) |
|
447 |
nil |
|
448 |
nil |
|
449 |
) |
|
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
450 |
) |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
451 |
) |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
452 |
nil |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
453 |
nil |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
454 |
) |
3722 | 455 |
) |
456 |
) |
|
457 |
nil |
|
458 |
nil |
|
459 |
) |
|
460 |
) |
|
5852 | 461 |
(MenuItem |
462 |
label: 'Smalltalk' |
|
463 |
translateLabel: true |
|
464 |
submenu: |
|
465 |
(Menu |
|
466 |
( |
|
467 |
(MenuItem |
|
468 |
enabled: hasSelectionInActiveWorkspace |
|
469 |
label: 'DoIt' |
|
470 |
itemValue: doIt |
|
471 |
translateLabel: true |
|
3154 | 472 |
) |
5852 | 473 |
(MenuItem |
474 |
enabled: hasSelectionInActiveWorkspace |
|
475 |
label: 'PrintIt' |
|
476 |
itemValue: printIt |
|
477 |
translateLabel: true |
|
3154 | 478 |
) |
5852 | 479 |
(MenuItem |
480 |
enabled: hasSelectionInActiveWorkspace |
|
481 |
label: 'InspectIt' |
|
482 |
itemValue: inspectIt |
|
483 |
translateLabel: true |
|
3154 | 484 |
) |
5852 | 485 |
(MenuItem |
486 |
label: '-' |
|
3154 | 487 |
) |
5852 | 488 |
(MenuItem |
489 |
enabled: hasHistory |
|
490 |
label: 'Redo Last' |
|
491 |
itemValue: redoLastDoIt |
|
492 |
translateLabel: true |
|
493 |
submenuChannel: redoRecentDoItMenu |
|
494 |
keepLinkedMenu: true |
|
495 |
horizontalLayout: true |
|
4790 | 496 |
) |
5852 | 497 |
(MenuItem |
498 |
label: '-' |
|
4790 | 499 |
) |
5852 | 500 |
(MenuItem |
501 |
enabled: hasSelectionInActiveWorkspace |
|
502 |
label: 'TimeIt' |
|
503 |
itemValue: timeIt |
|
504 |
translateLabel: true |
|
3384 | 505 |
) |
5852 | 506 |
(MenuItem |
507 |
enabled: hasSelectionInActiveWorkspace |
|
508 |
label: 'SpyOnIt' |
|
509 |
itemValue: spyOnIt |
|
510 |
translateLabel: true |
|
3384 | 511 |
) |
5852 | 512 |
(MenuItem |
513 |
label: '-' |
|
3384 | 514 |
) |
5852 | 515 |
(MenuItem |
516 |
enabled: hasSelectionInActiveWorkspace |
|
517 |
label: 'Browse Class' |
|
518 |
itemValue: browseIt |
|
519 |
translateLabel: true |
|
3154 | 520 |
) |
5852 | 521 |
(MenuItem |
522 |
enabled: hasSelectionInActiveWorkspace |
|
523 |
label: 'Browse Implementors of It' |
|
524 |
itemValue: browseImplementorsOfIt |
|
525 |
translateLabel: true |
|
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
526 |
) |
5852 | 527 |
(MenuItem |
528 |
enabled: hasSelectionInActiveWorkspace |
|
529 |
label: 'Browse References to It' |
|
530 |
itemValue: browseReferencesToIt |
|
531 |
translateLabel: true |
|
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
532 |
) |
5852 | 533 |
(MenuItem |
534 |
label: '-' |
|
4154 | 535 |
) |
5852 | 536 |
(MenuItem |
537 |
label: 'FileIn Text' |
|
538 |
itemValue: fileInText |
|
539 |
translateLabel: true |
|
5261 | 540 |
) |
5852 | 541 |
(MenuItem |
542 |
label: '-' |
|
5261 | 543 |
) |
5852 | 544 |
(MenuItem |
545 |
label: 'Add Global Variable...' |
|
546 |
itemValue: addGlobalVariable |
|
547 |
translateLabel: true |
|
4284 | 548 |
) |
5852 | 549 |
(MenuItem |
550 |
label: 'Remove Global Variable...' |
|
551 |
itemValue: removeGlobalVariable |
|
552 |
translateLabel: true |
|
4154 | 553 |
) |
3154 | 554 |
) |
555 |
nil |
|
556 |
nil |
|
557 |
) |
|
558 |
) |
|
5852 | 559 |
(MenuItem |
560 |
label: 'Help' |
|
561 |
translateLabel: true |
|
562 |
startGroup: right |
|
563 |
submenu: |
|
564 |
(Menu |
|
565 |
( |
|
566 |
(MenuItem |
|
567 |
label: 'Documentation' |
|
568 |
itemValue: openDocumentation |
|
569 |
translateLabel: true |
|
3154 | 570 |
) |
5852 | 571 |
(MenuItem |
572 |
label: '-' |
|
3154 | 573 |
) |
5852 | 574 |
(MenuItem |
575 |
label: 'About this Application...' |
|
576 |
itemValue: openAboutThisApplication |
|
577 |
translateLabel: true |
|
3154 | 578 |
) |
579 |
) |
|
580 |
nil |
|
581 |
nil |
|
582 |
) |
|
583 |
) |
|
584 |
) |
|
585 |
nil |
|
586 |
nil |
|
587 |
) |
|
3193 | 588 |
! |
589 |
||
590 |
tabMenu |
|
591 |
"This resource specification was automatically generated |
|
592 |
by the MenuEditor of ST/X." |
|
593 |
||
594 |
"Do not manually edit this!! If it is corrupted, |
|
595 |
the MenuEditor may not be able to read the specification." |
|
596 |
||
597 |
" |
|
598 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#tabMenu |
|
599 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication tabMenu)) startUp |
|
600 |
" |
|
601 |
||
602 |
<resource: #menu> |
|
603 |
||
604 |
^ |
|
605 |
#(#Menu |
|
606 |
#( |
|
607 |
#(#MenuItem |
|
3222 | 608 |
#label: 'Add Buffer' |
3193 | 609 |
#translateLabel: true |
3651 | 610 |
"/ #triggerOnDown: true |
3193 | 611 |
#value: #addWorkspace |
612 |
) |
|
613 |
#(#MenuItem |
|
614 |
#label: 'Rename...' |
|
615 |
#translateLabel: true |
|
3651 | 616 |
"/ #triggerOnDown: true |
3193 | 617 |
#value: #renameWorkspace: |
618 |
) |
|
619 |
#(#MenuItem |
|
620 |
#label: '-' |
|
621 |
) |
|
622 |
#(#MenuItem |
|
3222 | 623 |
#label: 'Remove Buffer' |
3193 | 624 |
#translateLabel: true |
3651 | 625 |
"/ #triggerOnDown: true |
3193 | 626 |
#value: #removeWorkspace: |
627 |
#enabled: #canRemoveWorkspace: |
|
628 |
) |
|
629 |
) |
|
630 |
nil |
|
631 |
nil |
|
632 |
) |
|
3154 | 633 |
! ! |
634 |
||
3332 | 635 |
!WorkspaceApplication class methodsFor:'special startup'! |
636 |
||
637 |
openSystemWorkspace |
|
5681 | 638 |
|wsApp path needRemove font| |
3345 | 639 |
|
640 |
needRemove := true. |
|
3332 | 641 |
|
642 |
wsApp := self new. |
|
643 |
wsApp allButOpen. |
|
3337 | 644 |
wsApp window extent:640@400. |
3332 | 645 |
|
3345 | 646 |
path := (Smalltalk getSystemFileName:'README') ? '../../README'. |
5490 | 647 |
path := path asFilename. |
648 |
path isReadable ifTrue:[ |
|
3345 | 649 |
wsApp addWindow:(HVScrollableView for:Workspace) named:'README' asFirst:false. |
650 |
wsApp loadFile:path. |
|
651 |
wsApp removeWorkspace:1. "/ the original Workspace |
|
4183 | 652 |
wsApp renameWorkspace:1 to:'LICENCE README'. |
3345 | 653 |
needRemove := false. |
654 |
]. |
|
3334 | 655 |
|
3346 | 656 |
"/ path := (Smalltalk getSystemFileName:'doc/online/english/LICENCE_STX.html') ? '../../doc/online/english/LICENCE_STX.html'. |
657 |
"/ path asFilename exists ifTrue:[ |
|
658 |
"/ wsApp addWindow:(licenceView := HVScrollableView for:HTMLDocumentView) named:'License' asFirst:false. |
|
659 |
"/ licenceView homeDocument:'../../doc/online/english/LICENCE_STX.html'. |
|
660 |
"/ licenceView updateLabelFlag:false. |
|
661 |
"/ needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
|
662 |
"/ needRemove := false. |
|
663 |
"/ ]. |
|
3332 | 664 |
|
5684 | 665 |
wsApp graphicsDevice platformName = 'X11' ifTrue:[ |
666 |
font := Font family:'unifont' face:'medium' style:'roman' size:16 encoding:'iso10646-1'. |
|
667 |
font := font onDevice:wsApp graphicsDevice ifAbsent:nil. |
|
668 |
font isNil ifTrue:[ |
|
669 |
font := Font family:'arial' face:'medium' style:'roman' size:12 encoding:'iso10646-1'. |
|
670 |
font := font onDevice:wsApp graphicsDevice ifAbsent:nil. |
|
671 |
]. |
|
672 |
] ifFalse:[ |
|
5685 | 673 |
font := Font family:'Arial Unicode MS' face:'medium' style:'roman' size:10 encoding:'ms-ansi'. |
5681 | 674 |
font := font onDevice:wsApp graphicsDevice ifAbsent:nil. |
675 |
]. |
|
676 |
||
5649 | 677 |
#( |
5693 | 678 |
('Hello_utf8.wsp' 'Hello' #'utf8' ) |
679 |
('Welcome.wsp' 'Welcome' nil ) |
|
5692 | 680 |
('Setup.wsp' 'Setup' nil ) |
5693 | 681 |
('Keyboard.wsp' 'Keyboard' nil ) |
682 |
('GettingStarted.wsp' 'Getting Started' nil ) |
|
5692 | 683 |
) triplesDo:[:file :title :forcedEncoding| |
684 |
|pane encoding| |
|
5681 | 685 |
|
5649 | 686 |
path := (Smalltalk getSystemFileName:file). |
5681 | 687 |
|
5649 | 688 |
(path notNil and:[path asFilename isReadable]) ifTrue:[ |
5681 | 689 |
wsApp addWindow:(pane := HVScrollableView for:Workspace) named:title asFirst:false. |
5692 | 690 |
|
691 |
forcedEncoding notNil ifTrue:[ |
|
5694 | 692 |
encoding := forcedEncoding. |
5804 | 693 |
font notNil ifTrue:[ |
694 |
pane font:font. |
|
695 |
] |
|
5692 | 696 |
] ifFalse:[ |
697 |
encoding := SourceCodeManagerUtilities guessEncodingOfFile:path. |
|
698 |
(encoding == #'iso8859-1' or:[encoding == #'ascii']) ifTrue:[ |
|
699 |
encoding := nil |
|
5681 | 700 |
]. |
701 |
]. |
|
5692 | 702 |
wsApp loadFile:path encoding:encoding label:title. |
5649 | 703 |
needRemove ifTrue:[wsApp removeWorkspace:1]. "/ the original Workspace |
704 |
needRemove := false. |
|
705 |
]. |
|
3345 | 706 |
]. |
5693 | 707 |
wsApp openWindow. |
708 |
wsApp selectedWorkspaceIndexHolder value:2. |
|
3332 | 709 |
|
710 |
" |
|
711 |
self openSystemWorkspace |
|
712 |
" |
|
4542 | 713 |
! |
714 |
||
715 |
openWith:initialText |
|
716 |
"launch a new workspace with some initial contents" |
|
717 |
||
5098 | 718 |
^ self openWith:initialText selected:false |
719 |
||
720 |
" |
|
721 |
WorkspaceApplication openWith:'Transcript showCR:''hello world''' |
|
722 |
" |
|
723 |
! |
|
724 |
||
725 |
openWith:initialText selected:selectedBoolean |
|
726 |
"launch a new workspace with some initial contents" |
|
727 |
||
4542 | 728 |
|workspace| |
729 |
||
730 |
workspace := self new. |
|
731 |
workspace open. |
|
5098 | 732 |
workspace selectedWorkspace contents:initialText selected:selectedBoolean. |
4542 | 733 |
^ workspace |
734 |
||
735 |
" |
|
736 |
WorkspaceApplication openWith:'Transcript showCR:''hello world''' |
|
737 |
" |
|
3332 | 738 |
! ! |
739 |
||
3193 | 740 |
!WorkspaceApplication methodsFor:'aspects'! |
741 |
||
4474 | 742 |
autoDefineVariables |
743 |
autoDefineVariables isNil ifTrue:[ |
|
744 |
autoDefineVariables := ValueHolder new. |
|
745 |
(UserPreferences current autoDefineWorkspaceVariables) ifTrue:[ |
|
5547
65af7af97085
initial value of #autoDefine was not set correctly
Claus Gittinger <cg@exept.de>
parents:
5490
diff
changeset
|
746 |
autoDefineVariables value:#workspace. |
4474 | 747 |
]. |
748 |
autoDefineVariables onChangeSend:#autoDefineVariablesChanged to:self. |
|
749 |
]. |
|
750 |
^ autoDefineVariables. |
|
751 |
! |
|
752 |
||
4136 | 753 |
hasHistory |
754 |
^ Workspace doItHistory size > 0. |
|
5852 | 755 |
! |
756 |
||
757 |
setCompilerForSyntax |
|
758 |
|syntax| |
|
759 |
||
760 |
syntax := syntaxHolder value. |
|
761 |
self selectedWorkspace compilerClass:(self compilerClassForSyntaxName:syntax). |
|
762 |
! |
|
763 |
||
764 |
syntaxHolder |
|
765 |
syntaxHolder isNil ifTrue:[ |
|
766 |
syntaxHolder := #Smalltalk asValue. |
|
767 |
syntaxHolder onChangeSend:#setCompilerForSyntax to:self |
|
768 |
]. |
|
769 |
^ syntaxHolder |
|
3193 | 770 |
! ! |
771 |
||
4358 | 772 |
!WorkspaceApplication methodsFor:'aspects-queries'! |
3193 | 773 |
|
3812 | 774 |
anyWorkspaceVariableIsDefined |
775 |
^ Workspace workspaceVariables size > 0 |
|
3154 | 776 |
! ! |
777 |
||
778 |
!WorkspaceApplication methodsFor:'initialization & release'! |
|
779 |
||
780 |
closeRequest |
|
4031
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
781 |
(self askIfAnyModified:'Text was not saved. Close anyway ?' yesButton:'Close') ifFalse:[ |
3154 | 782 |
^ self |
783 |
]. |
|
784 |
||
785 |
^ super closeRequest |
|
786 |
! ! |
|
787 |
||
4359 | 788 |
!WorkspaceApplication methodsFor:'menu-actions'! |
3154 | 789 |
|
4154 | 790 |
addGlobalVariable |
791 |
|name nameKey selection| |
|
792 |
||
793 |
selection := self selectedWorkspacesTextView selection ? ''. |
|
794 |
||
795 |
name := Dialog |
|
796 |
request:'Name of new Global Variable:' |
|
797 |
initialAnswer:(selection asString string) |
|
798 |
okLabel:'Add' |
|
799 |
title:'Enter Variable Name'. |
|
800 |
name size == 0 ifTrue:[ |
|
801 |
^ self |
|
802 |
]. |
|
803 |
nameKey := name asSymbol. |
|
804 |
||
4284 | 805 |
(Smalltalk includesKey:nameKey) ifTrue:[ |
4154 | 806 |
self warn:'Global named ''' , name , ''' already exists.'. |
807 |
^ self. |
|
808 |
]. |
|
809 |
Smalltalk at:nameKey put:nil. |
|
810 |
! |
|
811 |
||
4099 | 812 |
addGlobalVariableInspector |
813 |
|v| |
|
814 |
||
815 |
v := self addInspectorOn:(Smalltalk) basic:false suppressPseudoSlots:true. |
|
816 |
v fieldListLabel:'Name'. |
|
4208 | 817 |
self renameWorkspace:(self selectedWorkspaceIndexHolder value) to:'Globals (Smalltalk)'. |
4099 | 818 |
! |
819 |
||
4096
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
820 |
addInspectorOn:aValue basic:isBasicInspector suppressPseudoSlots:suppressPseudoSlots |
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
821 |
|view cls resultString| |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
822 |
|
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
823 |
isBasicInspector ifFalse:[ |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
824 |
cls := aValue inspectorClass. |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
825 |
]. |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
826 |
cls isNil ifTrue:[ |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
827 |
cls := InspectorView |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
828 |
]. |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
829 |
view := cls new. |
4096
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
830 |
view suppressPseudoSlots:suppressPseudoSlots. |
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
831 |
view inspect:aValue. |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
832 |
"/ v allowFollow:true. |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
833 |
aValue isBehavior ifTrue:[ |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
834 |
resultString := aValue name |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
835 |
] ifFalse:[ |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
836 |
resultString := aValue classNameWithArticle |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
837 |
]. |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
838 |
self addWindow:view named:('Inspecting: ' , resultString). |
4096
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
839 |
^ view |
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
840 |
! |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
841 |
|
3196 | 842 |
addWorkspace |
5295
e3c5a7b20d9d
refactored (added abstract superclass)
Claus Gittinger <cg@exept.de>
parents:
5262
diff
changeset
|
843 |
self addWindow:(self createWorkspace) named:'Workspace%1' |
3196 | 844 |
! |
845 |
||
3722 | 846 |
addWorkspaceVariable |
847 |
|name selection| |
|
848 |
||
849 |
selection := self selectedWorkspacesTextView selection ? ''. |
|
850 |
||
851 |
name := Dialog |
|
852 |
request:'Name of new Workspace Variable:' |
|
853 |
initialAnswer:(selection asString string) |
|
854 |
okLabel:'Add' |
|
855 |
title:'Enter Variable Name'. |
|
856 |
name size == 0 ifTrue:[ |
|
857 |
^ self |
|
858 |
]. |
|
859 |
Workspace addWorkspaceVariable:name. |
|
860 |
! |
|
861 |
||
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
862 |
addWorkspaceVariableInspector |
4096
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
863 |
|v| |
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
864 |
|
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
865 |
v := self addInspectorOn:(Workspace workspaceVariables) basic:false suppressPseudoSlots:true. |
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
866 |
v dereferenceValueHolders:true. |
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
867 |
v fieldListLabel:'Name'. |
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
868 |
self renameWorkspace:(self selectedWorkspaceIndexHolder value) to:'Variables'. |
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
869 |
! |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
870 |
|
3752 | 871 |
askForFilterBlock:message template:template rememberIn:nameOfClassVar |
872 |
|filterBlockString filterBlock dialog textHolder classVarValue| |
|
873 |
||
874 |
classVarValue := self class classVarAt:nameOfClassVar ifAbsent:nil. |
|
875 |
classVarValue isNil ifTrue:[ |
|
876 |
self class classVarAt:nameOfClassVar put:template. |
|
877 |
classVarValue := template. |
|
878 |
]. |
|
879 |
||
880 |
textHolder := ValueHolder new. |
|
881 |
dialog := Dialog |
|
882 |
forRequestText:(resources string:message) |
|
883 |
lines:25 |
|
884 |
columns:70 |
|
885 |
initialAnswer:classVarValue |
|
886 |
model:textHolder. |
|
887 |
dialog addButton:(Button label:'Template' action:[textHolder value:template. textHolder changed:#value.]). |
|
888 |
dialog open. |
|
889 |
dialog accepted ifFalse:[^ nil]. |
|
890 |
||
891 |
filterBlockString := textHolder value. |
|
892 |
self class classVarAt:nameOfClassVar put:filterBlockString. |
|
893 |
||
894 |
filterBlock := Parser evaluate:filterBlockString. |
|
895 |
filterBlock isBlock ifFalse:[ |
|
5490 | 896 |
self error:'bad input for filterBlock' mayProceed:true. |
3752 | 897 |
^ nil |
898 |
]. |
|
899 |
||
900 |
^ filterBlock |
|
901 |
! |
|
902 |
||
4474 | 903 |
autoDefineVariablesChanged |
904 |
|autoDefine| |
|
905 |
||
906 |
autoDefine := autoDefineVariables value. |
|
907 |
UserPreferences current autoDefineWorkspaceVariables:(autoDefine == #workspace). |
|
908 |
workspaces do:[:each | |
|
909 |
each autoDefineVariables:autoDefine |
|
910 |
]. |
|
911 |
! |
|
912 |
||
3198 | 913 |
basicInspectIt |
914 |
self inspectIt:true |
|
915 |
! |
|
916 |
||
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
917 |
browseImplementorsOfIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
918 |
self selectedWorkspacesTextView browseImplementorsOfIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
919 |
! |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
920 |
|
3154 | 921 |
browseIt |
3198 | 922 |
self selectedWorkspacesTextView browseIt |
3154 | 923 |
! |
924 |
||
3383
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
925 |
browseReferencesToIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
926 |
self selectedWorkspacesTextView browseReferencesToIt |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
927 |
! |
fb3b6909bd1a
+ browseReferencesToIt & browserImplementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
3347
diff
changeset
|
928 |
|
4136 | 929 |
clearHistory |
930 |
Workspace clearDoItHistory |
|
931 |
! |
|
932 |
||
3154 | 933 |
doIt |
3198 | 934 |
self selectedWorkspacesTextView doIt |
3154 | 935 |
! |
936 |
||
937 |
inspectIt |
|
3198 | 938 |
self inspectIt:false |
939 |
! |
|
940 |
||
4086
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
941 |
inspectIt:isBasicInspector |
9f685ed7ad3f
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
4031
diff
changeset
|
942 |
|ws| |
3196 | 943 |
|
3198 | 944 |
ws := self selectedWorkspacesTextView. |
3196 | 945 |
ws |
946 |
do:(ws selection) |
|
947 |
withValueDo:[:result | |
|
4096
1c393b3edbcd
Workspace-Variable inspector
Claus Gittinger <cg@exept.de>
parents:
4086
diff
changeset
|
948 |
self addInspectorOn:result basic:isBasicInspector suppressPseudoSlots:false |
3196 | 949 |
] |
950 |
||
951 |
"/ self selectedWorkspace inspectIt |
|
3154 | 952 |
! |
953 |
||
3812 | 954 |
inspectWorkspaceVariables |
955 |
|wsvars| |
|
956 |
||
957 |
wsvars := Workspace workspaceVariables. |
|
958 |
wsvars size == 0 ifTrue:[ |
|
959 |
Dialog information:'No Workspace Variables are defined'. |
|
960 |
^ self |
|
961 |
]. |
|
962 |
wsvars inspect |
|
963 |
! |
|
964 |
||
3332 | 965 |
loadFile:aFileName |
5649 | 966 |
self loadFile:aFileName encoding:nil |
967 |
! |
|
968 |
||
5692 | 969 |
loadFile:aFileName encoding:encodingSymbolOrNil |
970 |
|lbl| |
|
971 |
||
972 |
lbl := aFileName asFilename withoutSuffix baseName. |
|
973 |
self loadFile:aFileName encoding:encodingSymbolOrNil label:lbl. |
|
974 |
! |
|
975 |
||
976 |
loadFile:aFileName encoding:encodingSymbolOrNil label:label |
|
977 |
|file ws| |
|
3332 | 978 |
|
979 |
file := aFileName asFilename. |
|
5490 | 980 |
ws := self selectedWorkspacesTextView. |
981 |
[ |
|
5692 | 982 |
|contents| |
983 |
||
984 |
contents := file contents. |
|
985 |
encodingSymbolOrNil notNil ifTrue:[ |
|
986 |
contents := contents encodeFrom:encodingSymbolOrNil into:#'unicode'. |
|
5742 | 987 |
ws externalEncoding:encodingSymbolOrNil. |
5692 | 988 |
]. |
989 |
ws contents:contents. |
|
5752
1377fd220c4c
remember loaded file (for save as)
Claus Gittinger <cg@exept.de>
parents:
5742
diff
changeset
|
990 |
ws defaultFileNameForFileDialog:file pathName. |
5490 | 991 |
] on:StreamError do:[:ex| |
992 |
Dialog warn:(resources string:'Cannot open %1: %2' with:file asString with:ex description). |
|
5196
13f6e4eaac91
fix #loadFile: check if file exists
Michael Beyl <mb@exept.de>
parents:
5140
diff
changeset
|
993 |
^ self |
13f6e4eaac91
fix #loadFile: check if file exists
Michael Beyl <mb@exept.de>
parents:
5140
diff
changeset
|
994 |
]. |
3332 | 995 |
ws modified:false. |
996 |
||
997 |
tabList size <= 1 ifTrue:[ |
|
5692 | 998 |
self window label:label. |
3332 | 999 |
] ifFalse:[ |
5692 | 1000 |
tabList at:self selectedWorkspaceIndexHolder value put:label |
3332 | 1001 |
] |
1002 |
! |
|
1003 |
||
3154 | 1004 |
menuLoad |
3332 | 1005 |
|file| |
3154 | 1006 |
|
3193 | 1007 |
(self askIfModified:'Text was modified. Load anyway ?' yesButton:'Load') ifFalse:[ ^ self]. |
1008 |
||
5846 | 1009 |
file := Dialog requestFileName:(resources string:'Load file') default:'file.wsp' pattern:'*.wsp'. |
5490 | 1010 |
file size ~~ 0 ifTrue:[ |
3332 | 1011 |
self loadFile:file |
3154 | 1012 |
] |
1013 |
! |
|
1014 |
||
3334 | 1015 |
newSystemWorkspace |
1016 |
self class openSystemWorkspace |
|
1017 |
! |
|
1018 |
||
3154 | 1019 |
openDocumentation |
1020 |
"opens the documentation file" |
|
1021 |
||
1022 |
self openHTMLDocument: 'tools/misc/TOP.html#WORKSPACE' |
|
1023 |
! |
|
1024 |
||
4267 | 1025 |
pasteAndExecute:aString |
1026 |
self paste:aString. |
|
4136 | 1027 |
self printIt |
1028 |
! |
|
1029 |
||
3154 | 1030 |
printIt |
3198 | 1031 |
self selectedWorkspacesTextView printIt |
3193 | 1032 |
! |
1033 |
||
3752 | 1034 |
processText |
1035 |
|template filterBlock newList oldList answer nChanged changedLines flags| |
|
1036 |
||
1037 |
template := |
|
1038 |
'"/ general text processor; |
|
1039 |
"/ the following block should evaluate to a new line, |
|
1040 |
"/ given the original line as argument. |
|
1041 |
"/ Beginner warning: Smalltalk know-how is useful here. |
|
1042 |
||
1043 |
[:line | |
|
1044 |
"/ any processing on line. |
|
1045 |
"/ Notice, that line might be a Text object (i.e. non-string), |
|
1046 |
"/ |
|
1047 |
"/ Useful operations on the line are: |
|
1048 |
"/ - '' .... '' , concatenation of any prefix/suffix |
|
1049 |
"/ - leftPaddedTo:size padding |
|
1050 |
"/ - rightPaddedTo:size padding |
|
1051 |
"/ - copyTo:(size min:N) |
|
1052 |
"/ - asUppercase |
|
1053 |
"/ - asLowercase |
|
4141 | 1054 |
"/ - withoutSeparators remove whiteSpace |
1055 |
"/ - asCollectionOfWords words |
|
3752 | 1056 |
|
1057 |
"/ makes everything bold |
|
1058 |
"/ |
|
1059 |
"/ line allBold |
|
1060 |
||
4141 | 1061 |
"/ first word only |
1062 |
"/ |
|
1063 |
"/ line withoutSeparators asCollectionOfWords first |
|
1064 |
||
3752 | 1065 |
"/ dummy filter (keeps all lines as-is) |
1066 |
"/ |
|
1067 |
line |
|
1068 |
] |
|
1069 |
'. |
|
1070 |
filterBlock := self askForFilterBlock:'Processing block:' |
|
1071 |
template:template |
|
1072 |
rememberIn:#LastProcessingBlockString. |
|
1073 |
filterBlock isNil ifTrue:[^ self]. |
|
1074 |
||
1075 |
oldList := self selectedWorkspacesTextView list. |
|
1076 |
oldList := oldList collect:[:lineOrNil | lineOrNil ? '']. |
|
4141 | 1077 |
newList := oldList collect:[:line | |newLine| |
1078 |
newLine := line. |
|
1079 |
Error handle:[:ex | |
|
1080 |
] do:[ |
|
1081 |
newLine := filterBlock value:line |
|
1082 |
]. |
|
1083 |
newLine |
|
1084 |
]. |
|
3752 | 1085 |
newList := newList collect:[:line | (line isString and:[line size == 0]) ifTrue:[nil] ifFalse:[line]]. |
1086 |
||
1087 |
flags := (1 to:oldList size) collect:[:i | (oldList at:i) ~= (newList at:i)]. |
|
1088 |
flags := flags select:[:flag | flag]. |
|
1089 |
nChanged := flags size. |
|
1090 |
nChanged == 0 ifTrue:[ |
|
1091 |
self information:'No lines were changed.'. |
|
1092 |
^ self |
|
1093 |
]. |
|
1094 |
||
1095 |
answer := Dialog confirmWithCancel:(resources |
|
1096 |
string:'%1 lines changed. Change text ?' |
|
1097 |
with:nChanged) |
|
1098 |
labels:#( 'Cancel' 'No, Show Changed' 'Yes'). |
|
1099 |
answer isNil ifTrue:[^ self]. |
|
1100 |
answer ifFalse:[ |
|
1101 |
changedLines := (1 to:oldList size) select:[:i | (oldList at:i) ~= (newList at:i)]. |
|
1102 |
changedLines := changedLines collect:[:i | (newList at:i)]. |
|
1103 |
TextBox openOn:(changedLines asStringCollection) title:'Changed lines'. |
|
1104 |
^ self. |
|
1105 |
]. |
|
1106 |
||
1107 |
self selectedWorkspacesTextView list:newList. |
|
1108 |
! |
|
1109 |
||
4136 | 1110 |
redoLastDoIt |
4267 | 1111 |
|s| |
4136 | 1112 |
|
4267 | 1113 |
s := self lastDoItsString. |
1114 |
s notNil ifTrue:[ |
|
1115 |
self pasteAndExecute:s |
|
1116 |
] |
|
4136 | 1117 |
! |
1118 |
||
3722 | 1119 |
removeAllWorkspaceVariables |
5846 | 1120 |
(Dialog confirm:(resources string:'Do you really want to remove all Workspace Variables ?')) |
3722 | 1121 |
ifTrue:[ |
1122 |
Workspace removeAllWorkspaceVariables |
|
1123 |
]. |
|
1124 |
! |
|
1125 |
||
4284 | 1126 |
removeGlobalVariable |
1127 |
|name nameKey selection value| |
|
1128 |
||
1129 |
selection := self selectedWorkspacesTextView selection ? ''. |
|
1130 |
||
1131 |
name := Dialog |
|
1132 |
request:'Remove Global Variable:' |
|
1133 |
initialAnswer:(selection asString string) |
|
1134 |
okLabel:'Remove' |
|
1135 |
title:'Remove Global'. |
|
1136 |
||
1137 |
name size == 0 ifTrue:[^ self]. |
|
1138 |
nameKey := name asSymbolIfInterned. |
|
1139 |
nameKey isNil ifTrue:[^ self]. |
|
1140 |
||
1141 |
(Smalltalk includesKey:nameKey) ifFalse:[ |
|
1142 |
self warn:('No such Global Binding: ''%1''.' bindWith:name). |
|
1143 |
^ self. |
|
1144 |
]. |
|
1145 |
||
1146 |
value := Smalltalk at:nameKey. |
|
1147 |
value notNil ifTrue:[ |
|
1148 |
(self confirm:('Global ''%1'' is currently bound to %2\\Remove Binding ?' bindWith:name with:value) withCRs) |
|
1149 |
ifFalse:[ |
|
1150 |
^ self. |
|
1151 |
]. |
|
1152 |
]. |
|
1153 |
Smalltalk at:nameKey put:nil. |
|
1154 |
Smalltalk removeKey:nameKey |
|
1155 |
! |
|
1156 |
||
3722 | 1157 |
removeWorkspaceVariable |
3812 | 1158 |
|name selection wsvars| |
1159 |
||
1160 |
wsvars := Workspace workspaceVariables. |
|
1161 |
wsvars size == 0 ifTrue:[ |
|
1162 |
Dialog information:'No Workspace Variables are defined'. |
|
1163 |
^ self |
|
1164 |
]. |
|
3722 | 1165 |
|
1166 |
selection := self selectedWorkspacesTextView selection ? ''. |
|
1167 |
||
1168 |
name := Dialog |
|
1169 |
request:'Variable to remove:' |
|
1170 |
initialAnswer:(selection asString string) |
|
1171 |
okLabel:'Remove' |
|
1172 |
title:'Enter Variable Name' |
|
3812 | 1173 |
list:(wsvars keys asOrderedCollection sort). |
3722 | 1174 |
name size == 0 ifTrue:[ |
1175 |
^ self |
|
1176 |
]. |
|
1177 |
Workspace removeWorkspaceVariable:name. |
|
1178 |
! |
|
1179 |
||
3384 | 1180 |
spyOnIt |
1181 |
self selectedWorkspacesTextView spyOnIt |
|
1182 |
! |
|
1183 |
||
1184 |
timeIt |
|
1185 |
self selectedWorkspacesTextView timeIt |
|
3154 | 1186 |
! ! |
1187 |
||
4790 | 1188 |
!WorkspaceApplication methodsFor:'menu-actions-editing'! |
1189 |
||
1190 |
babelFishTranslate:fromToModeString |
|
1191 |
"translate the selected text and paste it after the selection" |
|
1192 |
||
1193 |
self selectedWorkspace babelFishTranslate:fromToModeString |
|
1194 |
! |
|
1195 |
||
5261 | 1196 |
fileInText |
1197 |
self selectedWorkspacesTextView contentsAsString readStream fileIn |
|
1198 |
! |
|
1199 |
||
4790 | 1200 |
filterText |
1201 |
|template filterBlock newList oldList answer nDeleted deletedLines| |
|
1202 |
||
1203 |
template := |
|
1204 |
'"/ general text filter; |
|
1205 |
"/ the following block should evaluate to true for all lines |
|
1206 |
"/ you want to keep - lines for which the block returns false will be removed. |
|
1207 |
"/ Beginner warning: Smalltalk know-how is useful here. |
|
1208 |
||
1209 |
[:line | |
|
1210 |
"/ any condition on line. |
|
1211 |
"/ Notice, that line might be a Text object (i.e. non-string), |
|
1212 |
"/ so you may want to use line string. |
|
1213 |
"/ |
|
1214 |
"/ Useful queries on the line are: |
|
1215 |
"/ - size the length of the line |
|
1216 |
"/ - hasChangeOfEmphasis any bold, italic etc. |
|
1217 |
"/ - startsWith:someString |
|
1218 |
"/ - endsWith:someString |
|
1219 |
||
1220 |
"/ example filter (removes all empty lines) |
|
1221 |
"/ |
|
1222 |
"/ line size > 0 |
|
1223 |
||
1224 |
"/ example filter (removes all lines which do not end with some suffix) |
|
1225 |
"/ |
|
1226 |
"/ (line asLowercase endsWith:''foo'') not |
|
1227 |
||
1228 |
"/ dummy filter (keeps all lines) |
|
1229 |
"/ |
|
1230 |
true |
|
1231 |
] |
|
1232 |
'. |
|
1233 |
||
1234 |
filterBlock := self askForFilterBlock:'Filter block:' |
|
1235 |
template:template |
|
1236 |
rememberIn:#LastFilterBlockString. |
|
1237 |
filterBlock isNil ifTrue:[^ self]. |
|
1238 |
||
1239 |
oldList := self selectedWorkspacesTextView list. |
|
1240 |
oldList := oldList collect:[:lineOrNil | lineOrNil ? '']. |
|
1241 |
newList := oldList select:filterBlock. |
|
1242 |
newList := newList collect:[:line | (line isString and:[line size == 0]) ifTrue:[nil] ifFalse:[line]]. |
|
1243 |
nDeleted := oldList size - newList size. |
|
1244 |
nDeleted == 0 ifTrue:[ |
|
1245 |
self information:'No lines were deleted.'. |
|
1246 |
^ self |
|
1247 |
]. |
|
1248 |
||
1249 |
answer := Dialog confirmWithCancel:(resources |
|
1250 |
string:'%1 lines remain (%2 deleted). Change text ?' |
|
1251 |
with:newList size |
|
1252 |
with:nDeleted) |
|
1253 |
labels:#( 'Cancel' 'No, Show Deleted' 'Yes'). |
|
1254 |
answer isNil ifTrue:[^ self]. |
|
1255 |
answer ifFalse:[ |
|
1256 |
deletedLines := oldList reject:filterBlock. |
|
1257 |
TextBox openOn:(deletedLines asStringCollection) title:'Filtered lines'. |
|
1258 |
^ self. |
|
1259 |
]. |
|
1260 |
||
1261 |
self selectedWorkspacesTextView list:newList. |
|
1262 |
! |
|
1263 |
||
1264 |
googleSpellingSuggestion |
|
1265 |
self selectedWorkspacesTextView googleSpellingSuggestion |
|
1266 |
! |
|
1267 |
||
1268 |
pasteLastDoIt |
|
1269 |
|s| |
|
1270 |
||
1271 |
s := self lastDoItsString. |
|
1272 |
s notNil ifTrue:[ |
|
1273 |
self paste:s |
|
1274 |
] |
|
1275 |
! ! |
|
1276 |
||
4136 | 1277 |
!WorkspaceApplication methodsFor:'menu-dynamic'! |
1278 |
||
4267 | 1279 |
pasteRecentDoItMenu |
1280 |
<resource: #programMenu > |
|
1281 |
||
1282 |
^ self recentDoItsMenuFor:#'paste:' |
|
1283 |
! |
|
1284 |
||
1285 |
recentDoItsMenuFor:aSelector |
|
4136 | 1286 |
<resource: #programMenu > |
1287 |
||
1288 |
^ [ |
|
1289 |
|doIts m classHistory currentClass| |
|
1290 |
||
1291 |
doIts := Workspace doItHistory. |
|
1292 |
doIts size > 0 ifTrue:[ |
|
1293 |
m := Menu new. |
|
1294 |
doIts do:[:doItEntry | |
|
1295 |
|lines label item| |
|
1296 |
||
1297 |
label := doItEntry withoutLeadingSeparators asStringCollection first. |
|
1298 |
(label size > 20) ifTrue:[ |
|
1299 |
label := (label contractTo:20) |
|
1300 |
] ifFalse:[ |
|
1301 |
(lines size > 1) ifTrue:[ |
|
1302 |
label := label , '...' |
|
1303 |
]. |
|
1304 |
]. |
|
1305 |
label := '''' , label , ''''. |
|
1306 |
||
1307 |
item := MenuItem label:label. |
|
1308 |
m addItem:item. |
|
4267 | 1309 |
item value:aSelector. |
4136 | 1310 |
item argument:doItEntry. |
1311 |
]. |
|
1312 |
m addItem: (MenuItem new label:'-'). |
|
1313 |
m addItem: (MenuItem new |
|
5358 | 1314 |
label: (resources string:'Clear History'); |
4136 | 1315 |
value: #clearHistory; |
1316 |
activeHelpKey: #historyEmptyMenu; |
|
1317 |
translateLabel:true). |
|
1318 |
]. |
|
1319 |
m |
|
1320 |
]. |
|
4267 | 1321 |
! |
1322 |
||
1323 |
redoRecentDoItMenu |
|
1324 |
<resource: #programMenu > |
|
1325 |
||
1326 |
^ self recentDoItsMenuFor:#'pasteAndExecute:' |
|
4136 | 1327 |
! ! |
1328 |
||
3154 | 1329 |
!WorkspaceApplication methodsFor:'private'! |
1330 |
||
4031
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1331 |
askIfAnyModified:question yesButton:yesButtonText |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1332 |
(workspaces contains:[:aView | self isModifiedWorkspace:aView]) ifFalse:[^ true]. |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1333 |
|
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1334 |
(Dialog |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1335 |
confirm:(resources string:question) withCRs |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1336 |
yesLabel:(resources at:yesButtonText) |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1337 |
noLabel:(resources at:'Cancel')) |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1338 |
ifTrue:[ |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1339 |
"/ reset modified flag so question is asked only once |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1340 |
(workspaces select:[:aView | (self isModifiedWorkspace:aView)]) |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1341 |
do:[:eachModifiedTextView | |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1342 |
eachModifiedTextView modified:false. |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1343 |
]. |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1344 |
^ true |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1345 |
]. |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1346 |
^ false |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1347 |
! |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1348 |
|
5852 | 1349 |
compilerClassForSyntaxName:syntax |
1350 |
syntax == #Smalltalk ifTrue:[ |
|
1351 |
^ Compiler |
|
1352 |
]. |
|
1353 |
syntax == #JavaScript ifTrue:[ |
|
1354 |
^ JavaScriptCompiler |
|
1355 |
]. |
|
1356 |
^ Compiler |
|
1357 |
! |
|
1358 |
||
5295
e3c5a7b20d9d
refactored (added abstract superclass)
Claus Gittinger <cg@exept.de>
parents:
5262
diff
changeset
|
1359 |
createWorkspace |
5547
65af7af97085
initial value of #autoDefine was not set correctly
Claus Gittinger <cg@exept.de>
parents:
5490
diff
changeset
|
1360 |
|ws| |
65af7af97085
initial value of #autoDefine was not set correctly
Claus Gittinger <cg@exept.de>
parents:
5490
diff
changeset
|
1361 |
|
65af7af97085
initial value of #autoDefine was not set correctly
Claus Gittinger <cg@exept.de>
parents:
5490
diff
changeset
|
1362 |
ws := (HVScrollableView for:Workspace). |
65af7af97085
initial value of #autoDefine was not set correctly
Claus Gittinger <cg@exept.de>
parents:
5490
diff
changeset
|
1363 |
ws autoDefineVariables:autoDefineVariables. |
65af7af97085
initial value of #autoDefine was not set correctly
Claus Gittinger <cg@exept.de>
parents:
5490
diff
changeset
|
1364 |
^ ws |
3193 | 1365 |
! |
1366 |
||
4031
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1367 |
isModifiedWorkspace:aView |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1368 |
|view| |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1369 |
|
4267 | 1370 |
view := self workspaceViewOfView:aView. |
4031
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1371 |
|
4313 | 1372 |
(view isNil |
1373 |
or:[view modified not |
|
4031
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1374 |
or:[view contentsWasSaved |
4313 | 1375 |
or:[view contents withoutSeparators isEmpty]]]) ifTrue:[ |
4031
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1376 |
^ false |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1377 |
]. |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1378 |
^ true |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1379 |
! |
4ace4ff5fbbd
look for unsaved text in ANY workspace
Claus Gittinger <cg@exept.de>
parents:
3845
diff
changeset
|
1380 |
|
4267 | 1381 |
lastDoItsString |
1382 |
|history| |
|
3198 | 1383 |
|
4267 | 1384 |
history := Workspace doItHistory. |
1385 |
history size > 0 ifFalse:[ |
|
1386 |
self selectedWorkspacesTextView flash. |
|
1387 |
^ nil |
|
3198 | 1388 |
]. |
4267 | 1389 |
^ history first |
5852 | 1390 |
! |
1391 |
||
1392 |
syntaxNameForCompilerClass:aClass |
|
1393 |
aClass == Compiler ifTrue:[ |
|
1394 |
^ #Smalltalk |
|
1395 |
]. |
|
1396 |
aClass == JavaScriptCompiler ifTrue:[ |
|
1397 |
^ #JavaScript |
|
1398 |
]. |
|
1399 |
^ #Smalltalk |
|
1400 |
! |
|
1401 |
||
1402 |
workspaceSelectionChanged |
|
5855 | 1403 |
|compilerClass selectedWorkspace| |
5852 | 1404 |
|
1405 |
super workspaceSelectionChanged. |
|
5855 | 1406 |
selectedWorkspace := self selectedWorkspace. |
1407 |
compilerClass := selectedWorkspace isNil ifTrue:[Compiler] ifFalse:[selectedWorkspace compilerClass]. |
|
5852 | 1408 |
self syntaxHolder setValue:(self syntaxNameForCompilerClass:compilerClass). |
3154 | 1409 |
! ! |
1410 |
||
1411 |
!WorkspaceApplication class methodsFor:'documentation'! |
|
1412 |
||
1413 |
version |
|
5855 | 1414 |
^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.87 2004-05-17 19:20:54 cg Exp $' |
3154 | 1415 |
! ! |