AbstractDirectoryBrowser.st
author penk
Thu, 30 Oct 2003 14:36:10 +0100
changeset 5330 db3c33306631
parent 5139 4cef12eebbb7
child 5335 c676d4fdd3f5
permissions -rw-r--r--
drag and drop scrolling no up and down scrolling here anymore

"
 COPYRIGHT (c) 2003 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:libtool' }"

AbstractFileBrowser subclass:#AbstractDirectoryBrowser
	instanceVariableNames:'inDropMode canDropItem browser updateToExternFileHolderLock'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Tools-File'
!

!AbstractDirectoryBrowser class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2003 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.
"
!

documentation
"
    Abstract class containing the common code from DirectoryTreeBrowser and
    DirectoryContentsBrowser applications.
"
! !

!AbstractDirectoryBrowser methodsFor:'accessing'!

updateToExternFileHolderLock
    "return the value of the instance variable 'updateToExternFileHolder' (automatically generated)"

    updateToExternFileHolderLock isNil ifTrue:[
        updateToExternFileHolderLock := self class newLock.
    ].
    ^ updateToExternFileHolderLock
! !

!AbstractDirectoryBrowser methodsFor:'drag & drop'!

canDrop:aContext

    ^ inDropMode and:[canDropItem]
!

doDrop:aContext 
    |col destinationPath receiver didDrop|

    destinationPath := self dropDestinationPath.

    self dropLeave:aContext.

    destinationPath ifNil:[^ self].

    aContext dropSource argument == #archivApplication ifTrue:[
        receiver := aContext dropSource receiver.
        receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true.
        ^ self
    ].

    col := aContext dropObjects collect:[:obj | obj theObject].
    didDrop := self copyOrMoveFiles:col to:destinationPath.
    didDrop ifFalse:[
        aContext clearHasDroppedFlagToSuppressFeedBack
    ].           
!

dropEnter:aContext

    |dropedObjects|

    self dropTargetItemChangedTo:nil in:aContext.
    inDropMode := false.

"/    self directory isNil ifTrue:[^ self].
    dropedObjects := aContext dropObjects.

    dropedObjects do:[:aObject| 
        |checkObject checkObjectString|

        aObject isFileObject ifFalse:[^ self].

        checkObject := aObject theObject.
        checkObject isFilename not ifTrue:[^ self].
        ((aContext dropSource argument == #archivApplication) not) ifTrue:[
            checkObject isSpecialFile ifTrue:[^ self].
            checkObject isReadable ifFalse:[^ self].
        ].
    ].
    inDropMode := true.
!

dropLeave:aDropContext 
    "send the last time, when leaving the widget
    "
    inDropMode ifFalse:[ ^ self ].

    self dropTargetItemChangedTo:nil in:aDropContext.
    self removeExpandItemTimedBlock.
    inDropMode := false.
!

dropTargetItemChangedTo:anItem in:aContext

    self subclassResponsibility
!

getDropObjects:anArgument

    ^ self selectedFiles collect:[:file| DropObject newFile:file].
!

getLineNumberFor:aDropContext
    | yVisible|

    yVisible := (aDropContext targetPoint y).
    ^ browser yVisibleToRowNr:yVisible.
!

pushUserEvent:selector withArgument:argument
    self window sensor 
        pushUserEvent:selector 
        for:self 
        withArgument:argument
! !

!AbstractDirectoryBrowser methodsFor:'file actions'!

doCopy
    "copy current selected files/directories
    "

    self copyFilesToClipBoard:(self selectedFiles).
!

doCut
    "cut current selected files/directories"

    self cutFilesToClipBoard:(self selectedFiles).
!

doDelete
    "delete current selected files/directories
    "
    self deleteFiles:(self selectedFiles copy).
! !

!AbstractDirectoryBrowser methodsFor:'selection'!

selectedFiles

    ^ self selectedItems collect:[:item| item fileName].
! !

!AbstractDirectoryBrowser methodsFor:'startup & release'!

initialize

    inDropMode := false.
    ^ super initialize.
!

postOpenAsSubcanvasWith:aBuilder

    super postOpenAsSubcanvasWith:aBuilder.
    self postOpen.
!

postOpenWith:aBuilder
    "only invoked if the application not started from a master"

    super postOpenWith:aBuilder.
    self postOpen.
!

preBuildWith:aBuilder

    self masterApplication isNil ifTrue:[
        self masterApplication:nil.
    ].
    ^ super preBuildWith:aBuilder.
! !

!AbstractDirectoryBrowser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/AbstractDirectoryBrowser.st,v 1.8 2003-10-30 13:36:01 penk Exp $'
! !