AbstractDesktop.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 11 Oct 2011 16:53:59 +0100
branchjv
changeset 17883 209190914636
parent 17761 b0e5971141bc
child 17941 3651a18f3703
permissions -rw-r--r--
svn:keywords property set correctly

"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libbasic' }"

Object subclass:#AbstractDesktop
	instanceVariableNames:''
	classVariableNames:'Current'
	poolDictionaries:''
	category:'System-Desktop'
!

!AbstractDesktop class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!AbstractDesktop class methodsFor:'initialization'!

initialize

    "
        self initialize. 
        Desktop
    "

    Current := nil.
    Smalltalk at: #Desktop put:self current

    "Created: / 11-08-2009 / 17:09:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!AbstractDesktop class methodsFor:'instance creation'!

new
    ^ self basicNew initialize.
! !

!AbstractDesktop class methodsFor:'accessing'!

best

    "
        AbstractDesktop best
    "

    (self allSubclasses asSortedCollection: [:a :b|a priority > b priority])
        do:[:cls|cls isAvailable ifTrue:[^cls new]].
    ^nil "maybe error?"

    "Created: / 11-08-2009 / 17:09:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

current

    Current ifNil:
        [Current := self best].
    ^Current

    "Created: / 11-08-2009 / 17:08:26 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

priority

    "The higher numbers a checked first"

    self subclassResponsibility

    "Created: / 11-08-2009 / 16:38:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!AbstractDesktop class methodsFor:'testing'!

isAvailable

    "Returns true if this desktop is available on this computer"

    self subclassResponsibility

    "Created: / 11-08-2009 / 16:38:11 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!AbstractDesktop methodsFor:'operations'!

edit: filenames

    "
        Opens desktop's preferred editor on given filenames.

        filenames - a String or Filename or collection of those.
    "

    | files |
    files := self toArrayOfFilenames: filenames.

    "Created: / 11-08-2009 / 17:31:14 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!AbstractDesktop methodsFor:'utilities'!

toArrayOfFilenames: filenameOrCollectionOfThose

    ^(filenameOrCollectionOfThose isCollection 
        and:[filenameOrCollectionOfThose isString not])
            ifTrue:[filenameOrCollectionOfThose collect:[:e|e asFilename]]
            ifFalse:[Array with:filenameOrCollectionOfThose asFilename]

    "Created: / 11-08-2009 / 17:28:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!AbstractDesktop class methodsFor:'documentation'!

version
    ^'$Id: AbstractDesktop.st 10717 2011-10-11 15:53:59Z vranyj1 $'
!

version_SVN
    ^ '$Id: AbstractDesktop.st 10717 2011-10-11 15:53:59Z vranyj1 $'
! !

AbstractDesktop initialize!