31 poolDictionaries:'' |
31 poolDictionaries:'' |
32 privateIn:HierarchicalFileList |
32 privateIn:HierarchicalFileList |
33 ! |
33 ! |
34 |
34 |
35 HierarchicalFileList::HierarchicalFileItem subclass:#Directory |
35 HierarchicalFileList::HierarchicalFileItem subclass:#Directory |
36 instanceVariableNames:'modificationTime makeIconGray quickChildrenInfo' |
36 instanceVariableNames:'modificationTime makeIconGray quickChildrenInfo isInAccessible' |
37 classVariableNames:'StateUnknown StateHasChildren StateHasNoChildren StateFetching' |
37 classVariableNames:'StateUnknown StateHasChildren StateHasNoChildren StateFetching' |
38 poolDictionaries:'' |
38 poolDictionaries:'' |
39 privateIn:HierarchicalFileList |
39 privateIn:HierarchicalFileList |
40 ! |
40 ! |
41 |
41 |
330 |
330 |
331 childrenFor:anItem |
331 childrenFor:anItem |
332 "returns all visible children derived from the physical |
332 "returns all visible children derived from the physical |
333 directory contents." |
333 directory contents." |
334 |
334 |
335 |contents list matchBlock| |
335 |contents list match| |
336 |
336 |
337 anItem isDirectory ifFalse:[^ #()]. |
337 anItem isDirectory ifFalse:[^ #()]. |
338 |
338 |
339 contents := DirectoryContents directoryNamed:anItem fileName. |
339 contents := DirectoryContents directoryNamed:anItem fileName. |
340 contents isNil ifTrue:[ ^ #() ]. |
340 |
341 |
341 (contents isNil or:[contents isReadable not]) ifTrue:[ |
342 list := OrderedCollection new. |
342 anItem beInAccessible. |
343 matchBlock := self matchBlockFor:anItem. |
343 ] ifFalse:[ |
344 |
344 contents notEmpty ifTrue:[ |
345 contents itemsDo:[:anItem| |
345 list := OrderedCollection new. |
346 (matchBlock isNil or:[matchBlock value:(anItem fileName) value:(anItem isDirectory)]) ifTrue:[ |
346 match := self matchBlockFor:anItem. |
347 list add:(HierarchicalFileItem forContentsItem:anItem). |
347 |
348 ] |
348 contents itemsDo:[:each| |
349 ]. |
349 ( match isNil |
350 |
350 or:[match value:(each fileName) value:(each isDirectory)] |
351 list isEmpty ifTrue:[^ #()]. |
351 ) ifTrue:[ |
352 list sort:self sortBlock. |
352 list add:(HierarchicalFileItem forContentsItem:each). |
353 ^ list |
353 ] |
|
354 ]. |
|
355 list notEmpty ifTrue:[ |
|
356 list sort:self sortBlock. |
|
357 ^ list |
|
358 ]. |
|
359 ]. |
|
360 ]. |
|
361 ^ #() |
354 ! |
362 ! |
355 |
363 |
356 hasChildrenFor:anItem |
364 hasChildrenFor:anItem |
357 "returns true if the physical directory contains at least |
365 "returns true if the physical directory contains at least |
358 one visible item; otherwise false." |
366 one visible item; otherwise false." |
723 self fileName printOn:aStream |
731 self fileName printOn:aStream |
724 ! ! |
732 ! ! |
725 |
733 |
726 !HierarchicalFileList::HierarchicalFileItem methodsFor:'protocol'! |
734 !HierarchicalFileList::HierarchicalFileItem methodsFor:'protocol'! |
727 |
735 |
|
736 displayIcon:anIcon atX:x y:y on:aGC |
|
737 "called to draw the icon - if the item is inaccessible |
|
738 a red cross is drawn over thge item" |
|
739 |
|
740 |x0 y0 y1 w| |
|
741 |
|
742 anIcon displayOn:aGC x:x y:y. |
|
743 |
|
744 self isInAccessible ifTrue:[ |
|
745 aGC paint:(Color red). |
|
746 |
|
747 y0 := y + 1. |
|
748 y1 := y + anIcon height - 2. |
|
749 |
|
750 x0 := x - 1. |
|
751 w := anIcon width. |
|
752 |
|
753 2 timesRepeat:[ |
|
754 aGC displayLineFromX:x0 y:y0 toX:(x0 + w) y:y1. |
|
755 aGC displayLineFromX:x0 y:y1 toX:(x0 + w) y:y0. |
|
756 x0 := x0 + 1. |
|
757 ]. |
|
758 ]. |
|
759 ! |
|
760 |
728 flushChildren |
761 flushChildren |
729 "flush the children (because node is not visible) |
762 "flush the children (because node is not visible) |
730 Can be redefined by subclass" |
763 Can be redefined by subclass" |
731 |
764 |
732 children := nil. |
765 children := nil. |
817 ! |
857 ! |
818 |
858 |
819 icon |
859 icon |
820 "returns the icon" |
860 "returns the icon" |
821 |
861 |
822 |nameKey| |
862 |nameKey filename| |
823 |
863 |
824 isExpanded ifTrue:[ |
864 isExpanded ifTrue:[ |
825 (makeIconGray == true) ifTrue:[ |
865 makeIconGray == true ifTrue:[ nameKey := #directoryOpenGray ] |
826 nameKey := #directoryOpenGray |
866 ifFalse:[ nameKey := #directoryOpen ]. |
827 ] ifFalse:[ |
|
828 nameKey := #directoryOpen |
|
829 ] |
|
830 ] ifFalse:[ |
867 ] ifFalse:[ |
831 makeIconGray == true ifTrue:[ |
868 makeIconGray == true ifTrue:[ nameKey := #directoryGray ] |
832 nameKey := #directoryGray |
|
833 ] |
|
834 ]. |
869 ]. |
835 |
870 |
836 nameKey notNil ifTrue:[ |
871 nameKey notNil ifTrue:[ |
837 ^ FileBrowser iconForKeyMatching:nameKey |
872 ^ FileBrowser iconForKeyMatching:nameKey |
838 ]. |
873 ]. |
839 |
874 icon notNil ifTrue:[^ icon ]. |
840 icon isNil ifTrue:[ |
875 |
841 ^ super icon |
876 filename := contentsItem fileName. |
|
877 |
|
878 self isRemoteDirectory ifTrue:[ |
|
879 nameKey := FileBrowser iconKeyForRemoteDirectory:filename. |
|
880 ] ifFalse:[ |
|
881 contentsItem isSymbolicLink ifTrue:[ |
|
882 icon := FileBrowser iconForLinkedDirectory. |
|
883 ] ifFalse:[ |
|
884 nameKey := filename mimeTypeFromName. |
|
885 nameKey isNil ifTrue:[ nameKey := #directory ]. |
|
886 icon := FileBrowser iconForKeyMatching:nameKey. |
|
887 ]. |
842 ]. |
888 ]. |
843 ^ icon |
889 ^ icon |
844 ! |
890 ! |
845 |
891 |
846 label |
892 label |
887 "/ set to suppress reading of children |
933 "/ set to suppress reading of children |
888 children := #(). |
934 children := #(). |
889 modificationTime := self fileName modificationTime. |
935 modificationTime := self fileName modificationTime. |
890 model stopIndicatorValidationFor:self. |
936 model stopIndicatorValidationFor:self. |
891 |
937 |
|
938 "/ set to false - will be set by my model during reading the contents |
|
939 isInAccessible := false. |
892 list := model childrenFor:self. |
940 list := model childrenFor:self. |
893 |
941 |
894 list size ~~ 0 ifTrue:[ |
942 list size ~~ 0 ifTrue:[ |
895 list do:[:aChild| aChild parent:self]. |
943 list do:[:aChild| aChild parent:self]. |
896 children := list. |
944 children := list. |
934 ! ! |
982 ! ! |
935 |
983 |
936 !HierarchicalFileList::Directory methodsFor:'fetching'! |
984 !HierarchicalFileList::Directory methodsFor:'fetching'! |
937 |
985 |
938 basicFetchIndicator |
986 basicFetchIndicator |
939 |linkName fileName hasChildren info fileItem| |
987 |linkName fileName hasChildren info fileItem model| |
940 |
988 |
941 fileName := self fileName. |
989 fileName := self fileName. |
942 fileItem := DirectoryContents contentsItemForFileName:fileName. |
990 fileItem := DirectoryContents contentsItemForFileName:fileName. |
943 |
991 |
944 fileItem notNil ifTrue:[ |
992 fileItem notNil ifTrue:[ |
954 (OperatingSystem mountPoints contains:[:mp | mp mountPointPath = linkName and:[mp isRemote]]) ifTrue:[ |
1002 (OperatingSystem mountPoints contains:[:mp | mp mountPointPath = linkName and:[mp isRemote]]) ifTrue:[ |
955 "do not follow mounted directories automatically (could be an NFS hardlink)" |
1003 "do not follow mounted directories automatically (could be an NFS hardlink)" |
956 ^ self. |
1004 ^ self. |
957 ]. |
1005 ]. |
958 |
1006 |
959 hasChildren := self model notNil and:[ DirectoryContents directoryNamed:fileName detect:(self model matchBlock) ]. |
1007 (model := self model) notNil ifTrue:[ |
|
1008 isInAccessible := false. |
|
1009 |
|
1010 hasChildren := DirectoryContents |
|
1011 directoryNamed:fileName |
|
1012 detect:(model matchBlock) |
|
1013 onOpenErrorDo:[:fn| isInAccessible := true ]. |
|
1014 |
|
1015 ] ifFalse:[ |
|
1016 hasChildren := false. |
|
1017 ]. |
960 self knownToHaveChildren:hasChildren. |
1018 self knownToHaveChildren:hasChildren. |
961 "/ self assert:children isNil. |
1019 "/ self assert:children isNil. |
962 |
1020 |
963 (children isNil and:[info notNil]) ifTrue:[ |
1021 (children isNil and:[info notNil]) ifTrue:[ |
964 "setup modification time to suppress monitorCycle" |
1022 "setup modification time to suppress monitorCycle" |
1058 quickChildrenInfo := StateFetching |
1116 quickChildrenInfo := StateFetching |
1059 ! ! |
1117 ! ! |
1060 |
1118 |
1061 !HierarchicalFileList::Directory methodsFor:'queries'! |
1119 !HierarchicalFileList::Directory methodsFor:'queries'! |
1062 |
1120 |
|
1121 beInAccessible |
|
1122 isInAccessible := true. |
|
1123 ! |
|
1124 |
1063 canExpand |
1125 canExpand |
1064 super canExpand ifTrue:[^ true]. |
1126 super canExpand ifTrue:[^ true]. |
1065 |
1127 |
1066 "/ in case we are currently fetching the subdirectory |
1128 "/ in case we are currently fetching the subdirectory |
1067 "/ self isFetchingChildrenInfo ifTrue:[ |
1129 "/ self isFetchingChildrenInfo ifTrue:[ |