-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #342 Cannot open anymore OS folder X.
Also move to use a visitor instead of extension methods
- Loading branch information
Showing
9 changed files
with
79 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
" | ||
I'm a simple visitor in charge of opening an operating system browser on the provided path string. | ||
" | ||
Class { | ||
#name : #PhLFileBrowser, | ||
#superclass : #OSPlatformVisitor, | ||
#instVars : [ | ||
'process', | ||
'vmPath', | ||
'launchInALoginShell', | ||
'imageFile', | ||
'usePharoSettings', | ||
'path' | ||
], | ||
#category : #'PharoLauncher-Core-Model' | ||
} | ||
|
||
{ #category : #'instance creation' } | ||
PhLFileBrowser class >> openOn: aFileReferenceOrPathString [ | ||
|
||
^ self new | ||
path: aFileReferenceOrPathString; | ||
open. | ||
] | ||
|
||
{ #category : #action } | ||
PhLFileBrowser >> open [ | ||
self visit | ||
] | ||
|
||
{ #category : #accessing } | ||
PhLFileBrowser >> path: aFileReferenceOrPathString [ | ||
"Opens an OS-specific file and directory browser on ==aFileReference==. If aFileReference is a file, opens the browser on its containing directory instead." | ||
| ref | | ||
aFileReferenceOrPathString isNil ifTrue: [ ^ nil ]. | ||
ref := aFileReferenceOrPathString asFileReference. | ||
ref exists ifFalse: [ ^ nil ]. | ||
|
||
ref := ref isFile ifTrue: [ ref parent ] ifFalse: [ ref ]. | ||
(ref isNil or: [ ref exists not ]) | ||
ifTrue: [ ^ nil ]. | ||
|
||
path := ref fullName. | ||
] | ||
|
||
{ #category : #visiting } | ||
PhLFileBrowser >> visitMacOS: aPlatform [ | ||
^ PhLProcessWrapper new | ||
shellCommand; | ||
addArgument: ('open "{1}"' format: {path}); | ||
runUnwatch | ||
] | ||
|
||
{ #category : #visiting } | ||
PhLFileBrowser >> visitUnix: aPlatform [ | ||
^ PhLProcessWrapper new | ||
shellCommand; | ||
addArgument: ('xdg-open "{1}"' format: {path}); | ||
runUnwatch | ||
] | ||
|
||
{ #category : #visiting } | ||
PhLFileBrowser >> visitWindows: aPlatform [ | ||
^ aPlatform privShellExplore: path | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Class { | ||
#name : #PhLFileBrowserTest, | ||
#superclass : #TestCase, | ||
#category : #'PharoLauncher-Tests-Core' | ||
} | ||
|
||
{ #category : #tests } | ||
PhLFileBrowserTest >> testCanOpenAFileBrowserOnImageFolder [ | ||
| path | | ||
path := Smalltalk image imageDirectory fullName. | ||
PhLFileBrowser openOn: path. | ||
] |