UIHelpTool.st
changeset 2018 635babad51d3
parent 2002 caa9b0a1e638
child 2020 9de675480091
equal deleted inserted replaced
2017:842d445b706a 2018:635babad51d3
   548     ].
   548     ].
   549     self cancel.
   549     self cancel.
   550 !
   550 !
   551 
   551 
   552 modified
   552 modified
   553     "true if any items are added, deleted or modified
   553     "true if any items are added, deleted or modified"
   554     "
   554 
   555     classItemList do:[:aClassItem|
   555     ^ classItemList contains:[:aClassItem | aClassItem modified ].
   556 	aClassItem modified ifTrue:[^ true].
       
   557     ].
       
   558     ^ false
       
   559 !
   556 !
   560 
   557 
   561 modified:aBoolean
   558 modified:aBoolean
   562     "true if any items are added, deleted or modified
   559     "true if any items are added, deleted or modified
   563     "
   560     "
   648 
   645 
   649 infoLabelHolder
   646 infoLabelHolder
   650     "returns the info label as value holder"
   647     "returns the info label as value holder"
   651 
   648 
   652     masterApplication notNil ifTrue:[
   649     masterApplication notNil ifTrue:[
       
   650         builder aspectAt:#useAlienInfoLabelHolder put:true.
   653         ^ masterApplication infoLabelHolder
   651         ^ masterApplication infoLabelHolder
   654     ].
   652     ].
   655     ^ super infoLabelHolder
   653     ^ super infoLabelHolder
   656 !
   654 !
   657 
   655 
  1111     classItemList do:[:aClassItem| 
  1109     classItemList do:[:aClassItem| 
  1112         aClassItem createHelpMethodNamed:(self specSelector) 
  1110         aClassItem createHelpMethodNamed:(self specSelector) 
  1113     ].
  1111     ].
  1114 !
  1112 !
  1115 
  1113 
  1116 openDocumentation
  1114 
  1117     "opens the documentation file of the Help Tool
       
  1118     "
       
  1119     self openHTMLDocument: 'tools/uipainter/HelpTool.html'
       
  1120 ! !
       
  1121 
       
  1122 !UIHelpTool::ClassItem class methodsFor:'instance creation'!
       
  1123 
       
  1124 onClass:aClass
       
  1125     |root|
       
  1126 
       
  1127     root := self new.
       
  1128     root onClass:aClass.
       
  1129     ^ root
       
  1130 ! !
       
  1131 
       
  1132 !UIHelpTool::ClassItem methodsFor:'accessing'!
       
  1133 
  1115 
  1134 list
  1116 list
  1135     "returns the hierarchical list assigned to the classItem; the
  1117     "returns the hierarchical list assigned to the classItem; the
  1136      list contains the keyItems
  1118      list contains the keyItems
  1137     "
  1119     "
  1147     "returns the class or nil if unspecified
  1129     "returns the class or nil if unspecified
  1148     "
  1130     "
  1149     ^ theClass
  1131     ^ theClass
  1150 ! !
  1132 ! !
  1151 
  1133 
  1152 !UIHelpTool::ClassItem methodsFor:'change & update'!
  1134 !UIHelpTool::ClassIte
  1153 
  1135 
  1154 helpTextChangedFor:anItem
  1136 helpTextChangedFor:anItem
  1155     "called if an helpKey changed its contents
  1137     "called if an helpKey changed its contents
  1156     "
  1138     "
  1157     self model notNil ifTrue:[
  1139     self model notNil ifTrue:[
  1161 ! !
  1143 ! !
  1162 
  1144 
  1163 !UIHelpTool::ClassItem methodsFor:'code generation'!
  1145 !UIHelpTool::ClassItem methodsFor:'code generation'!
  1164 
  1146 
  1165 createHelpMethodNamed:aMethodName
  1147 createHelpMethodNamed:aMethodName
       
  1148     |stream|
       
  1149 
       
  1150     (modified and:[theClass notNil]) ifFalse:[
       
  1151         ^ self
       
  1152     ].
       
  1153     KeyItem| |helpText|
       
  1154         helpText := aKeyItem helpText.
       
  1155         helpText isNil ifTrue:[ helpText := '' ].
       
  1156 
       
  1157         stream nextPutLine:(aKeyItem helpKey storeString).
       
  1158         stream nextPutLine:(helpText storeString); ccreateHelpMethodNamed:aMethodName
  1166     |stream|
  1159     |stream|
  1167 
  1160 
  1168     (modified and:[theClass notNil]) ifFalse:[
  1161     (modified and:[theClass notNil]) ifFalse:[
  1169         ^ self
  1162         ^ self
  1170     ].
  1163     ].
  1197         compile:(stream contents)
  1190         compile:(stream contents)
  1198         forClass:theClass class 
  1191         forClass:theClass class 
  1199         inCategory:'help specs'.
  1192         inCategory:'help specs'.
  1200 
  1193 
  1201     self modified:false.
  1194     self modified:false.
  1202 ! !
  1195 
  1203 
       
  1204 !UIHelpTool::ClassItem methodsFor:'displaying'!
       
  1205 
       
  1206 icon
       
  1207     "returns the display icon (always nil)
       
  1208     "
       
  1209     ^ nil
       
  1210 !
       
  1211 
       
  1212 label
       
  1213     "returns the display label
       
  1214     "
       
  1215     |label|
       
  1216 
       
  1217     theClass notNil ifTrue:[ label := theClass name ]
       
  1218 		   ifFalse:[ label := '** not yet defined **' ].
       
  1219 
       
  1220     modified ifTrue:[
       
  1221 	label := Text string:label color:(Color red).
       
  1222     ].
       
  1223     ^ label
       
  1224 ! !
       
  1225 
       
  1226 !UIHelpTool::ClassItem methodsFor:'instance creation'!
       
  1227 
  1196 
  1228 initialize
  1197 initialize
  1229     "setup defaults
  1198     "setup defaults
  1230     "
  1199     "
  1231     super initialize.
  1200     super initialize.
  1243 ! !
  1212 ! !
  1244 
  1213 
  1245 !UIHelpTool::ClassItem methodsFor:'private'!
  1214 !UIHelpTool::ClassItem methodsFor:'private'!
  1246 
  1215 
  1247 basicAdd:aChild sortBlock:aBlock
  1216 basicAdd:aChild sortBlock:aBlock
       
  1217     "catch low-level add to update the 
       
  1218 
       
  1219 basicAdd:aChild sortBlock:aBlock
  1248     "catch low-level add to update the modification flag
  1220     "catch low-level add to update the modification flag
  1249     "
  1221     "
  1250     self   modified:true.
  1222     self   modified:true.
  1251     aChild modified:true.
  1223     aChild modified:true.
  1252 
  1224 
  1256 basicAddAll:aList beforeIndex:anIndex
  1228 basicAddAll:aList beforeIndex:anIndex
  1257     "catch low-level add to update the modification flag
  1229     "catch low-level add to update the modification flag
  1258     "
  1230     "
  1259     self modified:true.
  1231     self modified:true.
  1260 
  1232 
  1261     aList do:[:el| el modified:true ].
  1233     aList 
  1262     ^ super basicAddAll:aList beforeIndex:anIndex.
       
  1263 !
       
  1264 
  1234 
  1265 basicRemoveFromIndex:startIndex toIndex:stopIndex
  1235 basicRemoveFromIndex:startIndex toIndex:stopIndex
  1266     "catch low-level remove to update the modification flag
  1236     "catch low-level remove to update the modification flag
  1267     "
  1237     "
  1268     self isUnspecified ifFalse:[
  1238     self isUnspecified ifFalse:[
  1278     "
  1248     "
  1279     ^ theClass isNil
  1249     ^ theClass isNil
  1280 !
  1250 !
  1281 
  1251 
  1282 modified
  1252 modified
  1283     "true, if any item is modified, created or deleted
  1253     "true, if any 
  1284     "
       
  1285     ^ modified
       
  1286 !
       
  1287 
  1254 
  1288 modified:aBoolean
  1255 modified:aBoolean
  1289     "true, if any item is modified, created or deleted
  1256     "true, if any item is modified, created or deleted
  1290     "
  1257     "
  1291     modified ~~ aBoolean ifTrue:[
  1258     modified ~~ aBoolean ifTrue:[
  1306 
  1273 
  1307     aKey size ~~ 0 ifTrue:[
  1274     aKey size ~~ 0 ifTrue:[
  1308 	key := aKey asSymbol.
  1275 	key := aKey asSymbol.
  1309 
  1276 
  1310 	self do:[:anItem|
  1277 	self do:[:anItem|
  1311 	    anItem helpKey == key ifTrue:[ ^ anItem ].
  1278 	    anItem helpKemodified:aBoolean
  1312 	]
  1279     "true, if any item is modified, created or deleted
  1313     ].
  1280     "
  1314     ^ nil
  1281     modified ~~ aBoolean ifTrue:[
  1315 ! !
  1282 	modified := aBoolean.
  1316 
  1283 
  1317 !UIHelpTool::KeyItem class methodsFor:'instance creation'!
  1284 	modified ifFalse:[
  1318 
  1285 	    self do:[:el| el modified:false ].
  1319 helpKey:aKey helpText:aText 
  1286 	].
  1320     |key|
  1287     ].
  1321 
  1288 ! !
  1322     key := self new.
  1289 
  1323     key helpKey:aKey helpText:aText.
  1290 !UIHelpTool::ClassItem methodsFor:'searching'!
  1324     ^ key
  1291 
  1325 ! !
  1292 
  1326 
       
  1327 !UIHelpTool::KeyItem methodsFor:'accessing'!
       
  1328 
  1293 
  1329 helpKey
  1294 helpKey
  1330     "returns the helpKey, a symbol
  1295     "returns the helpKey, a symbol
  1331     "
  1296     "
  1332     ^ helpKey
  1297     ^ helpKey
  1348 
  1313 
  1349     text ~= helpText ifTrue:[
  1314     text ~= helpText ifTrue:[
  1350         helpText := text.
  1315         helpText := text.
  1351 
  1316 
  1352         (modified or:[parent isNil]) ifFalse:[
  1317         (modified or:[parent isNil]) ifFalse:[
       
  1318             parent h
       
  1319 
       
  1320 helpText:aText
       
  1321     "set the contents assigned to the helpKey; if the contents changes,
       
  1322      a notification is raised.
       
  1323     "
       
  1324     |text|
       
  1325 
       
  1326     text := sehelpText:aText
       
  1327     "set the contents assigned to the helpKey; if the contents changes,
       
  1328      a notification is raised.
       
  1329     "
       
  1330     |text|
       
  1331 
       
  1332     text := self formatText:aText.
       
  1333 
       
  1334     text ~= helpText ifTrue:[
       
  1335         helpText := text.
       
  1336 
       
  1337         (modified or:[parent isNil]) ifFalse:[
  1353             parent helpTextChangedFor:self.
  1338             parent helpTextChangedFor:self.
  1354         ]
  1339         ]
  1355     ].
  1340     ].
  1356 ! !
  1341 ! !
  1357 
  1342 
  1358 !UIHelpTool::KeyItem methodsFor:'displaying'!
  1343 !
  1359 
       
  1360 icon
       
  1361     "returns the display icon (always nil)
       
  1362     "
       
  1363     ^ icon
       
  1364 !
       
  1365 
       
  1366 icon:anIcon
       
  1367 
       
  1368     icon ~= anIcon ifTrue:[
       
  1369         icon := anIcon.
       
  1370         self changed:#icon.
       
  1371     ].
       
  1372 !
       
  1373 
       
  1374 label
       
  1375     "returns the display label
       
  1376     "
       
  1377     modified ifTrue:[
       
  1378 	^ Text string:helpKey color:(Color red)
       
  1379     ].
       
  1380     ^ helpKey
       
  1381 ! !
       
  1382 
       
  1383 !UIHelpTool::KeyItem methodsFor:'instance creation'!
       
  1384 
  1344 
  1385 helpKey:aKey helpText:aText
  1345 helpKey:aKey helpText:aText
  1386     "set the key and contents without a change notification
  1346     "set the key and contents without a change notification
  1387     "
  1347     "
  1388     helpKey  := aKey asSymbol.
  1348     helpKey  := aKey asSymbol.
  1398 ! !
  1358 ! !
  1399 
  1359 
  1400 !UIHelpTool::KeyItem methodsFor:'private'!
  1360 !UIHelpTool::KeyItem methodsFor:'private'!
  1401 
  1361 
  1402 formatText:aText
  1362 formatText:aText
       
  1363     "format the text, replace carriage return by spaces
       
  1364 
       
  1365 formatText:aText
  1403     "format the text, replace carriage return by spaces and compress spaces
  1366     "format the text, replace carriage return by spaces and compress spaces
  1404     "
  1367     "
  1405     |text result|
  1368     |text result|
  1406 
  1369 
  1407     aText size ~~ 0 ifTrue:[
  1370     aText size ~~ 0 ifTrue:[
  1409 
  1372 
  1410 	text notEmpty ifTrue:[
  1373 	text notEmpty ifTrue:[
  1411 	    result := text first.
  1374 	    result := text first.
  1412 
  1375 
  1413 	    text from:2 do:[:t| result := result, ' ', t ].
  1376 	    text from:2 do:[:t| result := result, ' ', t ].
  1414 	    ^ result
  1377 	    ^ resu
  1415        ].
       
  1416     ].
       
  1417     ^ nil
       
  1418 ! !
       
  1419 
       
  1420 !UIHelpTool::KeyItem methodsFor:'queries'!
       
  1421 
       
  1422 modified
       
  1423     "returns true if the helpText is modified
       
  1424     "
       
  1425     ^ modified
       
  1426 !
       
  1427 
  1378 
  1428 modified:aBoolean
  1379 modified:aBoolean
  1429     "set the modification flag
  1380     "set the modification flag
  1430     "
  1381     "
  1431     aBoolean == modified ifFalse:[
  1382     aBoolean == modified ifFalse:[
  1437 !UIHelpTool class methodsFor:'documentation'!
  1388 !UIHelpTool class methodsFor:'documentation'!
  1438 
  1389 
  1439 version
  1390 version
  1440     ^ '$Header$'
  1391     ^ '$Header$'
  1441 ! !
  1392 ! !
       
  1393 ader: /cvs/stx/stx/libtool2/UIHelpTool.st,v 1.77 2006/02/15 21:55:10 cg Exp $'modified
       
  1394     "returns true if the helpText is modified
       
  1395     "
       
  1396     ^ modified
       
  1397 !
       
  1398 
       
  1399 modified:aBoolean
       
  1400     "set the modification flag
       
  1401     "
       
  1402     aBoolean == modified ifFalse:[
       
  1403 	modified := aBoolean.
       
  1404 	self changed:#redraw.
       
  1405   Vù Vù!
       
  1406 
       
  1407 !UIHelpTool class methodsFor:'documentation'!
       
  1408 
       
  1409 version
       
  1410     ^ '$Header$'
       
  1411 ! !