640 ) |
679 ) |
641 ) |
680 ) |
642 ) |
681 ) |
643 ! |
682 ! |
644 |
683 |
645 classDefineSpec |
|
646 "this window spec was automatically generated by the ST/X UIPainter" |
|
647 |
|
648 "do not manually edit this - the painter/builder may not be able to |
|
649 handle the specification if its corrupted." |
|
650 |
|
651 " |
|
652 UIPainter new openOnClass:MenuEditor andSelector:#classDefineSpec |
|
653 MenuEditor new openInterface:#classDefineSpec |
|
654 " |
|
655 |
|
656 <resource: #canvas> |
|
657 |
|
658 ^ |
|
659 |
|
660 #(#FullSpec |
|
661 #'window:' |
|
662 #(#WindowSpec |
|
663 #'name:' 'Menu Editor' |
|
664 #'layout:' #(#LayoutFrame 262 0 426 0 508 0 519 0) |
|
665 #'label:' 'Menu Editor' |
|
666 #'min:' #(#Point 10 10) |
|
667 #'max:' #(#Point 1152 900) |
|
668 #'bounds:' #(#Rectangle 262 426 509 520) |
|
669 #'usePreferredExtent:' false |
|
670 ) |
|
671 #'component:' |
|
672 #(#SpecCollection |
|
673 #'collection:' |
|
674 #( |
|
675 #(#LabelSpec |
|
676 #'name:' 'boxLabel' |
|
677 #'layout:' #(#LayoutFrame 2 0.0 4 0 -2 1.0 24 0) |
|
678 #'label:' 'Class for code:' |
|
679 #'adjust:' #left |
|
680 #'resizeForLabel:' true |
|
681 ) |
|
682 #(#InputFieldSpec |
|
683 #'name:' 'classNameField' |
|
684 #'layout:' #(#LayoutFrame 2 0.0 27 0 -2 1.0 49 0) |
|
685 #'tabable:' true |
|
686 #'model:' #classNameChannel |
|
687 #'acceptOnReturn:' false |
|
688 #'acceptOnTab:' false |
|
689 ) |
|
690 #(#UISubSpecification |
|
691 #'name:' 'SubSpecification' |
|
692 #'layout:' #(#LayoutFrame 0 0 -29 1 0 1 -5 1) |
|
693 #'majorKey:' #ToolApplicationModel |
|
694 #'minorKey:' #windowSpecForCommitWithoutChannels |
|
695 ) |
|
696 ) |
|
697 ) |
|
698 ) |
|
699 ! |
|
700 |
|
701 detailsEditSpec |
684 detailsEditSpec |
702 "this window spec was automatically generated by the ST/X UIPainter" |
685 "this window spec was automatically generated by the ST/X UIPainter" |
703 |
686 |
704 "do not manually edit this - the painter/builder may not be able to |
687 "do not manually edit this - the painter/builder may not be able to |
705 handle the specification if its corrupted." |
688 handle the specification if its corrupted." |
1042 #'label:' '-' |
1028 #'label:' '-' |
1043 ) |
1029 ) |
1044 #(#MenuItem |
1030 #(#MenuItem |
1045 #'label:' 'Load...' |
1031 #'label:' 'Load...' |
1046 #'translateLabel:' true |
1032 #'translateLabel:' true |
1047 #'value:' #doFromClass |
1033 #'value:' #doLoad |
1048 #'activeHelpKey:' #fileLoad |
1034 #'activeHelpKey:' #fileLoad |
1049 #'enabled:' #isStandAlone |
1035 #'enabled:' #isStandAlone |
1050 ) |
1036 ) |
1051 #(#MenuItem |
1037 #(#MenuItem |
1052 #'label:' '-' |
1038 #'label:' '-' |
1053 ) |
1039 ) |
1054 #(#MenuItem |
1040 #(#MenuItem |
1055 #'label:' 'Save' |
1041 #'label:' 'Save' |
1056 #'value:' #doInstallSpec |
1042 #'value:' #doSave |
1057 #'activeHelpKey:' #fileSave |
1043 #'activeHelpKey:' #fileSave |
|
1044 ) |
|
1045 #(#MenuItem |
|
1046 #'label:' 'Save As...' |
|
1047 #'value:' #doSaveAs |
|
1048 #'activeHelpKey:' #fileSaveAs |
1058 ) |
1049 ) |
1059 #(#MenuItem |
1050 #(#MenuItem |
1060 #'label:' '-' |
1051 #'label:' '-' |
1061 ) |
1052 ) |
1062 #(#MenuItem |
1053 #(#MenuItem |
1063 #'label:' 'Pick A Menu' |
1054 #'label:' 'Pick A Menu...' |
1064 #'value:' #doPickAMenu |
1055 #'value:' #doPickAMenu |
1065 #'activeHelpKey:' #filePickAMenu |
1056 #'activeHelpKey:' #filePickAMenu |
1066 #'enabled:' #isStandAlone |
1057 #'enabled:' #isStandAlone |
1067 ) |
1058 ) |
1068 #(#MenuItem |
1059 #(#MenuItem |
1069 #'label:' 'Define Class...' |
1060 #'label:' '-' |
1070 #'value:' #doDefineClass |
|
1071 #'activeHelpKey:' #fileDefineClass |
|
1072 #'enabled:' #isStandAlone |
|
1073 ) |
1061 ) |
1074 #(#MenuItem |
1062 #(#MenuItem |
1075 #'label:' 'Browse Class' |
1063 #'label:' 'Browse Class' |
1076 #'value:' #doBrowseAppClass |
1064 #'value:' #doBrowseClass |
1077 #'activeHelpKey:' #fileBrowseClass |
1065 #'activeHelpKey:' #fileBrowseClass |
1078 ) |
1066 ) |
1079 #(#MenuItem |
1067 #(#MenuItem |
1080 #'label:' '-' |
1068 #'label:' '-' |
1081 ) |
1069 ) |
1240 ) |
1228 ) |
1241 #(#MenuItem |
1229 #(#MenuItem |
1242 #'label:' 'Move Up' |
1230 #'label:' 'Move Up' |
1243 #'value:' #doStepUp |
1231 #'value:' #doStepUp |
1244 #'activeHelpKey:' #editMoveUp |
1232 #'activeHelpKey:' #editMoveUp |
1245 #'enabled:' #enabledStepOver |
1233 #'enabled:' #valueOfEnableMovingUp |
1246 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #upIcon 'Move Up') |
1234 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #upIcon 'Move Up') |
1247 ) |
1235 ) |
1248 #(#MenuItem |
1236 #(#MenuItem |
1249 #'label:' 'Move Down' |
1237 #'label:' 'Move Down' |
1250 #'value:' #doStepDown |
1238 #'value:' #doStepDown |
1251 #'activeHelpKey:' #editMoveDown |
1239 #'activeHelpKey:' #editMoveDown |
1252 #'enabled:' #enabledStepOver |
1240 #'enabled:' #valueOfEnableMovingDown |
1253 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downIcon 'Move Down') |
1241 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downIcon 'Move Down') |
1254 ) |
1242 ) |
1255 #(#MenuItem |
1243 #(#MenuItem |
1256 #'label:' 'Move In' |
1244 #'label:' 'Move In' |
1257 #'value:' #doStepIn |
1245 #'value:' #doStepIn |
1258 #'activeHelpKey:' #editMoveIn |
1246 #'activeHelpKey:' #editMoveIn |
1259 #'enabled:' #enabledStepIn |
1247 #'enabled:' #valueOfEnableMovingIn |
1260 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downRightIcon 'Move In') |
1248 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downRightIcon 'Move In') |
1261 ) |
1249 ) |
1262 #(#MenuItem |
1250 #(#MenuItem |
1263 #'label:' 'Move Out' |
1251 #'label:' 'Move Out' |
1264 #'value:' #doStepOut |
1252 #'value:' #doStepOut |
1265 #'activeHelpKey:' #editMoveOut |
1253 #'activeHelpKey:' #editMoveOut |
1266 #'enabled:' #enabledStepOut |
1254 #'enabled:' #valueOfEnableMovingOut |
1267 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #leftDownIcon 'Move Out') |
1255 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #leftDownIcon 'Move Out') |
1268 ) |
1256 ) |
1269 ) nil |
1257 ) nil |
1270 nil |
1258 nil |
1271 ) |
1259 ) |
1297 #'labelImage:' #(#ResourceRetriever nil #newIcon) |
1285 #'labelImage:' #(#ResourceRetriever nil #newIcon) |
1298 ) |
1286 ) |
1299 #(#MenuItem |
1287 #(#MenuItem |
1300 #'label:' 'Load' |
1288 #'label:' 'Load' |
1301 #'isButton:' true |
1289 #'isButton:' true |
1302 #'value:' #doFromClass |
1290 #'value:' #doLoad |
1303 #'activeHelpKey:' #fileLoad |
1291 #'activeHelpKey:' #fileLoad |
1304 #'labelImage:' #(#ResourceRetriever nil #loadIcon) |
1292 #'labelImage:' #(#ResourceRetriever nil #loadIcon) |
1305 ) |
1293 ) |
1306 #(#MenuItem |
1294 #(#MenuItem |
1307 #'label:' 'Save' |
1295 #'label:' 'Save' |
1308 #'isButton:' true |
1296 #'isButton:' true |
1309 #'value:' #doInstallSpec |
1297 #'value:' #doSave |
1310 #'activeHelpKey:' #fileSave |
1298 #'activeHelpKey:' #fileSave |
1311 #'labelImage:' #(#ResourceRetriever nil #saveIcon) |
1299 #'labelImage:' #(#ResourceRetriever nil #saveIcon) |
1312 ) |
1300 ) |
1313 #(#MenuItem |
1301 #(#MenuItem |
1314 #'label:' '' |
1302 #'label:' '' |
1354 #(#MenuItem |
1342 #(#MenuItem |
1355 #'label:' 'Move Up' |
1343 #'label:' 'Move Up' |
1356 #'isButton:' true |
1344 #'isButton:' true |
1357 #'value:' #doStepUp |
1345 #'value:' #doStepUp |
1358 #'activeHelpKey:' #editMoveUp |
1346 #'activeHelpKey:' #editMoveUp |
1359 #'enabled:' #enabledStepOver |
1347 #'enabled:' #valueOfEnableMovingUp |
1360 #'labelImage:' #(#ResourceRetriever nil #upIcon) |
1348 #'labelImage:' #(#ResourceRetriever nil #upIcon) |
1361 ) |
1349 ) |
1362 #(#MenuItem |
1350 #(#MenuItem |
1363 #'label:' 'Move Down' |
1351 #'label:' 'Move Down' |
1364 #'isButton:' true |
1352 #'isButton:' true |
1365 #'value:' #doStepDown |
1353 #'value:' #doStepDown |
1366 #'activeHelpKey:' #editMoveDown |
1354 #'activeHelpKey:' #editMoveDown |
1367 #'enabled:' #enabledStepOver |
1355 #'enabled:' #valueOfEnableMovingDown |
1368 #'labelImage:' #(#ResourceRetriever nil #downIcon) |
1356 #'labelImage:' #(#ResourceRetriever nil #downIcon) |
1369 ) |
1357 ) |
1370 #(#MenuItem |
1358 #(#MenuItem |
1371 #'label:' 'Move In' |
1359 #'label:' 'Move In' |
1372 #'isButton:' true |
1360 #'isButton:' true |
1373 #'value:' #doStepIn |
1361 #'value:' #doStepIn |
1374 #'activeHelpKey:' #editMoveIn |
1362 #'activeHelpKey:' #editMoveIn |
1375 #'enabled:' #enabledStepIn |
1363 #'enabled:' #valueOfEnableMovingIn |
1376 #'labelImage:' #(#ResourceRetriever nil #downRightIcon) |
1364 #'labelImage:' #(#ResourceRetriever nil #downRightIcon) |
1377 ) |
1365 ) |
1378 #(#MenuItem |
1366 #(#MenuItem |
1379 #'label:' 'Move Out' |
1367 #'label:' 'Move Out' |
1380 #'isButton:' true |
1368 #'isButton:' true |
1381 #'value:' #doStepOut |
1369 #'value:' #doStepOut |
1382 #'activeHelpKey:' #editMoveOut |
1370 #'activeHelpKey:' #editMoveOut |
1383 #'enabled:' #enabledStepOut |
1371 #'enabled:' #valueOfEnableMovingOut |
1384 #'labelImage:' #(#ResourceRetriever nil #leftDownIcon) |
1372 #'labelImage:' #(#ResourceRetriever nil #leftDownIcon) |
1385 ) |
1373 ) |
1386 ) nil |
1374 ) nil |
1387 nil |
1375 nil |
1388 ) |
1376 ) |
1519 self helpTool dictionary:aDictionary |
1490 self helpTool dictionary:aDictionary |
1520 ! ! |
1491 ! ! |
1521 |
1492 |
1522 !MenuEditor methodsFor:'aspects'! |
1493 !MenuEditor methodsFor:'aspects'! |
1523 |
1494 |
1524 aspectFor:aKey |
|
1525 "returns aspect for a key or nil" |
|
1526 |
|
1527 ^aspects at: aKey ifAbsent: [super aspectFor:aKey] |
|
1528 |
|
1529 |
|
1530 ! |
|
1531 |
|
1532 enabledStepIn |
|
1533 "returns whether user can put selected item in next submenu" |
|
1534 |
|
1535 ^builder booleanValueAspectFor: #enabledStepIn |
|
1536 ! |
|
1537 |
|
1538 enabledStepOut |
|
1539 "returns whether user can put selected item out of current parent submenu" |
|
1540 |
|
1541 ^builder booleanValueAspectFor: #enabledStepOut |
|
1542 |
|
1543 ! |
|
1544 |
|
1545 enabledStepOver |
|
1546 "returns whether user can shift selected item up or down" |
|
1547 |
|
1548 ^builder booleanValueAspectFor:#enabledStepOver |
|
1549 ! |
|
1550 |
|
1551 hasAnySingleSelection |
1495 hasAnySingleSelection |
1552 |
1496 |
1553 ^builder booleanValueAspectFor: #hasAnySingleSelection |
1497 ^builder booleanValueAspectFor: #hasAnySingleSelection |
1554 ! |
1498 ! |
1555 |
1499 |
1639 self hasAnySingleSelection value:true. |
1566 self hasAnySingleSelection value:true. |
1640 (parent := node parent) notNil |
1567 (parent := node parent) notNil |
1641 ifTrue: |
1568 ifTrue: |
1642 [ |
1569 [ |
1643 next := parent childAt:((parent indexOfChild:node) + 1). |
1570 next := parent childAt:((parent indexOfChild:node) + 1). |
1644 self enabledStepIn value:(next notNil and:[next hasChildren]). |
1571 self valueOfEnableMovingIn value:(next notNil and:[next hasChildren]). |
1645 self enabledStepOver value:(parent children size > 1). |
1572 self valueOfEnableMovingUpOrDown value:(parent children size > 1). |
1646 self enabledStepOut value:(parent parent notNil). |
1573 self valueOfEnableMovingOut value:parent parent notNil. |
1647 self hasValidSingleSelection value:true. |
1574 self hasValidSingleSelection value:true. |
1648 self hasValidSelection value:true. |
1575 self hasValidSelection value:true. |
1649 ^ self |
1576 ^ self |
1650 ] |
1577 ] |
1651 ] |
1578 ] |
1652 ifFalse: |
1579 ifFalse: |
1653 [ |
1580 [ |
1654 self hasAnySingleSelection value:false. |
1581 self hasAnySingleSelection value:false. |
1655 self treeView numberOfSelections ~~ 0 ifTrue:[ |
1582 self treeView numberOfSelections ~~ 0 ifTrue:[ |
1656 state := (self treeView isInSelection:1) not |
1583 state := (self treeView isInSelection:1) not |
1657 ] |
1584 ] |
1658 ]. |
1585 ]. |
1659 self enabledStepOver value:false. |
1586 self valueOfEnableMovingUpOrDown value:false. |
1660 self enabledStepIn value:false. |
1587 self valueOfEnableMovingIn value:false. |
1661 self enabledStepOut value:false. |
1588 self valueOfEnableMovingOut value:false. |
1662 self hasValidSingleSelection value:false. |
1589 self hasValidSingleSelection value:false. |
1663 self hasValidSelection value:state. |
1590 self hasValidSelection value:state. |
1664 ! ! |
1591 ! ! |
1665 |
1592 |
1666 !MenuEditor methodsFor:'event handling'! |
1593 !MenuEditor methodsFor:'event handling'! |
1667 |
1594 |
1668 doesNotUnderstand: aMessage |
1595 doesNotUnderstand: aMessage |
1678 |
1605 |
1679 ! ! |
1606 ! ! |
1680 |
1607 |
1681 !MenuEditor methodsFor:'help'! |
1608 !MenuEditor methodsFor:'help'! |
1682 |
1609 |
1683 defaultInfoLabel |
|
1684 |
|
1685 specClass isNil ifTrue: [^'No menu class defined']. |
|
1686 ^specClass printString, ' >> ', self treeView selectorName |
|
1687 |
|
1688 ! |
|
1689 |
|
1690 openTutorial |
1610 openTutorial |
1691 |
1611 |
1692 self openTutorial: 'tools/MenuEditor/TOP.html'. |
1612 self openTutorial: 'tools/MenuEditor/TOP.html'. |
1693 |
1613 |
1694 ! ! |
1614 ! ! |
1695 |
1615 |
|
1616 !MenuEditor methodsFor:'initialization'! |
|
1617 |
|
1618 initialize |
|
1619 "initialize value holders for the menu item properties" |
|
1620 |
|
1621 |holder| |
|
1622 |
|
1623 super initialize. |
|
1624 |
|
1625 aspects at:#seperatorSelection put:(holder := SelectionInList new). |
|
1626 holder list: Item separatorList. |
|
1627 holder addDependent:self. |
|
1628 |
|
1629 ! ! |
|
1630 |
1696 !MenuEditor methodsFor:'private'! |
1631 !MenuEditor methodsFor:'private'! |
1697 |
|
1698 checkMenuItemModified |
|
1699 "check menu item modification" |
|
1700 |
|
1701 self valueOfEnablingCommitButtons value |
|
1702 ifTrue: |
|
1703 [ |
|
1704 ((YesNoBox title:'Menu item was modified!!\Save it?\' withCRs) |
|
1705 noText:'No'; |
|
1706 yesText:'Yes'; |
|
1707 showAtPointer; |
|
1708 accepted) |
|
1709 ifFalse: |
|
1710 [ |
|
1711 self valueOfEnablingCommitButtons value: false. |
|
1712 isModified := false. |
|
1713 ^true |
|
1714 ]. |
|
1715 self accept |
|
1716 ]. |
|
1717 ^true |
|
1718 ! |
|
1719 |
1632 |
1720 helpKey |
1633 helpKey |
1721 |
1634 |
1722 |node| |
1635 |node| |
1723 (node := self treeView selectedNode) notNil ifTrue:[ |
1636 (node := self treeView selectedNode) notNil ifTrue:[ |
1856 |
1758 |
1857 !MenuEditor methodsFor:'startup / release'! |
1759 !MenuEditor methodsFor:'startup / release'! |
1858 |
1760 |
1859 buildFrom:aClass andSelector:aSelector |
1761 buildFrom:aClass andSelector:aSelector |
1860 |
1762 |
1861 |oldClass newClass| |
1763 |oldClass| |
1862 |
1764 |
1863 self valueOfEnablingCommitButtons value: false. |
1765 self valueOfEnablingCommitButtons value: false. |
1864 oldClass := self specClass. |
1766 oldClass := self specClass. |
1865 self specClass:aClass. |
1767 self specClass:aClass. |
1866 newClass := self specClass. |
1768 specSelector := aSelector. |
1867 |
1769 |
1868 (self isStandAlone and:[oldClass ~= newClass]) ifTrue:[ |
1770 (self isStandAlone and:[oldClass ~= specClass]) ifTrue:[ |
1869 self helpTool helpSpecFrom:newClass |
1771 self helpTool helpSpecFrom:specClass |
1870 ]. |
1772 ]. |
1871 self treeView buildFrom: newClass andSelector: aSelector. |
1773 self treeView buildFrom: specClass andSelector: specSelector. |
1872 |
1774 |
1873 aClass notNil & aSelector notNil |
1775 self updateHistory. |
1874 ifTrue: |
|
1875 [ |
|
1876 |className message| |
|
1877 aClass isClass ifTrue: [className := aClass name]. |
|
1878 aClass isString ifTrue: [className := aClass]. |
|
1879 message := className, ' ', aSelector. |
|
1880 self addToHistory: message -> #loadFromMessage: |
|
1881 ]. |
|
1882 |
|
1883 self updateInfoLabel. |
1776 self updateInfoLabel. |
1884 self treeView selection: 2. |
1777 self treeView selection: 2. |
1885 self menuChanged |
1778 self menuChanged |
1886 |
1779 |
1887 ! |
1780 ! |
1888 |
1781 |
1889 checkModified |
|
1890 "check menu modification |
|
1891 " |
|
1892 isModified |
|
1893 ifTrue: |
|
1894 [ |
|
1895 ((YesNoBox title:'Menu was modified!!') |
|
1896 noText:'Cancel'; |
|
1897 yesText:'Waste it and proceed'; |
|
1898 showAtPointer; |
|
1899 accepted) ifFalse: [^false]. |
|
1900 isModified := false |
|
1901 ]. |
|
1902 ^true |
|
1903 |
|
1904 |
|
1905 ! |
|
1906 |
|
1907 closeRequest |
|
1908 "close request" |
|
1909 |
|
1910 (self checkMenuItemModified and: [self checkModified]) ifTrue: [super closeRequest] |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 ! |
|
1917 |
|
1918 initialize |
|
1919 "initialize value holders for the menu item properties" |
|
1920 |
|
1921 |holder| |
|
1922 |
|
1923 super initialize. |
|
1924 aspects := IdentityDictionary new. |
|
1925 tabSelection := 0. |
|
1926 |
|
1927 #( |
|
1928 label |
|
1929 accessCharacterPos |
|
1930 argument |
|
1931 submenuChannel |
|
1932 enabled |
|
1933 value |
|
1934 nameKey |
|
1935 indication |
|
1936 translateLabel |
|
1937 isButton |
|
1938 shortcutKey |
|
1939 startGroup |
|
1940 retriever |
|
1941 iconAndLabel |
|
1942 icon |
|
1943 isVisible |
|
1944 |
|
1945 ) do:[:aKey| |
|
1946 aspects at:aKey put:(holder := ValueHolder new). |
|
1947 holder addDependent: self |
|
1948 ]. |
|
1949 |
|
1950 aspects at:#seperatorSelection put:(holder := SelectionInList new). |
|
1951 holder list: Item separatorList. |
|
1952 holder addDependent:self. |
|
1953 |
|
1954 ! |
|
1955 |
|
1956 loadFromMessage: aMessage |
|
1957 |
|
1958 (((aMessage size > 0) and: [self checkMenuItemModified]) and: [self checkModified]) |
|
1959 ifTrue: |
|
1960 [ |
|
1961 |readStream aClass aSelector| |
|
1962 readStream := aMessage readStream. |
|
1963 aClass := Smalltalk at: (readStream upTo: $ ) asSymbol. |
|
1964 aSelector := readStream upToEnd asSymbol. |
|
1965 self buildFrom: aClass andSelector: aSelector |
|
1966 ] |
|
1967 ! |
|
1968 |
|
1969 openModalOnClass:aClass andSelector:aSelector |
1782 openModalOnClass:aClass andSelector:aSelector |
1970 |
1783 |
1971 specClass := Association key:aClass value:aSelector. |
1784 specClass := Association key:aClass value:aSelector. |
1972 super openInterfaceModal. |
1785 super openInterfaceModal. |
1973 |
1786 |
2011 self isHelpToolSelected |
1821 self isHelpToolSelected |
2012 ifTrue: [helpCanvas raise] |
1822 ifTrue: [helpCanvas raise] |
2013 ifFalse: [specCanvas raise] |
1823 ifFalse: [specCanvas raise] |
2014 ! ! |
1824 ! ! |
2015 |
1825 |
2016 !MenuEditor methodsFor:'user interactions'! |
1826 !MenuEditor methodsFor:'user actions'! |
2017 |
1827 |
2018 accept |
1828 accept |
2019 "invoked by button 'OK' and by save requests of menu item changes" |
1829 "invoked by button 'OK' and by save requests of menu item changes" |
2020 |
1830 |
2021 |node| |
1831 |node| |
|
1832 |
2022 node := self treeView selectedNode. |
1833 node := self treeView selectedNode. |
2023 node notNil |
1834 node notNil |
2024 ifTrue: |
1835 ifTrue: |
2025 [ |
1836 [ |
2026 self isHelpToolSelected |
1837 self isHelpToolSelected |
2048 self helpTool helpKey:(self helpKey). |
1861 self helpTool helpKey:(self helpKey). |
2049 aspects do:[:anAspect| anAspect value:nil]. |
1862 aspects do:[:anAspect| anAspect value:nil]. |
2050 node contents toAspects:aspects |
1863 node contents toAspects:aspects |
2051 ]. |
1864 ]. |
2052 self valueOfEnablingCommitButtons value: false. |
1865 self valueOfEnablingCommitButtons value: false. |
2053 isModified := false |
1866 modified := false |
2054 ! |
1867 ! |
2055 |
1868 |
2056 doBrowseAppClass |
1869 doNew |
2057 "open a browser on the class" |
1870 |
2058 |
1871 self buildFrom: nil andSelector: self treeView selectorName |
2059 |cls| |
1872 ! |
2060 |
1873 |
2061 (cls := self resolveName: self specClass) notNil |
1874 doPickAMenu |
2062 ifTrue: |
1875 |
2063 [ |
1876 |view| |
2064 SystemBrowser openInClass:cls class selector: self treeView selectorName |
1877 |
2065 ] |
1878 view := Screen current viewFromUser. |
2066 ifFalse: |
1879 |
2067 [ |
1880 (view isNil or:[view == Screen current rootView]) ifTrue:[ |
2068 self information:'No valid class defined!!'. |
1881 ^ self |
2069 ] |
1882 ]. |
2070 ! |
1883 view specClass == MenuPanelSpec ifTrue:[ |
2071 |
1884 ^ self treeView buildFromMenu: view asMenu |
2072 doDefineClass |
1885 ]. |
2073 |
1886 ^ nil |
2074 aspects at:#classNameChannel put:(self specClass asValue). |
1887 ! |
2075 |
1888 |
2076 (self openDialogInterface:#classDefineSpec) ifTrue:[ |
1889 doSave |
2077 self specClass:((aspects at:#classNameChannel) value) |
1890 |cls treeView menu spec mthd category code| |
2078 ]. |
1891 |
2079 |
1892 cls := self resolveName:(self specClass). |
2080 ! |
1893 |
2081 |
|
2082 doEditImage |
|
2083 |
|
2084 |cls resourceClass resourceSelector imageResourceMessage readStream| |
|
2085 |
|
2086 cls := self resolveName: self specClass. |
|
2087 cls isNil ifTrue:[ |
1894 cls isNil ifTrue:[ |
2088 ^ self information:'No valid class defined!!'. |
1895 ^ self information:'No valid class defined!!'. |
2089 ]. |
1896 ]. |
2090 (aspects at:#icon) value size > 0 |
1897 |
2091 ifTrue: [resourceSelector := (aspects at:#icon) value] |
1898 treeView := self treeView. |
2092 ifFalse: [resourceSelector := #stxIcon]. |
|
2093 (aspects at:#retriever) value size > 0 |
|
2094 ifTrue: [resourceClass := (aspects at:#retriever) value] |
|
2095 ifFalse: [resourceClass := cls withAllSuperclasses detect: [:cls| cls class implements: resourceSelector] ifNone: [cls]]. |
|
2096 |
|
2097 (imageResourceMessage := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil |
|
2098 ifTrue: |
|
2099 [ |
|
2100 readStream := imageResourceMessage readStream. |
|
2101 resourceClass := (readStream upTo: $ ) asSymbol. |
|
2102 resourceSelector := readStream upToEnd asSymbol. |
|
2103 resourceClass size > 0 ifTrue: [(aspects at:#retriever) value: resourceClass]. |
|
2104 resourceSelector size > 0 ifTrue: [(aspects at:#icon) value: resourceSelector. self valueOfEnablingCommitButtons value: true] |
|
2105 ] |
|
2106 ! |
|
2107 |
|
2108 doFromClass |
|
2109 |
|
2110 self loadFromMessage: |
|
2111 (ResourceSelectionBrowser |
|
2112 request: 'Load Menu From Class' |
|
2113 onSuperclass: nil |
|
2114 andClass: specClass |
|
2115 andSelector: self treeView selectorName |
|
2116 withResourceTypes: #(menu)) |
|
2117 ! |
|
2118 |
|
2119 doInstallSpec |
|
2120 |cls selector treeView menu spec mthd category code| |
|
2121 |
|
2122 cls := self resolveName:(self specClass). |
|
2123 |
|
2124 cls isNil ifTrue:[ |
|
2125 ^ self information:'No valid class defined!!'. |
|
2126 ]. |
|
2127 treeView := self treeView. |
|
2128 selector := treeView selectorName. |
|
2129 menu := treeView asMenu. |
1899 menu := treeView asMenu. |
2130 |
1900 |
2131 menu isNil ifTrue:[ |
1901 menu isNil ifTrue:[ |
2132 ^ self information:'No menu defined!!' |
1902 ^ self information:'No menu defined!!' |
2133 ]. |
1903 ]. |
2137 spec := spec contents. |
1907 spec := spec contents. |
2138 |
1908 |
2139 "/ if that method already exists, do not overwrite the category |
1909 "/ if that method already exists, do not overwrite the category |
2140 |
1910 |
2141 category := 'menu specs'. |
1911 category := 'menu specs'. |
2142 (mthd := cls class compiledMethodAt:selector) notNil ifTrue:[ |
1912 (mthd := cls class compiledMethodAt:specSelector) notNil ifTrue:[ |
2143 category := mthd category. |
1913 category := mthd category. |
2144 ]. |
1914 ]. |
2145 |
1915 |
2146 code := Character excla asString |
1916 code := Character excla asString |
2147 , cls name , ' class methodsFor:' , category storeString |
1917 , cls name , ' class methodsFor:' , category storeString |
2148 , Character excla asString , '\\' |
1918 , Character excla asString , '\\' |
2149 |
1919 |
2150 , selector , '\' |
1920 , specSelector , '\' |
2151 , ' "this window spec was automatically generated by the ST/X MenuEditor"\\' |
1921 , ' "this window spec was automatically generated by the ST/X MenuEditor"\\' |
2152 , ' "do not manually edit this - the builder may not be able to\' |
1922 , ' "do not manually edit this - the builder may not be able to\' |
2153 , ' handle the specification if its corrupted."\\' |
1923 , ' handle the specification if its corrupted."\\' |
2154 , ' "\' |
1924 , ' "\' |
2155 , ' MenuEditor new openOnClass:' , cls name , ' andSelector:#' , selector , '\' |
1925 , ' MenuEditor new openOnClass:' , cls name , ' andSelector:#' , specSelector , '\' |
2156 , ' (Menu new fromLiteralArrayEncoding:(' , cls name , ' ' , selector , ')) startUp\' |
1926 , ' (Menu new fromLiteralArrayEncoding:(' , cls name , ' ' , specSelector , ')) startUp\' |
2157 , ' "\'. |
1927 , ' "\'. |
2158 |
1928 |
2159 code := code |
1929 code := code |
2160 , '\' |
1930 , '\' |
2161 , ' <resource: #menu>\\' |
1931 , ' <resource: #menu>\\' |
2171 (ReadStream on:code) fileIn. |
1941 (ReadStream on:code) fileIn. |
2172 |
1942 |
2173 self isStandAlone ifTrue:[ |
1943 self isStandAlone ifTrue:[ |
2174 self helpTool installHelpSpecInto:(self specClass) |
1944 self helpTool installHelpSpecInto:(self specClass) |
2175 ]. |
1945 ]. |
2176 didInstall := true. |
1946 self updateHistory. |
2177 isModified := false. |
1947 hasSaved := true. |
2178 |
1948 modified := false. |
2179 ! |
1949 |
2180 |
1950 ! |
2181 doNew |
1951 |
2182 |
1952 doSaveAs |
2183 self buildFrom:nil andSelector: self treeView selectorName |
1953 |
2184 ! |
1954 super doSaveAs. |
2185 |
1955 |
2186 doPickAMenu |
1956 self treeView selectorName: specSelector |
2187 |
|
2188 |view| |
|
2189 |
|
2190 view := Screen current viewFromUser. |
|
2191 |
|
2192 (view isNil or:[view == Screen current rootView]) ifTrue:[ |
|
2193 ^ self |
|
2194 ]. |
|
2195 view specClass == MenuPanelSpec ifTrue:[ |
|
2196 ^ self treeView buildFromMenu: view asMenu |
|
2197 ]. |
|
2198 ^ nil |
|
2199 ! |
1957 ! |
2200 |
1958 |
2201 doStepDown |
1959 doStepDown |
2202 "shift selected menu item one step down" |
1960 "shift selected menu item one step down" |
2203 |
1961 |
2204 self treeView selectedNodeChangeSequenceOrder:1. |
1962 self treeView selectedNodeChangeSequenceOrder:1. |
2205 isModified := true. |
1963 modified := true. |
2206 |
1964 |
2207 |
1965 |
2208 |
1966 |
2209 |
1967 |
2210 ! |
1968 ! |
2211 |
1969 |
2212 doStepIn |
1970 doStepIn |
2213 "move selected menu item into next submenu" |
1971 "move selected menu item into next submenu" |
2214 |
1972 |
2215 self treeView selectedNodeBecomeChildOfNext. |
1973 self treeView selectedNodeBecomeChildOfNext. |
2216 isModified := true. |
1974 modified := true. |
2217 |
1975 |
2218 |
1976 |
2219 |
1977 |
2220 |
1978 |
2221 |
1979 |
2476 |
2234 |
2477 ! ! |
2235 ! ! |
2478 |
2236 |
2479 !MenuEditor::Item methodsFor:'queries'! |
2237 !MenuEditor::Item methodsFor:'queries'! |
2480 |
2238 |
|
2239 iconFor: aNode |
|
2240 |
|
2241 aNode hasChildren |
|
2242 ifTrue: |
|
2243 [ |
|
2244 ^MenuEditor submenuImage |
|
2245 ] |
|
2246 ifFalse: |
|
2247 [ |
|
2248 submenuChannel notNil |
|
2249 ifTrue: |
|
2250 [ |
|
2251 ^MenuEditor linkSubmenuImage |
|
2252 ] |
|
2253 ifFalse: |
|
2254 [ |
|
2255 self isSeparator |
|
2256 ifTrue: [^MenuEditor menuSeparatorImage] |
|
2257 ifFalse: [^MenuEditor menuItemImage] |
|
2258 ] |
|
2259 ] |
|
2260 ! |
|
2261 |
2481 isSeparator |
2262 isSeparator |
2482 "returns true if item is a seperator" |
2263 "returns true if item is a seperator" |
2483 |
2264 |
2484 ^self separatorType notNil |
2265 ^self separatorType notNil |
2485 ! ! |
2266 ! |
2486 |
2267 |
2487 !MenuEditor::TreeView class methodsFor:'defaults'! |
2268 treeViewLabel |
2488 |
2269 |
2489 defaultMenuMessage |
2270 ^label asBoldText, |
2490 "this message is the default yo be sent to the menuHolder to get a menu" |
2271 (value notNil ifTrue: [': [', |
2491 |
2272 value , |
2492 ^#menu |
2273 (argument notNil ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']), |
2493 |
2274 ']'] ifFalse: ['']) |
2494 |
|
2495 ! ! |
2275 ! ! |
2496 |
2276 |
2497 !MenuEditor::TreeView class methodsFor:'documentation'! |
2277 !MenuEditor::TreeView class methodsFor:'documentation'! |
2498 |
2278 |
2499 documentation |
2279 documentation |
2510 " |
2290 " |
2511 |
2291 |
2512 |
2292 |
2513 ! ! |
2293 ! ! |
2514 |
2294 |
2515 !MenuEditor::TreeView class methodsFor:'initialization'! |
|
2516 |
|
2517 initialize |
|
2518 |
|
2519 super initialize. |
|
2520 |
|
2521 Images := nil |
|
2522 ! ! |
|
2523 |
|
2524 !MenuEditor::TreeView class methodsFor:'resources'! |
|
2525 |
|
2526 images |
|
2527 "returns an IdentityDictionary containing a list of images and keys used |
|
2528 " |
|
2529 ^ Images ? |
|
2530 (Images := IdentityDictionary new |
|
2531 at: #menuItemImage put: MenuEditor menuItemImage; |
|
2532 at: #menuSeparatorImage put: MenuEditor menuSeparatorImage; |
|
2533 at: #submenuImage put: MenuEditor submenuImage; |
|
2534 at: #linkSubmenuImage put: MenuEditor linkSubmenuImage; |
|
2535 yourself) |
|
2536 |
|
2537 |
|
2538 |
|
2539 ! ! |
|
2540 |
|
2541 !MenuEditor::TreeView methodsFor:'accessing'! |
2295 !MenuEditor::TreeView methodsFor:'accessing'! |
2542 |
2296 |
2543 selectorName |
2297 selectorName |
2544 ^ (listOfNodes first contents label) asSymbol |
2298 |
|
2299 ^(listOfNodes first contents label) asSymbol |
|
2300 ! |
|
2301 |
|
2302 selectorName: aSymbol |
|
2303 |
|
2304 listOfNodes first contents label: aSymbol |
2545 ! ! |
2305 ! ! |
2546 |
2306 |
2547 !MenuEditor::TreeView methodsFor:'building'! |
2307 !MenuEditor::TreeView methodsFor:'building'! |
2548 |
2308 |
2549 buildFrom:aClass andSelector:aSelector |
2309 buildFrom:aClass andSelector:aSelector |
2713 |
2464 |
2714 ! ! |
2465 ! ! |
2715 |
2466 |
2716 !MenuEditor::TreeView methodsFor:'initialization'! |
2467 !MenuEditor::TreeView methodsFor:'initialization'! |
2717 |
2468 |
2718 fetchImageResources |
|
2719 "initialize heavily used device resources - to avoid rendering |
|
2720 images again and again later; returns maximum extent of the images used." |
|
2721 |
|
2722 |defaultExtent imageWidth imageHeight maxWidth maxHeight| |
|
2723 |
|
2724 defaultExtent := super fetchImageResources. |
|
2725 maxHeight := defaultExtent y. |
|
2726 maxWidth := defaultExtent x. |
|
2727 |
|
2728 images do: |
|
2729 [:anIcon| |
|
2730 (imageWidth := anIcon widthOn:self) > maxWidth ifTrue:[maxWidth := imageWidth]. |
|
2731 (imageHeight := anIcon heightOn:self) > maxHeight ifTrue:[maxHeight := imageHeight]. |
|
2732 ]. |
|
2733 ^maxWidth@maxHeight |
|
2734 |
|
2735 ! |
|
2736 |
|
2737 initialize |
2469 initialize |
2738 |
2470 |
2739 super initialize. |
2471 super initialize. |
2740 |
2472 |
2741 images := IdentityDictionary new. |
|
2742 |
|
2743 self class images associationsDo:[:imageAsso|images at: imageAsso key put:(imageAsso value onDevice:device)]. |
|
2744 self multipleSelectOk:true. |
2473 self multipleSelectOk:true. |
2745 self showDirectoryIndicator: true. |
2474 self showDirectoryIndicator: true. |
2746 self showDirectoryIndicatorForRoot: false. |
2475 self showDirectoryIndicatorForRoot: false. |
2747 self selectConditionBlock: [:i|self application checkMenuItemModified]. |
2476 self selectConditionBlock: [:i|self application checkMenuItemModified]. |
2748 self validateDoubleClickBlock: [:node| node ~~ listOfNodes first]. |
2477 self validateDoubleClickBlock: [:node| node ~~ listOfNodes first]. |
|
2478 |
|
2479 self model iconAction: [:aNode| aNode contents iconFor: aNode]. |
|
2480 self model labelAction: [:aNode| aNode contents treeViewLabel] |
2749 ! ! |
2481 ! ! |
2750 |
2482 |
2751 !MenuEditor::TreeView methodsFor:'menus'! |
2483 !MenuEditor::TreeView methodsFor:'menus'! |
2752 |
2484 |
2753 doCopy |
2485 doCopy |
2754 |
2486 |
2755 self hasSelection ifTrue:[ |
2487 self hasSelection ifTrue:[ |
2756 CopyBuffer := OrderedCollection new. |
2488 self application clipboard: OrderedCollection new. |
2757 self selectionDo:[:i| CopyBuffer add:((listOfNodes at:i) copy)] |
2489 self selectionDo:[:i| self application clipboard add:((listOfNodes at:i) copy)] |
2758 ] |
2490 ] |
2759 ! |
2491 ! |
2760 |
2492 |
2761 doCreateItem |
2493 doCreateItem |
2762 |
2494 |
2804 |
2537 |
2805 ! |
2538 ! |
2806 |
2539 |
2807 doPaste |
2540 doPaste |
2808 |
2541 |
2809 (CopyBuffer notNil and:[self selectedNode notNil]) ifTrue:[ |
2542 (self application clipboard notNil and:[self selectedNode notNil]) ifTrue:[ |
2810 self addElement:(CopyBuffer collect:[:el| el copy]) |
2543 self addElement:(self application clipboard collect:[:el| el copy]) |
2811 ]. |
2544 ]. |
2812 ! ! |
2545 ! ! |
2813 |
2546 |
2814 !MenuEditor::TreeView methodsFor:'private'! |
2547 !MenuEditor::TreeView methodsFor:'private'! |
2815 |
2548 |
2816 addElement: aNode |
2549 addElement: aNode |
2817 "add something after selection" |
2550 "add something after selection" |
2818 |
2551 |
2819 self checkMenuItemModified |
2552 self checkMenuItemModified |
2820 ifTrue: |
2553 ifTrue: |
2821 [ |
2554 [ |
|
2555 self selectedNodeAdd: aNode. |
2822 (aNode isCollection not and: [aNode name = 'Item']) |
2556 (aNode isCollection not and: [aNode name = 'Item']) |
2823 ifTrue: |
2557 ifTrue: |
2824 [ |
2558 [ |
2825 |label| |
2559 |label| |
2826 label := aNode name, ' ', |
2560 label := aNode name, ' ', |
2827 (self selectedNode parent notNil ifTrue: |
2561 (self selectedNode parent notNil |
2828 [(((self selectedNode children size = 0 ifTrue: [self selectedNode parent children] ifFalse: [self selectedNode children]) select: [:node| |
2562 ifTrue: |
2829 |lab| lab := node contents label. ((node children size = 0) & node contents submenuChannel isNil & (lab ~= '-') & (lab ~= '=') & (lab ~= ''))]) size + 1) printString] ifFalse: ['1']). |
2563 [ |
2830 aNode name: label. |
2564 (((self selectedNode children size = 0 |
2831 aNode contents label: label. |
2565 ifTrue: [self selectedNode parent children] |
2832 ]. |
2566 ifFalse: [self selectedNode children]) select: |
2833 self selectedNodeAdd: aNode. |
2567 [:node| |
|
2568 |lab| |
|
2569 lab := node contents label. |
|
2570 ((node children size = 0) & |
|
2571 node contents submenuChannel isNil & |
|
2572 (lab ~= '-') & (lab ~= '=') & (lab ~= '')) |
|
2573 ]) size) printString] |
|
2574 ifFalse: ['1']). |
|
2575 |
|
2576 aNode name: label string asBoldText. |
|
2577 aNode contents label: label string. |
|
2578 ]. |
2834 aNode isCollection ifFalse: [self selectNode: aNode] ifTrue: [self selection: (aNode collect: [:node| self indexOfNode: node])]. |
2579 aNode isCollection ifFalse: [self selectNode: aNode] ifTrue: [self selection: (aNode collect: [:node| self indexOfNode: node])]. |
2835 self setModified. |
2580 self setModified. |
2836 ] |
2581 ] |
2837 ! |
2582 ! |
2838 |
2583 |
2839 checkMenuItemModified |
2584 checkMenuItemModified |
2840 |
2585 |
2841 ^self topView application checkMenuItemModified |
2586 ^self topView application checkItemModified |
2842 ! |
2587 ! |
2843 |
2588 |
2844 nodeLabel:aLabel |
2589 nodeLabel:aLabel |
2845 |
2590 |
2846 ^TreeItem name:aLabel contents: (MenuEditor::Item new label:aLabel) |
2591 ^TreeItem new contents: (MenuEditor::Item new label:aLabel) |
2847 ! |
2592 ! |
2848 |
2593 |
2849 selectedNodeAdd:something |
2594 selectedNodeAdd:something |
2850 |
2595 |
2851 |node| |
2596 |node| |
2867 |
2612 |
2868 ! |
2613 ! |
2869 |
2614 |
2870 setModified |
2615 setModified |
2871 |
2616 |
2872 self topView application isModified: true. |
2617 self topView application modified: true. |
2873 |
2618 |
2874 self topView application updateEnabledChannels |
2619 self topView application updateEnabledChannels |
2875 ! ! |
|
2876 |
|
2877 !MenuEditor::TreeView methodsFor:'selection'! |
|
2878 |
|
2879 updateNode: aNode |
|
2880 |
|
2881 |name treeItem index| |
|
2882 |
|
2883 name := aNode label. |
|
2884 treeItem := listOfNodes detect: [:n| n contents = aNode] ifNone: [1]. |
|
2885 index := self indexOfNode: treeItem. |
|
2886 treeItem name: name. |
|
2887 self redrawLine: index. |
|
2888 ! ! |
|
2889 |
|
2890 !MenuEditor::TreeView methodsFor:'startup / release'! |
|
2891 |
|
2892 destroy |
|
2893 "destroy images" |
|
2894 |
|
2895 super destroy. |
|
2896 |
|
2897 Images := nil |
|
2898 |
|
2899 |
|
2900 ! ! |
2620 ! ! |
2901 |
2621 |
2902 !MenuEditor class methodsFor:'documentation'! |
2622 !MenuEditor class methodsFor:'documentation'! |
2903 |
2623 |
2904 version |
2624 version |