

DiskBrowser subclass: #ApplicationLauncher

  instanceVariableNames: ''

  classVariableNames: ''

  poolDictionaries: '' !





!ApplicationLauncher class methods ! !







!ApplicationLauncher methods !

 

classComment

        "This class is a simple subclass of DiskBrowser that shows the

            power of Smalltalk/V Windows and OOP.  By overriding three

            methods, we create a new kind of browser that permits the user

            to directly launch a Windows application from Smalltalk.



        Program design and code by Graphic User Interfaces, Inc., Laurence

            Rozier and Dan Shafer.



        Contributed to the public domain provided this method remains intact."!

 

file: filePane

        "Private -- Set the selected file to the one

         selected in the filePane and launch it."

    | app |



    selectedFile := filePane selectedItem.

    app := (selectedDirectory drivePathName), '/',selectedFile.

    KernelLibrary winExec:

        (app) asParameter

        cmdShow: (( WinConstants at: 'SwShownormal') asParameter).!

 

files: filePane

        "Private -- Fill the filePane with a sorted list of

          .exe files for the selected directory."

    | answer |

    sortedFileList := SortedCollection sortBlock:

        sortedFileList sortBlock.

    answer := SortedCollection new.

    selectedDirectory == nil

        ifTrue: [^filePane contents: answer].

    sortedFileList addAll: (selectedDirectory formatted: '*.exe').

    sortedFileList do: [:each | answer add: (each at: 1)].

    filePane contents: answer.!



open



    super open.

    self mainView label: 'Application Launcher'.! !

