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