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