AbstractFileBrowser.st
changeset 17769 156241c3adef
parent 17768 dde98b4c9580
child 17772 52be86700796
equal deleted inserted replaced
17768:dde98b4c9580 17769:156241c3adef
   158     "Created: / 19-11-2017 / 14:48:19 / cg"
   158     "Created: / 19-11-2017 / 14:48:19 / cg"
   159 !
   159 !
   160 
   160 
   161 maxFileSizeShownWithoutAsking:anIntegerOrNilForDefault
   161 maxFileSizeShownWithoutAsking:anIntegerOrNilForDefault
   162     "the max. filesize which is loaded without asking if only the first
   162     "the max. filesize which is loaded without asking if only the first
   163      part should be shown"
   163      part should be shown.
       
   164      Nil resets to the default (currently 1Mb)"
   164 
   165 
   165     MaxFileSizeShownWithoutAsking := anIntegerOrNilForDefault
   166     MaxFileSizeShownWithoutAsking := anIntegerOrNilForDefault
       
   167 
       
   168     "
       
   169      self maxFileSizeShownWithoutAsking:nil
       
   170     "
   166 
   171 
   167     "Created: / 19-11-2017 / 14:48:45 / cg"
   172     "Created: / 19-11-2017 / 14:48:45 / cg"
   168 !
   173 !
   169 
   174 
   170 resetClassVars
   175 resetClassVars
  3049                                                         with:thisFileSizeString)
  3054                                                         with:thisFileSizeString)
  3050                                     labels:#('Cancel' 'Show All' 'Show First Part' ).
  3055                                     labels:#('Cancel' 'Show All' 'Show First Part' ).
  3051                 ].
  3056                 ].
  3052             answer isNil ifTrue:[^ nil].
  3057             answer isNil ifTrue:[^ nil].
  3053             answer ifTrue:[
  3058             answer ifTrue:[
  3054                 sizeLimit := 4 * 1024 * 1024
  3059                 sizeLimit := (4 * 1024 * 1024) "max:self maxFileSizeShownWithoutAsking".
  3055             ] ifFalse:[
  3060             ] ifFalse:[
  3056                 setNewLimit ifTrue:[
  3061                 setNewLimit ifTrue:[
  3057                     self maxFileSizeShownWithoutAsking:(self maxFileSizeShownWithoutAsking max:f fileSize).
  3062                     self maxFileSizeShownWithoutAsking:(self maxFileSizeShownWithoutAsking max:f fileSize).
  3058                 ].    
  3063                 ].    
  3059             ].    
  3064             ].    
  3081         numberOfAddressDigits:addrDigits
  3086         numberOfAddressDigits:addrDigits
  3082         addressStart:0
  3087         addressStart:0
  3083         characterEncoding:characterEncoding
  3088         characterEncoding:characterEncoding
  3084 
  3089 
  3085     "Created: / 12-11-2017 / 12:08:10 / cg"
  3090     "Created: / 12-11-2017 / 12:08:10 / cg"
  3086     "Modified: / 19-11-2017 / 14:54:28 / cg"
  3091     "Modified: / 19-11-2017 / 15:01:34 / cg"
  3087 !
  3092 !
  3088 
  3093 
  3089 contentsOfFileAsHexDump:f 
  3094 contentsOfFileAsHexDump:f 
  3090     "opens the file, get its contents and generates a dump for it"
  3095     "opens the file, get its contents and generates a dump for it"
  3091 
  3096 
  6926 
  6931 
  6927     "Modified: / 20-05-2010 / 11:15:35 / cg"
  6932     "Modified: / 20-05-2010 / 11:15:35 / cg"
  6928 !
  6933 !
  6929 
  6934 
  6930 fileContentsAsByteArray
  6935 fileContentsAsByteArray
  6931     |file|
  6936     |file fileSize|
  6932 
  6937 
  6933     file := self firstSelectedFile.
  6938     file := self firstSelectedFile.
  6934     file isNil ifTrue:[^ self ].
  6939     file isNil ifTrue:[^ self ].
  6935     file asFilename fileSize > (1024*1024) ifTrue:[
  6940 
  6936         file asFilename fileSize > (128*1024*1024) ifTrue:[
  6941     file := file asFilename.
       
  6942     
       
  6943     (fileSize := file fileSize) > (1024*1024) ifTrue:[
       
  6944         fileSize > (128*1024*1024) ifTrue:[
  6937             Dialog warn:(resources string:'File is too big').
  6945             Dialog warn:(resources string:'File is too big').
  6938             ^ self.
  6946             ^ self.
  6939         ].
  6947         ].
  6940         (Dialog confirm:(resources string:'File is big - proceed ?')) ifFalse:[^ self].
  6948         (Dialog confirm:(resources 
  6941     ].
  6949                             string:'File is big (%1) - proceed?' 
  6942     file asFilename binaryContentsOfEntireFile inspect
  6950                             with:(UnitConverter fileSizeStringFor:fileSize))
       
  6951         ) ifFalse:[^ self].
       
  6952     ].
       
  6953     file binaryContentsOfEntireFile inspect
       
  6954 
       
  6955     "Modified: / 19-11-2017 / 14:58:43 / cg"
  6943 !
  6956 !
  6944 
  6957 
  6945 fileFileIn
  6958 fileFileIn
  6946     "fileIn the selected file(s)"
  6959     "fileIn the selected file(s)"
  6947 
  6960 
  8024 !
  8037 !
  8025 
  8038 
  8026 openDiffViewOn:fileArg1 and:fileArg2
  8039 openDiffViewOn:fileArg1 and:fileArg2
  8027     "open a diff-view on two files"
  8040     "open a diff-view on two files"
  8028 
  8041 
  8029     |file1 file2 text1 text2 d err nm l1 sameContents msg|
  8042     |file1 file2 file1Size file2Size text1 text2 d err nm l1 sameContents msg|
  8030 
  8043 
  8031     file1 := fileArg1.
  8044     file1 := fileArg1.
  8032     file2 := fileArg2.
  8045     file2 := fileArg2.
  8033 
  8046 
  8034     self withWaitCursorDo:[
  8047     self withWaitCursorDo:[
  8065             Dialog warn:(resources string:err with:nm pathName allBold).
  8078             Dialog warn:(resources string:err with:nm pathName allBold).
  8066             ^ self
  8079             ^ self
  8067         ].
  8080         ].
  8068 
  8081 
  8069         self withActivityIndicationDo:[
  8082         self withActivityIndicationDo:[
  8070             ((file1 notNil and:[file1 fileSize > (1024*1024*32)])
  8083             file1Size := file1 isNil ifTrue:[0] ifFalse:[file1 fileSize].
  8071             or:[ file2 fileSize > (1024*1024*32) ]) ifTrue:[
  8084             file2Size := file2 isNil ifTrue:[0] ifFalse:[file2 fileSize].
  8072                 file1 fileSize = file2 fileSize ifTrue:[
  8085             
       
  8086             ((file1Size > (1024*1024*32)) or:[ file2Size > (1024*1024*32) ]) ifTrue:[
       
  8087                 file1Size = file2Size ifTrue:[
  8073                     ProgressIndicator
  8088                     ProgressIndicator
  8074                         displayBusyIndicator:'Comparing...'
  8089                         displayBusyIndicator:'Comparing...'
  8075                         at:(Screen default center)
  8090                         at:(Screen default center)
  8076                         during:[
  8091                         during:[
  8077                             sameContents := (file1 sameContentsAs:file2).
  8092                             sameContents := (file1 sameContentsAs:file2).
  8113                 d topView label:(resources string:'File Differences').
  8128                 d topView label:(resources string:'File Differences').
  8114             ]
  8129             ]
  8115         ]
  8130         ]
  8116     ]
  8131     ]
  8117 
  8132 
  8118     "Modified: / 03-05-2012 / 08:03:16 / cg"
  8133     "Modified: / 19-11-2017 / 15:00:47 / cg"
  8119 !
  8134 !
  8120 
  8135 
  8121 openDirectoryDiffView
  8136 openDirectoryDiffView
  8122     "open a directory diff-view"
  8137     "open a directory diff-view"
  8123 
  8138