HierarchicalFileList.st
author penk
Tue, 06 Aug 2002 13:59:48 +0200
changeset 2127 effea319e46b
parent 2104 327f2f77ec12
child 2128 f79308387ed7
permissions -rw-r--r--
add printString method to see file for Item
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     1
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     3
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     4
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     5
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     6
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     9
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    10
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    11
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    12
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    13
1780
867e59c91ff7 use icons derived from FileBrowser
ca
parents: 1582
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
867e59c91ff7 use icons derived from FileBrowser
ca
parents: 1582
diff changeset
    15
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
HierarchicalList subclass:#HierarchicalFileList
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
    17
	instanceVariableNames:'icons matchBlock showCursor'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
1430
ae9e48cc7b9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1399
diff changeset
    20
	category:'Views-Support'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
HierarchicalItem subclass:#File
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	instanceVariableNames:'fileName baseName icon'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	classVariableNames:''
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	poolDictionaries:''
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
	privateIn:HierarchicalFileList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
HierarchicalFileList::File subclass:#Directory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	instanceVariableNames:'modificationTime'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	classVariableNames:''
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	poolDictionaries:''
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	privateIn:HierarchicalFileList::File
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    37
!HierarchicalFileList class methodsFor:'documentation'!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    38
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    39
copyright
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    40
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    41
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    42
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    43
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    44
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    45
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    46
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    47
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    48
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    49
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    50
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    51
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    52
! !
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!HierarchicalFileList class methodsFor:'examples'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
test
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    |top sel list item|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    list := HierarchicalFileList new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    list directory:(Filename homeDirectory).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    list showRoot:false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    list matchBlock:[:fn :isDir| |suf rslt|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
                         (rslt := isDir) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
                             suf := fn suffix.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
                             suf size ~~ 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
                                 rslt := (    suf = 'c'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
                                          or:[suf = 'h'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
                                          or:[suf = 'hi']]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
                                         )
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
                             ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
                         ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
                         rslt
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
                     ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    top := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    sel := ScrollableView for:HierarchicalListView miniScroller:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
                       origin:0.0@0.0 corner:1.0@1.0 in:top.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    sel list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    list root expand.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    top open.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!HierarchicalFileList class methodsFor:'resources'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
icons
1780
867e59c91ff7 use icons derived from FileBrowser
ca
parents: 1582
diff changeset
    94
    ^ FileBrowser icons.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
!HierarchicalFileList methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
directory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    "returns the root directory or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    ^ root notNil ifTrue:[root fileName] ifFalse:[nil]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
directory:aDirectory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    "set the root directory or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    |directory|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
1960
2363303c1c8c monitoring must be enebled by user (no longer automatically)
ca
parents: 1867
diff changeset
   115
"/    must explicitly enabled by user: ca
2363303c1c8c monitoring must be enebled by user (no longer automatically)
ca
parents: 1867
diff changeset
   116
"/    monitoringTaskDelay := 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    (aDirectory notNil and:[(directory := aDirectory asFilename) exists]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
        directory isDirectory ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
            directory := directory directory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
        directory := nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    directory = self directory ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        directory notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
            directory := File fileName:directory isDirectory:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        self root:directory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!HierarchicalFileList methodsFor:'actions'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
matchBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    "set the matchBlock - if non-nil, it controls which files are visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    ^ matchBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
        
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
matchBlock:aBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    "set the matchBlock - if non-nil, it controls which files are visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    matchBlock := aBlock.
1866
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   147
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   148
    root notNil ifTrue:[
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   149
        self recursionLock critical:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   150
            self stopMonitoringTask.
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   151
            root matchBlockChanged.
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   152
        ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   153
        self startMonitoringTask.
1866
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   154
    ].
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   155
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
2104
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   158
!HierarchicalFileList methodsFor:'private monitoring task'!
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   159
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   160
monitoringCycle
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   161
    "the block evaluated by the monitoring task; test whether directory is expanded
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   162
     otherwise we have not to evaluate the directory contents.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   163
     think about remote file-systems
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   164
    "
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   165
    |index item|
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   166
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   167
    item  := root.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   168
    index := showRoot ifTrue:[1] ifFalse:[0].
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   169
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   170
    [item notNil] whileTrue:[
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   171
        (item isDirectory and:[item getChildren notNil]) ifTrue:[
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   172
            "/ children already initialized; thus we can update the contents
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   173
            item monitoringCycle
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   174
        ].
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   175
        Processor yield.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   176
        index := index + 1.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   177
        item  := self at:index ifAbsent:nil.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   178
    ].
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   179
! !
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   180
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
!HierarchicalFileList methodsFor:'protocol'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
childrenFor:anItem
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    "returns all visible children derived from the physical
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
     directory contents.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    |contents list block|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    list := #().
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    anItem isDirectory ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
        ^ list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   195
    contents := DirectoryContents directoryNamed:(anItem fileName).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   197
    contents notNil ifTrue:[
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   198
        list  := OrderedCollection new.
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   199
        block := self matchBlockFor:anItem.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   201
        block isNil ifTrue:[
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   202
            contents contentsDo:[:fn :isDir|
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   203
                list add:(File fileName:fn isDirectory:isDir)
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   204
            ]
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   205
        ] ifFalse:[
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   206
            contents contentsDo:[:fn :isDir|
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   207
                (block value:fn value:isDir) ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
                    list add:(File fileName:fn isDirectory:isDir)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
                ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    ^ list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
hasChildrenFor:anItem
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    "returns true if the physical directory contains at least
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
     one visible item otherwise false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    |block|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    anItem isDirectory ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        ^ false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    (block := self matchBlockFor:anItem) isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        block := [:aFilename :isDirectory| true ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    ^ DirectoryContents directoryNamed:(anItem fileName) detect:block
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
iconFor:anItem
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "returns the icon for an item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    "
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   239
    |fn key suff mimeType icn|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    fn := anItem fileName.
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   242
    icons isNil ifTrue:[ icons := self class icons ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    fn isDirectory ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
        (fn isReadable and:[fn isExecutable]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
            key := fn isSymbolicLink ifTrue:[#directoryLink]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
                                    ifFalse:[#directory]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
            key := #directoryLocked
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   250
        ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   251
        ^ icons at:key ifAbsent:nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    ].
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   253
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   254
    fn isReadable     ifFalse:[ ^ icons at:#fileLocked ifAbsent:nil ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   255
    fn isSymbolicLink  ifTrue:[ ^ icons at:#fileLink   ifAbsent:nil ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   256
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   257
    suff := fn suffix.
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   258
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   259
    (suff = 'bak' or:[suff = 'sav']) ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   260
        suff := fn withoutSuffix suffix.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   263
    suff size > 0 ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   264
        ( #( 'o' 'so' 'a' ) includes:suff) ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   265
             ^ icons at:#executableFile ifAbsent:nil
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   266
        ].        
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   267
        mimeType := MIMETypes mimeTypeForSuffix:suff.
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   268
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   269
        mimeType notNil ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   270
            (icn := icons at:mimeType ifAbsent:nil) notNil ifTrue:[^ icn].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   271
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   272
            (mimeType startsWith:'image/') ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   273
                ^ icons at:#imageFile ifAbsent:nil
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   274
            ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   275
        ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   276
    ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   277
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   278
    fn isExecutableProgram ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   279
        ^ icons at:#executableFile ifAbsent:nil
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   280
    ].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   281
    ^ icons at:#file ifAbsent:nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
matchBlockFor:anItem
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    "get the matchBlock - if non-nil, it controls which files are
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
     visible within the physical directory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    ^ matchBlock        
2095
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   289
!
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   290
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   291
validateIcon:anIcon for:anItem
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   292
    ^ anIcon
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   295
!HierarchicalFileList methodsFor:'searching'!
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   296
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   297
detectItemFor:aPathOrFilename
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   298
    "make a filename visible
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   299
    "
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   300
    |file node p1 p2 sz|
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   301
1582
bed19387e545 bug fix
ca
parents: 1581
diff changeset
   302
    aPathOrFilename isNil ifTrue:[^ nil].
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   303
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   304
    file := aPathOrFilename asFilename.
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   305
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   306
    file exists ifFalse:[
1582
bed19387e545 bug fix
ca
parents: 1581
diff changeset
   307
        ^ nil
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   308
    ].
1582
bed19387e545 bug fix
ca
parents: 1581
diff changeset
   309
    (node := root) isNil ifTrue:[^ nil].
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   310
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   311
    p1 := node pathName.
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   312
    p2 := file pathName.
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   313
1582
bed19387e545 bug fix
ca
parents: 1581
diff changeset
   314
    (p2 startsWith:p1) ifFalse:[^ nil].
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   315
    sz := 1 + p1 size.
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   316
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   317
    (p1 last == Filename separator) ifFalse:[
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   318
        sz := sz + 1.
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   319
    ].
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   320
1582
bed19387e545 bug fix
ca
parents: 1581
diff changeset
   321
    p2 size > sz ifFalse:[^ nil].
1581
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   322
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   323
    p2 :=  Filename components:(p2 copyFrom:sz).
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   324
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   325
    p2 do:[:bn|
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   326
        node := node detect:[:el| el baseName = bn] ifNone:nil.
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   327
        node isNil ifTrue:[^ nil ].
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   328
    ].
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   329
    ^ node
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   330
! !
5a8b7ce35090 detct item for a specific fileName
ca
parents: 1431
diff changeset
   331
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
!HierarchicalFileList::File class methodsFor:'instance creation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
fileName:aFileName isDirectory:isDirectory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    "instance creation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
    |item|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    item := isDirectory ifTrue:[Directory new] ifFalse:[HierarchicalFileList::File new].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    item fileName:aFileName.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
  ^ item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
!HierarchicalFileList::File methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
baseName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    "returns the baseName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    ^ baseName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
children
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    "always returns an empty list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
    ^ #()
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
fileName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
    "returns the fileName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
    ^ fileName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
fileName:fname
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
    "instance creation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    fileName := fname.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    baseName := fname baseName.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
icon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    "returns the icon key
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    |model|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
2095
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   381
    model := self model.
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   382
    model ifNil:[^ nil].
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   383
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    icon isNil ifTrue:[
2095
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   385
        icon := model iconFor:self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    ].
2095
46120b1fd644 can change icon
penk
parents: 1960
diff changeset
   387
    ^ model validateIcon:icon for:self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
label
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
    "returns the printable name, the baseName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    ^ baseName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
pathName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    "returns the pathName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
    ^ fileName pathName
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
!HierarchicalFileList::File methodsFor:'accessing hierarchy'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
recursiveExpand
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    "redefined to expand
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
    self expand
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
!HierarchicalFileList::File methodsFor:'invalidate'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    "invalidate the contents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
    self invalidateRepairNow:false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
invalidateRepairNow
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
    "invalidate the contents; repair now
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
    self invalidateRepairNow:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
invalidateRepairNow:doRepair
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
    "invalidate the contents; dependent on the boolean
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
     do repair immediately
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
1866
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   436
!
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   437
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   438
matchBlockChanged
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   439
    "called if the matchBlock changed
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   440
    "
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   441
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
2127
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   444
!HierarchicalFileList::File methodsFor:'printing'!
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   445
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   446
printString
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   447
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   448
    ^ super printString, ' for: ', self fileName asString
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   449
! !
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   450
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
!HierarchicalFileList::File methodsFor:'queries'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
hasChildren
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    "always returns false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    ^ false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
isDirectory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
    "always returns false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    ^ false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
!HierarchicalFileList::File::Directory methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
children
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
    "returns the list of children
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
    |model list|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   473
    children notNil ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   474
        ^ children
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   475
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   477
    (model := self model) isNil ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   478
        "/ must reread later
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   479
        modificationTime := children := nil.
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   480
        ^ nil
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   481
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   483
    children := #().
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   484
    modificationTime := fileName modificationTime.
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   485
    list := model childrenFor:self.
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   486
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   487
    list size ~~ 0 ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   488
        list do:[:aChild| aChild parent:self].
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   489
        children := list.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
    ^ children
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
icon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
    "returns the icon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
    (isExpanded and:[children size ~~ 0]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
        ^ nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
    ^ super icon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
2104
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   503
!HierarchicalFileList::File::Directory methodsFor:'accessing-hierarchy'!
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   504
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   505
expand
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   506
    "expand children; must redefine to raise a notification
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   507
     if children are not yet initialized and after initialization empty.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   508
    "
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   509
    |notInit|
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   510
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   511
    notInit := children isNil.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   512
    super expand.
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   513
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   514
    notInit ifTrue:[
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   515
        (children notNil and:[children isEmpty]) ifTrue:[
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   516
            "/ no children exists
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   517
            "/ indicator +/- has changed to unexistant
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   518
            self changed:#redraw
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   519
        ]
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   520
    ].
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   521
! !
327f2f77ec12 support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents: 2095
diff changeset
   522
2127
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   523
!HierarchicalFileList::File::Directory methodsFor:'printing'!
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   524
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   525
printString
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   526
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   527
    ^ super printString, ' for: ', self fileName asString
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   528
! !
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   529
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
!HierarchicalFileList::File::Directory methodsFor:'queries'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
hasChildren
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    "returns true if children exists
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
    ^ children isNil or:[children notEmpty]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
isDirectory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
    "always returns true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    ^ true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
!HierarchicalFileList::File::Directory methodsFor:'validation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
invalidateRepairNow:doRepair
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
    "invalidate contents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
    modificationTime := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
    doRepair ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
        self monitoringCycle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
        (isExpanded or:[children size == 0]) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
            children := nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
1866
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   563
matchBlockChanged
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   564
    "called if the matchBlock changed
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   565
    "
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   566
    modificationTime := nil.
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   567
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   568
    isExpanded ifFalse:[
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   569
        children := nil.
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   570
    ] ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   571
        self monitoringCycle.
1866
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   572
1867
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   573
        children size ~~ 0 ifTrue:[
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   574
            children do:[:aChild| aChild matchBlockChanged ]
a50479cd3653 recompute list if matchBlock changed
ca
parents: 1866
diff changeset
   575
        ]
1866
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   576
    ].
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   577
!
2993c95f7f69 recompute list if matchBlock changed
ca
parents: 1780
diff changeset
   578
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
monitoringCycle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
    "run monitoring cycle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    |list size name modifyTime isNotEmpty wasNotEmpty model|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
    modifyTime := fileName modificationTime.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
    (modificationTime notNil and:[modifyTime <= modificationTime]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
    model := self model.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
    modificationTime := modifyTime.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
    isExpanded ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
     "/ CHECK WHETHER CHILDREN EXIST( INDICATOR )
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
     "/ =========================================
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
        isNotEmpty := model hasChildrenFor:self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
     "/ check whether has changed durring evaluation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
        (isExpanded or:[modificationTime ~= modifyTime]) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
            wasNotEmpty := children isNil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
            children    := isNotEmpty ifTrue:[nil] ifFalse:[#()].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
            wasNotEmpty ~~ isNotEmpty ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
                self changed
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
 "/ START MERGING( CONTENTS IS VISIBLE )
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
 "/ ====================================
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
    list := model childrenFor:self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    list size == 0 ifTrue:[                         "/ contents becomes empty
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
        ^ self removeAll                            "/ clear contents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
    (size := children size) == 0 ifTrue:[           "/ old contents was empty 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
        ^ self addAll:list.                         "/ take over new contents
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    size to:1 by:-1 do:[:anIndex|                   "/ remove invisible items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
        name := (children at:anIndex) baseName.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
        (list findFirst:[:i|i baseName = name]) == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
            self removeIndex:anIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
    list keysAndValuesDo:[:anIndex :anItem|         "/ add new visible items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
        name := anItem baseName.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
        (children findFirst:[:i|i baseName = name]) == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
            self add:anItem beforeIndex:anIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
!HierarchicalFileList class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
version
2127
effea319e46b add printString method to see file for Item
penk
parents: 2104
diff changeset
   644
    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.13 2002-08-06 11:59:48 penk Exp $'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
! !