MenuEditor.st
changeset 1988 1f898443e253
parent 1984 6e994247bf8e
child 1992 f026ffeb44db
equal deleted inserted replaced
1987:3889bd6912fb 1988:1f898443e253
   725             #itemValue: #doCopy
   725             #itemValue: #doCopy
   726             #translateLabel: true
   726             #translateLabel: true
   727           )
   727           )
   728          #(#MenuItem
   728          #(#MenuItem
   729             #activeHelpKey: #editPaste
   729             #activeHelpKey: #editPaste
   730             #enabled: #valueOfCanPaste
   730             #enabled: #canPasteHolder
   731             #label: 'Paste'
   731             #label: 'Paste'
   732             #itemValue: #doPaste
   732             #itemValue: #doPaste
   733             #translateLabel: true
   733             #translateLabel: true
   734           )
   734           )
   735          #(#MenuItem
   735          #(#MenuItem
  1189             isButton: true
  1189             isButton: true
  1190             labelImage: (ResourceRetriever ToolbarIconLibrary copyMenuItemIcon)
  1190             labelImage: (ResourceRetriever ToolbarIconLibrary copyMenuItemIcon)
  1191           )
  1191           )
  1192          (MenuItem
  1192          (MenuItem
  1193             activeHelpKey: editPaste
  1193             activeHelpKey: editPaste
  1194             enabled: valueOfCanPaste
  1194             enabled: canPasteHolder
  1195             label: 'Paste'
  1195             label: 'Paste'
  1196             itemValue: doPaste
  1196             itemValue: doPaste
  1197             translateLabel: true
  1197             translateLabel: true
  1198             isButton: true
  1198             isButton: true
  1199             labelImage: (ResourceRetriever ToolbarIconLibrary pasteMenuItemIcon)
  1199             labelImage: (ResourceRetriever ToolbarIconLibrary pasteMenuItemIcon)
  1462     "get the help tool application
  1462     "get the help tool application
  1463     "
  1463     "
  1464     ^ wizards at:#help ifAbsentPut:[ |tool|
  1464     ^ wizards at:#help ifAbsentPut:[ |tool|
  1465         tool := UIHelpTool new.
  1465         tool := UIHelpTool new.
  1466         tool masterApplication:self.
  1466         tool masterApplication:self.
  1467         tool modifiedHolder: self valueOfEnablingCommitButtons.
  1467         tool modifiedHolder: self enablingCommitButtonsHolder.
  1468         tool builder window:(ApplicationSubView new client:tool).
  1468         tool builder window:(ApplicationSubView new client:tool).
  1469         tool masterApplication:self.
  1469         tool masterApplication:self.
  1470         tool
  1470         tool
  1471     ]
  1471     ]
  1472 !
  1472 !
  1473 
  1473 
  1474 imageTool
  1474 imageTool
  1475     "get the image tool application
  1475     "get the image tool application
  1476     "
  1476     "
  1477   ^ wizards at:#image ifAbsentPut:[ |tool|
  1477   ^ wizards at:#image ifAbsentPut:[ |tool|
  1478 	tool := ResourceEditor new createBuilder.
  1478         tool := ResourceEditor new createBuilder.
  1479 	tool masterApplication:self.
  1479         tool masterApplication:self.
  1480 	tool modifiedChannel: self valueOfEnablingCommitButtons.
  1480         tool modifiedChannel: self enablingCommitButtonsHolder.
  1481 	tool builder window:(ApplicationSubView new client:tool).
  1481         tool builder window:(ApplicationSubView new client:tool).
  1482 	tool
  1482         tool
  1483     ]
  1483     ]
  1484 !
  1484 !
  1485 
  1485 
  1486 useHelpTool:aHelpTool
  1486 useHelpTool:aHelpTool
  1487     "take the help dictionaries from aHelpTool into my helpTool
  1487     "take the help dictionaries from aHelpTool into my helpTool
  1641     "rebuild menu from a Menu
  1641     "rebuild menu from a Menu
  1642     "
  1642     "
  1643     |root menu|
  1643     |root menu|
  1644 
  1644 
  1645     aMenu isCollection ifTrue:[menu := aMenu decodeAsLiteralArray]
  1645     aMenu isCollection ifTrue:[menu := aMenu decodeAsLiteralArray]
  1646 		      ifFalse:[menu := aMenu].
  1646                       ifFalse:[menu := aMenu].
  1647 
  1647 
  1648     self valueOfEnablingCommitButtons value:false.
  1648     self enablingCommitButtonsHolder value:false.
  1649     root := listOfItems root.
  1649     root := listOfItems root.
  1650 
  1650 
  1651     self withoutNotifyDo:[
  1651     self withoutNotifyDo:[
  1652 	selectionHolder setValue:#().
  1652         selectionHolder setValue:#().
  1653 	root menu:aMenu labeled:(aSelector ? specSelector).
  1653         root menu:aMenu labeled:(aSelector ? specSelector).
  1654     ].
  1654     ].
  1655     self selectedItem:root.
  1655     self selectedItem:root.
  1656     self updateHistory.
  1656     self updateHistory.
  1657 !
  1657 !
  1658 
  1658 
  2017     "
  2017     "
  2018     |objects|
  2018     |objects|
  2019 
  2019 
  2020     dropOverLine := nil.
  2020     dropOverLine := nil.
  2021 
  2021 
  2022     self valueOfEnablingCommitButtons value ifTrue:[
  2022     self enablingCommitButtonsHolder value ifTrue:[
  2023         "/ current editing spec is modified (couldn't accept operation)
  2023         "/ current editing spec is modified (couldn't accept operation)
  2024         ^ self
  2024         ^ self
  2025     ].
  2025     ].
  2026     objects := aContext dropObjects.
  2026     objects := aContext dropObjects.
  2027     objects isEmpty ifTrue:[ ^ self ].  "/ nothing to drop ???
  2027     objects isEmpty ifTrue:[ ^ self ].  "/ nothing to drop ???
  2136 !MenuEditor methodsFor:'initialization & release'!
  2136 !MenuEditor methodsFor:'initialization & release'!
  2137 
  2137 
  2138 closeRequest
  2138 closeRequest
  2139     "ask for modification
  2139     "ask for modification
  2140     "
  2140     "
  2141     self valueOfEnablingCommitButtons value ifTrue:[
  2141     self enablingCommitButtonsHolder value ifTrue:[
  2142         self setModified.
  2142         self setModified.
  2143         self askForListModification.
  2143         self askForListModification.
  2144         modified ifTrue:[^ self].
  2144         modified ifTrue:[^ self].
  2145         self clearModified.
  2145         self clearModified.
  2146     ].
  2146     ].
  2247 
  2247 
  2248 clearModified
  2248 clearModified
  2249     "clear the modifiedChannel and the commitPanel"
  2249     "clear the modifiedChannel and the commitPanel"
  2250 
  2250 
  2251     modified := false.
  2251     modified := false.
  2252     self valueOfEnablingCommitButtons value:false.
  2252     self enablingCommitButtonsHolder value:false.
  2253     self clearModifiedFlag.
  2253     self clearModifiedFlag.
  2254 !
  2254 !
  2255 
  2255 
  2256 generateMenuSpec
  2256 generateMenuSpec
  2257     "generate and returns the current menu spec or nil
  2257     "generate and returns the current menu spec or nil
  2346     "called whenever the selection changed; test whether
  2346     "called whenever the selection changed; test whether
  2347      current item is not modified ....
  2347      current item is not modified ....
  2348     "
  2348     "
  2349     |oldSelectedItem newSelectedItem anythingChanged|
  2349     |oldSelectedItem newSelectedItem anythingChanged|
  2350 
  2350 
  2351     self valueOfEnablingCommitButtons value ifFalse:[
  2351     self enablingCommitButtonsHolder value ifFalse:[
  2352         ^ true
  2352         ^ true
  2353     ].
  2353     ].
  2354     oldSelectedItem := self selectedItem.
  2354     oldSelectedItem := self selectedItem.
  2355     oldSelectedItem ifNil:[^ true].
  2355     oldSelectedItem ifNil:[^ true].
  2356 
  2356 
  2357     newSelectedItem := listOfItems at:anIndex ifAbsent:nil.
  2357     newSelectedItem := listOfItems at:anIndex ifAbsent:nil.
  2358     oldSelectedItem == newSelectedItem ifTrue:[
  2358     oldSelectedItem == newSelectedItem ifTrue:[
  2359         ^ true
  2359         ^ true
  2360     ].
  2360     ].
  2361 
  2361 
  2362     anythingChanged := self valueOfEnablingCommitButtons value.
  2362     anythingChanged := self enablingCommitButtonsHolder value.
  2363     anythingChanged ifTrue:[          
  2363     anythingChanged ifTrue:[          
  2364         self autoAcceptOnSelectionChange value ifTrue:[
  2364         self autoAcceptOnSelectionChange value ifTrue:[
  2365             self accept.
  2365             self accept.
  2366             ^ true
  2366             ^ true
  2367         ].
  2367         ].