799 children isNil ifTrue:[ self readChildren ]. |
812 children isNil ifTrue:[ self readChildren ]. |
800 ]. |
813 ]. |
801 ^ children |
814 ^ children |
802 ! |
815 ! |
803 |
816 |
804 flushChildren |
|
805 "flush the children because node not visible .... |
|
806 " |
|
807 children notNil ifTrue:[ |
|
808 "keep hasChildren information |
|
809 " |
|
810 children size ~~ 0 ifTrue:[ fetchOperation := #hasChildren ] |
|
811 ifFalse:[ fetchOperation := #hasNoChildren ]. |
|
812 children := nil. |
|
813 ]. |
|
814 ! |
|
815 |
|
816 icon |
817 icon |
817 "returns the icon key |
818 "returns the icon |
818 " |
819 " |
|
820 |
|
821 |nameKey| |
|
822 |
819 isExpanded ifTrue:[ |
823 isExpanded ifTrue:[ |
|
824 (makeIconGray == true) ifTrue:[ |
|
825 nameKey := #directoryOpenGray |
|
826 ] ifFalse:[ |
|
827 nameKey := #directoryOpen |
|
828 ] |
|
829 ] ifFalse:[ |
820 makeIconGray == true ifTrue:[ |
830 makeIconGray == true ifTrue:[ |
821 ^ FileBrowser iconForKeyMatching:#directoryOpenGray |
831 nameKey := #directoryGray |
822 ]. |
832 ] |
823 ^ FileBrowser iconForKeyMatching:#directoryOpen |
833 ]. |
824 ]. |
834 |
825 makeIconGray == true ifTrue:[ |
835 nameKey notNil ifTrue:[ |
826 ^ FileBrowser iconForKeyMatching:#directoryGray |
836 ^ FileBrowser iconForKeyMatching:nameKey |
827 ]. |
837 ]. |
|
838 |
828 icon isNil ifTrue:[ |
839 icon isNil ifTrue:[ |
829 ^ super icon |
840 ^ super icon |
830 ]. |
841 ]. |
831 ^ icon |
842 ^ icon |
832 ! |
843 ! |
924 !HierarchicalFileList::Directory methodsFor:'fetching'! |
935 !HierarchicalFileList::Directory methodsFor:'fetching'! |
925 |
936 |
926 basicFetchIndicator |
937 basicFetchIndicator |
927 |hasChildren| |
938 |hasChildren| |
928 |
939 |
929 hasChildren := DirectoryContents directoryNamed:self fileName detect:(self model matchBlock). |
940 hasChildren := DirectoryContents directoryNamed:(self fileName) detect:(self model matchBlock). |
930 hasChildren ifTrue:[ |
941 self knownToHaveChildren:hasChildren. |
931 fetchOperation := #hasChildren |
942 children notNil ifTrue:[self halt]. |
932 ] ifFalse:[ |
943 |
933 fetchOperation := #hasNoChildren |
|
934 ]. |
|
935 children isNil ifTrue:[ |
944 children isNil ifTrue:[ |
936 "setup modification time to suppress monitorCycle |
945 "setup modification time to suppress monitorCycle |
937 " |
946 " |
938 modificationTime := self fileName modificationTime. |
947 modificationTime := self fileName modificationTime. |
939 ]. |
948 ]. |
940 ! |
949 ! |
941 |
950 |
942 fetchIndicator |
951 fetchIndicator |
943 "fetch the indicator value which indicates whether children exists or not |
952 "fetch the indicator value which indicates whether children exist or not. |
944 called by the list |
953 Called by the lists update process. |
945 " |
954 " |
946 children notNil ifTrue:[ |
955 children notNil ifTrue:[ |
947 "/ children already read |
956 "/ children already read |
948 fetchOperation := nil. |
957 self forgetAboutChildren. |
949 ^ self |
|
950 ]. |
|
951 |
|
952 fetchOperation ~~ #fetching ifTrue:[ |
|
953 "/ children will be updated .... |
|
954 ^ self |
958 ^ self |
955 ]. |
959 ]. |
|
960 |
|
961 self isFetchingChildrenInfo ifFalse:[ |
|
962 "/ children will be updated in a second.... |
|
963 ^ self |
|
964 ]. |
956 "/ suppress restart of fetchIndicator |
965 "/ suppress restart of fetchIndicator |
957 |
966 |
958 self basicFetchIndicator. |
967 self basicFetchIndicator. |
959 |
968 |
|
969 children notNil ifTrue:[self halt]. |
|
970 |
960 children notNil ifTrue:[ |
971 children notNil ifTrue:[ |
961 fetchOperation := nil. |
972 self forgetAboutChildren. |
962 children notEmpty ifTrue:[ self changed:#redraw ]. |
973 children notEmpty ifTrue:[ self changed:#redraw ]. |
963 ] ifFalse:[ |
974 ] ifFalse:[ |
964 "/ is a remote or very slow file system |
975 "/ is a remote or very slow file system |
965 fetchOperation == #hasChildren ifTrue:[ |
976 self isKnownToHaveChildren ifTrue:[ |
966 self changed:#redraw |
977 self changed:#redraw |
967 ]. |
978 ]. |
968 ]. |
979 ]. |
969 ! |
980 ! |
970 |
981 |
971 resetFetchIndicator |
982 resetFetchIndicator |
972 "update indication cycle has deregistered the item |
983 "update indication cycle has deregistered the item |
973 " |
984 " |
974 fetchOperation := nil. |
985 |
|
986 self forgetAboutChildren. |
|
987 ! ! |
|
988 |
|
989 !HierarchicalFileList::Directory methodsFor:'private'! |
|
990 |
|
991 flushChildren |
|
992 "flush the children because the node is going to be invisible. |
|
993 " |
|
994 children notNil ifTrue:[ |
|
995 self knownToHaveChildren:(children size ~~ 0). |
|
996 children := nil. |
|
997 ]. |
|
998 ! ! |
|
999 |
|
1000 !HierarchicalFileList::Directory methodsFor:'private - quick children info'! |
|
1001 |
|
1002 forgetAboutChildren |
|
1003 quickChildrenInfo := StateUnknown |
|
1004 ! |
|
1005 |
|
1006 isChildrenInfoValid |
|
1007 ^ quickChildrenInfo ~~ StateUnknown and:[quickChildrenInfo ~~ StateFetching] |
|
1008 ! |
|
1009 |
|
1010 isFetchingChildrenInfo |
|
1011 ^ quickChildrenInfo == StateFetching |
|
1012 ! |
|
1013 |
|
1014 isKnownToHaveChildren |
|
1015 ^ quickChildrenInfo == StateHasChildren |
|
1016 ! |
|
1017 |
|
1018 isKnownToHaveNoChildren |
|
1019 ^ quickChildrenInfo == StateHasNoChildren |
|
1020 ! |
|
1021 |
|
1022 knownToHaveChildren:aBoolean |
|
1023 aBoolean ifTrue:[ |
|
1024 quickChildrenInfo := StateHasChildren. |
|
1025 ] ifFalse:[ |
|
1026 quickChildrenInfo := StateHasNoChildren. |
|
1027 ]. |
|
1028 ! |
|
1029 |
|
1030 setFetchingChildrenInfo |
|
1031 quickChildrenInfo := StateFetching |
975 ! ! |
1032 ! ! |
976 |
1033 |
977 !HierarchicalFileList::Directory methodsFor:'queries'! |
1034 !HierarchicalFileList::Directory methodsFor:'queries'! |
978 |
1035 |
|
1036 canExpand |
|
1037 super canExpand ifTrue:[^ true]. |
|
1038 "/ in case we are fetching the subdirectory |
|
1039 self isFetchingChildrenInfo ifTrue:[ |
|
1040 self halt. |
|
1041 ]. |
|
1042 |
|
1043 ^ false |
|
1044 ! |
|
1045 |
979 hasChildren |
1046 hasChildren |
980 "returns true if children exists |
1047 "returns true if children exist |
981 " |
1048 " |
982 |model| |
1049 |model| |
983 |
1050 |
984 children notNil ifTrue:[ |
1051 children notNil ifTrue:[ |
985 fetchOperation := nil. |
1052 self forgetAboutChildren. |
986 ^ children size ~~ 0 |
1053 ^ children size ~~ 0 |
987 ]. |
1054 ]. |
988 |
1055 |
989 fetchOperation notNil ifTrue:[ |
1056 self isFetchingChildrenInfo ifTrue:[ |
990 ^ fetchOperation == #hasChildren |
1057 ^ false. |
|
1058 ]. |
|
1059 self isChildrenInfoValid ifTrue:[ |
|
1060 ^ self isKnownToHaveChildren |
991 ]. |
1061 ]. |
992 |
1062 |
993 model := self model. |
1063 model := self model. |
994 |
1064 |
995 model notNil ifTrue:[ |
1065 model notNil ifTrue:[ |
996 fetchOperation := #fetching. |
1066 self setFetchingChildrenInfo. |
997 model startIndicatorValidationFor:self. |
1067 model startIndicatorValidationFor:self. |
998 ] ifFalse:[ |
1068 ] ifFalse:[ |
999 self error:'should not happen' mayProceed:true. |
1069 self error:'should not happen' mayProceed:true. |
1000 fetchOperation := nil |
1070 self forgetAboutChildren |
1001 ]. |
1071 ]. |
1002 ^ children size ~~ 0 |
1072 children size ~~ 0 ifTrue:[self halt. ^ true]. |
|
1073 ^ false |
1003 ! |
1074 ! |
1004 |
1075 |
1005 isDirectory |
1076 isDirectory |
1006 "always returns true |
1077 "always returns true |
1007 " |
1078 " |
1062 children notNil ifTrue:[ |
1135 children notNil ifTrue:[ |
1063 timeChanged ifFalse:[ |
1136 timeChanged ifFalse:[ |
1064 ^ self |
1137 ^ self |
1065 ]. |
1138 ]. |
1066 ]. |
1139 ]. |
|
1140 |
1067 DirectoryContents flushCachedDirectoryFor:(self fileName). |
1141 DirectoryContents flushCachedDirectoryFor:(self fileName). |
1068 isExpanded ifFalse:[ |
1142 isExpanded ifFalse:[ |
1069 timeChanged ifTrue:[ |
1143 timeChanged ifTrue:[ |
1070 fetchOperation := children := nil. |
1144 children := nil. |
|
1145 self forgetAboutChildren. |
1071 self changed:#redraw. |
1146 self changed:#redraw. |
1072 ]. |
1147 ]. |
1073 ^ self |
1148 ^ self |
1074 ]. |
1149 ]. |
|
1150 |
|
1151 children isNil ifTrue:[ children := #() ]. "/ disable update during merge |
|
1152 |
|
1153 self forgetAboutChildren. |
1075 model := self model. |
1154 model := self model. |
1076 children isNil ifTrue:[ children := #() ]. "/ disable update during merge |
1155 mergedList := model childrenFor:self. |
1077 |
|
1078 |
|
1079 fetchOperation := nil. |
|
1080 mergedList := model childrenFor:self. |
|
1081 |
1156 |
1082 mergedList size == 0 ifTrue:[ |
1157 mergedList size == 0 ifTrue:[ |
1083 self removeAll. |
1158 self removeAll. |
1084 ^ self |
1159 ^ self |
1085 ]. |
1160 ]. |
1086 |
1161 |
1087 size := children size. |
1162 size := children size. |
1088 |
|
1089 size == 0 ifTrue:[ |
1163 size == 0 ifTrue:[ |
1090 self addAll:mergedList. |
1164 self addAll:mergedList. |
1091 ^ self |
1165 ^ self |
1092 ]. |
1166 ]. |
1093 |
1167 |
1137 |
1211 |
1138 hasChildren |
1212 hasChildren |
1139 "returns true if children exists |
1213 "returns true if children exists |
1140 " |
1214 " |
1141 children notNil ifTrue:[ |
1215 children notNil ifTrue:[ |
1142 fetchOperation := nil. |
1216 self forgetAboutChildren. |
1143 ^ children size ~~ 0 |
1217 ^ children size ~~ 0 |
1144 ]. |
1218 ]. |
1145 fetchOperation := #hasChildren. |
1219 |
1146 ^ true |
1220 "/ assume that there are children; |
|
1221 "/ this might be wrong and clicking on the expand-icon |
|
1222 "/ will then not perform an expand, but remove the can-expand indicator. |
|
1223 self knownToHaveChildren:true. |
|
1224 ^ true |
1147 ! |
1225 ! |
1148 |
1226 |
1149 isRemoteDirectory |
1227 isRemoteDirectory |
1150 ^ true |
1228 ^ true |
1151 ! ! |
1229 ! ! |
1152 |
1230 |
1153 !HierarchicalFileList class methodsFor:'documentation'! |
1231 !HierarchicalFileList class methodsFor:'documentation'! |
1154 |
1232 |
1155 version |
1233 version |
1156 ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.43 2003-03-03 10:21:56 penk Exp $' |
1234 ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.44 2003-04-08 13:38:08 cg Exp $' |
1157 ! ! |
1235 ! ! |
|
1236 |
|
1237 HierarchicalFileList::Directory initialize! |