Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "Remove UIManager dependencies from Compression."" #16106

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/BaselineOfBasicTools/BaselineOfBasicTools.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ BaselineOfBasicTools >> baseline: spec [
with: [ spec requires: #( 'Tool-Diff' 'MonticelloGUI' ) ].
spec package: 'System-Sources-Tests'. "<= Not sure this one should be here but it is where the classes were loaded before been extracted from Tests package."
spec package: 'System-Announcements-Tests'. "<= Not sure this one should be here but it is where the classes were loaded before been extracted from Tests package."
spec package: 'System-Spec'.
spec package: 'RPackage-Tests'.
spec package: 'Monticello-Tests'.
spec package: 'MonticelloGUI-Tests'.
Expand Down
34 changes: 12 additions & 22 deletions src/Compression/ZipArchive.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ ZipArchive class >> compressionStored [
^CompressionStored
]

{ #category : 'file in/out' }
ZipArchive class >> extractAllIn: aFileReferenceOrFileName [
"Service method to extract all contents of a zip."
| directory |
directory := (UIManager default chooseDirectoryFrom: aFileReferenceOrFileName asFileReference) ifNil: [^ self].
^ (self new)
readFrom: aFileReferenceOrFileName;
extractAllTo: directory
]

{ #category : 'file in/out' }
ZipArchive class >> extractFrom: aZipFile to: aDirectory [

Expand Down Expand Up @@ -148,33 +138,33 @@ ZipArchive >> extractAllTo: aDirectory [
ZipArchive >> extractAllTo: aDirectory informing: job [
"Extract all elements to the given directory; notifying user via UI on progress and if existing files exist"

| job1 barValue |
job1 := job ifNil: [ DummySystemProgressItem new ].
| barValue |

barValue := 0.
self members select: #isDirectory thenDo: [ :entry |
| dir shouldUpdateInfos lastUpdate |
lastUpdate := 0.
(shouldUpdateInfos := (Time millisecondsSince: lastUpdate) >= 100)
ifTrue: [
lastUpdate := Time millisecondClockValue.
job1 title: 'Creating ' , entry fileName ].
job title: 'Creating ' , entry fileName ].
dir := (entry fileName findTokens: '/')
inject: aDirectory
into: [ :base :part | base / part ].
dir ensureCreateDirectory.
barValue := barValue + 1.
shouldUpdateInfos ifTrue: [ job1 currentValue: barValue ] ].
shouldUpdateInfos ifTrue: [ job currentValue: barValue ] ].
self members reject: #isDirectory thenDo: [ :entry |
| shouldUpdateInfos lastUpdate |
lastUpdate := 0.
(shouldUpdateInfos := (Time millisecondsSince: lastUpdate) >= 100)
ifTrue: [
lastUpdate := Time millisecondClockValue.
job1 title: 'Extracting ' , entry fileName ].
job title: 'Extracting ' , entry fileName ].
entry extractInDirectory: aDirectory.
barValue := barValue + 1.
shouldUpdateInfos ifTrue: [
job1 currentValue: barValue.
job currentValue: barValue.
lastUpdate := Time millisecondClockValue ] ].
^ self
]
Expand All @@ -183,8 +173,8 @@ ZipArchive >> extractAllTo: aDirectory informing: job [
ZipArchive >> extractAllTo: aDirectory informing: aBar overwrite: allOverwrite [
"Extract all elements to the given directory. Informs user when a file exists and set to overwrite"

| bar overwriteAll barValue |
bar := aBar ifNil: [ DummySystemProgressItem new ].
| overwriteAll barValue |

overwriteAll := allOverwrite.
barValue := 0.
self members select: #isDirectory thenDo: [ :entry |
Expand All @@ -193,24 +183,24 @@ ZipArchive >> extractAllTo: aDirectory informing: aBar overwrite: allOverwrite [
(shouldUpdateInfos := (Time millisecondsSince: lastUpdate) >= 100)
ifTrue: [
lastUpdate := Time millisecondClockValue.
bar label: 'Creating ' , entry fileName ].
aBar label: 'Creating ' , entry fileName ].
dir := (entry fileName findTokens: '/')
inject: aDirectory
into: [ :base :part | base / part ].
dir ensureCreateDirectory.
barValue := barValue + 1.
shouldUpdateInfos ifTrue: [ bar value: barValue ] ].
shouldUpdateInfos ifTrue: [ aBar value: barValue ] ].
self members reject: #isDirectory thenDo: [ :entry |
| shouldUpdateInfos lastUpdate |
lastUpdate := 0.
(shouldUpdateInfos := (Time millisecondsSince: lastUpdate) >= 100)
ifTrue: [
lastUpdate := Time millisecondClockValue.
bar label: 'Extracting ' , entry fileName ].
aBar label: 'Extracting ' , entry fileName ].
entry extractInDirectory: aDirectory.
barValue := barValue + 1.
shouldUpdateInfos ifTrue: [
bar value: barValue.
aBar value: barValue.
lastUpdate := Time millisecondClockValue ] ]
]

Expand Down
14 changes: 14 additions & 0 deletions src/System-Spec/Archive.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Extension { #name : 'Archive' }

{ #category : '*System-Spec' }
Archive class >> application [

^ StPharoApplication current
]

{ #category : '*System-Spec' }
Archive class >> openDirectoryDialog [
"Answer a new instance of <StOpenDirectoryDialog>"

^ self application openDirectoryDialog
]
27 changes: 27 additions & 0 deletions src/System-Spec/GZipReadStream.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Extension { #name : 'GZipReadStream' }

{ #category : '*System-Spec' }
GZipReadStream class >> openWithContents: contentsString label: titleString [
"Open a text viewer on contentsString and window label titleString"

SpTextPresenter new
text: contentsString;
open;
withWindowDo: [ : w |
w
title: titleString;
extent: 600 @ 800 ]
]

{ #category : '*System-Spec' }
GZipReadStream class >> viewContents: fullFileName [
"Open the decompressed contents of the .gz file with the given name."

| file |
(file := fullFileName asFileReference) binaryReadStreamDo: [ :aStream |
self with: aStream do: [ :aGzStream |
self
openWithContents: aGzStream upToEnd
label: 'Decompressed contents of: ' , file basename ] ]

]
7 changes: 7 additions & 0 deletions src/System-Spec/StPharoApplication.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : 'StPharoApplication' }

{ #category : '*System-Spec' }
StPharoApplication >> openDirectoryDialog [

^ StOpenDirectoryDialog new
]
18 changes: 18 additions & 0 deletions src/System-Spec/ZipArchive.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Extension { #name : 'ZipArchive' }

{ #category : '*System-Spec' }
ZipArchive class >> extractAllIn: aFileReferenceOrFileName [
"Service method to extract all contents of a zip.
Example:
ZipArchive extractAllIn: 'my_file.zip'
"
| directory |

directory := (self openDirectoryDialog
currentDirectory: FileSystem workingDirectory;
openModal) ifNil: [ ^ self ].

^ self new
readFrom: aFileReferenceOrFileName;
extractAllTo: directory
]
1 change: 1 addition & 0 deletions src/System-Spec/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'System-Spec' }