MenuEditor.st
changeset 637 0fac61dcb6fd
parent 634 ebc0beb615c5
child 640 56a4339cbdbe
equal deleted inserted replaced
636:b06bea6cbe1b 637:0fac61dcb6fd
  1756 
  1756 
  1757 ! !
  1757 ! !
  1758 
  1758 
  1759 !MenuEditor methodsFor:'startup / release'!
  1759 !MenuEditor methodsFor:'startup / release'!
  1760 
  1760 
  1761 buildFrom:aClass andSelector:aSelector
  1761 buildFromClass:aClass andSelector:aSelector
  1762 
  1762 
  1763     |oldClass|
  1763     self isStandAlone ifTrue:[
  1764 
       
  1765     self valueOfEnablingCommitButtons value: false.
       
  1766     oldClass := self specClass.
       
  1767     self specClass:aClass.
       
  1768     specSelector := aSelector.
       
  1769 
       
  1770     (self isStandAlone and:[oldClass ~= specClass]) ifTrue:[
       
  1771         self helpTool helpSpecFrom:specClass
  1764         self helpTool helpSpecFrom:specClass
  1772     ].              
  1765     ].              
  1773     self treeView buildFrom: specClass andSelector: specSelector.
  1766     self treeView buildFromClass: aClass andSelector: specSelector.
  1774 
  1767 
  1775     self updateHistory.
  1768     self updateHistory.
  1776     self updateInfoLabel.
  1769     self updateInfoLabel.
  1777     self treeView selection: 2.
  1770     self treeView selection: 2.
  1778     self menuChanged
  1771     self menuChanged
  1809             self buildFrom:cls andSelector:nil.
  1802             self buildFrom:cls andSelector:nil.
  1810             ^self treeView buildFromMenu:sel.
  1803             ^self treeView buildFromMenu:sel.
  1811         ]
  1804         ]
  1812         
  1805         
  1813     ].
  1806     ].
  1814     self buildFrom:cls andSelector:sel
  1807     self buildFromClass:cls andSelector:sel
  1815 !
  1808 !
  1816 
  1809 
  1817 postOpenWith:aBuilder
  1810 postOpenWith:aBuilder
  1818 
  1811 
  1819     super postOpenWith:aBuilder.
  1812     super postOpenWith:aBuilder.
  1827 
  1820 
  1828 accept
  1821 accept
  1829     "invoked by button 'OK' and by save requests of menu item changes"
  1822     "invoked by button 'OK' and by save requests of menu item changes"
  1830 
  1823 
  1831     |node|
  1824     |node|
       
  1825 
       
  1826     super accept.
  1832 
  1827 
  1833     node := self treeView selectedNode.
  1828     node := self treeView selectedNode.
  1834     node notNil
  1829     node notNil
  1835     ifTrue:
  1830     ifTrue:
  1836     [
  1831     [
  1845             node contents buildFromAspects: aspects.
  1840             node contents buildFromAspects: aspects.
  1846             node changed.
  1841             node changed.
  1847             specSelector := self treeView selectorName.
  1842             specSelector := self treeView selectorName.
  1848         ]
  1843         ]
  1849     ].
  1844     ].
  1850     self valueOfEnablingCommitButtons value:false.
  1845 
  1851     modified := true
       
  1852 !
  1846 !
  1853 
  1847 
  1854 cancel
  1848 cancel
  1855     "invoked by button 'Cancel'"
  1849     "invoked by button 'Cancel'"
  1856 
  1850 
  1869 doNew
  1863 doNew
  1870 
  1864 
  1871     self askForModification
  1865     self askForModification
  1872     ifTrue: 
  1866     ifTrue: 
  1873     [
  1867     [
  1874         self buildFrom: nil andSelector: self treeView selectorName
  1868         specClass := specSelector := nil.
       
  1869         self buildFromClass: nil andSelector: #menu
  1875     ]
  1870     ]
  1876 !
  1871 !
  1877 
  1872 
  1878 doPickAMenu
  1873 doPickAMenu
  1879 
  1874 
  1891 !
  1886 !
  1892 
  1887 
  1893 doSave
  1888 doSave
  1894     |cls treeView menu spec mthd category code|
  1889     |cls treeView menu spec mthd category code|
  1895 
  1890 
  1896     cls := self resolveName:(self specClass).
  1891     super doSave ifTrue: [^nil].
  1897 
  1892 
  1898     cls isNil ifTrue:[
  1893     cls := self resolveName: specClass.
  1899         ^ self information:'No valid class defined!!'.
       
  1900     ].
       
  1901 
       
  1902     treeView := self treeView.
  1894     treeView := self treeView.
  1903     menu     := treeView asMenu.
  1895     menu     := treeView asMenu.
  1904 
       
  1905     menu isNil ifTrue:[
       
  1906         ^ self information:'No menu defined!!'
       
  1907     ].
       
  1908     menu := menu literalArrayEncoding.
  1896     menu := menu literalArrayEncoding.
  1909     spec := WriteStream on:String new.
  1897     spec := WriteStream on:String new.
  1910     UISpecification prettyPrintSpecArray:menu on:spec indent:5.
  1898     UISpecification prettyPrintSpecArray:menu on:spec indent:5.
  1911     spec := spec contents.
  1899     spec := spec contents.
  1912 
  1900 
  1953 
  1941 
  1954 !
  1942 !
  1955 
  1943 
  1956 doSaveAs
  1944 doSaveAs
  1957 
  1945 
  1958     super doSaveAs.
  1946     super doSaveAs ifTrue: [self treeView selectorName: specSelector]
  1959 
       
  1960     self treeView selectorName: specSelector
       
  1961 !
  1947 !
  1962 
  1948 
  1963 doStepDown
  1949 doStepDown
  1964     "shift selected menu item one step down"
  1950     "shift selected menu item one step down"
  1965 
  1951 
  2308     listOfNodes first contents label: aSymbol
  2294     listOfNodes first contents label: aSymbol
  2309 ! !
  2295 ! !
  2310 
  2296 
  2311 !MenuEditor::TreeView methodsFor:'building'!
  2297 !MenuEditor::TreeView methodsFor:'building'!
  2312 
  2298 
  2313 buildFrom:aClass andSelector:aSelector
  2299 buildFromClass:aClass andSelector:aSelector
  2314 
  2300 
  2315     |spec cls menu node|
  2301     |spec cls menu node|
  2316 
  2302 
  2317     (aClass notNil and:[aSelector notNil]) ifTrue:[
  2303     (aClass notNil and:[aSelector notNil]) ifTrue:[
  2318         cls := self application resolveName:aClass.
  2304         cls := self application resolveName:aClass.