MenuEditor.st
changeset 432 d35dccaa804c
parent 422 f85de4fc2a2c
child 441 b16598618359
equal deleted inserted replaced
431:23ff7c325946 432:d35dccaa804c
    76 ! !
    76 ! !
    77 
    77 
    78 !MenuEditor class methodsFor:'initialization'!
    78 !MenuEditor class methodsFor:'initialization'!
    79 
    79 
    80 initialize
    80 initialize
       
    81 
       
    82     super initialize.
    81 
    83 
    82     TreeView initialize
    84     TreeView initialize
    83 ! !
    85 ! !
    84 
    86 
    85 !MenuEditor class methodsFor:'code generation'!
    87 !MenuEditor class methodsFor:'code generation'!
   108 self generateCodeFor:MenuEditor menuSelector:#menu
   110 self generateCodeFor:MenuEditor menuSelector:#menu
   109 "
   111 "
   110 !
   112 !
   111 
   113 
   112 sourceCategory
   114 sourceCategory
   113     "returns the catagory where to instal the menu
   115     "returns the category where to install the menu
   114     "
   116     "
   115     ^ 'accessing menu'
   117     ^ 'accessing menu'
   116 ! !
   118 ! !
   117 
   119 
   118 !MenuEditor class methodsFor:'help specs'!
   120 !MenuEditor class methodsFor:'help specs'!
   214      
   216      
   215        #(#FullSpec
   217        #(#FullSpec
   216           #'window:' 
   218           #'window:' 
   217            #(#WindowSpec
   219            #(#WindowSpec
   218               #'name:' 'MenuEditor'
   220               #'name:' 'MenuEditor'
   219               #'layout:' #(#LayoutFrame 344 0 297 0 590 0 390 0)
   221               #'layout:' #(#LayoutFrame 262 0 426 0 508 0 519 0)
   220               #'label:' 'MenuEditor'
   222               #'label:' 'MenuEditor'
   221               #'min:' #(#Point 10 10)
   223               #'min:' #(#Point 10 10)
   222               #'max:' #(#Point 1152 900)
   224               #'max:' #(#Point 1152 900)
   223               #'bounds:' #(#Rectangle 344 297 591 391)
   225               #'bounds:' #(#Rectangle 262 426 509 520)
   224               #'usePreferredExtent:' false
   226               #'usePreferredExtent:' false
   225           )
   227           )
   226           #'component:' 
   228           #'component:' 
   227            #(#SpecCollection
   229            #(#SpecCollection
   228               #'collection:' 
   230               #'collection:' 
   229                #(
   231                #(
   230                  #(#LabelSpec
   232                  #(#LabelSpec
   231                     #'name:' 'boxLabel'
   233                     #'name:' 'boxLabel'
   232                     #'layout:' #(#LayoutFrame 0 0.0 4 0 0 1.0 24 0)
   234                     #'layout:' #(#LayoutFrame 2 0.0 4 0 -2 1.0 24 0)
   233                     #'label:' 'Class for menu spec:'
   235                     #'label:' 'Class for menu spec:'
   234                     #'adjust:' #left
   236                     #'adjust:' #left
   235                     #'resizeForLabel:' true
   237                     #'resizeForLabel:' true
   236                 )
   238                 )
   237                  #(#InputFieldSpec
   239                  #(#InputFieldSpec
   238                     #'name:' 'classNameField'
   240                     #'name:' 'classNameField'
   239                     #'layout:' #(#LayoutFrame 0 0.0 27 0 0 1.0 49 0)
   241                     #'layout:' #(#LayoutFrame 2 0.0 27 0 -2 1.0 49 0)
   240                     #'tabable:' true
   242                     #'tabable:' true
   241                     #'model:' #classNameChannel
   243                     #'model:' #classNameChannel
   242                     #'acceptOnReturn:' false
   244                     #'acceptOnReturn:' false
   243                     #'acceptOnTab:' false
   245                     #'acceptOnTab:' false
   244                 )
   246                 )
   245                  #(#HorizontalPanelViewSpec
   247                  #(#UISubSpecification
   246                     #'name:' 'commitPanel'
   248                     #'name:' 'SubSpecification'
   247                     #'layout:' #(#LayoutFrame 10 0.0 -29 1.0 -10 1.0 -5 1.0)
   249                     #'layout:' #(#LayoutFrame 0 0 -29 1 0 1 -5 1)
   248                     #'component:' 
   250                     #'majorKey:' #ToolApplicationModel
   249                      #(#SpecCollection
   251                     #'minorKey:' #windowSpecForCommitWithoutChannels
   250                         #'collection:' 
       
   251                          #(
       
   252                            #(#ActionButtonSpec
       
   253                               #'name:' 'button1'
       
   254                               #'label:' 'Cancel'
       
   255                               #'tabable:' true
       
   256                               #'model:' #cancel
       
   257                               #'extent:' #(#Point 109 24)
       
   258                           )
       
   259                            #(#ActionButtonSpec
       
   260                               #'name:' 'button2'
       
   261                               #'label:' 'OK'
       
   262                               #'tabable:' true
       
   263                               #'model:' #accept
       
   264                               #'isDefault:' true
       
   265                               #'extent:' #(#Point 109 24)
       
   266                           )
       
   267                         )
       
   268                     )
       
   269                     #'horizontalLayout:' #fitSpace
       
   270                     #'verticalLayout:' #fit
       
   271                     #'horizontalSpace:' 3
       
   272                     #'verticalSpace:' 3
       
   273                 )
   252                 )
   274               )
   253               )
   275           )
   254           )
   276       )
   255       )
   277 !
   256 !
  1458         helpTool masterApplication:self.
  1437         helpTool masterApplication:self.
  1459         helpCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
  1438         helpCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
  1460         specCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
  1439         specCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
  1461 
  1440 
  1462         helpCanvas client:helpTool.
  1441         helpCanvas client:helpTool.
  1463         helpTool masterApplication:self.
  1442         helpTool masterApplication:self.      
  1464         helpTool modifiedHolder: self valueOfEnablingCommitButtons.
  1443         helpTool modifiedHolder: self valueOfEnablingCommitButtons.
  1465 
  1444 
  1466         builder aspectAt:#noteBookView put:noteBook.
  1445         builder aspectAt:#noteBookView put:noteBook.
  1467     ].
  1446     ].
  1468     ^ noteBook
  1447     ^ noteBook
  1625 
  1604 
  1626 !MenuEditor methodsFor:'selection'!
  1605 !MenuEditor methodsFor:'selection'!
  1627 
  1606 
  1628 menuChanged
  1607 menuChanged
  1629 
  1608 
  1630     |node item slc sel old|
  1609     |node item slc sel old dep|
  1631 
  1610 
  1632     aspects do: [:holder| holder removeDependent:self].
  1611     aspects do: [:holder| holder removeDependent:self].
  1633     (node := self treeView selectedNode) notNil ifTrue:[
  1612     (node := self treeView selectedNode) notNil ifTrue:[
  1634         aspects do:[:anAspect| anAspect value:nil ].
  1613         aspects do:[:anAspect| anAspect value:nil ].
  1635         item := node contents.
  1614         item := node contents.
  1649             ].
  1628             ].
  1650         ] ifTrue:[
  1629         ] ifTrue:[
  1651             slc := self class perform:#slicesSeparatorMenu.
  1630             slc := self class perform:#slicesSeparatorMenu.
  1652         ]
  1631         ]
  1653     ].
  1632     ].
  1654     self helpTool helpKey:(self helpKey).
  1633 
       
  1634     self helpTool helpKey: self helpKey.
       
  1635     "Next line helps me to preserve myself against unnecessary settings of
       
  1636      valueOfEnablingCommitButtons to true in the help tool."
       
  1637     self valueOfEnablingCommitButtons value: false.
  1655 
  1638 
  1656     slc ~= slices  ifTrue:[
  1639     slc ~= slices  ifTrue:[
  1657         tabSelection ~~ 0 ifTrue:[
  1640         tabSelection ~~ 0 ifTrue:[
  1658             old := (slices at:tabSelection) first
  1641             old := (slices at:tabSelection) first
  1659         ].
  1642         ].
  1697         ].
  1680         ].
  1698         tabSelection == 1 ifTrue:[^ self].
  1681         tabSelection == 1 ifTrue:[^ self].
  1699         tabSelection := 1
  1682         tabSelection := 1
  1700     ].
  1683     ].
  1701 
  1684 
  1702     self isHelpToolSelected ifTrue:[   
  1685     self isHelpToolSelected ifTrue:[  
  1703         self helpTool helpKey:(self helpKey).
  1686         self helpTool helpKey:(self helpKey).
  1704         helpCanvas raise.
  1687         helpCanvas raise.
  1705     ] ifFalse:[                       
  1688     ] ifFalse:[                       
  1706         sel := (slices at:tabSelection) last.   
  1689         sel := (slices at:tabSelection) last.   
  1707         aspects do: [:holder| holder release].
  1690         aspects do: [:holder| holder release].
  1894     "invoked by button 'Cancel'"
  1877     "invoked by button 'Cancel'"
  1895 
  1878 
  1896     |node|
  1879     |node|
  1897     (node := self treeView selectedNode) notNil
  1880     (node := self treeView selectedNode) notNil
  1898     ifTrue:
  1881     ifTrue:
  1899     [
  1882     [          
  1900         self helpTool helpKey:(self helpKey).
  1883         self helpTool helpKey:(self helpKey).
  1901         aspects do:[:anAspect| anAspect value:nil].
  1884         aspects do:[:anAspect| anAspect value:nil].
  1902         node contents toAspects:aspects
  1885         node contents toAspects:aspects
  1903     ].
  1886     ].
  1904     self valueOfEnablingCommitButtons value: false.
  1887     self valueOfEnablingCommitButtons value: false.
  2102     box showAtPointer.
  2085     box showAtPointer.
  2103     box accepted
  2086     box accepted
  2104     ifTrue:
  2087     ifTrue:
  2105     [            
  2088     [            
  2106         self loadFromInClassesOf: box contents asSymbol
  2089         self loadFromInClassesOf: box contents asSymbol
  2107     ].
  2090     ]
  2108 
  2091 
  2109 
  2092 
  2110 
  2093 
  2111 !
  2094 !
  2112 
  2095 
  2697 setModified 
  2680 setModified 
  2698 
  2681 
  2699     self topView application isModified: true
  2682     self topView application isModified: true
  2700 ! !
  2683 ! !
  2701 
  2684 
  2702 !MenuEditor::TreeView methodsFor:'queries'!
       
  2703 
       
  2704 xOfFigureLevel2:aLevel
       
  2705 
       
  2706     ^super xOfFigureLevel: aLevel - 1 
       
  2707 
       
  2708 
       
  2709 
       
  2710 
       
  2711 
       
  2712 ! !
       
  2713 
       
  2714 !MenuEditor::TreeView methodsFor:'selection'!
  2685 !MenuEditor::TreeView methodsFor:'selection'!
  2715 
  2686 
  2716 updateNode: aNode
  2687 updateNode: aNode
  2717 
  2688 
  2718     |name treeItem index|
  2689     |name treeItem index|