author | tm |
Wed, 30 Oct 2002 10:40:43 +0100 | |
changeset 4111 | 1975ba8ba0a6 |
parent 4110 | 79f87cb97704 |
child 4146 | c7c4e3044e50 |
permissions | -rw-r--r-- |
3892 | 1 |
"{ Package: 'stx:libtool' }" |
2 |
||
3 |
AbstractFileBrowser subclass:#FileApplicationNoteBook |
|
3982 | 4 |
instanceVariableNames:'canvasHolder selectedEditorPage listOfApplications tabMenuIndex |
5 |
tabList selectionHistoryList privateTabList' |
|
6 |
classVariableNames:'' |
|
7 |
poolDictionaries:'' |
|
8 |
category:'Interface-Tools-File' |
|
3892 | 9 |
! |
10 |
||
11 |
AbstractFileApplicationNoteBookComponent subclass:#ArchiveViewApplication |
|
3982 | 12 |
instanceVariableNames:'archiveFileList enableStopButton fileTable currentSortOrder |
13 |
selectionHolder tableColumns commandProcess errorListHolder |
|
14 |
viewErrorList temporaryDirectory enableRemoveErrorOutput |
|
15 |
errorListVisibilityHolder hasListEntriesHolder archiver process |
|
16 |
terminateByMe columnDescriptors inDropMode' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
privateIn:FileApplicationNoteBook |
|
3892 | 20 |
! |
21 |
||
22 |
Object subclass:#ArchivItem |
|
3982 | 23 |
instanceVariableNames:'fileName size dateAndTime permissions icon ownerGroup method crc |
24 |
compressSize ratio version type isDirectory' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:FileApplicationNoteBook::ArchiveViewApplication |
|
3892 | 28 |
! |
29 |
||
30 |
AbstractFileApplicationNoteBookComponent subclass:#CommandResult |
|
3982 | 31 |
instanceVariableNames:'resultStream enableStopButton process labelHolder' |
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:FileApplicationNoteBook |
|
3892 | 35 |
! |
36 |
||
37 |
AbstractFileApplicationNoteBookComponent subclass:#HtmlViewApplication |
|
3982 | 38 |
instanceVariableNames:'htmlView labelHolder infoLabelHolder' |
39 |
classVariableNames:'' |
|
40 |
poolDictionaries:'' |
|
41 |
privateIn:FileApplicationNoteBook |
|
3892 | 42 |
! |
43 |
||
44 |
AbstractFileApplicationNoteBookComponent subclass:#ImageViewApplication |
|
3982 | 45 |
instanceVariableNames:'imageFile imageView image fitSize fitMode' |
46 |
classVariableNames:'' |
|
47 |
poolDictionaries:'' |
|
48 |
privateIn:FileApplicationNoteBook |
|
3892 | 49 |
! |
50 |
||
51 |
AbstractFileApplicationNoteBookComponent subclass:#Terminal |
|
3982 | 52 |
instanceVariableNames:'terminalView' |
53 |
classVariableNames:'' |
|
54 |
poolDictionaries:'' |
|
55 |
privateIn:FileApplicationNoteBook |
|
3892 | 56 |
! |
57 |
||
58 |
AbstractFileApplicationNoteBookComponent subclass:#TextEditor |
|
3982 | 59 |
instanceVariableNames:'fileContentsModel doSaveFile modifiedChannel editView enableSave |
60 |
enableReload presentation changeItemProcess closeApplication |
|
61 |
semaChangeItem printAsHexDump itemChanged itemRemoved |
|
4071 | 62 |
enableHexToggle textEditorChangeModificationTime md5CheckSum |
63 |
viewModifiedChannel' |
|
3982 | 64 |
classVariableNames:'' |
65 |
poolDictionaries:'' |
|
66 |
privateIn:FileApplicationNoteBook |
|
3892 | 67 |
! |
68 |
||
69 |
AbstractFileApplicationNoteBookComponent subclass:#XViewApplication |
|
3982 | 70 |
instanceVariableNames:'xView xFile vncServerPID vncPortNr vncConnection viewerPID |
71 |
vncLock vncServerIsTerminated xItem ext' |
|
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:FileApplicationNoteBook |
|
3892 | 75 |
! |
76 |
||
77 |
||
78 |
!FileApplicationNoteBook class methodsFor:'application list'! |
|
79 |
||
80 |
applicationList |
|
81 |
" returns a list of all applications to start by the NoteBookApplication with |
|
82 |
#className #type |
|
83 |
||
84 |
example: |
|
85 |
#( #'FooEditor' nil ) |
|
86 |
" |
|
87 |
||
88 |
^ #( |
|
89 |
#( #'TextEditor' #file ) |
|
90 |
#( #'TextEditor' #directoryDescription ) |
|
91 |
#( #'HtmlViewApplication' nil ) |
|
92 |
#( #'FindFileApplication' nil ) |
|
93 |
#( #'Terminal' nil ) |
|
94 |
#( #'ImageViewApplication' nil ) |
|
95 |
#( #'ArchiveViewApplication' nil ) |
|
96 |
#( #'CommandResult' nil ) |
|
97 |
#( #'XViewApplication' nil ) |
|
98 |
) |
|
99 |
! |
|
100 |
||
101 |
classFor:aApplicationListItem |
|
102 |
|rawName cls| |
|
103 |
||
104 |
rawName := aApplicationListItem at:1. |
|
105 |
(cls := self privateClassesAt:rawName) isNil ifTrue:[ |
|
106 |
cls := Smalltalk at:rawName. |
|
107 |
]. |
|
108 |
^ cls |
|
109 |
! |
|
110 |
||
111 |
defaultApplication |
|
112 |
" returns the application to be started if no itemQuery returns true or no supportedSuffix is supported |
|
113 |
" |
|
114 |
||
115 |
^ self applicationList detect:[: applItem| |
|
116 |
(((self classFor:applItem) == self textEditorClass) |
|
117 |
and:[(self typeFor:applItem) == #file]) |
|
118 |
] ifNone:[nil]. |
|
119 |
! |
|
120 |
||
121 |
typeFor:aApplicationListItem |
|
122 |
||
123 |
^ aApplicationListItem at:2 |
|
124 |
! ! |
|
125 |
||
126 |
!FileApplicationNoteBook class methodsFor:'classAccess'! |
|
127 |
||
128 |
textEditorClass |
|
129 |
||
130 |
^ TextEditor |
|
131 |
! ! |
|
132 |
||
133 |
!FileApplicationNoteBook class methodsFor:'defaults'! |
|
134 |
||
135 |
openAnotherApplicationOnSameItem |
|
136 |
||
137 |
^ false |
|
138 |
! ! |
|
139 |
||
140 |
!FileApplicationNoteBook class methodsFor:'interface specs'! |
|
141 |
||
142 |
windowSpec |
|
143 |
"This resource specification was automatically generated |
|
144 |
by the UIPainter of ST/X." |
|
145 |
||
146 |
"Do not manually edit this!! If it is corrupted, |
|
147 |
the UIPainter may not be able to read the specification." |
|
148 |
||
149 |
" |
|
150 |
UIPainter new openOnClass:NoteBookApplication andSelector:#windowSpec |
|
151 |
NoteBookApplication new openInterface:#windowSpec |
|
152 |
NoteBookApplication open |
|
153 |
" |
|
154 |
||
155 |
<resource: #canvas> |
|
156 |
||
157 |
^ |
|
158 |
#(#FullSpec |
|
159 |
#name: #windowSpec |
|
160 |
#window: |
|
161 |
#(#WindowSpec |
|
162 |
#label: 'FileBrowserV2TextEditor' |
|
163 |
#name: 'FileBrowserV2TextEditor' |
|
164 |
#min: #(#Point 10 10) |
|
165 |
#max: #(#Point 1024 768) |
|
166 |
#bounds: #(#Rectangle 16 42 316 342) |
|
167 |
) |
|
168 |
#component: |
|
169 |
#(#SpecCollection |
|
170 |
#collection: #( |
|
171 |
#(#NoteBookViewSpec |
|
172 |
#name: 'CommandAndTextEditor' |
|
173 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
174 |
#model: #selectedEditorPage |
|
175 |
#menu: #tabList |
|
176 |
#useIndex: true |
|
177 |
#accessTabMenuAction: #tabMenuAt: |
|
178 |
#canvas: #canvasHolder |
|
179 |
#keepCanvasAlive: true |
|
180 |
) |
|
181 |
) |
|
182 |
||
183 |
) |
|
184 |
) |
|
185 |
! ! |
|
186 |
||
187 |
!FileApplicationNoteBook class methodsFor:'menu specs'! |
|
188 |
||
189 |
tabMenu |
|
190 |
"This resource specification was automatically generated |
|
191 |
by the MenuEditor of ST/X." |
|
192 |
||
193 |
"Do not manually edit this!! If it is corrupted, |
|
194 |
the MenuEditor may not be able to read the specification." |
|
195 |
||
196 |
" |
|
197 |
MenuEditor new openOnClass:FileApplicationNoteBook andSelector:#tabMenu |
|
198 |
(Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook tabMenu)) startUp |
|
199 |
" |
|
200 |
||
201 |
<resource: #menu> |
|
202 |
||
203 |
^ |
|
204 |
#(#Menu |
|
205 |
#( |
|
206 |
#(#MenuItem |
|
4045 | 207 |
#label: 'Select in Filelist' |
208 |
#translateLabel: true |
|
209 |
#value: #doSelectInList |
|
210 |
) |
|
211 |
#(#MenuItem |
|
3892 | 212 |
#label: 'Close' |
213 |
#translateLabel: true |
|
214 |
#value: #doCloseApplication |
|
215 |
) |
|
216 |
) |
|
217 |
nil |
|
218 |
nil |
|
219 |
) |
|
220 |
! ! |
|
221 |
||
222 |
!FileApplicationNoteBook methodsFor:'accessing'! |
|
223 |
||
224 |
listOfApplications |
|
225 |
"return the value of the instance variable 'listOfApplications' (automatically generated)" |
|
226 |
||
227 |
listOfApplications isNil ifTrue:[ |
|
228 |
listOfApplications := OrderedCollection new. |
|
229 |
]. |
|
230 |
^ listOfApplications |
|
231 |
! |
|
232 |
||
233 |
selectionHistoryList |
|
234 |
||
235 |
selectionHistoryList isNil ifTrue:[ |
|
236 |
selectionHistoryList := OrderedCollection new. |
|
237 |
]. |
|
238 |
^ selectionHistoryList |
|
239 |
! |
|
240 |
||
241 |
selectionHistoryList:aCol |
|
242 |
||
243 |
selectionHistoryList := aCol |
|
244 |
! ! |
|
245 |
||
246 |
!FileApplicationNoteBook methodsFor:'accessing applications'! |
|
247 |
||
248 |
getAllApplicationsByClass:aClass andType:aType |
|
249 |
||
250 |
^ self listOfApplications select:[ : appl | |
|
251 |
((appl class = aClass) |
|
252 |
and:[appl type = aType]) |
|
253 |
]. |
|
254 |
! |
|
255 |
||
256 |
getApplicationByType:aType |
|
257 |
||
258 |
^ self listOfApplications detect:[ : appl | |
|
259 |
(appl type == aType) |
|
260 |
] ifNone:[nil]. |
|
261 |
! |
|
262 |
||
263 |
getIndexFor:aApplication |
|
264 |
||
265 |
| index | |
|
266 |
||
267 |
index := self listOfApplications indexOf:aApplication. |
|
268 |
index ~~ 0 ifTrue:[ |
|
269 |
^ index. |
|
270 |
]. |
|
271 |
^ nil. |
|
272 |
! |
|
273 |
||
274 |
getSameApplicationsFor:aApplication |
|
275 |
||
276 |
^ self listOfApplications select:[ : appl | |
|
277 |
( (appl ~= aApplication) |
|
278 |
and:[ (appl isKindOf:(aApplication class)) |
|
279 |
and:[ (appl item = (aApplication item)) |
|
280 |
and:[ (appl type == aApplication type) ]]]) |
|
281 |
]. |
|
282 |
! ! |
|
283 |
||
284 |
!FileApplicationNoteBook methodsFor:'actions-app-common'! |
|
285 |
||
286 |
changeItem:aItem for:aAppl |
|
287 |
||
288 |
| applIndex string| |
|
289 |
||
290 |
applIndex := self getIndexFor:aAppl. |
|
3982 | 291 |
(aItem notNil and:[aItem isDirectory not " and:[aAppl type ~= #directoryDescription]"]) ifTrue:[ |
3892 | 292 |
(aAppl changeItem:aItem) ifFalse:[ ^ self]. |
293 |
self fileHistory add:aItem. |
|
294 |
self enableFileHistory value:true. |
|
295 |
]. |
|
296 |
string := aAppl getTabString. |
|
4045 | 297 |
self privateTabList at:applIndex put:(Text fromString:string). |
3892 | 298 |
self doSelect:aAppl. |
299 |
! |
|
300 |
||
4045 | 301 |
changeModified:aBoolean for:aAppl |
302 |
||
303 |
| index text| |
|
304 |
||
305 |
index := self getIndexFor:aAppl. |
|
306 |
index isNil ifTrue:[ ^ self]. |
|
307 |
text := self privateTabList at:index ifAbsent:nil. |
|
308 |
text notNil ifTrue:[ |
|
309 |
aBoolean ifTrue:[ |
|
310 |
text emphasizeAllWith:#color->(Color red:49.9992 green:0.0 blue:0.0). |
|
311 |
] ifFalse:[ |
|
312 |
text emphasisAllRemove:#color. |
|
313 |
]. |
|
314 |
self privateTabList at:index put:(text copy). |
|
315 |
]. |
|
316 |
! |
|
317 |
||
3892 | 318 |
closeSubCanvas:aApplication |
319 |
||
3929 | 320 |
| applIndex historyList localHistoryList selectedPage| |
3892 | 321 |
|
322 |
applIndex := self getIndexFor:aApplication. |
|
323 |
applIndex notNil ifTrue:[ |
|
324 |
"/ "/ UPDATE THE LAST SELECTION BECAUSE SEL INDEX IS DECREMENTED FOR HIGHER INDEXES |
|
325 |
"/ self lastSelection:applIndex. |
|
326 |
||
327 |
historyList := self selectionHistoryList. |
|
328 |
historyList remove:applIndex ifAbsent:nil. |
|
329 |
localHistoryList := OrderedCollection new. |
|
330 |
historyList notEmpty ifTrue:[ |
|
3929 | 331 |
selectedPage := historyList last. |
3892 | 332 |
] ifFalse:[ |
3929 | 333 |
selectedPage := 1. |
334 |
]. |
|
335 |
self selectedEditorPage value:selectedPage. |
|
336 |
||
3892 | 337 |
historyList do:[ : index | |
338 |
index <= applIndex ifTrue:[ |
|
339 |
localHistoryList add:index |
|
340 |
] ifFalse:[ |
|
341 |
localHistoryList add:(index - 1) |
|
342 |
] |
|
343 |
]. |
|
344 |
self selectionHistoryList:localHistoryList. |
|
345 |
self listOfApplications removeIndex:applIndex. |
|
346 |
self privateTabList removeIndex:applIndex. |
|
347 |
self privateTabList isEmpty ifTrue:[ |
|
348 |
self viewNoteBookApplicationHolder value:false. |
|
349 |
self enableViewNoteBookApplication value:false. |
|
350 |
] ifFalse:[ |
|
351 |
historyList notEmpty ifTrue:[ |
|
352 |
self selectedEditorPage value:(self selectionHistoryList last). |
|
353 |
] |
|
354 |
] |
|
355 |
]. |
|
356 |
||
357 |
"/ because subCanvas was configured to keep its view, |
|
358 |
"/ we must destroy it here. |
|
3987 | 359 |
aApplication window destroy. |
3892 | 360 |
! |
361 |
||
362 |
doCloseApplication |
|
363 |
||
364 |
| appl | |
|
365 |
||
366 |
appl := self listOfApplications at:tabMenuIndex. |
|
367 |
appl doClose. |
|
368 |
! |
|
369 |
||
4045 | 370 |
doSelectInList |
371 |
||
372 |
| appl fileName| |
|
373 |
||
374 |
appl := self listOfApplications at:tabMenuIndex. |
|
375 |
fileName := appl fileName. |
|
376 |
fileName notNil ifTrue:[ |
|
377 |
self gotoFile:fileName. |
|
378 |
]. |
|
379 |
! |
|
380 |
||
3892 | 381 |
openApplByFileItem:aItem |
382 |
||
383 |
" use the default class list for open of applications by item " |
|
384 |
||
385 |
| applList applItem itemClass| |
|
386 |
||
387 |
aItem isNil ifTrue:[ ^ self ]. |
|
388 |
applList := self applicationList. |
|
4110 | 389 |
self openAlwaysInTextEditor value ifTrue:[ |
390 |
^ self openDefaultApplicationByItem:aItem. |
|
391 |
]. |
|
3892 | 392 |
applItem := applList detect:[: aApplItem| |
393 |
itemClass := self class classFor:aApplItem. |
|
394 |
(itemClass canOpenItem:aItem). |
|
395 |
] ifNone:[nil]. |
|
396 |
applItem isNil ifTrue:[ ^ self openDefaultApplicationByItem:aItem]. |
|
397 |
applItem notNil ifTrue:[ |
|
398 |
| itemType | |
|
399 |
itemType := self class typeFor:applItem. |
|
400 |
itemClass := self class classFor:applItem. |
|
401 |
(self openApplicationClass:itemClass withItem:aItem withType:itemType) isNil ifTrue:[ |
|
402 |
^ self openDefaultApplicationByItem:aItem. |
|
403 |
]. |
|
404 |
]. |
|
405 |
! |
|
406 |
||
407 |
openApplicationClass:aClass withItem:aItem withType:aType |
|
408 |
||
409 |
| existingAppl newAppl| |
|
410 |
||
411 |
" do not open not readable items " |
|
412 |
(aItem notNil and:[aItem isDirectory not and:[aItem fileName isReadable not]]) ifTrue:[ |
|
413 |
Dialog warn:'Can not open unreadable file ', aItem fileName baseName. |
|
414 |
AbortSignal raise. |
|
415 |
]. |
|
416 |
existingAppl := self tryToGetExistingApplFor:aClass withItem:aItem withType:aType. |
|
417 |
existingAppl notNil ifTrue:[ |
|
418 |
self doSelect:existingAppl. |
|
419 |
^ existingAppl |
|
420 |
]. |
|
421 |
newAppl := aClass new. |
|
422 |
newAppl type:aType. |
|
423 |
(newAppl item:aItem) ifFalse:[ ^ nil ]. |
|
3906 | 424 |
(aItem notNil and:[(aItem isDirectory not) and:[aType ~= #directoryDescription]]) ifTrue:[ |
3892 | 425 |
self fileHistory add:aItem. |
426 |
self enableFileHistory value:true. |
|
427 |
]. |
|
428 |
self setSameFileIndexFor:newAppl. |
|
429 |
self startApplication:newAppl. |
|
430 |
^ newAppl |
|
431 |
! |
|
432 |
||
433 |
openDefaultApplicationByItem:aItem |
|
434 |
" open the default application if no application for item is available or the start of the |
|
435 |
available application failed |
|
436 |
" |
|
437 |
| applItem | |
|
438 |
||
439 |
applItem := self class defaultApplication. |
|
440 |
applItem notNil ifTrue:[ |
|
441 |
| itemType itemClass| |
|
442 |
itemType := self class typeFor:applItem. |
|
443 |
itemClass := self class classFor:applItem. |
|
444 |
^ self openApplicationClass:itemClass withItem:aItem withType:itemType. |
|
445 |
]. |
|
446 |
^ nil |
|
447 |
! |
|
448 |
||
449 |
setSameFileIndexFor:anAppl |
|
450 |
||
451 |
|sameFiles index item| |
|
452 |
||
453 |
self class openAnotherApplicationOnSameItem not ifTrue:[ |
|
454 |
anAppl sameFileIndex:nil. |
|
455 |
^ self. |
|
456 |
]. |
|
457 |
item := anAppl item. |
|
458 |
item notNil ifTrue:[ |
|
459 |
| hasSameFiles | |
|
460 |
sameFiles := self getSameApplicationsFor:anAppl. |
|
461 |
hasSameFiles := sameFiles notEmpty. |
|
462 |
hasSameFiles ifTrue:[ |
|
463 |
(sameFiles size == 1 and:[sameFiles first sameFileIndex isNil]) ifTrue:[ |
|
464 |
anAppl sameFileIndex:1. |
|
465 |
^ self |
|
466 |
] ifFalse:[ |
|
467 |
index := (sameFiles collect:[:el | (el sameFileIndex ? 1)]) max. |
|
468 |
anAppl sameFileIndex:index + 1. |
|
469 |
^ self |
|
470 |
] |
|
471 |
]. |
|
472 |
anAppl sameFileIndex:nil. |
|
473 |
]. |
|
474 |
! |
|
475 |
||
476 |
startApplication:aApplication |
|
477 |
||
478 |
| window| |
|
479 |
||
480 |
aApplication masterApplication:self. |
|
481 |
aApplication window ifNil:[ |
|
482 |
window := ApplicationSubView new. |
|
483 |
aApplication createBuilder. |
|
484 |
window client:aApplication. |
|
485 |
]. |
|
486 |
self listOfApplications add:aApplication. |
|
4045 | 487 |
self privateTabList add:(Text fromString:(aApplication getTabString)). |
3892 | 488 |
self viewNoteBookApplicationHolder value:true. |
489 |
self enableViewNoteBookApplication value:true. |
|
490 |
self doSelect:aApplication. |
|
3987 | 491 |
"/ [ |
3892 | 492 |
aApplication postOpenWith:aApplication builder. |
3987 | 493 |
"/ ] forkAt:Processor activePriority. |
3892 | 494 |
! |
495 |
||
496 |
tabStringAdd:aString for:aAppl |
|
497 |
||
498 |
| index text stream| |
|
499 |
||
500 |
index := self getIndexFor:aAppl. |
|
501 |
index isNil ifTrue:[ ^ self]. |
|
502 |
text := self privateTabList at:index. |
|
503 |
stream := WriteStream on:''. |
|
504 |
stream nextPutAll:text. |
|
505 |
stream space. |
|
506 |
stream nextPutAll:aString. |
|
4045 | 507 |
self privateTabList at:index put:(Text fromString:(stream contents)). |
3892 | 508 |
stream close. |
509 |
! |
|
510 |
||
511 |
tabStringChangeTo:aString for:aAppl |
|
512 |
||
513 |
| index| |
|
514 |
||
515 |
index := self getIndexFor:aAppl. |
|
516 |
index isNil ifTrue:[ ^ self]. |
|
4045 | 517 |
self privateTabList at:index put:(Text fromString:aString). |
3892 | 518 |
! |
519 |
||
520 |
tryToGetExistingApplFor:aClass withItem:aItem withType:aType |
|
521 |
||
522 |
||
523 |
|sameAppl changeAppl selAppl| |
|
524 |
||
525 |
aClass wantNewApplicationAnyway ifTrue:[^ nil]. |
|
526 |
sameAppl := self getAllApplicationsByClass:aClass andType:aType. |
|
527 |
sameAppl isEmpty ifTrue:[^ nil]. |
|
528 |
((aType == #directoryDescription) or:[aType == #commandResult]) ifTrue:[ |
|
529 |
changeAppl := sameAppl first. |
|
530 |
] ifFalse:[ |
|
531 |
(self openMultipleApplicationsForType value) ifTrue:[ |
|
532 |
"/ open more than one application for a class and a type |
|
533 |
(self class openAnotherApplicationOnSameItem) ifTrue:[ |
|
534 |
"/ open a new application anyway, no matters if item already open |
|
535 |
^ nil |
|
536 |
] ifFalse:[ |
|
537 |
"/ if item already changed select the application |
|
538 |
selAppl := sameAppl detect:[ : appl | |
|
539 |
(appl item = aItem) |
|
540 |
] ifNone:[nil]. |
|
541 |
]. |
|
542 |
] ifFalse:[ |
|
543 |
"/ keep in same application change the first application of the same class and type - if item not changed otherwise open new |
|
544 |
changeAppl := sameAppl detect:[ : appl | |
|
545 |
(appl isModified not) |
|
546 |
] ifNone:[nil]. |
|
547 |
]. |
|
548 |
]. |
|
549 |
changeAppl notNil ifTrue:[ |
|
550 |
self changeItem:aItem for:changeAppl. |
|
551 |
selAppl := changeAppl. |
|
552 |
]. |
|
553 |
^ selAppl. |
|
554 |
! ! |
|
555 |
||
556 |
!FileApplicationNoteBook methodsFor:'actions-app-spec'! |
|
557 |
||
558 |
changeDirectoryDescription |
|
559 |
||
560 |
| aInfoItem| |
|
561 |
||
562 |
aInfoItem := self getInfoItem. |
|
563 |
aInfoItem isNil ifTrue:[ ^ self closeDirectoryDescription ]. |
|
564 |
self openDirectoryDescription. |
|
565 |
! |
|
566 |
||
567 |
closeDirectoryDescription |
|
568 |
||
569 |
| dirContApll | |
|
570 |
||
571 |
dirContApll := self getApplicationByType:#directoryDescription. |
|
572 |
dirContApll notNil ifTrue:[ |
|
573 |
dirContApll doClose. |
|
574 |
]. |
|
575 |
! |
|
576 |
||
577 |
openArchiveViewApplication:aItem |
|
578 |
||
579 |
| result | |
|
580 |
result := self openApplicationClass:ArchiveViewApplication withItem:aItem withType:nil. |
|
581 |
result isNil ifTrue:[ |
|
582 |
Dialog warn:'file type of ', aItem fileName baseName, ' not yet supported'. |
|
583 |
^ self. |
|
584 |
]. |
|
585 |
! |
|
586 |
||
587 |
openCommandResultApplication |
|
588 |
||
589 |
||
590 |
^ self openApplicationClass:CommandResult withItem:nil withType:#commandResult |
|
591 |
! |
|
592 |
||
593 |
openDirectoryDescription |
|
594 |
||
595 |
| appl aInfoItem| |
|
596 |
||
597 |
aInfoItem := self getInfoItem. |
|
598 |
aInfoItem notNil ifTrue:[ |
|
599 |
appl := self openTextEditorOn:aInfoItem type:#directoryDescription. |
|
600 |
]. |
|
601 |
! |
|
602 |
||
603 |
openSearchFileOn:aItem |
|
604 |
||
605 |
^ self openApplicationClass:FindFileApplication withItem:aItem withType:nil |
|
606 |
! |
|
607 |
||
608 |
openTerminalApplication:aItem |
|
609 |
||
610 |
^ self openApplicationClass:Terminal withItem:aItem withType:nil |
|
611 |
! |
|
612 |
||
613 |
openTextEditorOn:aItem |
|
614 |
||
615 |
^ self openTextEditorOn:aItem type:#file |
|
616 |
! |
|
617 |
||
618 |
openTextEditorOn:aItem type:aDirDescrOrFile |
|
619 |
||
620 |
^ self openApplicationClass:TextEditor withItem:aItem withType:aDirDescrOrFile |
|
621 |
! ! |
|
622 |
||
623 |
!FileApplicationNoteBook methodsFor:'applicationlist access'! |
|
624 |
||
625 |
applicationList |
|
626 |
^ self class applicationList |
|
627 |
! ! |
|
628 |
||
629 |
!FileApplicationNoteBook methodsFor:'aspects'! |
|
630 |
||
631 |
canvasHolder |
|
632 |
||
633 |
canvasHolder isNil ifTrue:[ |
|
634 |
canvasHolder := ValueHolder new. |
|
635 |
]. |
|
636 |
^ canvasHolder. |
|
637 |
! |
|
638 |
||
639 |
privateTabList |
|
640 |
||
641 |
privateTabList isNil ifTrue:[ |
|
642 |
privateTabList := List new. |
|
643 |
privateTabList addDependent:self. |
|
644 |
]. |
|
645 |
^ privateTabList. |
|
646 |
! |
|
647 |
||
648 |
selectedEditorPage |
|
649 |
||
650 |
selectedEditorPage isNil ifTrue:[ |
|
651 |
selectedEditorPage := ValueHolder new. |
|
652 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
653 |
selectedEditorPage addDependent:self. |
|
654 |
"/ selectedEditorPage onChangeSend:#selectedEditorPageChanged to:self. |
|
655 |
]. |
|
656 |
^ selectedEditorPage. |
|
657 |
! |
|
658 |
||
659 |
tabList |
|
660 |
||
661 |
tabList isNil ifTrue:[ |
|
662 |
tabList := (List new) asValue. |
|
663 |
]. |
|
664 |
^ tabList. |
|
665 |
! |
|
666 |
||
667 |
tabList:aValue |
|
668 |
||
669 |
tabList := aValue. |
|
670 |
! ! |
|
671 |
||
672 |
!FileApplicationNoteBook methodsFor:'change & update'! |
|
673 |
||
674 |
update:something with:aParameter from:changedObject |
|
675 |
"Invoked when an object that I depend upon sends a change notification." |
|
676 |
||
677 |
"stub code automatically generated - please change as required" |
|
678 |
||
4071 | 679 |
| appl sel| |
3892 | 680 |
|
681 |
||
682 |
changedObject == self currentDirectories ifTrue:[ |
|
683 |
self viewDirectoryDescription value ifTrue:[ |
|
684 |
self changeDirectoryDescription. |
|
685 |
]. |
|
686 |
^ self. |
|
687 |
]. |
|
688 |
changedObject == self viewDirectoryDescription ifTrue:[ |
|
4071 | 689 |
self viewDirectoryDescriptionChanged. |
3892 | 690 |
^ self. |
691 |
]. |
|
692 |
changedObject == self privateTabList ifTrue:[ |
|
693 |
| privateListOfTabs | |
|
694 |
privateListOfTabs := changedObject. |
|
695 |
privateListOfTabs size > 1 ifTrue:[ |
|
696 |
self tabList value:privateListOfTabs. |
|
697 |
self tabList changed. |
|
698 |
] ifFalse:[ |
|
699 |
self tabList value:nil. |
|
700 |
]. |
|
701 |
^ self |
|
702 |
]. |
|
703 |
changedObject == self selectedEditorPage ifTrue:[ |
|
704 |
| listOfEdits indexOfLastSel list | |
|
705 |
||
706 |
sel := changedObject value. |
|
707 |
"/ dont want the tabs with one application - thats why i have to change my tablist |
|
708 |
"/ sel goes to if - i want select the last selection |
|
709 |
sel = 0 ifTrue:[ |
|
710 |
^ self. |
|
711 |
]. |
|
712 |
list := self selectionHistoryList. |
|
713 |
(list includes:sel) ifTrue:[ |
|
714 |
list remove:sel |
|
715 |
]. |
|
716 |
list add:sel. |
|
717 |
self selectionHistoryList:list. |
|
718 |
appl := self listOfApplications at:sel. |
|
719 |
self doSelect:appl. |
|
720 |
]. |
|
721 |
||
722 |
^ super update:something with:aParameter from:changedObject |
|
4071 | 723 |
! |
724 |
||
725 |
viewDirectoryDescriptionChanged |
|
726 |
||
727 |
||
728 |
|viewDirDescr| |
|
729 |
||
730 |
viewDirDescr := self viewDirectoryDescription value. |
|
731 |
viewDirDescr ifTrue:[ |
|
732 |
self openDirectoryDescription. |
|
733 |
] ifFalse:[ |
|
734 |
self closeDirectoryDescription. |
|
735 |
]. |
|
736 |
^ self. |
|
3892 | 737 |
! ! |
738 |
||
739 |
!FileApplicationNoteBook methodsFor:'menu & actions'! |
|
740 |
||
741 |
tabMenuAt:aTab |
|
742 |
||
743 |
|menu| |
|
744 |
||
745 |
menu := Menu new fromLiteralArrayEncoding:self class tabMenu. |
|
746 |
menu ifNil:[ ^ nil ]. |
|
747 |
tabMenuIndex := aTab. |
|
748 |
menu receiver:self. |
|
749 |
^ menu |
|
750 |
! ! |
|
751 |
||
752 |
!FileApplicationNoteBook methodsFor:'queries'! |
|
753 |
||
754 |
getSameFilesModifiedFor:aAppl |
|
755 |
||
756 |
| sameFileAppl colOfChanged | |
|
757 |
||
758 |
sameFileAppl := self getSameApplicationsFor:aAppl. |
|
759 |
sameFileAppl notEmpty ifTrue:[ |
|
760 |
colOfChanged := OrderedCollection new. |
|
761 |
sameFileAppl do:[ : el | |
|
762 |
el modifiedChannel value ifTrue:[ |
|
763 |
colOfChanged add:el. |
|
764 |
] |
|
765 |
] |
|
766 |
]. |
|
767 |
^ colOfChanged |
|
768 |
! ! |
|
769 |
||
770 |
!FileApplicationNoteBook methodsFor:'selection'! |
|
771 |
||
772 |
doSelect:anAppl |
|
773 |
||
774 |
| index fileName| |
|
775 |
||
776 |
fileName := anAppl fileName. |
|
777 |
fileName notNil ifTrue:[ |
|
778 |
self changeFileBrowserTitleTo:fileName baseName. |
|
4045 | 779 |
self notifyChannel value:(fileName asString) |
3982 | 780 |
"/ self gotoFile:fileName. |
3892 | 781 |
]. |
782 |
index := self getIndexFor:anAppl. |
|
3955
43aea4062c21
select file of application if selection changed in NoteBook
penk
parents:
3954
diff
changeset
|
783 |
|
3892 | 784 |
|
785 |
index notNil ifTrue:[ |
|
786 |
canvasHolder value:(anAppl window). |
|
787 |
self selectedEditorPage value:index. |
|
788 |
] |
|
789 |
! ! |
|
790 |
||
791 |
!FileApplicationNoteBook methodsFor:'startup & release'! |
|
792 |
||
3954 | 793 |
closeRequest |
794 |
||
4082 | 795 |
self tryCloseApplications ifTrue:[ |
796 |
super closeRequest. |
|
797 |
^ true |
|
3954 | 798 |
]. |
4082 | 799 |
^ false. |
3954 | 800 |
! |
801 |
||
3892 | 802 |
makeDependent |
803 |
||
804 |
self viewDirectoryDescription addDependent:self. |
|
805 |
self currentDirectories addDependent:self. |
|
806 |
! |
|
807 |
||
808 |
postOpenAsSubcanvasWith:aBuilder |
|
809 |
||
4071 | 810 |
self viewDirectoryDescriptionChanged. |
3892 | 811 |
^ super postOpenAsSubcanvasWith:aBuilder. |
812 |
! |
|
813 |
||
814 |
postOpenWith:aBuilder |
|
815 |
||
816 |
" |
|
817 |
only invoked if the application not started from a master |
|
818 |
" |
|
3982 | 819 |
self openTextEditorOn:(DirectoryContentsBrowser itemClass fileName:(Filename homeDirectory construct:'.bashrc')). |
3892 | 820 |
^ super postOpenWith:aBuilder |
821 |
! |
|
822 |
||
823 |
preBuildWith:aBuilder |
|
824 |
||
825 |
self masterApplication isNil ifTrue:[ |
|
826 |
self masterApplication:nil. |
|
827 |
]. |
|
828 |
^ super preBuildWith:aBuilder. |
|
4082 | 829 |
! |
830 |
||
831 |
tryCloseApplications |
|
832 |
||
833 |
self listOfApplications do:[:appl| |
|
834 |
appl doClose not ifTrue:[ |
|
835 |
^ false. |
|
836 |
]. |
|
837 |
]. |
|
838 |
^ true |
|
3892 | 839 |
! ! |
840 |
||
841 |
!FileApplicationNoteBook::ArchiveViewApplication class methodsFor:'common options'! |
|
842 |
||
843 |
SupportedFiles |
|
844 |
||
845 |
| dict | |
|
846 |
dict := Dictionary new. |
|
847 |
||
848 |
#( |
|
849 |
'application/x-tar-compressed' tarGZipArchive |
|
850 |
'application/x-tar' tarArchive |
|
851 |
'application/x-gzip-compressed' gzipArchive |
|
852 |
'application/x-zip-compressed' zipArchive |
|
853 |
) pairWiseDo:[ : mimeType :classSelector | |
|
854 |
dict at:mimeType put:classSelector. |
|
855 |
]. |
|
856 |
^ dict |
|
857 |
! |
|
858 |
||
859 |
classSelectorFor:aItem |
|
860 |
||
3951 | 861 |
| class mimeType| |
3892 | 862 |
aItem hasMimeType ifFalse:[^nil]. |
3951 | 863 |
mimeType := aItem mimeType. |
864 |
class := self SupportedFiles at:mimeType ifAbsent:nil. |
|
865 |
(mimeType = 'application/x-gzip-compressed') ifTrue:[ |
|
866 |
(aItem lastButOneSuffix = 'tar') ifTrue:[ |
|
3892 | 867 |
class := #tarGZipArchive. |
868 |
]. |
|
869 |
]. |
|
870 |
^ class. |
|
871 |
! ! |
|
872 |
||
873 |
!FileApplicationNoteBook::ArchiveViewApplication class methodsFor:'defaults'! |
|
874 |
||
875 |
tabStringFor:aApplicationType |
|
876 |
||
877 |
^ 'Archive for:' |
|
878 |
! ! |
|
879 |
||
880 |
!FileApplicationNoteBook::ArchiveViewApplication class methodsFor:'image specs'! |
|
881 |
||
882 |
removeError |
|
883 |
"This resource specification was automatically generated |
|
884 |
by the ImageEditor of ST/X." |
|
885 |
||
886 |
"Do not manually edit this!! If it is corrupted, |
|
887 |
the ImageEditor may not be able to read the specification." |
|
888 |
||
889 |
" |
|
890 |
self removeError inspect |
|
891 |
ImageEditor openOnClass:self andSelector:#removeError |
|
892 |
Icon flushCachedIcons |
|
893 |
" |
|
894 |
||
895 |
<resource: #image> |
|
896 |
||
897 |
^Icon |
|
898 |
constantNamed:#'FileApplicationNoteBook::ArchiveViewApplication class removeError' |
|
899 |
ifAbsentPut:[(Depth8Image new) width: 28; height: 22; photometric:(#palette); bitsPerSample:(#(8 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
900 |
@@@@@@@@@@@FA @@@@@@@@XF@@@@@@@@@@@@@@@@@@@@@@@@@@XF@@@@@@XF@@@@@@@@@@@@@@@@@@@@@@@@@@@@A X@@@XF@@@@@@@@@@@@@@@@@@@@@@@@ |
|
901 |
@@@@@@@FA XF@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@XF@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@XFA X@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@XF |
|
902 |
@@@FA @@@@@@@@@@@@@@@@@@@@@@@@@@@@XF@@@@@@XF@@@@@@@@@@@@@@@@@@@@@@@@@@XF@@@@@@@@A X@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
903 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
904 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
905 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
906 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 8 4 8 105 133 190 121 133 157 129 129 129 194 194 194 255 0 0]; mask:((Depth1Image new) width: 28; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@LC@@@A!! @@@L0@@@A8@@@@L@@@@G @@@CL@@@A!! @@@0L@@@@@@@BY=5LAIUUT S5UU8D!!UUPAFU\#@@@@@@@LR9@@D)J @A:R(@@P$*@@CIN @@@@@@@@@a') ; yourself); yourself] |
|
907 |
! ! |
|
908 |
||
909 |
!FileApplicationNoteBook::ArchiveViewApplication class methodsFor:'interface specs'! |
|
910 |
||
911 |
windowSpec |
|
912 |
"This resource specification was automatically generated |
|
913 |
by the UIPainter of ST/X." |
|
914 |
||
915 |
"Do not manually edit this!! If it is corrupted, |
|
916 |
the UIPainter may not be able to read the specification." |
|
917 |
||
918 |
" |
|
3951 | 919 |
UIPainter new openOnClass:FileApplicationNoteBook::ArchiveViewApplication andSelector:#windowSpec |
920 |
FileApplicationNoteBook::ArchiveViewApplication new openInterface:#windowSpec |
|
921 |
FileApplicationNoteBook::ArchiveViewApplication open |
|
3892 | 922 |
" |
923 |
||
924 |
<resource: #canvas> |
|
925 |
||
926 |
^ |
|
927 |
#(#FullSpec |
|
928 |
#name: #windowSpec |
|
929 |
#window: |
|
930 |
#(#WindowSpec |
|
931 |
#label: 'Archive Application' |
|
932 |
#name: 'Archive Application' |
|
933 |
#min: #(#Point 10 10) |
|
934 |
#max: #(#Point 1024 768) |
|
935 |
#bounds: #(#Rectangle 12 22 688 514) |
|
936 |
#menu: #mainMenu |
|
937 |
) |
|
938 |
#component: |
|
939 |
#(#SpecCollection |
|
940 |
#collection: #( |
|
941 |
#(#MenuPanelSpec |
|
942 |
#name: 'MenuTerminal' |
|
943 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
944 |
#menu: #menu |
|
945 |
#textDefault: true |
|
946 |
) |
|
947 |
#(#'FileBrowserV2UISpecifications::PanelSpec' |
|
948 |
#name: 'VerticalPanel' |
|
949 |
#layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 0 1.0) |
|
950 |
#borderWidth: 1 |
|
951 |
#whichView: #last |
|
952 |
#orientation: #vertical |
|
953 |
#visibility: #errorListVisibilityHolder |
|
954 |
#component: |
|
955 |
#(#SpecCollection |
|
956 |
#collection: #( |
|
957 |
#(#DataSetSpec |
|
958 |
#name: 'Table1' |
|
959 |
#model: #selectionHolder |
|
960 |
#menu: #fileListMenu |
|
961 |
#hasHorizontalScrollBar: true |
|
962 |
#hasVerticalScrollBar: true |
|
963 |
#dataList: #archiveFileList |
|
964 |
#useIndex: false |
|
965 |
#has3Dsepartors: false |
|
966 |
#doubleClickSelector: #dblClick |
|
967 |
#columnHolder: #tableColumns |
|
968 |
#multipleSelectOk: true |
|
969 |
#verticalSpacing: 0 |
|
970 |
#postBuildCallback: #postBuildFileTable: |
|
971 |
#properties: |
|
972 |
#(#PropertyListDictionary |
|
3951 | 973 |
#dropSelector: #doDrop: |
3892 | 974 |
#dragArgument: #archivApplication |
975 |
#startDragSelector: #doStartDrag:in: |
|
976 |
#displayObjectSelector: #getDisplayObjects: |
|
977 |
#dropObjectSelector: #getDropObjects: |
|
978 |
#dropArgument: #archivApplication |
|
3951 | 979 |
#canDropSelector: #canDrop: |
980 |
#leaveSelector: #dropLeave: |
|
981 |
#overSelector: nil |
|
982 |
#enterSelector: #dropEnter: |
|
3892 | 983 |
) |
984 |
) |
|
985 |
#(#SequenceViewSpec |
|
986 |
#name: 'ErrorList' |
|
987 |
#initiallyDisabled: true |
|
988 |
#hasHorizontalScrollBar: true |
|
989 |
#hasVerticalScrollBar: true |
|
990 |
#backgroundColor: #(#Color 100.0 100.0 100.0) |
|
991 |
#isMultiSelect: true |
|
992 |
#useIndex: false |
|
993 |
#sequenceList: #errorListHolder |
|
994 |
) |
|
995 |
) |
|
996 |
||
997 |
) |
|
998 |
#handles: #(#Any 0.5 1.0) |
|
999 |
) |
|
1000 |
) |
|
1001 |
||
1002 |
) |
|
1003 |
) |
|
1004 |
! ! |
|
1005 |
||
1006 |
!FileApplicationNoteBook::ArchiveViewApplication class methodsFor:'menu specs'! |
|
1007 |
||
1008 |
fileListMenu |
|
1009 |
"This resource specification was automatically generated |
|
1010 |
by the MenuEditor of ST/X." |
|
1011 |
||
1012 |
"Do not manually edit this!! If it is corrupted, |
|
1013 |
the MenuEditor may not be able to read the specification." |
|
1014 |
||
1015 |
" |
|
1016 |
MenuEditor new openOnClass:NoteBookApplication::ArchiveViewApplication andSelector:#fileListMenu |
|
1017 |
(Menu new fromLiteralArrayEncoding:(NoteBookApplication::ArchiveViewApplication fileListMenu)) startUp |
|
1018 |
" |
|
1019 |
||
1020 |
<resource: #menu> |
|
1021 |
||
1022 |
^ |
|
1023 |
#(#Menu |
|
1024 |
#( |
|
1025 |
#(#MenuItem |
|
1026 |
#label: 'Extract to Directory' |
|
1027 |
#translateLabel: true |
|
1028 |
#value: #extractAll |
|
1029 |
#enabled: #hasSelectionInList |
|
1030 |
) |
|
1031 |
#(#MenuItem |
|
1032 |
#label: 'Delete from Archiv' |
|
1033 |
#translateLabel: true |
|
1034 |
#value: #removeFilesFromArchiv |
|
1035 |
#enabled: #canDelete |
|
1036 |
#shortcutKeyCharacter: #Delete |
|
1037 |
) |
|
1038 |
#(#MenuItem |
|
1039 |
#label: 'View' |
|
1040 |
#translateLabel: true |
|
1041 |
#isVisible: #isEmbeddedApplication |
|
1042 |
#value: #viewFile |
|
4001 | 1043 |
#enabled: #canViewFile |
3892 | 1044 |
) |
1045 |
#(#MenuItem |
|
1046 |
#label: 'Copy Filenames' |
|
1047 |
#translateLabel: true |
|
1048 |
#value: #copyFilesToClipboard |
|
1049 |
#enabled: #hasSelectionInList |
|
1050 |
) |
|
1051 |
#(#MenuItem |
|
1052 |
#label: 'Select All' |
|
1053 |
#translateLabel: true |
|
1054 |
#value: #selectAll |
|
1055 |
#enabled: #hasListEntriesHolder |
|
1056 |
) |
|
1057 |
) |
|
1058 |
nil |
|
1059 |
nil |
|
1060 |
) |
|
1061 |
! |
|
1062 |
||
1063 |
menu |
|
1064 |
"This resource specification was automatically generated |
|
1065 |
by the MenuEditor of ST/X." |
|
1066 |
||
1067 |
"Do not manually edit this!! If it is corrupted, |
|
1068 |
the MenuEditor may not be able to read the specification." |
|
1069 |
||
1070 |
" |
|
1071 |
MenuEditor new openOnClass:FileApplicationNoteBook::ArchiveViewApplication andSelector:#menu |
|
1072 |
(Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::ArchiveViewApplication menu)) startUp |
|
1073 |
" |
|
1074 |
||
1075 |
<resource: #menu> |
|
1076 |
||
1077 |
^ |
|
1078 |
#(#Menu |
|
1079 |
#( |
|
1080 |
#(#MenuItem |
|
1081 |
#label: 'Stop' |
|
1082 |
#translateLabel: true |
|
1083 |
#isButton: true |
|
1084 |
#nameKey: #Stop |
|
1085 |
#value: #doStopProcess |
|
1086 |
#enabled: #enableStopButton |
|
1087 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #stop22x22Icon) |
|
1088 |
) |
|
1089 |
#(#MenuItem |
|
1090 |
#label: 'Exctract' |
|
1091 |
#translateLabel: true |
|
1092 |
#isButton: true |
|
1093 |
#value: #extractAll |
|
1094 |
#enabled: #hasListEntriesHolder |
|
1095 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #extract28x28Icon) |
|
1096 |
) |
|
1097 |
#(#MenuItem |
|
1098 |
#label: 'Remove Output' |
|
1099 |
#translateLabel: true |
|
1100 |
#isButton: true |
|
1101 |
#value: #removeErrorOutput |
|
1102 |
#enabled: #enableRemoveErrorOutput |
|
1103 |
#labelImage: #(#ResourceRetriever nil #removeError) |
|
1104 |
) |
|
1105 |
#(#MenuItem |
|
1106 |
#label: 'Close' |
|
1107 |
#translateLabel: true |
|
1108 |
#isButton: true |
|
1109 |
#hideMenuOnActivated: false |
|
1110 |
#isVisible: #isEmbeddedApplication |
|
1111 |
#startGroup: #right |
|
1112 |
#value: #doClose |
|
1113 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
1114 |
) |
|
1115 |
) |
|
1116 |
nil |
|
1117 |
nil |
|
1118 |
) |
|
1119 |
! ! |
|
1120 |
||
1121 |
!FileApplicationNoteBook::ArchiveViewApplication class methodsFor:'queries'! |
|
1122 |
||
1123 |
canOpenItem:aItem |
|
1124 |
||
1125 |
^ (aItem hasMimeType and:[(aItem mimeType isArchiv) and:[OperatingSystem isUNIXlike]]) |
|
1126 |
! |
|
1127 |
||
1128 |
wantNewApplicationAnyway |
|
1129 |
||
1130 |
^ false |
|
1131 |
! ! |
|
1132 |
||
1133 |
!FileApplicationNoteBook::ArchiveViewApplication class methodsFor:'tableColumns specs'! |
|
1134 |
||
1135 |
tableColumns |
|
1136 |
"This resource specification was automatically generated |
|
1137 |
by the DataSetBuilder of ST/X." |
|
1138 |
||
1139 |
"Do not manually edit this!! If it is corrupted, |
|
1140 |
the DataSetBuilder may not be able to read the specification." |
|
1141 |
||
1142 |
" |
|
1143 |
DataSetBuilder new openOnClass:NoteBookApplication::ArchiveViewApplication andSelector:#tableColumns |
|
1144 |
" |
|
1145 |
||
1146 |
<resource: #tableColumns> |
|
1147 |
||
1148 |
^#( |
|
1149 |
#(#DataSetColumnSpec |
|
1150 |
#id: 'icon' |
|
1151 |
#labelButtonType: #Button |
|
3989 | 1152 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1153 |
#labelActionArgument: 'directory' |
1154 |
#width: 25 |
|
1155 |
#minWidth: 20 |
|
1156 |
#height: 16 |
|
1157 |
#model: #icon |
|
1158 |
#canSelect: false |
|
1159 |
#isResizeable: false |
|
1160 |
#showRowSeparator: false |
|
1161 |
#showColSeparator: false |
|
1162 |
) |
|
1163 |
#(#DataSetColumnSpec |
|
1164 |
#label: 'File Name' |
|
1165 |
#id: 'fileName' |
|
1166 |
#labelAlignment: #left |
|
1167 |
#labelButtonType: #Button |
|
3989 | 1168 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1169 |
#labelActionArgument: 'fileName' |
1170 |
#model: #fileName |
|
1171 |
#canSelect: false |
|
1172 |
#showRowSeparator: false |
|
1173 |
#showColSeparator: false |
|
1174 |
) |
|
1175 |
#(#DataSetColumnSpec |
|
1176 |
#label: 'Perm' |
|
1177 |
#id: 'permissions' |
|
1178 |
#labelButtonType: #Button |
|
3989 | 1179 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1180 |
#labelActionArgument: 'permissions' |
1181 |
#usePreferredWidth: true |
|
1182 |
#width: 75 |
|
1183 |
#model: #permissions |
|
1184 |
#canSelect: false |
|
1185 |
#showRowSeparator: false |
|
1186 |
#showColSeparator: false |
|
1187 |
) |
|
1188 |
#(#DataSetColumnSpec |
|
1189 |
#label: 'Version' |
|
1190 |
#id: 'version' |
|
1191 |
#labelButtonType: #Button |
|
3989 | 1192 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1193 |
#labelActionArgument: 'version' |
1194 |
#columnAlignment: #right |
|
1195 |
#width: 100 |
|
1196 |
#minWidth: 50 |
|
1197 |
#model: #version |
|
1198 |
#canSelect: false |
|
1199 |
#showRowSeparator: false |
|
1200 |
#showColSeparator: false |
|
1201 |
) |
|
1202 |
#(#DataSetColumnSpec |
|
1203 |
#label: 'Type' |
|
1204 |
#id: 'type' |
|
1205 |
#labelButtonType: #Button |
|
3989 | 1206 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1207 |
#labelActionArgument: 'type' |
1208 |
#columnAlignment: #right |
|
1209 |
#width: 100 |
|
1210 |
#minWidth: 50 |
|
1211 |
#model: #type |
|
1212 |
#canSelect: false |
|
1213 |
#showRowSeparator: false |
|
1214 |
#showColSeparator: false |
|
1215 |
) |
|
1216 |
#(#DataSetColumnSpec |
|
1217 |
#label: 'Owner/Group' |
|
1218 |
#id: 'ownerGroup' |
|
1219 |
#labelButtonType: #Button |
|
3989 | 1220 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1221 |
#labelActionArgument: 'ownerGroup' |
1222 |
#columnAlignment: #right |
|
1223 |
#width: 100 |
|
1224 |
#minWidth: 50 |
|
1225 |
#model: #ownerGroup |
|
1226 |
#canSelect: false |
|
1227 |
#showRowSeparator: false |
|
1228 |
#showColSeparator: false |
|
1229 |
) |
|
1230 |
#(#DataSetColumnSpec |
|
1231 |
#label: 'Size' |
|
1232 |
#id: 'size' |
|
1233 |
#labelButtonType: #Button |
|
3989 | 1234 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1235 |
#labelActionArgument: 'sizeAsNumber' |
1236 |
#columnAlignment: #right |
|
1237 |
#width: 80 |
|
1238 |
#model: #size |
|
1239 |
#canSelect: false |
|
1240 |
#showRowSeparator: false |
|
1241 |
#showColSeparator: false |
|
1242 |
) |
|
1243 |
#(#DataSetColumnSpec |
|
1244 |
#label: 'Date & Time' |
|
1245 |
#id: 'dateAndTime' |
|
1246 |
#labelAlignment: #right |
|
1247 |
#labelButtonType: #Button |
|
3989 | 1248 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1249 |
#labelActionArgument: 'dateAndTime' |
1250 |
#columnAlignment: #right |
|
1251 |
#usePreferredWidth: true |
|
1252 |
#width: 140 |
|
1253 |
#model: #dateAndTime |
|
1254 |
#canSelect: false |
|
1255 |
#showRowSeparator: false |
|
1256 |
#showColSeparator: false |
|
1257 |
) |
|
1258 |
#(#DataSetColumnSpec |
|
1259 |
#label: 'Method' |
|
1260 |
#id: 'method' |
|
1261 |
#labelButtonType: #Button |
|
3989 | 1262 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1263 |
#labelActionArgument: 'method' |
1264 |
#columnAlignment: #center |
|
1265 |
#usePreferredWidth: true |
|
1266 |
#width: 140 |
|
1267 |
#model: #method |
|
1268 |
#canSelect: false |
|
1269 |
#showRowSeparator: false |
|
1270 |
#showColSeparator: false |
|
1271 |
) |
|
1272 |
#(#DataSetColumnSpec |
|
1273 |
#label: 'CRC' |
|
1274 |
#id: 'crc' |
|
1275 |
#labelButtonType: #Button |
|
3989 | 1276 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1277 |
#labelActionArgument: 'crc' |
1278 |
#usePreferredWidth: true |
|
1279 |
#width: 140 |
|
1280 |
#model: #crc |
|
1281 |
#canSelect: false |
|
1282 |
#showRowSeparator: false |
|
1283 |
#showColSeparator: false |
|
1284 |
) |
|
1285 |
#(#DataSetColumnSpec |
|
1286 |
#label: 'Compress Size' |
|
1287 |
#id: 'compressSize' |
|
1288 |
#labelButtonType: #Button |
|
3989 | 1289 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1290 |
#labelActionArgument: 'compressSize' |
1291 |
#usePreferredWidth: true |
|
1292 |
#width: 140 |
|
1293 |
#model: #compressSize |
|
1294 |
#canSelect: false |
|
1295 |
#showRowSeparator: false |
|
1296 |
#showColSeparator: false |
|
1297 |
) |
|
1298 |
#(#DataSetColumnSpec |
|
1299 |
#label: 'Ratio' |
|
1300 |
#id: 'ratio' |
|
1301 |
#labelButtonType: #Button |
|
3989 | 1302 |
#labelActionSelector: #sortFileListsBy: |
3892 | 1303 |
#labelActionArgument: 'ratio' |
1304 |
#usePreferredWidth: true |
|
1305 |
#width: 140 |
|
1306 |
#model: #ratio |
|
1307 |
#canSelect: false |
|
1308 |
#showRowSeparator: false |
|
1309 |
#showColSeparator: false |
|
1310 |
) |
|
1311 |
) |
|
1312 |
! ! |
|
1313 |
||
1314 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'accessing'! |
|
1315 |
||
1316 |
archiver |
|
1317 |
"return the value of the instance variable 'archiver' (automatically generated)" |
|
1318 |
||
1319 |
^ archiver |
|
1320 |
! |
|
1321 |
||
1322 |
archiver:something |
|
1323 |
"set the value of the instance variable 'archiver' (automatically generated)" |
|
1324 |
||
1325 |
archiver := something. |
|
1326 |
! |
|
1327 |
||
1328 |
columnDescriptors |
|
1329 |
"return the value of the instance variable 'columnDescriptors' (automatically generated)" |
|
1330 |
||
1331 |
^ columnDescriptors |
|
1332 |
! |
|
1333 |
||
1334 |
columnDescriptors:aListOfColumns |
|
1335 |
"set the value of the instance variable 'columnDescriptors' (automatically generated)" |
|
1336 |
||
1337 |
columnDescriptors = aListOfColumns ifTrue:[ |
|
1338 |
^ self |
|
1339 |
]. |
|
1340 |
||
1341 |
columnDescriptors := OrderedCollection new. |
|
1342 |
||
1343 |
aListOfColumns keysAndValuesDo:[:anIndex :aDesc| |col| |
|
1344 |
col := aDesc isSequenceable ifTrue:[DataSetColumnSpec new fromLiteralArrayEncoding:aDesc] |
|
1345 |
ifFalse:[aDesc]. |
|
1346 |
columnDescriptors add:col. |
|
1347 |
]. |
|
1348 |
! |
|
1349 |
||
1350 |
item:aItem |
|
1351 |
"set the value of the instance variable 'item' (automatically generated)" |
|
1352 |
||
1353 |
| classSelector| |
|
1354 |
||
1355 |
super item:aItem. |
|
1356 |
classSelector := self class classSelectorFor:aItem. |
|
1357 |
(classSelector notNil and:[(Archiver respondsTo:classSelector) notNil]) ifTrue:[ |
|
1358 |
self makeProcessFor:[ |
|
1359 |
self archiver:((Archiver perform:classSelector) with:(self fileName)). |
|
1360 |
self setColumnsForArchiver. |
|
1361 |
] with:'setup archiv'. |
|
1362 |
^ true |
|
1363 |
]. |
|
1364 |
^ false |
|
1365 |
! |
|
1366 |
||
1367 |
temporaryDirectory |
|
1368 |
"return the value of the instance variable 'temporaryDirectory' (automatically generated)" |
|
1369 |
||
1370 |
temporaryDirectory isNil ifTrue:[ |
|
1371 |
temporaryDirectory := Filename newTemporary. |
|
1372 |
temporaryDirectory makeDirectory. |
|
1373 |
]. |
|
1374 |
^ temporaryDirectory |
|
1375 |
! ! |
|
1376 |
||
1377 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'actions'! |
|
1378 |
||
1379 |
changeItem:aItem |
|
1380 |
||
1381 |
self item:aItem. |
|
1382 |
self emptyList. |
|
1383 |
self listAllFilesFromArchiv. |
|
1384 |
^ true |
|
1385 |
! |
|
1386 |
||
1387 |
copyFilesToClipboard |
|
1388 |
||
1389 |
||
1390 |
|sel list stream| |
|
1391 |
||
1392 |
sel := self selectionHolder value. |
|
1393 |
list := self archiveFileList. |
|
1394 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
1395 |
stream := WriteStream on:''. |
|
1396 |
sel do:[: key | |
|
1397 |
stream nextPutAll:(key fileName asString). |
|
1398 |
stream cr. |
|
1399 |
]. |
|
1400 |
self window setTextSelection:stream contents. |
|
1401 |
stream close. |
|
1402 |
]. |
|
1403 |
! |
|
1404 |
||
1405 |
dblClick |
|
1406 |
||
1407 |
self viewFile. |
|
1408 |
! |
|
1409 |
||
1410 |
doStopProcess |
|
1411 |
||
1412 |
| archiver | |
|
1413 |
self stopProcess. |
|
1414 |
archiver := self archiver. |
|
1415 |
archiver notNil ifTrue:[ |
|
1416 |
self archiver stopProcess. |
|
1417 |
]. |
|
1418 |
self enableStopButton value:false. |
|
1419 |
! |
|
1420 |
||
1421 |
emptyList |
|
1422 |
||
1423 |
self archiveFileList value removeAll. |
|
1424 |
! |
|
1425 |
||
1426 |
removeErrorOutput |
|
1427 |
||
1428 |
self viewErrorList value:false. |
|
1429 |
self errorListHolder removeAll. |
|
1430 |
! |
|
1431 |
||
1432 |
removeTemporaryDirectory |
|
1433 |
||
1434 |
| tmp | |
|
1435 |
||
1436 |
temporaryDirectory notNil ifTrue:[ |
|
1437 |
tmp := self temporaryDirectory. |
|
1438 |
(FileDirectory directoryNamed:(tmp directory)) removeDirectory:tmp baseName. |
|
1439 |
temporaryDirectory := nil. |
|
1440 |
]. |
|
1441 |
! |
|
1442 |
||
1443 |
selectAll |
|
1444 |
||
1445 |
| sel listOfFiles| |
|
1446 |
||
1447 |
sel := OrderedCollection new. |
|
1448 |
listOfFiles := self archiveFileList value. |
|
1449 |
1 to:(listOfFiles size) do:[ : el | |
|
1450 |
sel add:el |
|
1451 |
]. |
|
1452 |
self selectionHolder value:sel. |
|
1453 |
! |
|
1454 |
||
1455 |
updateFileBrowserIfPresentWith:aDirectory |
|
1456 |
||
1457 |
| master| |
|
1458 |
||
1459 |
master := self masterApplication. |
|
1460 |
master notNil ifTrue:[ |
|
1461 |
master updateAndSelect:(OrderedCollection with:aDirectory). |
|
1462 |
]. |
|
1463 |
! |
|
1464 |
||
1465 |
viewFile |
|
1466 |
||
1467 |
| master item file tempDir| |
|
1468 |
||
4001 | 1469 |
self canViewFile ifFalse:[^ self]. |
3892 | 1470 |
master := self masterApplication. |
1471 |
self selectionHolder value size = 1 ifFalse:[ |
|
1472 |
Dialog warn:'only one file have to be selected'. |
|
1473 |
^ self. |
|
1474 |
]. |
|
1475 |
tempDir := self temporaryDirectory. |
|
1476 |
self extractSelectedFilesTo:tempDir askForExtractOptions:false. |
|
1477 |
process notNil ifTrue:[ |
|
1478 |
process waitUntilTerminated. |
|
1479 |
]. |
|
1480 |
file := tempDir construct:self selectionHolder value first fileName. |
|
1481 |
file exists ifTrue:[ |
|
3982 | 1482 |
item := DirectoryContentsBrowser itemClass fileName:file. |
3892 | 1483 |
]. |
1484 |
master notNil ifTrue:[ |
|
1485 |
master openApplByFileItem:item. |
|
1486 |
]. |
|
1487 |
! ! |
|
1488 |
||
1489 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'aspects'! |
|
1490 |
||
1491 |
archiveFileList |
|
1492 |
||
1493 |
archiveFileList isNil ifTrue:[ |
|
1494 |
archiveFileList := List new. |
|
1495 |
archiveFileList addDependent:self. |
|
1496 |
]. |
|
1497 |
^ archiveFileList. |
|
1498 |
! |
|
1499 |
||
1500 |
enableRemoveErrorOutput |
|
1501 |
"return/create the 'enableRemoveErrorOutput' value holder (automatically generated)" |
|
1502 |
||
1503 |
enableRemoveErrorOutput isNil ifTrue:[ |
|
1504 |
enableRemoveErrorOutput := false asValue. |
|
1505 |
]. |
|
1506 |
^ enableRemoveErrorOutput |
|
1507 |
! |
|
1508 |
||
1509 |
enableStopButton |
|
1510 |
||
1511 |
enableStopButton isNil ifTrue:[ |
|
1512 |
enableStopButton := false asValue. |
|
1513 |
]. |
|
1514 |
^ enableStopButton |
|
1515 |
! |
|
1516 |
||
1517 |
errorListHolder |
|
1518 |
||
1519 |
errorListHolder isNil ifTrue:[ |
|
1520 |
errorListHolder := List new. |
|
1521 |
]. |
|
1522 |
^ errorListHolder. |
|
1523 |
! |
|
1524 |
||
1525 |
errorListVisibilityHolder |
|
1526 |
||
1527 |
errorListVisibilityHolder isNil ifTrue:[ |
|
1528 |
errorListVisibilityHolder := false asValue. |
|
1529 |
]. |
|
1530 |
^ errorListVisibilityHolder |
|
1531 |
! |
|
1532 |
||
1533 |
hasSelectionInList |
|
1534 |
||
1535 |
| sel | |
|
1536 |
sel := self selectionHolder value. |
|
1537 |
^ (sel notNil and:[sel notEmpty]) |
|
1538 |
! |
|
1539 |
||
1540 |
selectionHolder |
|
1541 |
||
1542 |
selectionHolder isNil ifTrue:[ |
|
1543 |
selectionHolder := ValueHolder new. |
|
1544 |
selectionHolder addDependent:self. |
|
1545 |
]. |
|
1546 |
^ selectionHolder. |
|
1547 |
! |
|
1548 |
||
1549 |
tableColumns |
|
1550 |
||
1551 |
tableColumns isNil ifTrue:[ |
|
1552 |
tableColumns := self class tableColumns asValue. |
|
1553 |
]. |
|
1554 |
^ tableColumns. |
|
1555 |
! |
|
1556 |
||
1557 |
viewErrorList |
|
1558 |
"return/create the 'viewErrorList' value holder (automatically generated)" |
|
1559 |
||
1560 |
viewErrorList isNil ifTrue:[ |
|
1561 |
viewErrorList := false asValue. |
|
1562 |
viewErrorList onChangeSend:#viewErrorListChanged to:self. |
|
1563 |
]. |
|
1564 |
^ viewErrorList |
|
1565 |
! ! |
|
1566 |
||
1567 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'change & update'! |
|
1568 |
||
1569 |
update:something with:aParameter from:changedObject |
|
1570 |
"Invoked when an object that I depend upon sends a change notification." |
|
1571 |
||
1572 |
"stub code automatically generated - please change as required" |
|
1573 |
||
1574 |
changedObject == self archiveFileList ifTrue:[ |
|
1575 |
self hasListEntriesHolder value:(changedObject notEmpty). |
|
1576 |
^ self |
|
1577 |
]. |
|
1578 |
super update:something with:aParameter from:changedObject |
|
1579 |
! |
|
1580 |
||
1581 |
viewErrorListChanged |
|
1582 |
||
1583 |
| viewListValue| |
|
1584 |
||
1585 |
viewListValue := self viewErrorList value. |
|
1586 |
self enableRemoveErrorOutput value:viewListValue. |
|
1587 |
self errorListVisibilityHolder value:viewListValue. |
|
1588 |
! ! |
|
1589 |
||
1590 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'command execution'! |
|
1591 |
||
1592 |
getErrorBlock |
|
1593 |
||
1594 |
^ |
|
1595 |
[: x | |
|
1596 |
self viewErrorList value:true. |
|
1597 |
self errorListHolder value add:x. |
|
1598 |
] |
|
1599 |
! |
|
1600 |
||
1601 |
getErrorStream |
|
1602 |
||
1603 |
|errStream| |
|
1604 |
||
1605 |
errStream := ActorStream new. |
|
1606 |
errStream nextPutLineBlock:(self getErrorBlock). |
|
1607 |
^ errStream |
|
1608 |
! |
|
1609 |
||
1610 |
getOutBlock |
|
1611 |
||
1612 |
|firstLineNotReaded key| |
|
1613 |
||
1614 |
firstLineNotReaded := true. |
|
1615 |
^ [: line | |
|
1616 |
| words ownerGroup item archiverColumns itemWriter index itemWordCount| |
|
1617 |
||
1618 |
(firstLineNotReaded and:[archiver class hasTitleLine]) ifTrue:[ |
|
1619 |
firstLineNotReaded := false. |
|
1620 |
]ifFalse:[ |
|
1621 |
words := line asCollectionOfWords. |
|
1622 |
archiverColumns := archiver class columns. |
|
1623 |
item := ArchivItem new. |
|
1624 |
index := 1. |
|
1625 |
archiverColumns do:[:colDescr | |
|
1626 |
| itemStream | |
|
1627 |
itemWordCount := colDescr second. |
|
1628 |
itemWriter := ((colDescr first) asString, ':') asSymbol. |
|
1629 |
itemStream := WriteStream on:''. |
|
1630 |
index to:(index + itemWordCount - 1) do:[:i| |
|
1631 |
itemStream nextPutAll:(words at:i). |
|
1632 |
itemStream space. |
|
1633 |
]. |
|
1634 |
item perform:itemWriter with:(itemStream contents). |
|
1635 |
itemStream close. |
|
1636 |
index := index + itemWordCount. |
|
1637 |
]. |
|
1638 |
((archiverColumns collect:[:el| el first]) includes:#permissions) ifTrue:[ |
|
1639 |
(item permissions startsWith:$d) ifTrue:[ |
|
1640 |
key := #directory. |
|
1641 |
item isDirectory:true. |
|
1642 |
] ifFalse:[ |
|
1643 |
key := MIMETypes mimeTypeForFilename:(item fileName asFilename baseName). |
|
1644 |
item isDirectory:false. |
|
1645 |
]. |
|
1646 |
] ifFalse:[ |
|
1647 |
key := MIMETypes mimeTypeForFilename:(item fileName asFilename baseName). |
|
1648 |
]. |
|
1649 |
item icon:(FileBrowser iconForKeyMatching:key). |
|
1650 |
self archiveFileList value add:item |
|
1651 |
]. |
|
1652 |
] |
|
1653 |
! |
|
1654 |
||
1655 |
getOutStream |
|
1656 |
||
1657 |
|outStream| |
|
1658 |
||
1659 |
outStream := ActorStream new. |
|
1660 |
outStream nextPutLineBlock:(self getOutBlock). |
|
1661 |
^ outStream |
|
1662 |
! |
|
1663 |
||
1664 |
makeProcessFor:aBlock |
|
1665 |
||
1666 |
self makeProcessFor:aBlock with:'' |
|
1667 |
! |
|
1668 |
||
1669 |
makeProcessFor:aBlock with:string |
|
1670 |
||
1671 |
| locBlock | |
|
1672 |
||
1673 |
process notNil ifTrue:[ |
|
1674 |
process waitUntilTerminated. |
|
1675 |
terminateByMe ifTrue:[ |
|
1676 |
terminateByMe := false. |
|
1677 |
^ self |
|
1678 |
]. |
|
1679 |
]. |
|
1680 |
locBlock := [ [ |
|
1681 |
self notifyChannel value:string. |
|
1682 |
aBlock value. |
|
1683 |
self notifyChannel value:''. |
|
1684 |
] valueNowOrOnUnwindDo:[ |
|
1685 |
process := nil. |
|
1686 |
self enableStopButton value:false. |
|
1687 |
] |
|
1688 |
]. |
|
1689 |
process := locBlock newProcess. |
|
1690 |
process priority:(Processor systemBackgroundPriority). |
|
1691 |
process name:'ArchiveApplicationProcess'. |
|
1692 |
self enableStopButton value:true. |
|
1693 |
process resume. |
|
1694 |
! |
|
1695 |
||
1696 |
setColumnsForArchiver |
|
1697 |
||
1698 |
| newColumns archiverColumns allColumns iconColumn| |
|
1699 |
||
1700 |
archiverColumns := archiver class columns collect:[:el| el first]. |
|
1701 |
allColumns := OrderedCollection new. |
|
1702 |
newColumns := OrderedCollection new. |
|
1703 |
self class tableColumns do:[:el| |
|
1704 |
allColumns add:(DataSetColumnSpec new fromLiteralArrayEncoding:el). |
|
1705 |
]. |
|
1706 |
iconColumn := allColumns detect:[: col | (col id asSymbol) = #icon] ifNone:[nil]. |
|
1707 |
iconColumn notNil ifTrue:[ |
|
1708 |
newColumns add:iconColumn. |
|
1709 |
]. |
|
1710 |
allColumns do:[:col| |
|
1711 |
(archiverColumns includes:(col id asSymbol)) ifTrue:[ |
|
1712 |
newColumns add:col. |
|
1713 |
]. |
|
1714 |
]. |
|
1715 |
self tableColumns value:newColumns. |
|
1716 |
self columnDescriptors:(self tableColumns value). |
|
1717 |
! |
|
1718 |
||
1719 |
stopProcess |
|
1720 |
||
1721 |
|task| |
|
1722 |
||
1723 |
terminateByMe := true. |
|
1724 |
(task := process) notNil ifTrue:[ |
|
1725 |
process := nil. |
|
1726 |
||
1727 |
Object errorSignal handle:[:ex| |
|
1728 |
Dialog warn:ex description. |
|
1729 |
]do:[ |
|
1730 |
task isDead ifFalse:[ |
|
3919 | 1731 |
task terminateWithAllSubprocessesInGroup. |
3892 | 1732 |
task waitUntilTerminated. |
1733 |
] |
|
1734 |
] |
|
1735 |
]. |
|
1736 |
! ! |
|
1737 |
||
1738 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'command helper'! |
|
1739 |
||
1740 |
selectDirectoryDialog |
|
1741 |
||
1742 |
| dir directory haveDirectory| |
|
1743 |
||
1744 |
directory := self fileName directory. |
|
1745 |
haveDirectory := false. |
|
1746 |
[haveDirectory] whileFalse:[ |
|
1747 |
dir := Dialog requestDirectoryName:'Which directory ?' default:dir. |
|
3988 | 1748 |
dir isEmpty ifTrue:[ ^ nil]. |
3892 | 1749 |
dir := dir asFilename. |
1750 |
(dir isExecutable not or:[dir isWritable not]) ifTrue:[ |
|
1751 |
Dialog warn:'cant write to: ', dir asString. |
|
1752 |
]. |
|
1753 |
haveDirectory := true. |
|
1754 |
]. |
|
1755 |
^ dir |
|
3988 | 1756 |
! |
1757 |
||
1758 |
selectDirectoryDialog:message |
|
1759 |
||
1760 |
| dir directory haveDirectory| |
|
1761 |
||
1762 |
directory := self fileName directory. |
|
1763 |
haveDirectory := false. |
|
1764 |
[haveDirectory] whileFalse:[ |
|
1765 |
dir := Dialog requestDirectoryName:message default:dir. |
|
1766 |
dir isEmpty ifTrue:[ ^ nil]. |
|
1767 |
dir := dir asFilename. |
|
1768 |
(dir isExecutable not or:[dir isWritable not]) ifTrue:[ |
|
1769 |
Dialog warn:'Cannot write to: ', dir asString. |
|
1770 |
^ nil. |
|
1771 |
]. |
|
1772 |
haveDirectory := true. |
|
1773 |
]. |
|
1774 |
^ dir |
|
3892 | 1775 |
! ! |
1776 |
||
1777 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands add'! |
|
1778 |
||
1779 |
addFilesToArchiv:colOfFiles |
|
1780 |
||
1781 |
||
1782 |
self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
|
1783 |
self makeProcessFor:[ |
|
1784 |
self archiver addFilesToArchiv:colOfFiles. |
|
1785 |
] with:'add Files to archiv'. |
|
1786 |
(self archiver class == Archiver zipArchive) ifTrue:[ |
|
1787 |
self listAllFilesFromArchiv. |
|
1788 |
] ifFalse:[ |
|
1789 |
self listFilesFromArchiv:colOfFiles. |
|
1790 |
]. |
|
1791 |
^ true. |
|
1792 |
! ! |
|
1793 |
||
1794 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands extract'! |
|
1795 |
||
1796 |
extractAll |
|
1797 |
||
1798 |
self extractSelectedFilesTo:nil withSelection:#all |
|
1799 |
! |
|
1800 |
||
1801 |
extractSelectedFilesTo:aDirectory askForExtractOptions:askForExtractOptionsBoolean |
|
1802 |
||
1803 |
self extractSelectedFilesTo:aDirectory withSelection:#selection askForExtractOptions:askForExtractOptionsBoolean |
|
1804 |
! |
|
1805 |
||
1806 |
extractSelectedFilesTo:aDirectory withSelection:selectOrAll |
|
1807 |
||
1808 |
self extractSelectedFilesTo:aDirectory withSelection:selectOrAll askForExtractOptions:true. |
|
1809 |
! |
|
1810 |
||
1811 |
extractSelectedFilesTo:aDirectory withSelection:selectOrAll askForExtractOptions:askForExtractOptionsBoolean |
|
1812 |
||
1813 |
| dir| |
|
1814 |
||
1815 |
aDirectory isNil ifTrue:[ |
|
3988 | 1816 |
dir := self selectDirectoryDialog:'Extract in which directory ?'. |
3892 | 1817 |
dir isNil ifTrue:[^ self]. |
1818 |
] ifFalse:[ |
|
1819 |
dir := aDirectory. |
|
1820 |
]. |
|
1821 |
selectOrAll == #all ifTrue:[ |
|
1822 |
self extractAllTo:dir. |
|
1823 |
]. |
|
1824 |
selectOrAll == #selection ifTrue:[ |
|
1825 |
self extractSelectionTo:dir askForExtractOptions:askForExtractOptionsBoolean |
|
1826 |
]. |
|
4001 | 1827 |
"/ self updateFileBrowserIfPresentWith:dir. |
3892 | 1828 |
! ! |
1829 |
||
1830 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands extract private'! |
|
1831 |
||
1832 |
extractAllTo:aDirectory |
|
1833 |
||
1834 |
self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
|
1835 |
self makeProcessFor:[ |
|
1836 |
self archiver extractTo:aDirectory. |
|
1837 |
] with:'extract all files'. |
|
1838 |
^ true. |
|
1839 |
! |
|
1840 |
||
1841 |
extractSelectionTo:aDirectory askForExtractOptions:askForExtractOptionsBoolean |
|
1842 |
||
1843 |
| sel index extractWithDirectoryPart extractAllFilesInSelectedDirectories extractFiles| |
|
1844 |
||
1845 |
extractWithDirectoryPart := true. |
|
1846 |
extractAllFilesInSelectedDirectories := false. |
|
1847 |
sel := self selectionHolder value. |
|
1848 |
(sel isNil or:[sel isEmpty]) ifTrue:[ |
|
1849 |
sel := self archiveFileList value. |
|
1850 |
]. |
|
1851 |
sel := sel do:[:item| |
|
1852 |
item fileName: item fileName |
|
1853 |
]. |
|
1854 |
(askForExtractOptionsBoolean and:[self archiver class ~= Archiver zipArchive]) ifTrue:[ |
|
1855 |
extractFiles := self selRemoveFilesForDirs:sel. |
|
1856 |
] ifFalse:[ |
|
1857 |
extractFiles := sel. |
|
1858 |
]. |
|
1859 |
||
1860 |
askForExtractOptionsBoolean ifTrue:[ |
|
1861 |
index := extractFiles findFirst:[: el | el hasDirectoryPart]. |
|
1862 |
index ~= 0 ifTrue:[ |
|
1863 |
extractWithDirectoryPart := (Dialog confirmWithCancel:'Extract with directory part?' default:true). |
|
1864 |
extractWithDirectoryPart isNil ifTrue:[^ false]. |
|
1865 |
]. |
|
1866 |
]. |
|
1867 |
extractWithDirectoryPart ifTrue:[ |
|
1868 |
self extractWithDirectoryPartTo:aDirectory with:extractFiles. |
|
1869 |
] ifFalse:[ |
|
1870 |
self extractWithOutDirectoryPartTo:aDirectory with:extractFiles. |
|
1871 |
]. |
|
1872 |
^ true |
|
1873 |
! |
|
1874 |
||
1875 |
extractWithDirectoryPartTo:aDirectory with:extractFiles |
|
1876 |
||
1877 |
self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
|
1878 |
self makeProcessFor:[ |
|
1879 |
self archiver extractTo:aDirectory with:extractFiles. |
|
1880 |
] with:('extract Files to ', aDirectory asString). |
|
1881 |
^ true. |
|
1882 |
! |
|
1883 |
||
1884 |
extractWithOutDirectoryPartTo:aDirectory with:extractFiles |
|
1885 |
||
1886 |
self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
|
1887 |
self makeProcessFor:[ |
|
1888 |
self archiver extractWithOutDirectoryTo:aDirectory |
|
1889 |
with:(extractFiles collect:[:item| item fileName]). |
|
1890 |
] with:('extract Files to ', aDirectory asString). |
|
1891 |
^ true. |
|
1892 |
! ! |
|
1893 |
||
1894 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands list'! |
|
1895 |
||
1896 |
listAllFilesFromArchiv |
|
1897 |
||
1898 |
self archiveFileList value removeAll. |
|
1899 |
self listFilesFromArchiv:nil |
|
1900 |
! |
|
1901 |
||
1902 |
listFilesFromArchiv:newColOfFiles |
|
1903 |
||
1904 |
process notNil ifTrue:[ |
|
1905 |
process waitUntilTerminated. |
|
1906 |
]. |
|
1907 |
self archiver outStream:(self getOutStream) errorStream:(self getErrorStream) synchron:true. |
|
1908 |
self makeProcessFor:[ |
|
1909 |
self archiver listFilesFromArchiv:newColOfFiles. |
|
1910 |
] with:'list Files'. |
|
1911 |
! ! |
|
1912 |
||
1913 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands remove'! |
|
1914 |
||
1915 |
removeFilesFromArchiv |
|
1916 |
||
1917 |
| sel realSel list firtsPre stringCol stringRealSel| |
|
1918 |
||
1919 |
sel := self selectionHolder value. |
|
1920 |
stringCol := sel collect:[: item| item fileName]. |
|
1921 |
firtsPre := stringCol at:1. |
|
1922 |
stringCol from:2 do:[:el| |
|
1923 |
firtsPre := firtsPre commonPrefixWith:el. |
|
1924 |
]. |
|
1925 |
list := self archiveFileList value. |
|
1926 |
realSel := OrderedCollection new. |
|
1927 |
list do:[:item| |
|
1928 |
((item fileName) startsWith:firtsPre) ifTrue:[ |
|
1929 |
realSel add:item. |
|
1930 |
]. |
|
1931 |
]. |
|
1932 |
stringRealSel := realSel collect:[: item| item fileName]. |
|
1933 |
||
1934 |
self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
|
1935 |
self makeProcessFor:[ |
|
1936 |
self archiver removeFilesFromArchiv:stringCol. |
|
1937 |
] with:'remove files'. |
|
1938 |
||
1939 |
self archiveFileList value removeAll:realSel |
|
1940 |
! ! |
|
1941 |
||
1942 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'drag & drop'! |
|
1943 |
||
3951 | 1944 |
canDrop:aContext |
1945 |
||
1946 |
^ inDropMode |
|
3892 | 1947 |
! |
1948 |
||
1949 |
doDrop:aContext |
|
1950 |
||
1951 |
|col source arg objects| |
|
1952 |
||
1953 |
source := aContext dropSource. |
|
1954 |
arg := source argument. |
|
1955 |
objects := aContext dropObjects. |
|
1956 |
col := OrderedCollection new. |
|
1957 |
objects do:[:obj| |
|
1958 |
col add:(obj theObject). |
|
1959 |
]. |
|
1960 |
^ self addFilesToArchiv:col. |
|
1961 |
! |
|
1962 |
||
1963 |
doStartDrag:aDropSource in:aView |
|
1964 |
"set the cursors before starting the drag & drop operation |
|
1965 |
" |
|
1966 |
|hdl sel| |
|
1967 |
||
4018 | 1968 |
archiver class canDragnDrop ifFalse:[^ self]. |
3892 | 1969 |
sel := self selectionHolder value. |
1970 |
||
1971 |
hdl := DragAndDropManager new. |
|
1972 |
||
3951 | 1973 |
hdl disabledCursor:AbstractFileBrowser DisabledCursorImage. |
1974 |
hdl enabledCursor:AbstractFileBrowser EnabledCursorImage. |
|
3892 | 1975 |
hdl alienCursor:nil. |
1976 |
||
1977 |
hdl startDragFrom:aView dropSource:aDropSource offset:#topLeft |
|
1978 |
! |
|
1979 |
||
3951 | 1980 |
dropEnter:aContext |
1981 |
||
1982 |
| dropedObjects| |
|
1983 |
||
1984 |
inDropMode := false. |
|
1985 |
(aContext dropSource receiver == self) ifTrue:[^ self]. |
|
1986 |
dropedObjects := aContext dropObjects. |
|
1987 |
||
1988 |
||
1989 |
dropedObjects do:[:aObject| |checkObject checkObjectString| |
|
1990 |
aObject isFileObject ifFalse:[^ self]. |
|
1991 |
checkObject := aObject theObject. |
|
1992 |
checkObject isFilename not ifTrue:[^ self]. |
|
1993 |
checkObject isSpecialFile ifTrue:[^ self]. |
|
1994 |
]. |
|
1995 |
inDropMode := true. |
|
1996 |
! |
|
1997 |
||
1998 |
dropLeave:aContext |
|
1999 |
||
2000 |
inDropMode := false. |
|
2001 |
! |
|
2002 |
||
3892 | 2003 |
getDisplayObjects:anArgument |
2004 |
||
2005 |
| sel string size fnName stream| |
|
2006 |
sel := self selectionHolder value. |
|
2007 |
size := sel size. |
|
2008 |
size == 0 ifTrue:[^ '']. |
|
2009 |
stream := WriteStream on:''. |
|
2010 |
stream nextPutAll:(sel first fileName asFilename baseName asString). |
|
2011 |
size == 1 ifTrue:[ |
|
2012 |
fnName := 'ui_menuitem.xpm'. |
|
2013 |
] ifFalse:[ |
|
2014 |
fnName := 'ui_submenu_open.xpm'. |
|
2015 |
stream nextPutAll:' ... '. |
|
2016 |
stream nextPutAll:(sel last fileName asFilename baseName asString). |
|
2017 |
]. |
|
2018 |
string := stream contents. |
|
2019 |
stream close. |
|
2020 |
^ Array with:(LabelAndIcon icon:(Image fromFile:fnName) |
|
2021 |
string:(Text string:string emphasis:#bold) |
|
2022 |
) |
|
2023 |
! |
|
2024 |
||
2025 |
getDropObjects:anArgument |
|
2026 |
||
2027 |
| sel ret| |
|
2028 |
sel := self selectionHolder value. |
|
2029 |
ret := sel collect:[:el| |
|
3951 | 2030 |
DropObject newFile:(el fileName asFilename) |
3892 | 2031 |
]. |
2032 |
^ ret |
|
2033 |
! ! |
|
2034 |
||
2035 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'event handling'! |
|
2036 |
||
2037 |
processEvent:anEvent |
|
2038 |
"filter keyboard events. |
|
2039 |
Return true, if I have eaten the event" |
|
2040 |
||
2041 |
|focusView key rawKey| |
|
2042 |
||
2043 |
anEvent isKeyPressEvent ifTrue:[ |
|
2044 |
focusView := anEvent targetView. |
|
2045 |
key := anEvent key. |
|
2046 |
rawKey := anEvent rawKey. |
|
2047 |
||
2048 |
(focusView isSameOrComponentOf:self window) ifTrue:[ |
|
2049 |
"/ (key ~= #'Alt_L') ifTrue:[self halt.]. |
|
2050 |
(key == #Delete) ifTrue:[ |
|
2051 |
self removeFilesFromArchiv. |
|
2052 |
^ true |
|
2053 |
]. |
|
2054 |
] |
|
2055 |
]. |
|
2056 |
^ false |
|
2057 |
! ! |
|
2058 |
||
2059 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'initialization & release'! |
|
2060 |
||
2061 |
postBuildFileTable:aWidget |
|
2062 |
||
2063 |
fileTable := aWidget scrolledView. |
|
2064 |
fileTable wantsFocusWithPointerEnter. |
|
2065 |
"/ FileBrowser icons keysAndValuesDo:[:aKey :anIcon| |
|
2066 |
"/ fileTable registerImage:anIcon key:aKey. |
|
2067 |
"/ ]. |
|
2068 |
self columnDescriptors:(self class tableColumns). |
|
2069 |
! |
|
2070 |
||
2071 |
postOpenWith:aBuilder |
|
2072 |
||
2073 |
| currentDir contents suffix fileName file archivItem| |
|
2074 |
||
2075 |
self windowGroup addPreEventHook:self. |
|
2076 |
self masterApplication isNil ifTrue:[ |
|
2077 |
self masterApplication:nil. |
|
2078 |
currentDir := Filename homeDirectory. |
|
2079 |
contents := currentDir directoryContents. |
|
2080 |
fileName := contents detect:[: file | |
|
2081 |
suffix := file asFilename suffix asLowercase. |
|
2082 |
suffix = 'tgz' |
|
2083 |
] ifNone:[nil]. |
|
2084 |
fileName isNil ifTrue:[ |
|
2085 |
Dialog warn:'cant find a Zip file in ', currentDir asString. |
|
2086 |
^ self |
|
2087 |
]. |
|
2088 |
file := currentDir construct:fileName. |
|
3982 | 2089 |
archivItem := DirectoryContentsBrowser itemClass fileName:file. |
3892 | 2090 |
(self item:archivItem) ifFalse:[ |
2091 |
Dialog warn:'file type of ', item fileName asString, ' not supported'. |
|
2092 |
^ self. |
|
2093 |
]. |
|
2094 |
]. |
|
2095 |
self listAllFilesFromArchiv. |
|
2096 |
^ super postOpenWith:aBuilder. |
|
2097 |
! |
|
2098 |
||
2099 |
release |
|
2100 |
||
2101 |
self archiver release. |
|
2102 |
^ super release. |
|
2103 |
! ! |
|
2104 |
||
2105 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'queries'! |
|
2106 |
||
2107 |
archivType |
|
2108 |
||
2109 |
| file firstsuffix secondsuffix| |
|
2110 |
||
2111 |
file := self fileName. |
|
2112 |
firstsuffix := file withoutSuffix suffix. |
|
2113 |
secondsuffix := file suffix. |
|
2114 |
(secondsuffix = 'tgz' or:[firstsuffix = 'tar' and:[secondsuffix = 'gz']]) ifTrue:[ |
|
2115 |
^ #tarFileCompressed |
|
2116 |
]. |
|
2117 |
(secondsuffix = 'tar') ifTrue:[ |
|
2118 |
^ #tarFile |
|
2119 |
]. |
|
2120 |
(secondsuffix = 'gz') ifTrue:[ |
|
2121 |
^ #gzipFile |
|
2122 |
]. |
|
2123 |
(secondsuffix = 'zip') ifTrue:[ |
|
2124 |
^ #zipFile |
|
2125 |
]. |
|
2126 |
! |
|
2127 |
||
2128 |
canDelete |
|
2129 |
||
2130 |
^ (self hasOneSelectionInList and:[archiver class canRemoveFiles]) |
|
2131 |
! |
|
2132 |
||
4001 | 2133 |
canViewFile |
2134 |
||
2135 |
^ self archiver class canViewFile and:[self hasOneSelectionInList] |
|
2136 |
! |
|
2137 |
||
2138 |
hasListEntriesHolder |
|
2139 |
"return/create the 'hasListEntriesHolder' value holder (automatically generated)" |
|
2140 |
||
2141 |
hasListEntriesHolder isNil ifTrue:[ |
|
2142 |
hasListEntriesHolder := false asValue. |
|
2143 |
]. |
|
2144 |
^ hasListEntriesHolder |
|
2145 |
! |
|
2146 |
||
2147 |
hasOneSelectionInList |
|
2148 |
||
2149 |
| sel | |
|
2150 |
sel := self selectionHolder value. |
|
2151 |
^ (sel notNil and:[sel notEmpty and:[sel size = 1]]) |
|
2152 |
! |
|
2153 |
||
3892 | 2154 |
selRemoveFilesForDirs:aSel |
2155 |
||
2156 |
|stringCol newSel string| |
|
2157 |
||
2158 |
stringCol := (aSel collect:[: item| item fileName]). |
|
2159 |
newSel := aSel copy. |
|
2160 |
aSel do:[:item | |
|
2161 |
item isDirectory ifTrue:[ |
|
2162 |
string := item fileName. |
|
2163 |
stringCol doWithIndex:[:filename : index| |
|
2164 |
(filename ~= string and:[filename startsWith:string]) ifTrue:[ |
|
2165 |
newSel remove:(aSel at:index) ifAbsent:[nil]. |
|
2166 |
] |
|
2167 |
] |
|
2168 |
]. |
|
2169 |
]. |
|
2170 |
^ newSel. |
|
2171 |
! ! |
|
2172 |
||
2173 |
!FileApplicationNoteBook::ArchiveViewApplication methodsFor:'sorting'! |
|
2174 |
||
2175 |
generateSortBlock:instanceName |
|
2176 |
||
2177 |
| aSymbol cmpOp sortCaselessLocal| |
|
2178 |
||
2179 |
aSymbol := instanceName asSymbol. |
|
2180 |
sortCaselessLocal := self sortCaseless value. |
|
2181 |
currentSortOrder isNil ifTrue:[ |
|
2182 |
currentSortOrder := aSymbol. |
|
2183 |
currentSortOrder := Dictionary new. |
|
2184 |
currentSortOrder at:#column put:aSymbol. |
|
2185 |
currentSortOrder at:#reverse put:false. |
|
2186 |
currentSortOrder at:#sortCaseless put:sortCaselessLocal. |
|
2187 |
] ifFalse:[ |
|
2188 |
(currentSortOrder at:#column) = aSymbol ifTrue:[ |
|
2189 |
"/ same column like before - change sort order |
|
2190 |
| isReverse | |
|
2191 |
isReverse := currentSortOrder at:#reverse. |
|
2192 |
currentSortOrder at:#reverse put:(isReverse not). |
|
2193 |
] ifFalse:[ |
|
2194 |
"/ another column - remark column |
|
2195 |
currentSortOrder at:#column put:aSymbol. |
|
2196 |
] |
|
2197 |
]. |
|
2198 |
(currentSortOrder at:#reverse) ifTrue:[ |
|
2199 |
cmpOp := #'>' |
|
2200 |
] ifFalse:[ |
|
2201 |
cmpOp := #'<' |
|
2202 |
]. |
|
2203 |
^ [:a :b | |
|
2204 |
|entry1 entry2| |
|
2205 |
||
2206 |
entry1 := (a perform:aSymbol). |
|
2207 |
entry2 := (b perform:aSymbol). |
|
2208 |
aSymbol = #fileName ifTrue:[ |
|
2209 |
sortCaselessLocal ifTrue:[ |
|
2210 |
entry1 := entry1 asString asLowercase. |
|
2211 |
entry2 := entry2 asString asLowercase. |
|
2212 |
] ifFalse:[ |
|
2213 |
entry1 := entry1 asString. |
|
2214 |
entry2 := entry2 asString. |
|
2215 |
]. |
|
2216 |
]. |
|
2217 |
entry1 perform:cmpOp with:entry2 |
|
2218 |
]. |
|
2219 |
! |
|
2220 |
||
2221 |
sortList:instanceName |
|
2222 |
||
2223 |
||
2224 |
|sortBlock fileList sortCol| |
|
2225 |
||
2226 |
sortBlock := self generateSortBlock:instanceName. |
|
2227 |
fileList := self archiveFileList value. |
|
2228 |
sortCol := SortedCollection sortBlock:sortBlock. |
|
2229 |
sortCol addAll:fileList. |
|
2230 |
fileList removeAll. |
|
2231 |
fileList addAll:sortCol. |
|
2232 |
! ! |
|
2233 |
||
2234 |
!FileApplicationNoteBook::ArchiveViewApplication::ArchivItem methodsFor:'accessing'! |
|
2235 |
||
2236 |
compressSize |
|
2237 |
"return the value of the instance variable 'compressSize' (automatically generated)" |
|
2238 |
||
2239 |
^ compressSize |
|
2240 |
! |
|
2241 |
||
2242 |
compressSize:something |
|
2243 |
"set the value of the instance variable 'compressSize' (automatically generated)" |
|
2244 |
||
2245 |
compressSize := something. |
|
2246 |
! |
|
2247 |
||
2248 |
crc |
|
2249 |
"return the value of the instance variable 'crc' (automatically generated)" |
|
2250 |
||
2251 |
^ crc |
|
2252 |
! |
|
2253 |
||
2254 |
crc:something |
|
2255 |
"set the value of the instance variable 'crc' (automatically generated)" |
|
2256 |
||
2257 |
crc := something. |
|
2258 |
! |
|
2259 |
||
2260 |
dateAndTime |
|
2261 |
"return the value of the instance variable 'dateAndTime' (automatically generated)" |
|
2262 |
||
2263 |
^ dateAndTime |
|
2264 |
! |
|
2265 |
||
2266 |
dateAndTime:something |
|
2267 |
"set the value of the instance variable 'dateAndTime' (automatically generated)" |
|
2268 |
||
2269 |
dateAndTime := something. |
|
2270 |
! |
|
2271 |
||
2272 |
fileName |
|
2273 |
"return the value of the instance variable 'fileName' (automatically generated)" |
|
2274 |
||
2275 |
^ fileName |
|
2276 |
! |
|
2277 |
||
2278 |
fileName:something |
|
2279 |
"set the value of the instance variable 'fileName' (automatically generated)" |
|
2280 |
||
2281 |
fileName := something withoutSpaces. |
|
2282 |
! |
|
2283 |
||
2284 |
icon |
|
2285 |
"return the value of the instance variable 'icon' (automatically generated)" |
|
2286 |
||
2287 |
^ icon |
|
2288 |
! |
|
2289 |
||
2290 |
icon:something |
|
2291 |
"set the value of the instance variable 'icon' (automatically generated)" |
|
2292 |
||
2293 |
icon := something. |
|
2294 |
! |
|
2295 |
||
2296 |
isDirectory |
|
2297 |
"return the value of the instance variable 'directory' (automatically generated)" |
|
2298 |
||
2299 |
^ isDirectory |
|
2300 |
! |
|
2301 |
||
2302 |
isDirectory:something |
|
2303 |
"set the value of the instance variable 'isDirectory' (automatically generated)" |
|
2304 |
||
2305 |
isDirectory := something. |
|
2306 |
! |
|
2307 |
||
2308 |
method |
|
2309 |
"return the value of the instance variable 'method' (automatically generated)" |
|
2310 |
||
2311 |
^ method |
|
2312 |
! |
|
2313 |
||
2314 |
method:something |
|
2315 |
"set the value of the instance variable 'method' (automatically generated)" |
|
2316 |
||
2317 |
method := something. |
|
2318 |
! |
|
2319 |
||
2320 |
ownerGroup |
|
2321 |
"return the value of the instance variable 'owner' (automatically generated)" |
|
2322 |
||
2323 |
^ ownerGroup |
|
2324 |
! |
|
2325 |
||
2326 |
ownerGroup:something |
|
2327 |
"set the value of the instance variable 'owner' (automatically generated)" |
|
2328 |
||
2329 |
ownerGroup := something. |
|
2330 |
! |
|
2331 |
||
2332 |
permissions |
|
2333 |
"return the value of the instance variable 'permissions' (automatically generated)" |
|
2334 |
||
2335 |
^ permissions |
|
2336 |
! |
|
2337 |
||
2338 |
permissions:something |
|
2339 |
"set the value of the instance variable 'permissions' (automatically generated)" |
|
2340 |
||
2341 |
permissions := something. |
|
2342 |
! |
|
2343 |
||
2344 |
ratio |
|
2345 |
"return the value of the instance variable 'ratio' (automatically generated)" |
|
2346 |
||
2347 |
^ ratio |
|
2348 |
! |
|
2349 |
||
2350 |
ratio:something |
|
2351 |
"set the value of the instance variable 'ratio' (automatically generated)" |
|
2352 |
||
2353 |
ratio := something. |
|
2354 |
! |
|
2355 |
||
2356 |
size |
|
2357 |
"return the value of the instance variable 'size' (automatically generated)" |
|
2358 |
||
2359 |
^ size |
|
2360 |
! |
|
2361 |
||
2362 |
size:something |
|
2363 |
"set the value of the instance variable 'size' (automatically generated)" |
|
2364 |
||
2365 |
size := something. |
|
2366 |
! |
|
2367 |
||
2368 |
sizeAsNumber |
|
2369 |
"return the value of the instance variable 'size' (automatically generated)" |
|
2370 |
||
2371 |
^ size asInteger |
|
2372 |
! |
|
2373 |
||
2374 |
type |
|
2375 |
"return the value of the instance variable 'type' (automatically generated)" |
|
2376 |
||
2377 |
^ type |
|
2378 |
! |
|
2379 |
||
2380 |
type:something |
|
2381 |
"set the value of the instance variable 'type' (automatically generated)" |
|
2382 |
||
2383 |
type := something. |
|
2384 |
! |
|
2385 |
||
2386 |
version |
|
2387 |
"return the value of the instance variable 'version' (automatically generated)" |
|
2388 |
||
2389 |
^ version |
|
2390 |
! |
|
2391 |
||
2392 |
version:something |
|
2393 |
"set the value of the instance variable 'version' (automatically generated)" |
|
2394 |
||
2395 |
version := something. |
|
2396 |
! ! |
|
2397 |
||
2398 |
!FileApplicationNoteBook::ArchiveViewApplication::ArchivItem methodsFor:'printing'! |
|
2399 |
||
2400 |
printString |
|
2401 |
||
2402 |
^ self fileName asString |
|
2403 |
! ! |
|
2404 |
||
2405 |
!FileApplicationNoteBook::ArchiveViewApplication::ArchivItem methodsFor:'queries'! |
|
2406 |
||
2407 |
hasDirectoryPart |
|
2408 |
||
2409 |
^ self fileName asFilename components size ~= 1 |
|
2410 |
! ! |
|
2411 |
||
2412 |
!FileApplicationNoteBook::CommandResult class methodsFor:'defaults'! |
|
2413 |
||
2414 |
tabStringFor:aApplicationType |
|
2415 |
||
2416 |
^ 'Execution result' |
|
2417 |
! |
|
2418 |
||
2419 |
wantNewApplicationAnyway |
|
2420 |
||
2421 |
^ false |
|
2422 |
! ! |
|
2423 |
||
2424 |
!FileApplicationNoteBook::CommandResult class methodsFor:'interface specs'! |
|
2425 |
||
2426 |
windowSpec |
|
2427 |
"This resource specification was automatically generated |
|
2428 |
by the UIPainter of ST/X." |
|
2429 |
||
2430 |
"Do not manually edit this!! If it is corrupted, |
|
2431 |
the UIPainter may not be able to read the specification." |
|
2432 |
||
2433 |
" |
|
2434 |
UIPainter new openOnClass:NoteBookApplication::CommandResult andSelector:#windowSpec |
|
2435 |
NoteBookApplication::CommandResult new openInterface:#windowSpec |
|
2436 |
NoteBookApplication::CommandResult open |
|
2437 |
" |
|
2438 |
||
2439 |
<resource: #canvas> |
|
2440 |
||
2441 |
^ |
|
2442 |
#(#FullSpec |
|
2443 |
#name: #windowSpec |
|
2444 |
#window: |
|
2445 |
#(#WindowSpec |
|
2446 |
#label: 'NoteBookApplication::CommandResult' |
|
2447 |
#name: 'NoteBookApplication::CommandResult' |
|
2448 |
#min: #(#Point 10 10) |
|
2449 |
#max: #(#Point 1024 768) |
|
2450 |
#bounds: #(#Rectangle 16 42 519 395) |
|
2451 |
#menu: #mainMenu |
|
2452 |
) |
|
2453 |
#component: |
|
2454 |
#(#SpecCollection |
|
2455 |
#collection: #( |
|
2456 |
#(#MenuPanelSpec |
|
2457 |
#name: 'ToolBar1' |
|
2458 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
2459 |
#menu: #menu |
|
2460 |
#textDefault: true |
|
2461 |
) |
|
2462 |
#(#ArbitraryComponentSpec |
|
2463 |
#name: 'ArbitraryComponent1' |
|
2464 |
#layout: #(#LayoutFrame 0 0.0 32 0 0 1.0 0 1) |
|
2465 |
#hasHorizontalScrollBar: true |
|
2466 |
#hasVerticalScrollBar: true |
|
2467 |
#hasBorder: false |
|
2468 |
#component: #TextCollector |
|
2469 |
#postBuildCallback: #postBuildTextCollector: |
|
2470 |
) |
|
2471 |
#(#LabelSpec |
|
2472 |
#label: 'FileLabel' |
|
2473 |
#name: 'FileLabel' |
|
2474 |
#layout: #(#LayoutFrame 87 0 2 0 -36 1 30 0) |
|
2475 |
#level: -1 |
|
2476 |
#translateLabel: true |
|
2477 |
#labelChannel: #labelHolder |
|
2478 |
#adjust: #left |
|
2479 |
) |
|
2480 |
) |
|
2481 |
||
2482 |
) |
|
2483 |
) |
|
2484 |
! ! |
|
2485 |
||
2486 |
!FileApplicationNoteBook::CommandResult class methodsFor:'menu specs'! |
|
2487 |
||
2488 |
menu |
|
2489 |
"This resource specification was automatically generated |
|
2490 |
by the MenuEditor of ST/X." |
|
2491 |
||
2492 |
"Do not manually edit this!! If it is corrupted, |
|
2493 |
the MenuEditor may not be able to read the specification." |
|
2494 |
||
2495 |
" |
|
2496 |
MenuEditor new openOnClass:FileApplicationNoteBook::CommandResult andSelector:#menu |
|
2497 |
(Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::CommandResult menu)) startUp |
|
2498 |
" |
|
2499 |
||
2500 |
<resource: #menu> |
|
2501 |
||
2502 |
^ |
|
2503 |
#(#Menu |
|
2504 |
#( |
|
2505 |
#(#MenuItem |
|
2506 |
#label: 'Stop' |
|
2507 |
#translateLabel: true |
|
2508 |
#isButton: true |
|
2509 |
#nameKey: #Stop |
|
2510 |
#value: #doStopProcess |
|
2511 |
#enabled: #enableStopButton |
|
2512 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #stop22x22Icon 'Stop') |
|
2513 |
) |
|
2514 |
#(#MenuItem |
|
2515 |
#label: 'Close' |
|
2516 |
#translateLabel: true |
|
2517 |
#isButton: true |
|
2518 |
#nameKey: #Close |
|
2519 |
#isVisible: #isEmbeddedApplication |
|
2520 |
#startGroup: #right |
|
2521 |
#value: #doClose |
|
2522 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
2523 |
) |
|
2524 |
) |
|
2525 |
nil |
|
2526 |
nil |
|
2527 |
) |
|
2528 |
! ! |
|
2529 |
||
2530 |
!FileApplicationNoteBook::CommandResult methodsFor:'accessing'! |
|
2531 |
||
2532 |
resultStream |
|
2533 |
"return the value of the instance variable 'resultStream' (automatically generated)" |
|
2534 |
||
2535 |
^ resultStream |
|
2536 |
! |
|
2537 |
||
2538 |
resultStream:something |
|
2539 |
"set the value of the instance variable 'resultStream' (automatically generated)" |
|
2540 |
||
2541 |
resultStream := something. |
|
2542 |
! ! |
|
2543 |
||
2544 |
!FileApplicationNoteBook::CommandResult methodsFor:'actions'! |
|
2545 |
||
2546 |
changeTabTo:aString |
|
2547 |
||
2548 |
| masterApplication | |
|
2549 |
||
2550 |
self labelHolder value:aString. |
|
2551 |
masterApplication := self masterApplication. |
|
2552 |
masterApplication isNil ifFalse:[ |
|
2553 |
masterApplication tabStringChangeTo:aString for:self. |
|
2554 |
]. |
|
2555 |
! |
|
2556 |
||
2557 |
doStopProcess |
|
2558 |
||
2559 |
| myProcess | |
|
2560 |
||
2561 |
myProcess := self process value. |
|
2562 |
myProcess notNil ifTrue:[ |
|
2563 |
self notifyChannel value:('kill ', myProcess name). |
|
2564 |
myProcess terminate. |
|
2565 |
]. |
|
2566 |
! ! |
|
2567 |
||
2568 |
!FileApplicationNoteBook::CommandResult methodsFor:'aspects'! |
|
2569 |
||
2570 |
enableStopButton |
|
2571 |
||
2572 |
enableStopButton isNil ifTrue:[ |
|
2573 |
enableStopButton := false asValue. |
|
2574 |
]. |
|
2575 |
^ enableStopButton |
|
2576 |
! |
|
2577 |
||
2578 |
labelHolder |
|
2579 |
||
2580 |
labelHolder isNil ifTrue:[ |
|
2581 |
labelHolder := '' asValue. |
|
2582 |
]. |
|
2583 |
^ labelHolder. |
|
2584 |
! |
|
2585 |
||
2586 |
process |
|
2587 |
"return/create the 'process' value holder (automatically generated)" |
|
2588 |
||
2589 |
process isNil ifTrue:[ |
|
2590 |
process := ValueHolder new. |
|
2591 |
process addDependent:self. |
|
2592 |
]. |
|
2593 |
^ process |
|
2594 |
! ! |
|
2595 |
||
2596 |
!FileApplicationNoteBook::CommandResult methodsFor:'change & update'! |
|
2597 |
||
2598 |
update:something with:aParameter from:changedObject |
|
2599 |
"Invoked when an object that I depend upon sends a change notification." |
|
2600 |
||
2601 |
"stub code automatically generated - please change as required" |
|
2602 |
||
2603 |
changedObject == self process ifTrue:[ |
|
2604 |
self enableStopButton value:changedObject value notNil. |
|
2605 |
^ self |
|
2606 |
]. |
|
2607 |
super update:something with:aParameter from:changedObject |
|
2608 |
! ! |
|
2609 |
||
2610 |
!FileApplicationNoteBook::CommandResult methodsFor:'initialization & release'! |
|
2611 |
||
2612 |
postBuildTextCollector:aBuilder |
|
2613 |
||
2614 |
self resultStream:aBuilder scrolledView. |
|
2615 |
! |
|
2616 |
||
2617 |
postBuildWith:aBuilder |
|
2618 |
"This is a hook method generated by the Browser. |
|
2619 |
It will be invoked during the initialization of your app/dialog, |
|
2620 |
after all of the visual components have been built, |
|
2621 |
but BEFORE the top window is made visible. |
|
2622 |
Add any app-specific actions here (reading files, setting up values etc.) |
|
2623 |
See also #postOpenWith:, which is invoked after opening." |
|
2624 |
||
2625 |
"/ add any code here ... |
|
2626 |
||
2627 |
^ super postBuildWith:aBuilder |
|
2628 |
! |
|
2629 |
||
2630 |
postOpenWith:aBuilder |
|
2631 |
"This is a hook method generated by the Browser. |
|
2632 |
It will be invoked right after the applications window has been opened. |
|
2633 |
Add any app-specific actions here (starting background processes etc.). |
|
2634 |
See also #postBuildWith:, which is invoked before opening." |
|
2635 |
||
2636 |
"/ add any code here ... |
|
2637 |
||
2638 |
self masterApplication isNil ifTrue:[ |
|
2639 |
self masterApplication:nil. |
|
2640 |
]. |
|
2641 |
^ super postOpenWith:aBuilder |
|
2642 |
! |
|
2643 |
||
2644 |
release |
|
2645 |
||
2646 |
self doStopProcess. |
|
2647 |
^ super release |
|
2648 |
! ! |
|
2649 |
||
2650 |
!FileApplicationNoteBook::CommandResult methodsFor:'printing'! |
|
2651 |
||
2652 |
printString |
|
2653 |
||
2654 |
^ 'CommandResult Application' |
|
2655 |
! ! |
|
2656 |
||
2657 |
!FileApplicationNoteBook::HtmlViewApplication class methodsFor:'defaults'! |
|
2658 |
||
2659 |
tabStringFor:aApplicationType |
|
2660 |
||
2661 |
^ 'HTML View for:' |
|
2662 |
! ! |
|
2663 |
||
2664 |
!FileApplicationNoteBook::HtmlViewApplication class methodsFor:'interface specs'! |
|
2665 |
||
2666 |
windowSpec |
|
2667 |
"This resource specification was automatically generated |
|
2668 |
by the UIPainter of ST/X." |
|
2669 |
||
2670 |
"Do not manually edit this!! If it is corrupted, |
|
2671 |
the UIPainter may not be able to read the specification." |
|
2672 |
||
2673 |
" |
|
2674 |
UIPainter new openOnClass:NoteBookApplication::HtmlViewApplication andSelector:#windowSpec |
|
2675 |
NoteBookApplication::HtmlViewApplication new openInterface:#windowSpec |
|
2676 |
NoteBookApplication::HtmlViewApplication open |
|
2677 |
" |
|
2678 |
||
2679 |
<resource: #canvas> |
|
2680 |
||
2681 |
^ |
|
2682 |
#(#FullSpec |
|
2683 |
#name: #windowSpec |
|
2684 |
#window: |
|
2685 |
#(#WindowSpec |
|
2686 |
#label: 'NoteBookApplication::HtmlView' |
|
2687 |
#name: 'NoteBookApplication::HtmlView' |
|
2688 |
#min: #(#Point 10 10) |
|
2689 |
#max: #(#Point 1024 768) |
|
2690 |
#bounds: #(#Rectangle 16 42 692 534) |
|
2691 |
#menu: #mainMenu |
|
2692 |
) |
|
2693 |
#component: |
|
2694 |
#(#SpecCollection |
|
2695 |
#collection: #( |
|
2696 |
#(#MenuPanelSpec |
|
2697 |
#name: 'MenuHtml' |
|
2698 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
2699 |
#visibilityChannel: #isEmbeddedApplication |
|
2700 |
#menu: #menu |
|
2701 |
#textDefault: true |
|
2702 |
) |
|
2703 |
#(#ArbitraryComponentSpec |
|
2704 |
#name: 'HTMLView' |
|
2705 |
#layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 0 1) |
|
2706 |
#hasHorizontalScrollBar: true |
|
2707 |
#hasVerticalScrollBar: true |
|
2708 |
#miniScrollerHorizontal: false |
|
2709 |
#miniScrollerVertical: false |
|
2710 |
#hasBorder: false |
|
2711 |
#component: #HTMLDocumentView |
|
2712 |
#postBuildCallback: #postBuildHtmlView: |
|
2713 |
) |
|
2714 |
#(#LabelSpec |
|
2715 |
#label: 'FileLabel' |
|
2716 |
#name: 'FileLabel' |
|
2717 |
#layout: #(#LayoutFrame 212 0 2 0 -73 1 30 0) |
|
2718 |
#level: -1 |
|
2719 |
#translateLabel: true |
|
2720 |
#labelChannel: #labelHolder |
|
2721 |
#adjust: #left |
|
2722 |
) |
|
2723 |
) |
|
2724 |
||
2725 |
) |
|
2726 |
) |
|
2727 |
! ! |
|
2728 |
||
2729 |
!FileApplicationNoteBook::HtmlViewApplication class methodsFor:'menu specs'! |
|
2730 |
||
2731 |
menu |
|
2732 |
"This resource specification was automatically generated |
|
2733 |
by the MenuEditor of ST/X." |
|
2734 |
||
2735 |
"Do not manually edit this!! If it is corrupted, |
|
2736 |
the MenuEditor may not be able to read the specification." |
|
2737 |
||
2738 |
" |
|
2739 |
MenuEditor new openOnClass:FileApplicationNoteBook::HtmlViewApplication andSelector:#menu |
|
2740 |
(Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::HtmlViewApplication menu)) startUp |
|
2741 |
" |
|
2742 |
||
2743 |
<resource: #menu> |
|
2744 |
||
2745 |
^ |
|
2746 |
#(#Menu |
|
2747 |
#( |
|
2748 |
#(#MenuItem |
|
2749 |
#label: 'Reload' |
|
2750 |
#translateLabel: true |
|
2751 |
#isButton: true |
|
2752 |
#value: #doReload |
|
2753 |
#labelImage: #(#ResourceRetriever nil #htmlReloadIcon) |
|
2754 |
) |
|
2755 |
#(#MenuItem |
|
2756 |
#label: 'Back' |
|
2757 |
#translateLabel: true |
|
2758 |
#isButton: true |
|
2759 |
#value: #doGoBack |
|
2760 |
#labelImage: #(#ResourceRetriever #Icon #leftIcon) |
|
2761 |
) |
|
2762 |
#(#MenuItem |
|
2763 |
#label: 'Print' |
|
2764 |
#translateLabel: true |
|
2765 |
#isButton: true |
|
2766 |
#value: #doPrint |
|
2767 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #printer22x22Icon) |
|
2768 |
) |
|
2769 |
#(#MenuItem |
|
2770 |
#label: 'Close' |
|
2771 |
#translateLabel: true |
|
2772 |
#isButton: true |
|
2773 |
#hideMenuOnActivated: false |
|
2774 |
#startGroup: #right |
|
2775 |
#value: #doClose |
|
2776 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
2777 |
) |
|
2778 |
) |
|
2779 |
nil |
|
2780 |
nil |
|
2781 |
) |
|
2782 |
! ! |
|
2783 |
||
2784 |
!FileApplicationNoteBook::HtmlViewApplication class methodsFor:'queries'! |
|
2785 |
||
2786 |
canOpenItem:aItem |
|
2787 |
||
2788 |
^ (aItem hasMimeType and:[aItem mimeType isHtml]) |
|
2789 |
! |
|
2790 |
||
2791 |
wantNewApplicationAnyway |
|
2792 |
||
2793 |
^ false |
|
2794 |
! ! |
|
2795 |
||
2796 |
!FileApplicationNoteBook::HtmlViewApplication methodsFor:'accessing'! |
|
2797 |
||
2798 |
htmlView |
|
2799 |
"return the value of the instance variable 'imageView' (automatically generated)" |
|
2800 |
||
2801 |
^ htmlView |
|
2802 |
! |
|
2803 |
||
2804 |
htmlView:something |
|
2805 |
"set the value of the instance variable 'imageView' (automatically generated)" |
|
2806 |
||
2807 |
htmlView := something. |
|
2808 |
! |
|
2809 |
||
2810 |
item:aItem |
|
2811 |
||
2812 |
|retVal| |
|
2813 |
||
2814 |
self labelHolder value:aItem fileName asString. |
|
2815 |
retVal := super item:aItem. |
|
2816 |
self setupHtmlView. |
|
2817 |
^ retVal |
|
2818 |
! ! |
|
2819 |
||
2820 |
!FileApplicationNoteBook::HtmlViewApplication methodsFor:'actions'! |
|
2821 |
||
2822 |
doGoBack |
|
2823 |
||
2824 |
self htmlView menu_back. |
|
2825 |
! |
|
2826 |
||
2827 |
doGoHome |
|
2828 |
||
2829 |
self htmlView menu_home. |
|
2830 |
! |
|
2831 |
||
2832 |
doHelp |
|
2833 |
||
2834 |
self htmlView menu_help. |
|
2835 |
! |
|
2836 |
||
2837 |
doPrint |
|
2838 |
||
2839 |
self htmlView menu_print. |
|
2840 |
! |
|
2841 |
||
2842 |
doReload |
|
2843 |
||
2844 |
self htmlView menu_reload. |
|
2845 |
! |
|
2846 |
||
2847 |
setupHtmlView |
|
2848 |
||
2849 |
| html file directory| |
|
2850 |
||
2851 |
html := self htmlView. |
|
2852 |
html isNil ifTrue:[^ self]. |
|
2853 |
file := self fileName. |
|
2854 |
directory := file directoryName. |
|
2855 |
html homeDocument:(file asString). |
|
2856 |
html setTopDirectoryName:directory. |
|
2857 |
html uriHolder:self labelHolder. |
|
2858 |
html infoHolder:self notifyChannel. |
|
2859 |
html linkButtonPanel:nil. |
|
2860 |
^ html |
|
2861 |
! ! |
|
2862 |
||
2863 |
!FileApplicationNoteBook::HtmlViewApplication methodsFor:'aspects'! |
|
2864 |
||
2865 |
labelHolder |
|
2866 |
||
2867 |
labelHolder isNil ifTrue:[ |
|
2868 |
labelHolder := '' asValue. |
|
2869 |
]. |
|
2870 |
^ labelHolder. |
|
2871 |
! ! |
|
2872 |
||
2873 |
!FileApplicationNoteBook::HtmlViewApplication methodsFor:'initialization & release'! |
|
2874 |
||
2875 |
postBuildHtmlView:aWidget |
|
2876 |
||
2877 |
self htmlView: aWidget scrolledView. |
|
2878 |
self htmlView wantsFocusWithPointerEnter. |
|
2879 |
! |
|
2880 |
||
2881 |
postOpenWith:aBuilder |
|
2882 |
" |
|
2883 |
only invoked if the application not started from a master |
|
2884 |
" |
|
2885 |
||
2886 |
|currentDir contents suffix fileName| |
|
2887 |
||
2888 |
self masterApplication isNil ifTrue:[ |
|
2889 |
self masterApplication:nil. |
|
2890 |
currentDir := Filename homeDirectory. |
|
2891 |
||
2892 |
contents := currentDir directoryContents. |
|
2893 |
fileName := contents |
|
2894 |
detect:[:file | |
|
2895 |
suffix := file asFilename suffix asLowercase. |
|
2896 |
suffix = 'html' |
|
2897 |
] |
|
2898 |
ifNone:[nil]. |
|
2899 |
fileName isNil ifTrue:[ |
|
2900 |
Dialog warn:'cant find a HTML file in ' , currentDir asString. |
|
2901 |
^ self |
|
2902 |
]. |
|
3982 | 2903 |
self item:(DirectoryContentsBrowser itemClass fileName:('../../doc/online/english/TOP.html' asFilename)). |
3892 | 2904 |
]. |
2905 |
self setupHtmlView. |
|
2906 |
^ super postOpenWith:aBuilder |
|
2907 |
! ! |
|
2908 |
||
2909 |
!FileApplicationNoteBook::ImageViewApplication class methodsFor:'defaults'! |
|
2910 |
||
2911 |
tabStringFor:aApplicationType |
|
2912 |
||
2913 |
^ 'Image for:' |
|
2914 |
! ! |
|
2915 |
||
2916 |
!FileApplicationNoteBook::ImageViewApplication class methodsFor:'image specs'! |
|
2917 |
||
2918 |
fitSize20x20Icon |
|
2919 |
"This resource specification was automatically generated |
|
2920 |
by the ImageEditor of ST/X." |
|
2921 |
||
2922 |
"Do not manually edit this!! If it is corrupted, |
|
2923 |
the ImageEditor may not be able to read the specification." |
|
2924 |
||
2925 |
" |
|
2926 |
self fitSize20x20Icon inspect |
|
2927 |
ImageEditor openOnClass:self andSelector:#fitSize20x20Icon |
|
2928 |
" |
|
2929 |
||
2930 |
<resource: #image> |
|
2931 |
||
2932 |
^Icon |
|
2933 |
constantNamed:#'FileApplicationNoteBook::ImageViewApplication class fitSize20x20Icon' |
|
2934 |
ifAbsentPut:[(Depth4Image new) width: 20; height: 20; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
2935 |
@@DQDQDQDQDP@@@PDQDQDQDQ@P@A@ADQDQDQDP@PD@@PDQDQDPD@@QDQ@ADQDQ@@DQDQD@@@@@@@@@DQDQDPQDQDQ@DQDQDQDDQUUTPADQDQDQAEUUUT@QDQ |
|
2936 |
DQDPQEUUQ@DQDQDQDDQFQDPADQDQDQADQ$QD@QDQDQDPL3X3Q@DQDQDQDCL3L3LADQDQD@@@@@@@@@DQDQD@DQDQDP@QDQ@@DADQDQDA@@DA@ADQDQDQDP@P |
|
2937 |
@@@QDQDQDQDA@@@ADQDQDQDQD@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
2938 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
2939 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255 0 0 0 0 137 0 174 218 230 0 206 0 133 60 36]; mask:((Depth1Image new) width: 20; height: 20; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
2940 |
8@A00@@0(@APE@J@C@L@G?>@A?8@A?8@A?8@A?8@A?8@A?8@A?8@A?8@G?>@C@L@E@J@(@AP0@@08@A0@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
2941 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
2942 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
2943 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
2944 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; yourself); yourself] |
|
2945 |
! ! |
|
2946 |
||
2947 |
!FileApplicationNoteBook::ImageViewApplication class methodsFor:'interface specs'! |
|
2948 |
||
2949 |
windowSpec |
|
2950 |
"This resource specification was automatically generated |
|
2951 |
by the UIPainter of ST/X." |
|
2952 |
||
2953 |
"Do not manually edit this!! If it is corrupted, |
|
2954 |
the UIPainter may not be able to read the specification." |
|
2955 |
||
2956 |
" |
|
2957 |
UIPainter new openOnClass:FileApplicationNoteBook::ImageViewApplication andSelector:#windowSpec |
|
2958 |
FileApplicationNoteBook::ImageViewApplication new openInterface:#windowSpec |
|
2959 |
FileApplicationNoteBook::ImageViewApplication open |
|
2960 |
" |
|
2961 |
||
2962 |
<resource: #canvas> |
|
2963 |
||
2964 |
^ |
|
2965 |
#(#FullSpec |
|
2966 |
#name: #windowSpec |
|
2967 |
#window: |
|
2968 |
#(#WindowSpec |
|
2969 |
#label: 'ImageViewer' |
|
2970 |
#name: 'ImageViewer' |
|
2971 |
#min: #(#Point 10 10) |
|
2972 |
#max: #(#Point 1024 768) |
|
2973 |
#bounds: #(#Rectangle 16 42 692 534) |
|
2974 |
#menu: #mainMenu |
|
2975 |
) |
|
2976 |
#component: |
|
2977 |
#(#SpecCollection |
|
2978 |
#collection: #( |
|
2979 |
#(#MenuPanelSpec |
|
2980 |
#name: 'MenuTerminal' |
|
2981 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
2982 |
#visibilityChannel: #isEmbeddedApplication |
|
2983 |
#menu: #menu |
|
2984 |
#textDefault: true |
|
2985 |
) |
|
2986 |
#(#ArbitraryComponentSpec |
|
2987 |
#name: 'TerminalView' |
|
2988 |
#layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 0 1.0) |
|
2989 |
#hasHorizontalScrollBar: true |
|
2990 |
#hasVerticalScrollBar: true |
|
2991 |
#miniScrollerHorizontal: false |
|
2992 |
#miniScrollerVertical: false |
|
2993 |
#hasBorder: false |
|
2994 |
#component: #ImageView |
|
2995 |
#postBuildCallback: #postBuildImageView: |
|
2996 |
) |
|
2997 |
) |
|
2998 |
||
2999 |
) |
|
3000 |
) |
|
3001 |
! ! |
|
3002 |
||
3003 |
!FileApplicationNoteBook::ImageViewApplication class methodsFor:'menu specs'! |
|
3004 |
||
3005 |
menu |
|
3006 |
"This resource specification was automatically generated |
|
3007 |
by the MenuEditor of ST/X." |
|
3008 |
||
3009 |
"Do not manually edit this!! If it is corrupted, |
|
3010 |
the MenuEditor may not be able to read the specification." |
|
3011 |
||
3012 |
" |
|
3013 |
MenuEditor new openOnClass:FileApplicationNoteBook::ImageViewApplication andSelector:#menu |
|
3014 |
(Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::ImageViewApplication menu)) startUp |
|
3015 |
" |
|
3016 |
||
3017 |
<resource: #menu> |
|
3018 |
||
3019 |
^ |
|
3020 |
#(#Menu |
|
3021 |
#( |
|
3022 |
#(#MenuItem |
|
3023 |
#label: 'Edit' |
|
3024 |
#translateLabel: true |
|
3025 |
#isButton: true |
|
3026 |
#nameKey: #EditImage |
|
3027 |
#value: #editImage |
|
3028 |
) |
|
3029 |
#(#MenuItem |
|
3030 |
#label: '-' |
|
3031 |
) |
|
3032 |
#(#MenuItem |
|
3033 |
#label: 'FitSize' |
|
3034 |
#translateLabel: true |
|
3035 |
#isButton: true |
|
3036 |
#triggerOnDown: true |
|
3037 |
#labelImage: #(#ResourceRetriever #'FileApplicationNoteBook::ImageViewApplication' #fitSize20x20Icon) |
|
3038 |
#indication: #fitSize |
|
3039 |
) |
|
3040 |
#(#MenuItem |
|
3041 |
#label: '-' |
|
3042 |
) |
|
3043 |
#(#MenuItem |
|
3044 |
#label: 'Close' |
|
3045 |
#translateLabel: true |
|
3046 |
#isButton: true |
|
3047 |
#hideMenuOnActivated: false |
|
3048 |
#startGroup: #right |
|
3049 |
#value: #doClose |
|
3050 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
3051 |
) |
|
3052 |
) |
|
3053 |
nil |
|
3054 |
nil |
|
3055 |
) |
|
3056 |
! ! |
|
3057 |
||
3058 |
!FileApplicationNoteBook::ImageViewApplication class methodsFor:'queries'! |
|
3059 |
||
3060 |
canOpenItem:aItem |
|
3061 |
||
3062 |
^ (aItem hasMimeType and:[aItem mimeType isImage]) |
|
3063 |
! |
|
3064 |
||
3065 |
wantNewApplicationAnyway |
|
3066 |
||
3067 |
^ false |
|
3068 |
! ! |
|
3069 |
||
3070 |
!FileApplicationNoteBook::ImageViewApplication methodsFor:'accessing'! |
|
3071 |
||
3072 |
image:something |
|
3073 |
"set the value of the instance variable 'image' (automatically generated)" |
|
3074 |
||
3075 |
image := something. |
|
3076 |
! |
|
3077 |
||
3078 |
imageView |
|
3079 |
"return the value of the instance variable 'imageView' (automatically generated)" |
|
3080 |
||
3081 |
^ imageView |
|
3082 |
! |
|
3083 |
||
3084 |
imageView:something |
|
3085 |
"set the value of the instance variable 'imageView' (automatically generated)" |
|
3086 |
||
3087 |
imageView := something. |
|
3088 |
! ! |
|
3089 |
||
3090 |
!FileApplicationNoteBook::ImageViewApplication methodsFor:'actions'! |
|
3091 |
||
3092 |
changeItem:aItem |
|
3093 |
||
3094 |
self item:aItem. |
|
3095 |
self setupImageView. |
|
3096 |
^ true |
|
3097 |
! |
|
3098 |
||
3099 |
editImage |
|
3100 |
|img| |
|
3101 |
||
3102 |
img := self image. |
|
3103 |
img notNil ifTrue:[ |
|
3104 |
img edit. |
|
3105 |
]. |
|
3106 |
! |
|
3107 |
||
3108 |
image |
|
3109 |
|img fn e| |
|
3110 |
||
3111 |
fn := self fileName. |
|
3112 |
img := Image fromFile:fn. |
|
3113 |
img isNil ifTrue:[ |
|
3114 |
fn exists ifTrue:[ |
|
3115 |
e := 'Unknown/unsupported image format' |
|
3116 |
] ifFalse:[ |
|
3117 |
e := 'No such image' |
|
3118 |
]. |
|
3119 |
Dialog warn:e. |
|
3120 |
^ nil |
|
3121 |
]. |
|
3122 |
^ img. |
|
3123 |
! |
|
3124 |
||
3125 |
setupImageView |
|
4020 | 3126 |
|img oldCursor| |
3127 |
||
3128 |
[ |
|
3129 |
oldCursor := imageView cursor . |
|
3130 |
imageView cursor:Cursor wait. |
|
3131 |
imageView. |
|
3892 | 3132 |
img := self image. |
3133 |
img notNil ifTrue:[ |
|
3134 |
self image:img. |
|
3135 |
imageView image:img |
|
4020 | 3136 |
]. |
3137 |
imageView cursor:oldCursor. |
|
3138 |
] fork |
|
3892 | 3139 |
! ! |
3140 |
||
3141 |
!FileApplicationNoteBook::ImageViewApplication methodsFor:'aspects'! |
|
3142 |
||
3143 |
fitSize |
|
3144 |
"return/create the 'fitSize' value holder (automatically generated)" |
|
3145 |
||
3146 |
fitSize isNil ifTrue:[ |
|
3147 |
fitSize := ValueHolder new. |
|
3148 |
fitSize addDependent:self. |
|
3149 |
]. |
|
3150 |
^ fitSize |
|
3151 |
! ! |
|
3152 |
||
3153 |
!FileApplicationNoteBook::ImageViewApplication methodsFor:'change & update'! |
|
3154 |
||
3155 |
update:something with:aParameter from:changedObject |
|
3156 |
changedObject == self fitSize ifTrue:[ |
|
3157 |
changedObject value ifTrue:[ |
|
3158 |
imageView adjust:#fitBig. |
|
3159 |
] ifFalse:[ |
|
3160 |
imageView adjust:nil. |
|
3161 |
]. |
|
3162 |
^ self |
|
3163 |
]. |
|
3164 |
super update:something with:aParameter from:changedObject |
|
3165 |
! ! |
|
3166 |
||
3167 |
!FileApplicationNoteBook::ImageViewApplication methodsFor:'initialization & release'! |
|
3168 |
||
3169 |
postBuildImageView:aWidget |
|
3170 |
||
3171 |
self imageView: aWidget scrolledView. |
|
3172 |
self imageView wantsFocusWithPointerEnter. |
|
3173 |
! |
|
3174 |
||
3175 |
postOpenWith:aBuilder |
|
3176 |
" |
|
3177 |
only invoked if the application not started from a master |
|
3178 |
" |
|
3179 |
||
3180 |
|currentDir contents suffix fileName| |
|
3181 |
||
3182 |
self masterApplication isNil ifTrue:[ |
|
3183 |
self masterApplication:nil. |
|
3184 |
currentDir := Filename currentDirectory. |
|
3185 |
contents := currentDir directoryContents. |
|
3186 |
fileName := contents |
|
3187 |
detect:[:file | |
|
3188 |
suffix := file asFilename suffix asLowercase. |
|
3189 |
Image isImageFileSuffix:suffix |
|
3190 |
] |
|
3191 |
ifNone:[nil]. |
|
3192 |
fileName isNil ifTrue:[ |
|
3193 |
Dialog warn:'cant find a Image in ' , currentDir asString. |
|
3194 |
^ self |
|
3195 |
]. |
|
3982 | 3196 |
self item:(DirectoryContentsBrowser itemClass fileName:(currentDir construct:fileName)) |
3892 | 3197 |
]. |
3198 |
self setupImageView. |
|
3199 |
^ super postOpenWith:aBuilder |
|
3200 |
! ! |
|
3201 |
||
3202 |
!FileApplicationNoteBook::Terminal class methodsFor:'defaults'! |
|
3203 |
||
3204 |
tabStringFor:aApplicationType |
|
3205 |
||
3206 |
^ 'Terminal in:' |
|
3207 |
! ! |
|
3208 |
||
3209 |
!FileApplicationNoteBook::Terminal class methodsFor:'interface specs'! |
|
3210 |
||
3211 |
windowSpec |
|
3212 |
"This resource specification was automatically generated |
|
3213 |
by the UIPainter of ST/X." |
|
3214 |
||
3215 |
"Do not manually edit this!! If it is corrupted, |
|
3216 |
the UIPainter may not be able to read the specification." |
|
3217 |
||
3218 |
" |
|
3219 |
UIPainter new openOnClass:NoteBookApplication::Terminal andSelector:#windowSpec |
|
3220 |
NoteBookApplication::Terminal new openInterface:#windowSpec |
|
3221 |
NoteBookApplication::Terminal open |
|
3222 |
" |
|
3223 |
||
3224 |
<resource: #canvas> |
|
3225 |
||
3226 |
^ |
|
3227 |
#(#FullSpec |
|
3228 |
#name: #windowSpec |
|
3229 |
#window: |
|
3230 |
#(#WindowSpec |
|
3231 |
#label: 'NoteBookApplication::Terminal' |
|
3232 |
#name: 'NoteBookApplication::Terminal' |
|
3233 |
#min: #(#Point 10 10) |
|
3234 |
#max: #(#Point 1024 768) |
|
3235 |
#bounds: #(#Rectangle 16 42 692 534) |
|
3236 |
#menu: #mainMenu |
|
3237 |
) |
|
3238 |
#component: |
|
3239 |
#(#SpecCollection |
|
3240 |
#collection: #( |
|
3241 |
#(#MenuPanelSpec |
|
3242 |
#name: 'MenuTerminal' |
|
3243 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
3244 |
#menu: #menu |
|
3245 |
#textDefault: true |
|
3246 |
) |
|
3247 |
#(#ArbitraryComponentSpec |
|
3248 |
#name: 'TerminalView' |
|
3249 |
#layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 0 1.0) |
|
3250 |
#hasHorizontalScrollBar: true |
|
3251 |
#hasVerticalScrollBar: true |
|
3252 |
#miniScrollerHorizontal: false |
|
3253 |
#miniScrollerVertical: false |
|
3254 |
#hasBorder: false |
|
3255 |
#component: #terminalView |
|
3256 |
) |
|
3257 |
) |
|
3258 |
||
3259 |
) |
|
3260 |
) |
|
3261 |
! ! |
|
3262 |
||
3263 |
!FileApplicationNoteBook::Terminal class methodsFor:'menu specs'! |
|
3264 |
||
3265 |
menu |
|
3266 |
"This resource specification was automatically generated |
|
3267 |
by the MenuEditor of ST/X." |
|
3268 |
||
3269 |
"Do not manually edit this!! If it is corrupted, |
|
3270 |
the MenuEditor may not be able to read the specification." |
|
3271 |
||
3272 |
" |
|
3273 |
MenuEditor new openOnClass:FileApplicationNoteBook::Terminal andSelector:#menu |
|
3274 |
(Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::Terminal menu)) startUp |
|
3275 |
" |
|
3276 |
||
3277 |
<resource: #menu> |
|
3278 |
||
3279 |
^ |
|
3280 |
#(#Menu |
|
3281 |
#( |
|
3282 |
#(#MenuItem |
|
3283 |
#label: 'Save' |
|
3284 |
#translateLabel: true |
|
3285 |
#isButton: true |
|
3286 |
#nameKey: #Save |
|
3287 |
#value: #saveAs |
|
3288 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #saveToFile28x22Icon) |
|
3289 |
) |
|
3290 |
#(#MenuItem |
|
3291 |
#label: 'Close' |
|
3292 |
#translateLabel: true |
|
3293 |
#isButton: true |
|
3294 |
#hideMenuOnActivated: false |
|
3295 |
#isVisible: #isEmbeddedApplication |
|
3296 |
#startGroup: #right |
|
3297 |
#value: #doClose |
|
3298 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
3299 |
) |
|
3300 |
) |
|
3301 |
nil |
|
3302 |
nil |
|
3303 |
) |
|
3304 |
! ! |
|
3305 |
||
3306 |
!FileApplicationNoteBook::Terminal methodsFor:'accessing'! |
|
3307 |
||
3308 |
terminalView |
|
3309 |
||
3310 |
terminalView isNil ifTrue:[ |
|
3311 |
terminalView := VT100TerminalView new. |
|
3312 |
]. |
|
3313 |
^ terminalView. |
|
3314 |
! ! |
|
3315 |
||
3316 |
!FileApplicationNoteBook::Terminal methodsFor:'actions'! |
|
3317 |
||
3318 |
saveAs |
|
3319 |
||
3320 |
self terminalView save. |
|
3321 |
! ! |
|
3322 |
||
3323 |
!FileApplicationNoteBook::Terminal methodsFor:'initialization & release'! |
|
3324 |
||
3325 |
postBuildWith:aBuilder |
|
3326 |
||
3327 |
^ super postBuildWith:aBuilder |
|
3328 |
! |
|
3329 |
||
3330 |
shellFinished |
|
3331 |
||
3332 |
| master text string| |
|
3333 |
||
3334 |
master := self masterApplication. |
|
3335 |
master notNil ifTrue:[ |
|
3336 |
string := ' - closed'. |
|
3337 |
master tabStringAdd:string for:self. |
|
3338 |
]. |
|
3339 |
self notifyChannel value:'shell in ' , self fileName asString, ' finished'. |
|
3340 |
terminalView cr. |
|
3341 |
text := '>> shell closed' asText allBold. |
|
3342 |
text colorizeAllWith:Color red. |
|
3343 |
terminalView nextPutAll:text. |
|
3344 |
! |
|
3345 |
||
3346 |
startShell |
|
3347 |
|vt100| |
|
3348 |
||
3349 |
vt100 := self terminalView. |
|
3350 |
vt100 shellTerminateAction:[ self shellFinished ]. |
|
3351 |
vt100 startShellIn:(self fileName). |
|
3352 |
! ! |
|
3353 |
||
3354 |
!FileApplicationNoteBook::Terminal methodsFor:'printing'! |
|
3355 |
||
3356 |
printString |
|
3357 |
||
3358 |
^ ('Terminal on:', self fileName baseName) |
|
3359 |
! ! |
|
3360 |
||
3361 |
!FileApplicationNoteBook::Terminal methodsFor:'queries'! |
|
3362 |
||
3363 |
getTabStringEnd |
|
3364 |
||
3365 |
" get the tab string from the application list on the class side " |
|
3366 |
||
3367 |
^ '..', OperatingSystem fileSeparator, self fileName baseName, OperatingSystem fileSeparator |
|
3368 |
! ! |
|
3369 |
||
3370 |
!FileApplicationNoteBook::Terminal methodsFor:'startup & release'! |
|
3371 |
||
3372 |
postOpenWith:aBuilder |
|
3373 |
||
3374 |
" |
|
3375 |
only invoked if the application not started from a master |
|
3376 |
" |
|
3377 |
self masterApplication isNil ifTrue:[ |
|
3378 |
self masterApplication:nil. |
|
3982 | 3379 |
self item:(DirectoryContentsBrowser itemClass fileName:(Filename currentDirectory asAbsoluteFilename)). |
3892 | 3380 |
]. |
3381 |
self startShell. |
|
3382 |
^ super postOpenWith:aBuilder. |
|
3383 |
! ! |
|
3384 |
||
3385 |
!FileApplicationNoteBook::TextEditor class methodsFor:'defaults'! |
|
3386 |
||
3387 |
tabStringFor:aApplicationType |
|
3388 |
||
3389 |
aApplicationType == #directoryDescription ifTrue:[ |
|
3390 |
^ 'Directory description for:' |
|
3391 |
] ifFalse:[ |
|
3392 |
^ 'Editor on:' |
|
3393 |
]. |
|
3394 |
! |
|
3395 |
||
3396 |
wantNewApplicationAnyway |
|
3397 |
||
3398 |
^ false |
|
3399 |
! ! |
|
3400 |
||
3401 |
!FileApplicationNoteBook::TextEditor class methodsFor:'interface - specs'! |
|
3402 |
||
3403 |
windowSpec |
|
3404 |
"This resource specification was automatically generated |
|
3405 |
by the UIPainter of ST/X." |
|
3406 |
||
3407 |
"Do not manually edit this!! If it is corrupted, |
|
3408 |
the UIPainter may not be able to read the specification." |
|
3409 |
||
3410 |
" |
|
3950 | 3411 |
UIPainter new openOnClass:FileApplicationNoteBook::TextEditor andSelector:#windowSpec |
3412 |
FileApplicationNoteBook::TextEditor new openInterface:#windowSpec |
|
3413 |
FileApplicationNoteBook::TextEditor open |
|
3892 | 3414 |
" |
3415 |
||
3416 |
<resource: #canvas> |
|
3417 |
||
3418 |
^ |
|
3419 |
#(#FullSpec |
|
3420 |
#name: #windowSpec |
|
3421 |
#window: |
|
3422 |
#(#WindowSpec |
|
3423 |
#label: 'TextEditor' |
|
3424 |
#name: 'TextEditor' |
|
3425 |
#min: #(#Point 10 10) |
|
3426 |
#max: #(#Point 1024 768) |
|
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3427 |
#bounds: #(#Rectangle 16 42 666 342) |
3892 | 3428 |
) |
3429 |
#component: |
|
3430 |
#(#SpecCollection |
|
3431 |
#collection: #( |
|
3432 |
#(#MenuPanelSpec |
|
3433 |
#name: 'MenuTextEditor' |
|
3434 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
3435 |
#menu: #menu |
|
3436 |
#textDefault: true |
|
3437 |
) |
|
3438 |
#(#TextEditorSpec |
|
3439 |
#name: 'TextEditor' |
|
3440 |
#layout: #(#LayoutFrame 0 0.0 32 0 0 1.0 0 1.0) |
|
3441 |
#model: #fileContentsModel |
|
3442 |
#hasHorizontalScrollBar: true |
|
3443 |
#hasVerticalScrollBar: true |
|
4071 | 3444 |
#modifiedChannel: #viewModifiedChannel |
3892 | 3445 |
#acceptCallBack: #accept |
3950 | 3446 |
#allowDoIt: true |
3892 | 3447 |
#postBuildCallback: #postBuildTextEditor: |
3448 |
) |
|
3449 |
) |
|
3450 |
||
3451 |
) |
|
3452 |
) |
|
3453 |
! ! |
|
3454 |
||
3455 |
!FileApplicationNoteBook::TextEditor class methodsFor:'menu specs'! |
|
3456 |
||
3457 |
menu |
|
3458 |
"This resource specification was automatically generated |
|
3459 |
by the MenuEditor of ST/X." |
|
3460 |
||
3461 |
"Do not manually edit this!! If it is corrupted, |
|
3462 |
the MenuEditor may not be able to read the specification." |
|
3463 |
||
3464 |
" |
|
3465 |
MenuEditor new openOnClass:FileApplicationNoteBook::TextEditor andSelector:#menu |
|
3466 |
(Menu new fromLiteralArrayEncoding:(FileApplicationNoteBook::TextEditor menu)) startUp |
|
3467 |
" |
|
3468 |
||
3469 |
<resource: #menu> |
|
3470 |
||
3471 |
^ |
|
3472 |
#(#Menu |
|
3473 |
#( |
|
3474 |
#(#MenuItem |
|
3475 |
#label: 'Save' |
|
3476 |
#translateLabel: true |
|
3477 |
#isButton: true |
|
3478 |
#nameKey: #Save |
|
3479 |
#value: #accept |
|
3480 |
#enabled: #enableSave |
|
3481 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #saveToFile28x22Icon) |
|
3482 |
) |
|
3483 |
#(#MenuItem |
|
3484 |
#label: 'Reload' |
|
3485 |
#translateLabel: true |
|
3486 |
#isButton: true |
|
3487 |
#nameKey: #Reload |
|
3488 |
#value: #reload |
|
3489 |
#enabled: #enableReload |
|
3490 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #reloadFromFile28x22Icon) |
|
3491 |
) |
|
3492 |
#(#MenuItem |
|
3493 |
#label: '' |
|
3494 |
) |
|
3495 |
#(#MenuItem |
|
3496 |
#label: 'Print' |
|
3497 |
#translateLabel: true |
|
3498 |
#isButton: true |
|
3499 |
#nameKey: #Print |
|
3500 |
#value: #doPrint |
|
3501 |
#enabled: #enableHexToggle |
|
3502 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #printer22x22Icon) |
|
3503 |
) |
|
3504 |
#(#MenuItem |
|
3505 |
#label: '' |
|
3506 |
) |
|
3507 |
#(#MenuItem |
|
3508 |
#label: 'Hex' |
|
3509 |
#translateLabel: true |
|
3510 |
#isButton: true |
|
3511 |
#enabled: #enableHexToggle |
|
3512 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #hexToggle22x22Icon) |
|
3513 |
#indication: #printAsHexDump |
|
3514 |
) |
|
3515 |
#(#MenuItem |
|
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3516 |
#label: '' |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3517 |
) |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3518 |
#(#MenuItem |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3519 |
#label: 'Diff to Current' |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3520 |
#translateLabel: true |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3521 |
#isButton: true |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3522 |
#value: #openDiffView |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3523 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #diffIcon) |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3524 |
) |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3525 |
#(#MenuItem |
3892 | 3526 |
#label: 'Close' |
3527 |
#translateLabel: true |
|
3528 |
#isButton: true |
|
3529 |
#hideMenuOnActivated: false |
|
3530 |
#isVisible: #isEmbeddedApplication |
|
3531 |
#startGroup: #right |
|
3532 |
#value: #doClose |
|
3533 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
3534 |
) |
|
3535 |
) |
|
3536 |
nil |
|
3537 |
nil |
|
3538 |
) |
|
3539 |
! ! |
|
3540 |
||
3541 |
!FileApplicationNoteBook::TextEditor methodsFor:'accessing'! |
|
3542 |
||
3543 |
item:aDirContentsItem |
|
3544 |
||
3545 |
||
3546 |
self stopChangeItemProcess. |
|
3547 |
super item:aDirContentsItem. |
|
3548 |
(self askForChange) isNil ifTrue:[ ^ false]. |
|
3549 |
self setContents. |
|
3550 |
self startChangeItemProcess. |
|
3551 |
^ true |
|
3552 |
! |
|
3553 |
||
3554 |
presentation |
|
3555 |
"return the value of the instance variable 'presentation' (automatically generated)" |
|
3556 |
||
3557 |
presentation isNil ifTrue:[ |
|
3558 |
presentation := #asText. |
|
3559 |
]. |
|
3560 |
^ presentation |
|
3561 |
! |
|
3562 |
||
3563 |
presentation:something |
|
3564 |
"set the value of the instance variable 'presentation' (automatically generated)" |
|
3565 |
||
3566 |
presentation := something. |
|
3567 |
! |
|
3568 |
||
3569 |
semaChangeItem |
|
3570 |
||
3571 |
semaChangeItem isNil ifTrue:[ |
|
3572 |
semaChangeItem := Semaphore forMutualExclusion. |
|
3573 |
]. |
|
3574 |
^ semaChangeItem |
|
3575 |
! ! |
|
3576 |
||
3577 |
!FileApplicationNoteBook::TextEditor methodsFor:'actions'! |
|
3578 |
||
3579 |
accept |
|
3580 |
||
3581 |
| dir | |
|
3582 |
||
3583 |
self masterApplication class openAnotherApplicationOnSameItem ifTrue:[ |
|
3584 |
self updateSameFiles ifFalse:[ ^ self ]. |
|
3585 |
]. |
|
3586 |
self notifyChannel value:self fileName asString, ' saved'. |
|
3587 |
dir := self fileName directory. |
|
3588 |
dir exists not ifTrue:[ |
|
3589 |
dir recursiveMakeDirectory. |
|
3590 |
]. |
|
3591 |
editView saveAs:(self fileName). |
|
3592 |
self notifyChannel value:self fileName asString, ' saved'. |
|
3593 |
self semaChangeItem critical:[ |
|
3594 |
textEditorChangeModificationTime := nil. |
|
3595 |
self itemChanged value:false. |
|
3596 |
]. |
|
3597 |
self modifiedChannel value:false. |
|
3598 |
self itemRemoved value:false. |
|
3599 |
! |
|
3600 |
||
3601 |
askForChange |
|
3602 |
"ask for save changes |
|
3603 |
" |
|
3604 |
||
3605 |
|answer string| |
|
3606 |
||
3607 |
answer := false. |
|
3608 |
self modifiedChannel value ifTrue:[ |
|
3609 |
self itemChanged value ifTrue:[ |
|
3610 |
string := self fileName asString , ' was changed by someone else' |
|
3611 |
, Character cr , 'want to save your changes anyway ?' |
|
3612 |
]. |
|
3613 |
self itemRemoved value ifTrue:[ |
|
3614 |
string := self fileName asString , ' was removed by someone else' |
|
3615 |
, Character cr , 'want to save your changes anyway ?' |
|
3616 |
]. |
|
3617 |
string := 'save changed file ' , self fileName asString , ' ?' |
|
3618 |
]. |
|
3619 |
string notNil ifTrue:[ |
|
3620 |
answer := (Dialog confirmWithCancel:string). |
|
3621 |
answer isNil ifTrue:[^ answer]. |
|
3622 |
answer == true ifTrue:[ |
|
3623 |
self accept |
|
3624 |
] ifFalse:[ |
|
3625 |
self setContents. |
|
3626 |
] |
|
3627 |
]. |
|
3628 |
^ answer |
|
3629 |
! |
|
3630 |
||
3631 |
changeInformation |
|
3632 |
||
3633 |
| stream | |
|
3634 |
||
3635 |
stream := WriteStream with:(self getTabString). |
|
3636 |
masterApplication isNil ifTrue:[ |
|
3637 |
self window label:stream contents. |
|
3638 |
||
3639 |
] ifFalse:[ |
|
3640 |
masterApplication tabStringChangeTo:stream contents for:self. |
|
3641 |
]. |
|
3642 |
stream close. |
|
3643 |
! |
|
3644 |
||
4045 | 3645 |
changeInformationForModified:aBoolean |
3646 |
||
3647 |
||
3648 |
masterApplication isNil ifTrue:[ ^ self]. |
|
3649 |
masterApplication changeModified:aBoolean for:self. |
|
3650 |
! |
|
3651 |
||
3892 | 3652 |
doClose |
3653 |
||
3654 |
(self askForChange) isNil ifTrue:[ ^ false]. |
|
3655 |
self masterApplication notNil ifTrue:[ |
|
3954 | 3656 |
^ super doClose |
3892 | 3657 |
]. |
3658 |
^ true |
|
3659 |
! |
|
3660 |
||
3661 |
doPrint |
|
3662 |
"print the contents |
|
3663 |
" |
|
3664 |
(Dialog confirm:'printing ?') ifTrue:[ |
|
3665 |
editView doPrint. |
|
3666 |
]. |
|
3667 |
! |
|
3668 |
||
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3669 |
getContents |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3670 |
|
4071 | 3671 |
|file contents present text string| |
3892 | 3672 |
|
3673 |
file := self fileName. |
|
3674 |
RecursionInterruptSignal handle:[ : ex | |
|
3675 |
Dialog warn:file asString, ' is too big to be loaded !!'. |
|
3676 |
^ false. |
|
3677 |
] do:[ |
|
3678 |
present := self presentation. |
|
3679 |
present == #asText ifTrue:[ |
|
3680 |
contents := file contents. |
|
3681 |
] ifFalse:[ |
|
3682 |
present == #hexDump ifTrue:[ |
|
3683 |
contents := self getFileHexContents:file. |
|
3684 |
] |
|
3685 |
] |
|
3686 |
]. |
|
4071 | 3687 |
string := contents asString. |
3688 |
text := Text fromString:string. |
|
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3689 |
^ text |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3690 |
! |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3691 |
|
4071 | 3692 |
getHashForContents |
3693 |
||
3694 |
||
3695 |
| hashStream string| |
|
3696 |
||
4111
1975ba8ba0a6
ask if editView is available in getcontents changed by penk
tm
parents:
4110
diff
changeset
|
3697 |
(self hasMD5 and:[editView notNil]) ifTrue:[ |
4071 | 3698 |
hashStream := MD5Stream new. |
3699 |
string := editView contents asString. |
|
3700 |
hashStream nextPut:(string string). |
|
3701 |
^ hashStream hashValue. |
|
3702 |
]. |
|
3703 |
^ nil |
|
3704 |
! |
|
3705 |
||
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3706 |
openDiffView |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3707 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3708 |
|diffView text1 l1 text2 l2| |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3709 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3710 |
text1 := editView contents asText. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3711 |
l1 := 'changed version'. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3712 |
text2 := self getContents. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3713 |
l2 := 'current version'. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3714 |
diffView := DiffTextView openOn:text1 label:l1 and:text2 label:l2. |
4060 | 3715 |
diffView topView label:'file differences of ', self fileName asString. |
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3716 |
! |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3717 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3718 |
reload |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3719 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3720 |
self setContents. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3721 |
! |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3722 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3723 |
setContents |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3724 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3725 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3726 |
| text| |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3727 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3728 |
text := self getContents. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3729 |
self fileContentsModel value:text. |
4071 | 3730 |
self hasMD5 ifTrue:[ |
3731 |
md5CheckSum := self getHashForContents. |
|
3732 |
]. |
|
3892 | 3733 |
self enableReload value:false. |
3734 |
self itemChanged value:false. |
|
4045 | 3735 |
self modifiedChannel value:false. |
3892 | 3736 |
^ true |
3737 |
! |
|
3738 |
||
3739 |
updateSameFiles |
|
3740 |
||
3741 |
| master modifiedApplications stream filename action| |
|
3742 |
||
3743 |
master := self masterApplication. |
|
3744 |
master notNil ifTrue:[ |
|
3745 |
modifiedApplications := master getSameFilesModifiedFor:self. |
|
3746 |
(modifiedApplications isNil or:[modifiedApplications isEmpty]) ifTrue:[^ true ]. |
|
3747 |
filename := self fileName asString. |
|
3748 |
stream := WriteStream on:''. |
|
3749 |
stream nextPutAll:filename. |
|
3750 |
stream nextPutAll:' is modified in tab'. |
|
3751 |
modifiedApplications size > 1 ifTrue:[ |
|
3752 |
stream nextPutAll:'s'. |
|
3753 |
]. |
|
3754 |
stream cr. |
|
3755 |
modifiedApplications do:[ : el | |
|
3756 |
stream space. |
|
3757 |
stream nextPutAll:filename. |
|
3758 |
stream space. |
|
3759 |
el sameFileIndex notNil ifTrue:[ |
|
3760 |
stream nextPutAll:el sameFileIndex asString. |
|
3761 |
]. |
|
3762 |
stream cr. |
|
3763 |
]. |
|
3764 |
stream nextPutAll:'forget changes on other tab'. |
|
3765 |
modifiedApplications size > 1 ifTrue:[ |
|
3766 |
stream nextPutAll:'s'. |
|
3767 |
]. |
|
3768 |
stream nextPutAll:' ?'. |
|
3769 |
action := Dialog |
|
3770 |
choose:stream contents |
|
3771 |
labels:#('cancel' 'no' 'yes') |
|
3772 |
values:#(#cancel #no #yes) |
|
3773 |
default:#cancel. |
|
3774 |
||
3775 |
stream close. |
|
3776 |
action == #cancel ifTrue:[ ^ false ]. |
|
3777 |
action == #yes ifTrue:[ |
|
3778 |
"/ here force reload for other applications |
|
3779 |
modifiedApplications do:[ : el | |
|
3780 |
el reload. |
|
3781 |
] |
|
3782 |
]. |
|
3783 |
]. |
|
3784 |
^ true. |
|
3785 |
! ! |
|
3786 |
||
3787 |
!FileApplicationNoteBook::TextEditor methodsFor:'aspects'! |
|
3788 |
||
3789 |
doSaveFile |
|
3790 |
||
3791 |
doSaveFile isNil ifTrue:[ |
|
3792 |
doSaveFile := ValueHolder new. |
|
3793 |
]. |
|
3794 |
^ doSaveFile. |
|
3795 |
! |
|
3796 |
||
3797 |
enableHexToggle |
|
3798 |
||
3799 |
enableHexToggle isNil ifTrue:[ |
|
3800 |
enableHexToggle := true asValue. |
|
3801 |
]. |
|
3802 |
^ enableHexToggle |
|
3803 |
! |
|
3804 |
||
3805 |
enableReload |
|
3806 |
||
3807 |
enableReload isNil ifTrue:[ |
|
3808 |
enableReload := false asValue. |
|
3809 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
3810 |
"/ enableReload addDependent:self. |
|
3811 |
"/ enableReload onChangeSend:#enableReloadChanged to:self. |
|
3812 |
]. |
|
3813 |
^ enableReload. |
|
3814 |
! |
|
3815 |
||
3816 |
enableSave |
|
3817 |
||
3818 |
enableSave isNil ifTrue:[ |
|
3819 |
enableSave := false asValue. |
|
3820 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
3821 |
"/ enableSave addDependent:self. |
|
3822 |
"/ enableSave onChangeSend:#enableSaveChanged to:self. |
|
3823 |
]. |
|
3824 |
^ enableSave. |
|
3825 |
! |
|
3826 |
||
3827 |
fileContentsModel |
|
3828 |
||
3829 |
fileContentsModel isNil ifTrue:[ |
|
3830 |
fileContentsModel := ValueHolder new. |
|
3831 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
3832 |
"/ fileContentsModel addDependent:self. |
|
3833 |
"/ fileContentsModel onChangeSend:#fileContentsModelChanged to:self. |
|
3834 |
]. |
|
3835 |
^ fileContentsModel. |
|
3836 |
! |
|
3837 |
||
3838 |
itemChanged |
|
3839 |
||
3840 |
itemChanged isNil ifTrue:[ |
|
3841 |
itemChanged := false asValue. |
|
3842 |
itemChanged addDependent:self. |
|
3843 |
]. |
|
3844 |
^ itemChanged |
|
3845 |
! |
|
3846 |
||
3847 |
itemRemoved |
|
3848 |
||
3849 |
itemRemoved isNil ifTrue:[ |
|
3850 |
itemRemoved := false asValue. |
|
3851 |
itemRemoved addDependent:self. |
|
3852 |
]. |
|
3853 |
^ itemRemoved |
|
3854 |
! |
|
3855 |
||
3856 |
modifiedChannel |
|
3857 |
||
3858 |
modifiedChannel isNil ifTrue:[ |
|
3859 |
modifiedChannel := false asValue. |
|
3860 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
3861 |
modifiedChannel addDependent:self. |
|
3862 |
"/ modifiedChannel onChangeSend:#modifiedChannelChanged to:self. |
|
3863 |
]. |
|
3864 |
^ modifiedChannel. |
|
3865 |
! |
|
3866 |
||
3867 |
printAsHexDump |
|
3868 |
||
3869 |
printAsHexDump isNil ifTrue:[ |
|
3870 |
printAsHexDump := false asValue. |
|
3871 |
printAsHexDump addDependent:self. |
|
3872 |
]. |
|
3873 |
^ printAsHexDump. |
|
4071 | 3874 |
! |
3875 |
||
3876 |
viewModifiedChannel |
|
3877 |
||
3878 |
viewModifiedChannel isNil ifTrue:[ |
|
3879 |
viewModifiedChannel := false asValue. |
|
3880 |
viewModifiedChannel addDependent:self. |
|
3881 |
]. |
|
3882 |
^ viewModifiedChannel. |
|
3892 | 3883 |
! ! |
3884 |
||
3885 |
!FileApplicationNoteBook::TextEditor methodsFor:'change & update'! |
|
3886 |
||
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3887 |
changeTextColorForChanged |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3888 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3889 |
|text| |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3890 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3891 |
text := editView contents asText. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3892 |
self itemChanged value ifTrue:[ |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3893 |
self fileContentsModel value:(text |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3894 |
emphasizeAllWith:#color->(Color red)). |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3895 |
self fileContentsModel changed:#value. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3896 |
[editView flash] fork. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3897 |
] ifFalse:[ |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3898 |
self fileContentsModel value:(text |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3899 |
emphasizeAllWith:#color->(Color black)). |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3900 |
self fileContentsModel changed:#value. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3901 |
]. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3902 |
! |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3903 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3904 |
itemModified |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3905 |
|
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3906 |
| modified changed removed| |
3892 | 3907 |
|
3908 |
modified := self modifiedChannel value. |
|
3909 |
changed := self itemChanged value. |
|
3910 |
removed := self itemRemoved value. |
|
3911 |
||
4045 | 3912 |
self changeInformationForModified:(modified or:[changed]). |
3892 | 3913 |
self enableReload value:((modified or:[changed]) and:[removed not]). |
3914 |
! |
|
3915 |
||
3916 |
update:something with:aParameter from:changedObject |
|
3917 |
"Invoked when an object that I depend upon sends a change notification." |
|
3918 |
||
3919 |
"stub code automatically generated - please change as required" |
|
3920 |
||
4071 | 3921 |
|modified itemRem contMd5CheckSum viewModified| |
3922 |
||
3923 |
||
3924 |
changedObject == self viewModifiedChannel ifTrue:[ |
|
3925 |
viewModified := changedObject value. |
|
3926 |
self hasMD5 ifTrue:[ |
|
3927 |
self viewModifiedChannel value:false withoutNotifying:self. |
|
3928 |
viewModified ifTrue:[ |
|
3929 |
(self itemRemoved value not and:[self itemChanged value not]) ifTrue:[ |
|
3930 |
contMd5CheckSum := self getHashForContents. |
|
3931 |
contMd5CheckSum = md5CheckSum ifTrue:[ |
|
3932 |
self modifiedChannel value:false. |
|
3933 |
^ self. |
|
3934 |
]. |
|
3935 |
] |
|
3936 |
]. |
|
3937 |
]. |
|
3938 |
self modifiedChannel value:viewModified. |
|
3939 |
]. |
|
3892 | 3940 |
changedObject == self modifiedChannel ifTrue:[ |
3941 |
modified := changedObject value. |
|
4071 | 3942 |
self hasMD5 not ifTrue:[ |
3943 |
self viewModifiedChannel value:modified withoutNotifying:self. |
|
3944 |
]. |
|
3892 | 3945 |
self enableSave value:modified. |
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3946 |
self itemModified. |
3892 | 3947 |
^ self |
3948 |
]. |
|
3949 |
changedObject == self itemRemoved ifTrue:[ |
|
3950 |
itemRem := changedObject value. |
|
3951 |
itemRem == true ifTrue:[ |
|
3952 |
self enableSave value:true. |
|
3953 |
]. |
|
3954 |
self enableHexToggle value:itemRem not. |
|
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3955 |
self itemModified. |
3892 | 3956 |
^ self |
3957 |
]. |
|
3958 |
changedObject == self itemChanged ifTrue:[ |
|
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3959 |
self changeTextColorForChanged. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3960 |
self itemModified. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3961 |
"/ changedObject value == true ifTrue:[ |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3962 |
"/ self enableSave value:true. |
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
3963 |
"/ ]. |
3892 | 3964 |
^ self |
3965 |
]. |
|
3966 |
changedObject == self printAsHexDump ifTrue:[ |
|
3967 |
(self askForChange) isNil ifTrue:[ |
|
3968 |
self printAsHexDump value:changedObject value not withoutNotifying:self. |
|
3969 |
^ self |
|
3970 |
]. |
|
3971 |
changedObject value ifTrue:[ |
|
3972 |
self presentation:#hexDump. |
|
3973 |
] ifFalse:[ |
|
3974 |
self presentation:#asText. |
|
3975 |
]. |
|
3976 |
self changeInformation. |
|
3977 |
self setContents. |
|
3978 |
(self presentation == #hexDump) ifTrue:[ |
|
3979 |
editView readOnly:true. |
|
3980 |
] ifFalse:[ |
|
3981 |
editView readOnly:false. |
|
3982 |
]. |
|
3983 |
^ self |
|
3984 |
]. |
|
3985 |
||
3986 |
super update:something with:aParameter from:changedObject |
|
3987 |
! ! |
|
3988 |
||
3989 |
!FileApplicationNoteBook::TextEditor methodsFor:'printing'! |
|
3990 |
||
3991 |
printString |
|
3992 |
||
3993 |
^ ('TextEditor for:', self fileName baseName) |
|
3994 |
! ! |
|
3995 |
||
3996 |
!FileApplicationNoteBook::TextEditor methodsFor:'privat-process'! |
|
3997 |
||
3998 |
checkMyItemForChanges |
|
3999 |
||
4000 |
| dir exist myItem| |
|
4001 |
||
4002 |
dir := self fileName directory. |
|
4003 |
myItem := self item. |
|
4004 |
exist := myItem exists. |
|
4005 |
self itemRemoved value:(exist not). |
|
4006 |
exist ifTrue:[ |
|
4007 |
self semaChangeItem critical:[ |
|
4008 |
| time info| |
|
4009 |
info := self fileName asAbsoluteFilename info. |
|
3962
3906b10c42fd
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
3955
diff
changeset
|
4010 |
time := info modificationTime. |
3892 | 4011 |
textEditorChangeModificationTime isNil ifTrue:[ |
4012 |
textEditorChangeModificationTime := time. |
|
4013 |
]. |
|
4014 |
((textEditorChangeModificationTime = time) not) ifTrue:[ |
|
4015 |
"/ contents changed by someone else |
|
4016 |
textEditorChangeModificationTime := time. |
|
4017 |
self notifyChannel value:item fileName asString, ' was changed by someone else'. |
|
4018 |
self itemChanged value:true. |
|
4019 |
]. |
|
4020 |
] |
|
4021 |
] |
|
4022 |
! |
|
4023 |
||
4024 |
getFileHexContents:f |
|
4025 |
||
4026 |
|fileName stream data offs |
|
4027 |
addrDigits col line lineStream asciiLineStream lines| |
|
4028 |
||
4029 |
fileName := f baseName. |
|
4030 |
f isDirectory ifTrue:[ |
|
4031 |
^ Dialog warn:(resources string:'%1 is a directory.' with:fileName). |
|
4032 |
]. |
|
4033 |
f exists ifFalse:[ |
|
4034 |
Dialog warn:(resources string:'oops, ''%1'' is gone or unreadable.' with:fileName). |
|
4035 |
^ self |
|
4036 |
]. |
|
4037 |
f isReadable ifFalse:[ |
|
4038 |
Dialog warn:(resources string:'''%1'' is unreadable.' with:fileName). |
|
4039 |
^ self |
|
4040 |
]. |
|
4041 |
f fileSize > (512*1024) ifTrue:[ |
|
4042 |
(Dialog confirm:'Warning: the file is big (', (f fileSize//1024) printString , 'Kb). Show anyway ?') |
|
4043 |
ifFalse:[ |
|
4044 |
^ self |
|
4045 |
] |
|
4046 |
]. |
|
4047 |
stream := f readStream binary. |
|
4048 |
data := stream contents. |
|
4049 |
stream close. |
|
4050 |
||
4051 |
"/ subView list:nil. |
|
4052 |
col := 1. |
|
4053 |
offs := 0. |
|
4054 |
lines := StringCollection new. |
|
4055 |
||
4056 |
addrDigits := ((f fileSize + 1) log:16) truncated + 1. |
|
4057 |
||
4058 |
lineStream := '' writeStream. |
|
4059 |
asciiLineStream := '' writeStream. |
|
4060 |
||
4061 |
lineStream nextPutAll:(offs hexPrintString:addrDigits). |
|
4062 |
lineStream nextPutAll:': '. |
|
4063 |
||
4064 |
data do:[:byte | |
|
4065 |
lineStream nextPutAll:(byte hexPrintString:2). |
|
4066 |
(byte between:32 and:127) ifTrue:[ |
|
4067 |
asciiLineStream nextPut:(Character value:byte) |
|
4068 |
] ifFalse:[ |
|
4069 |
asciiLineStream nextPut:$. |
|
4070 |
]. |
|
4071 |
||
4072 |
offs := offs + 1. |
|
4073 |
col := col + 1. |
|
4074 |
col > 16 ifTrue:[ |
|
4075 |
lineStream nextPutAll:' '. |
|
4076 |
lineStream nextPutAll:asciiLineStream contents. |
|
4077 |
lines add:(lineStream contents). |
|
4078 |
(offs bitAnd:16rFF) == 0 ifTrue:[ |
|
4079 |
lines add:nil |
|
4080 |
]. |
|
4081 |
lineStream reset. |
|
4082 |
asciiLineStream reset. |
|
4083 |
||
4084 |
lineStream nextPutAll:(offs hexPrintString:addrDigits). |
|
4085 |
lineStream nextPutAll:': '. |
|
4086 |
col := 1. |
|
4087 |
] ifFalse:[ |
|
4088 |
lineStream space |
|
4089 |
] |
|
4090 |
]. |
|
4091 |
line := lineStream contents paddedTo:(3*16 + addrDigits + 1). |
|
4092 |
lines add:(line , ' ' , asciiLineStream contents). |
|
4093 |
^ lines |
|
4094 |
! |
|
4095 |
||
4096 |
startChangeItemProcess |
|
4097 |
||
4098 |
changeItemProcess isNil ifTrue:[ |
|
4099 |
self itemRemoved value:false. |
|
4100 |
self itemChanged value:false. |
|
4101 |
changeItemProcess := Process for:[ [ [true] whileTrue:[ |
|
4102 |
||
4103 |
self checkMyItemForChanges. |
|
4104 |
Delay waitForSeconds:1.0 |
|
4105 |
] |
|
4106 |
] valueNowOrOnUnwindDo:[ |
|
4107 |
changeItemProcess := nil. |
|
4108 |
textEditorChangeModificationTime := nil. |
|
4109 |
] |
|
4110 |
] |
|
4111 |
priority:(Processor systemBackgroundPriority). |
|
4112 |
||
4113 |
changeItemProcess name:('TextEditorLookForModify[', self fileName baseName, ']'). |
|
4114 |
changeItemProcess resume. |
|
4115 |
]. |
|
4116 |
! |
|
4117 |
||
4118 |
stopChangeItemProcess |
|
4119 |
||
4120 |
| task | |
|
4121 |
||
4122 |
task := changeItemProcess. |
|
4123 |
task notNil ifTrue:[ |
|
4124 |
changeItemProcess := nil. |
|
4125 |
||
4126 |
Object errorSignal handle:[:ex| |
|
4127 |
Dialog warn:ex description. |
|
4128 |
]do:[ |
|
4129 |
task isDead ifFalse:[ |
|
4130 |
task terminate. |
|
4131 |
task waitUntilTerminated. |
|
4132 |
] |
|
4133 |
] |
|
4134 |
]. |
|
4135 |
! ! |
|
4136 |
||
4137 |
!FileApplicationNoteBook::TextEditor methodsFor:'queries'! |
|
4138 |
||
4071 | 4139 |
hasMD5 |
4140 |
^ ( MD5Stream notNil and:[MD5Stream isLoaded]) |
|
4141 |
"/ ^ false |
|
4142 |
! |
|
4143 |
||
3892 | 4144 |
isModified |
4145 |
||
4146 |
^ self modifiedChannel value |
|
4147 |
! ! |
|
4148 |
||
4149 |
!FileApplicationNoteBook::TextEditor methodsFor:'startup & release'! |
|
4150 |
||
4151 |
closeRequest |
|
4152 |
||
4153 |
(self doClose) ifTrue:[ |
|
4154 |
^ super closeRequest. |
|
4105 | 4155 |
^ self stopChangeItemProcess. |
4156 |
||
3892 | 4157 |
]. |
4158 |
! |
|
4159 |
||
4160 |
postBuildTextEditor:aWidget |
|
4161 |
||
4162 |
editView := aWidget scrolledView. |
|
4163 |
! |
|
4164 |
||
4165 |
postBuildWith:aBuilder |
|
4166 |
||
4167 |
super postBuildWith:aBuilder. |
|
4168 |
! |
|
4169 |
||
4170 |
postOpenWith:aBuilder |
|
4171 |
||
4172 |
self masterApplication isNil ifTrue:[ |
|
4173 |
self masterApplication:nil. |
|
4047
e432ab54d1e7
contents color changed to red if modified by someone else
penk
parents:
4045
diff
changeset
|
4174 |
self item:(DirectoryContentsBrowser itemClass fileName:(Filename homeDirectory construct:'.bashrc')). |
3892 | 4175 |
]. |
4176 |
self setUpTextView. |
|
4177 |
self changeInformation. |
|
4178 |
^ super postOpenWith:aBuilder |
|
4179 |
! |
|
4180 |
||
4181 |
release |
|
4182 |
"release my resources |
|
4183 |
" |
|
4184 |
self stopChangeItemProcess. |
|
4185 |
super release. |
|
4186 |
! |
|
4187 |
||
4188 |
setUpTextView |
|
4189 |
||
4190 |
|paranthesis col| |
|
4191 |
||
4192 |
self item hasMimeType ifFalse:[^nil]. |
|
4193 |
(self item mimeType isHtml) ifTrue:[ |
|
4056 | 4194 |
paranthesis := editView parenthesisSpecification copy. |
3892 | 4195 |
((paranthesis at:#open) includes:$<) ifFalse:[ |
4056 | 4196 |
col := ((paranthesis at:#open) asOrderedCollection). |
4197 |
col add:$<. |
|
3892 | 4198 |
paranthesis at:#open put:col. |
4076 | 4199 |
editView parenthesisSpecification:paranthesis |
3892 | 4200 |
]. |
4201 |
]. |
|
4202 |
! ! |
|
4203 |
||
4204 |
!FileApplicationNoteBook::XViewApplication class methodsFor:'defaults'! |
|
4205 |
||
3906 | 4206 |
UnixVNCCommand |
4207 |
||
4208 |
^ 'Xvnc' |
|
4209 |
! |
|
4210 |
||
3892 | 4211 |
maxNumberOfVNCRestarts |
4212 |
||
4213 |
^ 10 |
|
4214 |
! |
|
4215 |
||
4216 |
mimeTypeUnixApplicationMapping |
|
4217 |
||
4218 |
" here insert the application and mime type pairs to open by XviewApplication |
|
4219 |
" |
|
4220 |
||
4221 |
^ |
|
4222 |
#( |
|
4223 |
#(#'application/postscript' #gv ) |
|
4224 |
#(#'application/pdf' #acroread ) |
|
4225 |
) |
|
4226 |
! |
|
4227 |
||
4228 |
tabStringFor:aApplicationType |
|
4229 |
||
4230 |
^ 'VNC for:' |
|
4231 |
! |
|
4232 |
||
4233 |
wantNewApplicationAnyway |
|
4234 |
||
4235 |
^ false |
|
4236 |
! ! |
|
4237 |
||
4238 |
!FileApplicationNoteBook::XViewApplication class methodsFor:'interface specs'! |
|
4239 |
||
4240 |
windowSpec |
|
4241 |
"This resource specification was automatically generated |
|
4242 |
by the UIPainter of ST/X." |
|
4243 |
||
4244 |
"Do not manually edit this!! If it is corrupted, |
|
4245 |
the UIPainter may not be able to read the specification." |
|
4246 |
||
4247 |
" |
|
4248 |
UIPainter new openOnClass:NoteBookApplication::XViewApplication andSelector:#windowSpec |
|
4249 |
NoteBookApplication::XViewApplication new openInterface:#windowSpec |
|
4250 |
NoteBookApplication::XViewApplication open |
|
4251 |
" |
|
4252 |
||
4253 |
<resource: #canvas> |
|
4254 |
||
4255 |
^ |
|
4256 |
#(#FullSpec |
|
4257 |
#name: #windowSpec |
|
4258 |
#window: |
|
4259 |
#(#WindowSpec |
|
4260 |
#label: 'XView' |
|
4261 |
#name: 'XView' |
|
4262 |
#min: #(#Point 10 10) |
|
4263 |
#max: #(#Point 1024 768) |
|
4264 |
#bounds: #(#Rectangle 12 22 688 514) |
|
4265 |
#menu: #mainMenu |
|
4266 |
) |
|
4267 |
#component: |
|
4268 |
#(#SpecCollection |
|
4269 |
#collection: #( |
|
4270 |
#(#MenuPanelSpec |
|
4271 |
#name: 'MenuTerminal' |
|
4272 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
4273 |
#visibilityChannel: #isEmbeddedApplication |
|
4274 |
#menu: #menu |
|
4275 |
#textDefault: true |
|
4276 |
) |
|
4277 |
#(#ArbitraryComponentSpec |
|
4278 |
#name: 'TerminalView' |
|
4279 |
#layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 0 1.0) |
|
4280 |
#hasHorizontalScrollBar: true |
|
4281 |
#hasVerticalScrollBar: true |
|
4282 |
#miniScrollerHorizontal: false |
|
4283 |
#miniScrollerVertical: false |
|
4284 |
#hasBorder: false |
|
4285 |
#component: #VNCFrameBufferView |
|
4286 |
#postBuildCallback: #postBuildXView: |
|
4287 |
) |
|
4288 |
) |
|
4289 |
||
4290 |
) |
|
4291 |
) |
|
4292 |
! ! |
|
4293 |
||
4294 |
!FileApplicationNoteBook::XViewApplication class methodsFor:'menu specs'! |
|
4295 |
||
4296 |
menu |
|
4297 |
"This resource specification was automatically generated |
|
4298 |
by the MenuEditor of ST/X." |
|
4299 |
||
4300 |
"Do not manually edit this!! If it is corrupted, |
|
4301 |
the MenuEditor may not be able to read the specification." |
|
4302 |
||
4303 |
" |
|
4304 |
MenuEditor new openOnClass:NoteBookApplication::ImageViewApplication andSelector:#menu |
|
4305 |
(Menu new fromLiteralArrayEncoding:(NoteBookApplication::ImageViewApplication menu)) startUp |
|
4306 |
" |
|
4307 |
||
4308 |
<resource: #menu> |
|
4309 |
||
4310 |
^ |
|
4311 |
#(#Menu |
|
4312 |
#( |
|
4313 |
#(#MenuItem |
|
4314 |
#label: 'Close' |
|
4315 |
#translateLabel: true |
|
4316 |
#isButton: true |
|
4317 |
#hideMenuOnActivated: false |
|
4318 |
#startGroup: #right |
|
4319 |
#value: #doClose |
|
4320 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
4321 |
) |
|
4322 |
) |
|
4323 |
nil |
|
4324 |
nil |
|
4325 |
) |
|
4326 |
! ! |
|
4327 |
||
4328 |
!FileApplicationNoteBook::XViewApplication class methodsFor:'queries'! |
|
4329 |
||
4330 |
canOpenItem:aItem |
|
4331 |
||
4332 |
| keySym canOpen| |
|
4333 |
||
4334 |
keySym := aItem mimeType asSymbol. |
|
4335 |
(OperatingSystem isUNIXlike) not ifTrue:[^ false]. |
|
4336 |
canOpen := self mimeTypeUnixApplicationMapping detect:[ : el | (el at:1) == keySym ] ifNone:[nil]. |
|
4337 |
canOpen isNil ifTrue:[^ false]. |
|
4338 |
(OperatingSystem executeCommand:('which ', self UnixVNCCommand)) ifTrue:[ |
|
4339 |
^ true |
|
4340 |
] ifFalse:[ |
|
4341 |
(Dialog warn:'cant start viewer for ' |
|
4342 |
, aItem fileName baseName |
|
4343 |
) |
|
4344 |
]. |
|
4345 |
^ false. |
|
4346 |
! ! |
|
4347 |
||
4348 |
!FileApplicationNoteBook::XViewApplication methodsFor:'accessing'! |
|
4349 |
||
4350 |
xView |
|
4351 |
"return the value of the instance variable 'imageView' (automatically generated)" |
|
4352 |
||
4353 |
^ xView |
|
4354 |
! |
|
4355 |
||
4356 |
xView:something |
|
4357 |
"set the value of the instance variable 'imageView' (automatically generated)" |
|
4358 |
||
4359 |
xView := something. |
|
4360 |
! ! |
|
4361 |
||
4362 |
!FileApplicationNoteBook::XViewApplication methodsFor:'actions'! |
|
4363 |
||
4364 |
changeInformation |
|
4365 |
||
4366 |
| stream| |
|
4367 |
||
4368 |
stream := WriteStream on:''. |
|
4369 |
stream nextPutAll:'XView on: '. |
|
4370 |
stream nextPutAll:self fileName baseName. |
|
4371 |
masterApplication isNil ifTrue:[ |
|
4372 |
self window label:stream contents. |
|
4373 |
||
4374 |
] ifFalse:[ |
|
4375 |
masterApplication tabStringChangeTo:stream contents for:self. |
|
4376 |
]. |
|
4377 |
stream close. |
|
4378 |
! |
|
4379 |
||
4380 |
setupXView |
|
4381 |
||
3906 | 4382 |
|xExt yExt mainView| |
3892 | 4383 |
|
4384 |
self startVNCserver. |
|
4385 |
xExt := self xView width asString. |
|
3906 | 4386 |
self masterApplication notNil ifTrue:[ |
4387 |
mainView := self builder windowGroup mainView. |
|
4388 |
"/ if the mainView is a FileBrowser take them y extent because size of notebook can be changed |
|
4389 |
(mainView application class == (Smalltalk at:#FileBrowserV2 ifAbsent:nil)) notNil ifTrue:[ |
|
4390 |
yExt := mainView height asString. |
|
4391 |
]. |
|
4392 |
]. |
|
4393 |
yExt isNil ifTrue:[ |
|
3892 | 4394 |
yExt := self xView height asString. |
4395 |
]. |
|
4396 |
ext := xExt, 'x', yExt. |
|
4397 |
self startViewer. |
|
4398 |
! ! |
|
4399 |
||
4400 |
!FileApplicationNoteBook::XViewApplication methodsFor:'actions VNC'! |
|
4401 |
||
4402 |
setupView |
|
4403 |
| renderer view| |
|
4404 |
||
4405 |
view := xView. |
|
4406 |
renderer := VNCRenderer for:vncConnection targetWindow:view device:xView device. |
|
4407 |
||
4408 |
view renderer:renderer. |
|
4409 |
view connection:vncConnection. |
|
4410 |
||
4411 |
VNCException handle:[:ex| |
|
4412 |
self stopViewer. |
|
4413 |
] do:[ |
|
4414 |
vncConnection |
|
4415 |
startMessageHandlerProcessForRenderer:renderer |
|
4416 |
errorHandler:[:ex | self stopViewer]. |
|
4417 |
]. |
|
4418 |
! |
|
4419 |
||
4420 |
startVNCserver |
|
4421 |
|cmd blocked connected numberOfVncStarts| |
|
4422 |
||
4423 |
connected := false. |
|
4424 |
numberOfVncStarts isNil ifTrue:[ |
|
4425 |
numberOfVncStarts := 1. |
|
4426 |
] ifFalse:[ |
|
4427 |
numberOfVncStarts := numberOfVncStarts + 1. |
|
4428 |
]. |
|
4429 |
||
4430 |
vncLock isNil ifTrue:[vncLock := Semaphore forMutualExclusion]. |
|
4431 |
||
4432 |
vncServerPID isNil ifTrue:[ |
|
4433 |
cmd := ('/usr/X11R6/bin/', self class UnixVNCCommand). |
|
4434 |
cmd asFilename exists ifFalse:[ |
|
4435 |
cmd := self class UnixVNCCommand. |
|
4436 |
]. |
|
4437 |
vncPortNr isNil ifTrue:[ |
|
4438 |
vncPortNr := 29 |
|
4439 |
]. |
|
4440 |
cmd := cmd , ' :' , vncPortNr printString , ' nologo -nevershared -localhost -depth 16 -geometry 1024x1024'. |
|
4441 |
||
4442 |
blocked := OperatingSystem blockInterrupts. |
|
4443 |
||
4444 |
vncServerPID := Processor |
|
4445 |
monitor:[ |
|
4446 |
vncServerIsTerminated := false. |
|
4447 |
OperatingSystem |
|
4448 |
exec:'/bin/sh' |
|
4449 |
withArguments:(Array with:'sh' with:'-c' with:cmd) |
|
4450 |
fileDescriptors:#() |
|
4451 |
closeDescriptors:#() |
|
4452 |
fork:true |
|
4453 |
newPgrp:true |
|
4454 |
inDirectory:nil. |
|
4455 |
] |
|
4456 |
action:[:status | |
|
4457 |
status stillAlive ifFalse:[ |
|
4458 |
OperatingSystem closePid:vncServerPID. |
|
4459 |
vncLock critical:[ |
|
4460 |
vncServerPID := nil. |
|
4461 |
self vncServerTerminated. |
|
4462 |
]. |
|
4463 |
]. |
|
4464 |
]. |
|
4465 |
||
4466 |
blocked ifFalse:[ |
|
4467 |
OperatingSystem unblockInterrupts |
|
4468 |
]. |
|
4469 |
]. |
|
4470 |
||
4471 |
self waitForTerminationOfServer ifTrue:[ |
|
4472 |
"/ Transcript showCR:'server has terminated really - try with next port'. |
|
4473 |
(numberOfVncStarts < self class maxNumberOfVNCRestarts) ifTrue:[ |
|
4474 |
vncPortNr := vncPortNr + 1. |
|
4475 |
"/ Transcript showCR:'try next port ', vncPortNr asString. |
|
4476 |
self startVNCserver. |
|
4477 |
] ifFalse:[ |
|
4478 |
Dialog warn:'have started servers from port ' |
|
4479 |
, (vncPortNr - self class maxNumberOfVNCRestarts) asString |
|
4480 |
, ' to ' |
|
4481 |
, vncPortNr |
|
4482 |
, ' - cant connect anyway'. |
|
4483 |
"/ Transcript showCR:'have started servers from port ', vncPortNr - self class maxNumberOfVNCRestarts, ' to ', vncPortNr. |
|
4484 |
]. |
|
4485 |
] ifFalse:[ |
|
4486 |
vncLock critical:[ |
|
4487 |
vncServerPID isNil ifTrue:[ |
|
4488 |
Dialog warn:'Cannot start Xvnc'. |
|
4489 |
] ifFalse:[ |
|
4490 |
VNCAuthenticationFailure handle:[:ex | |
|
4491 |
Dialog warn:'Wrong password'. |
|
4492 |
] do:[ |
|
4493 |
connected := self vncConnect. |
|
4494 |
]. |
|
4495 |
connected ifTrue:[self setupView]. |
|
4496 |
]. |
|
4497 |
]. |
|
4498 |
]. |
|
4499 |
! |
|
4500 |
||
4501 |
stopVNCServer |
|
4502 |
||
4503 |
vncServerPID notNil ifTrue:[ |
|
4504 |
OperatingSystem terminateProcess:vncServerPID. |
|
4505 |
Delay waitForSeconds:0.2. |
|
4506 |
vncServerPID notNil ifTrue:[ |
|
4507 |
OperatingSystem killProcess:vncServerPID. |
|
4508 |
vncServerPID := nil. |
|
4509 |
]. |
|
4510 |
]. |
|
4511 |
self vncServerTerminated. |
|
4512 |
! |
|
4513 |
||
4514 |
vncConnect |
|
4515 |
| tryConnects| |
|
4516 |
||
4517 |
vncConnection notNil ifTrue:[ |
|
4518 |
vncConnection close |
|
4519 |
]. |
|
4520 |
||
4521 |
vncConnection := VNCServerConnection new. |
|
4522 |
tryConnects := 1. |
|
4523 |
[tryConnects < 3] whileTrue:[ |
|
4524 |
VNCConnectionFailure handle:[:ex | |
|
4525 |
Delay waitForSeconds:0.5. |
|
4526 |
tryConnects := tryConnects + 1. |
|
4527 |
] do:[ |
|
4528 |
vncConnection connectTo:'localhost' port:vncPortNr. |
|
4529 |
^ true. |
|
4530 |
]. |
|
4531 |
]. |
|
4532 |
^ false |
|
4533 |
! |
|
4534 |
||
4535 |
vncServerTerminated |
|
4536 |
"/ Transcript showCR:'vnc server has terminated'. |
|
4537 |
"/ 'vnc server has terminated' errorPrintCR. |
|
4538 |
"/ Dialog information:'vnc server has terminated'. |
|
4539 |
||
4540 |
self stopViewer. |
|
4541 |
vncConnection notNil ifTrue:[ |
|
4542 |
vncConnection close. |
|
4543 |
vncConnection := nil |
|
4544 |
]. |
|
4545 |
vncServerIsTerminated := true. |
|
4546 |
! |
|
4547 |
||
4548 |
waitForTerminationOfServer |
|
4549 |
| cycles | |
|
4550 |
||
4551 |
cycles := 1. |
|
4552 |
[vncServerIsTerminated] whileFalse:[ |
|
4553 |
(cycles > 3) ifTrue:[^ false]. |
|
4554 |
cycles := cycles + 1. |
|
4555 |
Delay waitForSeconds:0.5. |
|
4556 |
]. |
|
4557 |
^ true |
|
4558 |
! ! |
|
4559 |
||
4560 |
!FileApplicationNoteBook::XViewApplication methodsFor:'actions viewer'! |
|
4561 |
||
4562 |
startViewer |
|
4563 |
|cmd keySym applItem | |
|
4564 |
||
4565 |
keySym := self item mimeType asSymbol. |
|
4566 |
applItem := self class mimeTypeUnixApplicationMapping detect:[ : el | (el at:1) == keySym ] ifNone:[nil]. |
|
4567 |
applItem isNil ifTrue:[ ^ self]. |
|
4568 |
||
4569 |
cmd := (applItem at:2) asString, ' -geometry ', ext, ' -display :' , vncPortNr printString , ' ' , self fileName asString. |
|
4570 |
self startViewer:cmd |
|
4571 |
! |
|
4572 |
||
4573 |
startViewer:viewerCommand |
|
4574 |
|blocked| |
|
4575 |
||
4576 |
viewerPID notNil ifTrue:[ |
|
4577 |
^ self |
|
4578 |
]. |
|
4579 |
||
4580 |
blocked := OperatingSystem blockInterrupts. |
|
4581 |
||
4582 |
viewerPID := Processor |
|
4583 |
monitor:[ |
|
4584 |
OperatingSystem |
|
4585 |
exec:'/bin/sh' |
|
4586 |
withArguments:(Array with:'sh' with:'-c' with:viewerCommand) |
|
4587 |
fileDescriptors:#() |
|
4588 |
closeDescriptors:#() |
|
4589 |
fork:true |
|
4590 |
newPgrp:true |
|
4591 |
inDirectory:nil. |
|
4592 |
] |
|
4593 |
action:[:status | |
|
4594 |
status stillAlive ifFalse:[ |
|
4595 |
OperatingSystem closePid:viewerPID. |
|
4596 |
viewerPID := nil. |
|
4597 |
self viewerTerminated. |
|
4598 |
]. |
|
4599 |
]. |
|
4600 |
||
4601 |
blocked ifFalse:[ |
|
4602 |
OperatingSystem unblockInterrupts |
|
4603 |
]. |
|
4604 |
||
4605 |
viewerPID isNil ifTrue:[ |
|
4606 |
Dialog warn:'Cannot start ', viewerCommand. |
|
4607 |
]. |
|
4608 |
! |
|
4609 |
||
4610 |
startXterm |
|
4611 |
|cmd| |
|
4612 |
||
4613 |
cmd := 'xterm -geometry 600x800 -display :' , vncPortNr printString. |
|
4614 |
self startViewer:cmd |
|
4615 |
! |
|
4616 |
||
4617 |
stopViewer |
|
4618 |
viewerPID notNil ifTrue:[ |
|
4619 |
OperatingSystem terminateProcess:viewerPID. |
|
4620 |
Delay waitForSeconds:0.2. |
|
4621 |
viewerPID notNil ifTrue:[ |
|
4622 |
OperatingSystem killProcess:viewerPID. |
|
4623 |
viewerPID := nil. |
|
4624 |
] |
|
4625 |
]. |
|
4626 |
! |
|
4627 |
||
4628 |
viewerTerminated |
|
4629 |
"/ Transcript showCR:'viewer has terminated'. |
|
4630 |
"/ 'viewer has terminated' errorPrintCR. |
|
4631 |
"/ Dialog information:'viewer has terminated'. |
|
4632 |
! ! |
|
4633 |
||
4634 |
!FileApplicationNoteBook::XViewApplication methodsFor:'initialization & release'! |
|
4635 |
||
4636 |
postBuildXView:aWidget |
|
4637 |
||
4638 |
self xView:aWidget scrolledView. |
|
4639 |
self xView wantsFocusWithPointerEnter. |
|
4640 |
aWidget autoHideScrollBars:true. |
|
4641 |
! |
|
4642 |
||
4643 |
postOpenWith:aBuilder |
|
4644 |
" |
|
4645 |
only invoked if the application not started from a master |
|
4646 |
" |
|
4647 |
||
4648 |
|currentDir contents suffix fileName| |
|
4649 |
||
4650 |
self masterApplication isNil ifTrue:[ |
|
4651 |
self masterApplication:nil. |
|
4652 |
currentDir := Filename homeDirectory. |
|
4653 |
contents := currentDir directoryContents. |
|
4654 |
fileName := contents |
|
4655 |
detect:[:file | |
|
4656 |
suffix := file asFilename suffix asLowercase. |
|
4657 |
suffix = 'pdf' |
|
4658 |
] |
|
4659 |
ifNone:[nil]. |
|
4660 |
fileName isNil ifTrue:[ |
|
4661 |
Dialog warn:'cant find a PDF File in ' , currentDir asString. |
|
4662 |
^ self |
|
4663 |
]. |
|
3982 | 4664 |
self item:(DirectoryContentsBrowser itemClass fileName:(currentDir construct:fileName)). |
3892 | 4665 |
]. |
4666 |
self changeInformation. |
|
4667 |
self setupXView. |
|
4668 |
^ super postOpenWith:aBuilder |
|
4669 |
! |
|
4670 |
||
4671 |
release |
|
4672 |
"/Transcript showCR:'release'. |
|
4673 |
self stopViewer. |
|
4674 |
self stopVNCServer. |
|
4675 |
^ super release |
|
4676 |
! ! |
|
4677 |
||
4678 |
!FileApplicationNoteBook class methodsFor:'documentation'! |
|
4679 |
||
4680 |
version |
|
4111
1975ba8ba0a6
ask if editView is available in getcontents changed by penk
tm
parents:
4110
diff
changeset
|
4681 |
^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.27 2002-10-30 09:40:43 tm Exp $' |
3892 | 4682 |
! ! |