MenuEditor.st
changeset 748 03bc27132916
parent 738 ebc4a399f4dc
child 764 5722b94330ef
equal deleted inserted replaced
747:c76003b74d7b 748:03bc27132916
   972      
   972      
   973        #(#FullSpec
   973        #(#FullSpec
   974           #window: 
   974           #window: 
   975            #(#WindowSpec
   975            #(#WindowSpec
   976               #name: 'Menu Editor'
   976               #name: 'Menu Editor'
   977               #layout: #(#LayoutFrame 473 0 301 0 1052 0 684 0)
   977               #layout: #(#LayoutFrame 88 0 294 0 627 0 673 0)
   978               #label: 'Menu Editor'
   978               #label: 'Menu Editor'
   979               #min: #(#Point 10 10)
   979               #min: #(#Point 510 390)
   980               #max: #(#Point 1152 900)
   980               #max: #(#Point 1152 900)
   981               #bounds: #(#Rectangle 473 301 1053 685)
   981               #bounds: #(#Rectangle 88 294 628 674)
   982               #menu: #menu
   982               #menu: #menu
   983               #usePreferredExtent: false
   983               #usePreferredExtent: false
   984           )
   984           )
   985           #component: 
   985           #component: 
   986            #(#SpecCollection
   986            #(#SpecCollection
  1013                                #(#SpecCollection
  1013                                #(#SpecCollection
  1014                                   #collection: 
  1014                                   #collection: 
  1015                                    #(
  1015                                    #(
  1016                                      #(#NoteBookViewSpec
  1016                                      #(#NoteBookViewSpec
  1017                                         #name: 'NoteBook'
  1017                                         #name: 'NoteBook'
  1018                                         #layout: #(#LayoutFrame 1 0.0 0 0.0 1 1.0 -26 1.0)
  1018                                         #layout: #(#LayoutFrame 1 0.0 0 0.0 1 1.0 -30 1.0)
  1019                                         #tabable: true
  1019                                         #tabable: true
  1020                                         #model: #tabModel
  1020                                         #model: #tabModel
  1021                                         #menu: #tabList
  1021                                         #menu: #tabList
  1022                                         #useIndex: true
  1022                                         #useIndex: true
  1023                                         #canvas: #noteBookView
  1023                                         #canvas: #noteBookView
  1068        #(#Menu
  1068        #(#Menu
  1069           
  1069           
  1070            #(
  1070            #(
  1071              #(#MenuItem
  1071              #(#MenuItem
  1072                 #label: 'About'
  1072                 #label: 'About'
  1073                 #activeHelpKey: #about
       
  1074                 #accessCharacterPosition: 1
  1073                 #accessCharacterPosition: 1
  1075                 #labelImage: #(#ResourceRetriever nil #menuIcon)
  1074                 #labelImage: #(#ResourceRetriever nil #menuIcon)
  1076                 #submenuChannel: #menuAbout
  1075                 #submenuChannel: #menuAbout
  1077             )
  1076             )
  1078              #(#MenuItem
  1077              #(#MenuItem
  1152                 #label: 'Test'
  1151                 #label: 'Test'
  1153                 #activeHelpKey: #test
  1152                 #activeHelpKey: #test
  1154                 #submenuChannel: #submenuTest
  1153                 #submenuChannel: #submenuTest
  1155             )
  1154             )
  1156              #(#MenuItem
  1155              #(#MenuItem
  1157                 #label: 'History'
       
  1158                 #activeHelpKey: #history
       
  1159                 #submenuChannel: #menuHistory
       
  1160             )
       
  1161              #(#MenuItem
       
  1162                 #label: 'Settings'
  1156                 #label: 'Settings'
  1163                 #submenu: 
  1157                 #submenu: 
  1164                  #(#Menu
  1158                  #(#Menu
  1165                     
  1159                     
  1166                      #(
  1160                      #(
  1171                     ) nil
  1165                     ) nil
  1172                     nil
  1166                     nil
  1173                 )
  1167                 )
  1174             )
  1168             )
  1175              #(#MenuItem
  1169              #(#MenuItem
       
  1170                 #label: 'History'
       
  1171                 #activeHelpKey: #history
       
  1172                 #submenuChannel: #menuHistory
       
  1173             )
       
  1174              #(#MenuItem
  1176                 #label: 'Help'
  1175                 #label: 'Help'
  1177                 #startGroup: #right
  1176                 #startGroup: #right
  1178                 #activeHelpKey: #help
  1177                 #submenu: 
  1179                 #submenuChannel: #menuHelp
  1178                  #(#Menu
       
  1179                     
       
  1180                      #(
       
  1181                        #(#MenuItem
       
  1182                           #label: 'Documentation'
       
  1183                           #value: #openHTMLDocument:
       
  1184                           #activeHelpKey: #helpTutorial
       
  1185                           #argument: 'tools/MenuEditor/TOP.html'
       
  1186                       )
       
  1187                        #(#MenuItem
       
  1188                           #label: '-'
       
  1189                       )
       
  1190                        #(#MenuItem
       
  1191                           #label: 'Help Tool'
       
  1192                           #value: #openHTMLDocument:
       
  1193                           #activeHelpKey: #helpHelpTool
       
  1194                           #argument: 'tools/uipainter/HelpTool.html'
       
  1195                       )
       
  1196                        #(#MenuItem
       
  1197                           #label: '-'
       
  1198                       )
       
  1199                        #(#MenuItem
       
  1200                           #label: 'Show Help Texts'
       
  1201                           #activeHelpKey: #helpShowHelp
       
  1202                           #indication: #showHelp:
       
  1203                       )
       
  1204                     ) nil
       
  1205                     nil
       
  1206                 )
  1180             )
  1207             )
  1181           ) nil
  1208           ) nil
  1182           nil
  1209           nil
  1183       )
  1210       )
  1184 !
  1211 !
  1551 useHelpTool: aHelpTool
  1578 useHelpTool: aHelpTool
  1552     "take the help dictionaries from aHelpTool into my helpTool"
  1579     "take the help dictionaries from aHelpTool into my helpTool"
  1553 
  1580 
  1554     self noteBookView.
  1581     self noteBookView.
  1555 
  1582 
  1556     self helpTool helpSpecFrom: aHelpTool specClass.
  1583     self helpTool buildFromClass: aHelpTool specClass.
  1557     self helpTool dictionaries: aHelpTool dictionaries.
  1584     self helpTool dictionaries:   aHelpTool dictionaries.
  1558     self helpTool dictionary:   aHelpTool dictionary
  1585     self helpTool dictionary:     aHelpTool dictionary
  1559 ! !
  1586 ! !
  1560 
  1587 
  1561 !MenuEditor methodsFor:'aspects'!
  1588 !MenuEditor methodsFor:'aspects'!
  1562 
  1589 
  1563 hasAnySingleSelection
  1590 hasAnySingleSelection
  1624 !MenuEditor methodsFor:'building'!
  1651 !MenuEditor methodsFor:'building'!
  1625 
  1652 
  1626 buildFromClass:aClass andSelector:aSelector
  1653 buildFromClass:aClass andSelector:aSelector
  1627 
  1654 
  1628     self isStandAlone ifTrue:[
  1655     self isStandAlone ifTrue:[
  1629         self helpTool helpSpecFrom:specClass
  1656         self helpTool buildFromClass:specClass
  1630     ].              
  1657     ].              
  1631     self treeView buildFromClass: aClass andSelector: aSelector.
  1658     self treeView buildFromClass: aClass andSelector: aSelector.
  1632 
  1659 
  1633     self updateHistory.
  1660     self updateHistory.
  1634     self updateInfoLabel.
  1661     self updateInfoLabel.
  1643         (aResourceSpec class == Menu ifTrue: [aResourceSpec] ifFalse: [aResourceSpec decodeAsLiteralArray])
  1670         (aResourceSpec class == Menu ifTrue: [aResourceSpec] ifFalse: [aResourceSpec decodeAsLiteralArray])
  1644 ! !
  1671 ! !
  1645 
  1672 
  1646 !MenuEditor methodsFor:'change & update'!
  1673 !MenuEditor methodsFor:'change & update'!
  1647 
  1674 
  1648 updateEnabledChannels
  1675 updateChannels
  1649     "update enabled channels"
  1676     "update channels"
  1650 
  1677 
  1651     |node parent next state|
  1678     |node parent next state|
  1652 
  1679 
  1653     state := false.   
  1680     state := false.   
  1654 
  1681 
  1662             next := parent childAt:((parent indexOfChild:node) + 1).
  1689             next := parent childAt:((parent indexOfChild:node) + 1).
  1663             self valueOfEnableMovingIn       value:(next notNil and:[next hasChildren]).
  1690             self valueOfEnableMovingIn       value:(next notNil and:[next hasChildren]).
  1664             self valueOfEnableMovingUpOrDown value:(parent children size > 1).
  1691             self valueOfEnableMovingUpOrDown value:(parent children size > 1).
  1665             self valueOfEnableMovingOut      value:parent parent notNil.
  1692             self valueOfEnableMovingOut      value:parent parent notNil.
  1666             self hasValidSingleSelection     value:true.
  1693             self hasValidSingleSelection     value:true.
  1667             self hasValidSelection           value:true.      
  1694             self hasValidSelection           value:true.  
  1668             self valueOfCanPaste             value: true & self valueOfCanPaste value.
  1695             self valueOfCanPaste             value:true & self valueOfCanPaste value. 
  1669             ^self
  1696             ^self
  1670         ]
  1697         ]
  1671     ]
  1698     ]
  1672     ifFalse:
  1699     ifFalse:
  1673     [
  1700     [
  1678     ].          
  1705     ].          
  1679     self valueOfEnableMovingUpOrDown value:false.
  1706     self valueOfEnableMovingUpOrDown value:false.
  1680     self valueOfEnableMovingIn       value:false.
  1707     self valueOfEnableMovingIn       value:false.
  1681     self valueOfEnableMovingOut      value:false.
  1708     self valueOfEnableMovingOut      value:false.
  1682     self hasValidSingleSelection     value:false.
  1709     self hasValidSingleSelection     value:false.
  1683     self hasValidSelection           value:state.
  1710     self hasValidSelection           value:state.     
  1684     self valueOfCanPaste             value: false.
  1711     self valueOfCanPaste             value:(self hasValidSingleSelection value or: [node == self treeView root]) & self valueOfCanPaste value. 
  1685 ! !
  1712 ! !
  1686 
  1713 
  1687 !MenuEditor methodsFor:'event handling'!
  1714 !MenuEditor methodsFor:'event handling'!
  1688 
  1715 
  1689 doesNotUnderstand: aMessage
  1716 doesNotUnderstand: aMessage
  1794         ] ifFalse:[
  1821         ] ifFalse:[
  1795             self tabList value:nil.
  1822             self tabList value:nil.
  1796             self tabSelection:0.
  1823             self tabSelection:0.
  1797         ]
  1824         ]
  1798     ].
  1825     ].
  1799     self updateEnabledChannels.
  1826     self updateChannels.
  1800     aspects do: [:holder| holder addDependent:self].
  1827     aspects do: [:holder| holder addDependent:self].
  1801 !
  1828 !
  1802 
  1829 
  1803 tabSelection: aSelection
  1830 tabSelection: aSelection
  1804     "put the section aSelection into the note book"
  1831     "put the section aSelection into the note book"
  1856 
  1883 
  1857     super postOpenWith:aBuilder.
  1884     super postOpenWith:aBuilder.
  1858 
  1885 
  1859     self isHelpToolSelected 
  1886     self isHelpToolSelected 
  1860         ifTrue:  [helpCanvas raise] 
  1887         ifTrue:  [helpCanvas raise] 
  1861         ifFalse: [specCanvas raise]    
  1888         ifFalse: [specCanvas raise]
       
  1889 
  1862 ! !
  1890 ! !
  1863 
  1891 
  1864 !MenuEditor methodsFor:'user actions'!
  1892 !MenuEditor methodsFor:'user actions'!
  1865 
  1893 
  1866 accept
  1894 accept
  1905     modified := false
  1933     modified := false
  1906 !
  1934 !
  1907 
  1935 
  1908 doNew
  1936 doNew
  1909 
  1937 
  1910     super doNew ifTrue: [self helpTool reset]
  1938     super doNew ifTrue: [self helpTool doNew]
  1911 !
  1939 !
  1912 
  1940 
  1913 doPickAMenu
  1941 doPickAMenu
  1914 
  1942 
  1915     |view|
  1943     |view|
  1970     (ReadStream on:code) fileIn.
  1998     (ReadStream on:code) fileIn.
  1971 
  1999 
  1972     self helpTool installHelpSpecsOnClass:self specClass.
  2000     self helpTool installHelpSpecsOnClass:self specClass.
  1973 
  2001 
  1974     self updateHistory.
  2002     self updateHistory.
       
  2003     self updateInfoLabel.
       
  2004 
  1975     hasSaved := true.
  2005     hasSaved := true.
  1976     modified := false.
  2006     modified := false.
  1977 
  2007 
  1978 !
  2008 !
  1979 
  2009 
  2505     "invoked if any key was pressed"
  2535     "invoked if any key was pressed"
  2506 
  2536 
  2507     <resource: #keyboard (#Delete #BackSpace #Cut #Copy #Paste)>
  2537     <resource: #keyboard (#Delete #BackSpace #Cut #Copy #Paste)>
  2508 
  2538 
  2509     (key == #Delete or:[key == #BackSpace]) ifTrue: [^self doDelete].
  2539     (key == #Delete or:[key == #BackSpace]) ifTrue: [^self doDelete].
  2510     key == #Cut  ifTrue:[^self doCut].
  2540     key == #Cut   ifTrue:[^self doCut].
  2511     key == #Copy  ifTrue:[^self doCopy].
  2541     key == #Copy  ifTrue:[^self doCopy].
  2512     key == #Paste ifTrue:[^self doPaste].
  2542     key == #Paste ifTrue:[^self doPaste].
  2513 
  2543 
  2514     super keyPress:key x:x y:y
  2544     super keyPress:key x:x y:y
  2515 
  2545 
  2535 
  2565 
  2536 doCopy
  2566 doCopy
  2537 
  2567 
  2538     self hasSelection ifTrue:[
  2568     self hasSelection ifTrue:[
  2539         self application clipboard: OrderedCollection new.
  2569         self application clipboard: OrderedCollection new.
  2540         self selectionDo:[:i| self application clipboard add:((listOfNodes at:i) copy)]
  2570         self selectionDo:[:i| self application clipboard add:((listOfNodes at:i) copy)].
       
  2571         self topView application updateAllToolInstances.
  2541     ]
  2572     ]
  2542 !
  2573 !
  2543 
  2574 
  2544 doCreateItem
  2575 doCreateItem
  2545 
  2576 
  2582         self doCopy.
  2613         self doCopy.
  2583         selectedNodes := self selection asSortedCollection.
  2614         selectedNodes := self selection asSortedCollection.
  2584         self selectedNodesRemove.
  2615         self selectedNodesRemove.
  2585         self selection: selectedNodes first - 1.
  2616         self selection: selectedNodes first - 1.
  2586         self setModified.
  2617         self setModified.
       
  2618         self topView application updateAllToolInstances.
  2587     ]
  2619     ]
  2588 
  2620 
  2589 !
  2621 !
  2590 
  2622 
  2591 doDelete
  2623 doDelete
  2679 
  2711 
  2680 setModified 
  2712 setModified 
  2681 
  2713 
  2682     self topView application modified: true.
  2714     self topView application modified: true.
  2683 
  2715 
  2684     self topView application updateEnabledChannels
  2716     self topView application updateChannels
  2685 ! !
  2717 ! !
  2686 
  2718 
  2687 !MenuEditor class methodsFor:'documentation'!
  2719 !MenuEditor class methodsFor:'documentation'!
  2688 
  2720 
  2689 version
  2721 version