--- a/MenuEditor.st Sat Feb 14 18:04:11 1998 +0100
+++ b/MenuEditor.st Sat Feb 14 20:34:45 1998 +0100
@@ -12,9 +12,8 @@
-ToolApplicationModel subclass:#MenuEditor
- instanceVariableNames:'isModified specClass specCanvas helpCanvas tabSelection aspects
- slices didInstall'
+ListSpecEditor subclass:#MenuEditor
+ instanceVariableNames:'specCanvas helpCanvas slices'
classVariableNames:''
poolDictionaries:''
category:'Interface-UIPainter'
@@ -30,8 +29,8 @@
!
SelectionInTreeView subclass:#TreeView
- instanceVariableNames:'images'
- classVariableNames:'CopyBuffer Images'
+ instanceVariableNames:''
+ classVariableNames:''
poolDictionaries:''
privateIn:MenuEditor
!
@@ -99,6 +98,43 @@
! !
+!MenuEditor class methodsFor:'accessing'!
+
+resourceType
+
+ ^#menu
+
+
+
+
+! !
+
+!MenuEditor class methodsFor:'aspects'!
+
+aspects
+
+^#(
+ label
+ accessCharacterPos
+ argument
+ submenuChannel
+ enabled
+ value
+ nameKey
+ indication
+ translateLabel
+ isButton
+ shortcutKey
+ startGroup
+ retriever
+ iconAndLabel
+ icon
+ isVisible
+
+ )
+
+! !
+
!MenuEditor class methodsFor:'code generation'!
sourceCategory
@@ -188,6 +224,9 @@
#fileSave
'Saves current menu spec and if modified the help spec.'
+#fileSaveAs
+'Opens a dialog to save current menu spec and if modified the help spec.'
+
#imageImageAndLabel
'Turns on/off displaying both image and textual label.'
@@ -642,62 +681,6 @@
)
!
-classDefineSpec
- "this window spec was automatically generated by the ST/X UIPainter"
-
- "do not manually edit this - the painter/builder may not be able to
- handle the specification if its corrupted."
-
- "
- UIPainter new openOnClass:MenuEditor andSelector:#classDefineSpec
- MenuEditor new openInterface:#classDefineSpec
- "
-
- <resource: #canvas>
-
- ^
-
- #(#FullSpec
- #'window:'
- #(#WindowSpec
- #'name:' 'Menu Editor'
- #'layout:' #(#LayoutFrame 262 0 426 0 508 0 519 0)
- #'label:' 'Menu Editor'
- #'min:' #(#Point 10 10)
- #'max:' #(#Point 1152 900)
- #'bounds:' #(#Rectangle 262 426 509 520)
- #'usePreferredExtent:' false
- )
- #'component:'
- #(#SpecCollection
- #'collection:'
- #(
- #(#LabelSpec
- #'name:' 'boxLabel'
- #'layout:' #(#LayoutFrame 2 0.0 4 0 -2 1.0 24 0)
- #'label:' 'Class for code:'
- #'adjust:' #left
- #'resizeForLabel:' true
- )
- #(#InputFieldSpec
- #'name:' 'classNameField'
- #'layout:' #(#LayoutFrame 2 0.0 27 0 -2 1.0 49 0)
- #'tabable:' true
- #'model:' #classNameChannel
- #'acceptOnReturn:' false
- #'acceptOnTab:' false
- )
- #(#UISubSpecification
- #'name:' 'SubSpecification'
- #'layout:' #(#LayoutFrame 0 0 -29 1 0 1 -5 1)
- #'majorKey:' #ToolApplicationModel
- #'minorKey:' #windowSpecForCommitWithoutChannels
- )
- )
- )
- )
-!
-
detailsEditSpec
"this window spec was automatically generated by the ST/X UIPainter"
@@ -833,7 +816,7 @@
<resource: #canvas>
^
-
+
#(#FullSpec
#'window:'
#(#WindowSpec
@@ -902,6 +885,9 @@
)
)
)
+
+
+
!
windowSpec
@@ -1044,7 +1030,7 @@
#(#MenuItem
#'label:' 'Load...'
#'translateLabel:' true
- #'value:' #doFromClass
+ #'value:' #doLoad
#'activeHelpKey:' #fileLoad
#'enabled:' #isStandAlone
)
@@ -1053,27 +1039,29 @@
)
#(#MenuItem
#'label:' 'Save'
- #'value:' #doInstallSpec
+ #'value:' #doSave
#'activeHelpKey:' #fileSave
)
#(#MenuItem
+ #'label:' 'Save As...'
+ #'value:' #doSaveAs
+ #'activeHelpKey:' #fileSaveAs
+ )
+ #(#MenuItem
#'label:' '-'
)
#(#MenuItem
- #'label:' 'Pick A Menu'
+ #'label:' 'Pick A Menu...'
#'value:' #doPickAMenu
#'activeHelpKey:' #filePickAMenu
#'enabled:' #isStandAlone
)
#(#MenuItem
- #'label:' 'Define Class...'
- #'value:' #doDefineClass
- #'activeHelpKey:' #fileDefineClass
- #'enabled:' #isStandAlone
+ #'label:' '-'
)
#(#MenuItem
#'label:' 'Browse Class'
- #'value:' #doBrowseAppClass
+ #'value:' #doBrowseClass
#'activeHelpKey:' #fileBrowseClass
)
#(#MenuItem
@@ -1242,28 +1230,28 @@
#'label:' 'Move Up'
#'value:' #doStepUp
#'activeHelpKey:' #editMoveUp
- #'enabled:' #enabledStepOver
+ #'enabled:' #valueOfEnableMovingUp
#'labelImage:' #(#ResourceRetriever #ToolApplicationModel #upIcon 'Move Up')
)
#(#MenuItem
#'label:' 'Move Down'
#'value:' #doStepDown
#'activeHelpKey:' #editMoveDown
- #'enabled:' #enabledStepOver
+ #'enabled:' #valueOfEnableMovingDown
#'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downIcon 'Move Down')
)
#(#MenuItem
#'label:' 'Move In'
#'value:' #doStepIn
#'activeHelpKey:' #editMoveIn
- #'enabled:' #enabledStepIn
+ #'enabled:' #valueOfEnableMovingIn
#'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downRightIcon 'Move In')
)
#(#MenuItem
#'label:' 'Move Out'
#'value:' #doStepOut
#'activeHelpKey:' #editMoveOut
- #'enabled:' #enabledStepOut
+ #'enabled:' #valueOfEnableMovingOut
#'labelImage:' #(#ResourceRetriever #ToolApplicationModel #leftDownIcon 'Move Out')
)
) nil
@@ -1299,14 +1287,14 @@
#(#MenuItem
#'label:' 'Load'
#'isButton:' true
- #'value:' #doFromClass
+ #'value:' #doLoad
#'activeHelpKey:' #fileLoad
#'labelImage:' #(#ResourceRetriever nil #loadIcon)
)
#(#MenuItem
#'label:' 'Save'
#'isButton:' true
- #'value:' #doInstallSpec
+ #'value:' #doSave
#'activeHelpKey:' #fileSave
#'labelImage:' #(#ResourceRetriever nil #saveIcon)
)
@@ -1356,7 +1344,7 @@
#'isButton:' true
#'value:' #doStepUp
#'activeHelpKey:' #editMoveUp
- #'enabled:' #enabledStepOver
+ #'enabled:' #valueOfEnableMovingUp
#'labelImage:' #(#ResourceRetriever nil #upIcon)
)
#(#MenuItem
@@ -1364,7 +1352,7 @@
#'isButton:' true
#'value:' #doStepDown
#'activeHelpKey:' #editMoveDown
- #'enabled:' #enabledStepOver
+ #'enabled:' #valueOfEnableMovingDown
#'labelImage:' #(#ResourceRetriever nil #downIcon)
)
#(#MenuItem
@@ -1372,7 +1360,7 @@
#'isButton:' true
#'value:' #doStepIn
#'activeHelpKey:' #editMoveIn
- #'enabled:' #enabledStepIn
+ #'enabled:' #valueOfEnableMovingIn
#'labelImage:' #(#ResourceRetriever nil #downRightIcon)
)
#(#MenuItem
@@ -1380,7 +1368,7 @@
#'isButton:' true
#'value:' #doStepOut
#'activeHelpKey:' #editMoveOut
- #'enabled:' #enabledStepOut
+ #'enabled:' #valueOfEnableMovingOut
#'labelImage:' #(#ResourceRetriever nil #leftDownIcon)
)
) nil
@@ -1483,23 +1471,6 @@
!MenuEditor methodsFor:'accessing'!
-isModified: aBoolean
- "sets menu tree modifications; invoked by the painter."
-
- isModified := aBoolean
-!
-
-specClass
-
- ^specClass
-!
-
-specClass:aClass
-
- aClass isBehavior ifTrue:[specClass := aClass name]
- ifFalse:[specClass := aClass]
-!
-
submenuTest
"returns submenu assigned to item test"
@@ -1521,33 +1492,6 @@
!MenuEditor methodsFor:'aspects'!
-aspectFor:aKey
- "returns aspect for a key or nil"
-
- ^aspects at: aKey ifAbsent: [super aspectFor:aKey]
-
-
-!
-
-enabledStepIn
- "returns whether user can put selected item in next submenu"
-
- ^builder booleanValueAspectFor: #enabledStepIn
-!
-
-enabledStepOut
- "returns whether user can put selected item out of current parent submenu"
-
- ^builder booleanValueAspectFor: #enabledStepOut
-
-!
-
-enabledStepOver
- "returns whether user can shift selected item up or down"
-
- ^builder booleanValueAspectFor:#enabledStepOver
-!
-
hasAnySingleSelection
^builder booleanValueAspectFor: #hasAnySingleSelection
@@ -1595,17 +1539,6 @@
!
-tabModel
-
- |holder|
- (holder := builder bindingAt:#tabModel) isNil ifTrue:[
- holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
- builder aspectAt:#tabModel put:holder.
- ].
- ^ holder
-
-!
-
treeView
"returns the tree view representing hierarchically all the menu items"
@@ -1620,12 +1553,6 @@
!MenuEditor methodsFor:'change & update'!
-update:something with:aParameter from:changedObject
- "one of my value holders has changed its value, so let me set the editing menu as modified"
-
- self valueOfEnablingCommitButtons value: true
-!
-
updateEnabledChannels
"update enabled channels"
@@ -1641,11 +1568,11 @@
ifTrue:
[
next := parent childAt:((parent indexOfChild:node) + 1).
- self enabledStepIn value:(next notNil and:[next hasChildren]).
- self enabledStepOver value:(parent children size > 1).
- self enabledStepOut value:(parent parent notNil).
- self hasValidSingleSelection value:true.
- self hasValidSelection value:true.
+ self valueOfEnableMovingIn value:(next notNil and:[next hasChildren]).
+ self valueOfEnableMovingUpOrDown value:(parent children size > 1).
+ self valueOfEnableMovingOut value:parent parent notNil.
+ self hasValidSingleSelection value:true.
+ self hasValidSelection value:true.
^ self
]
]
@@ -1656,11 +1583,11 @@
state := (self treeView isInSelection:1) not
]
].
- self enabledStepOver value:false.
- self enabledStepIn value:false.
- self enabledStepOut value:false.
- self hasValidSingleSelection value:false.
- self hasValidSelection value:state.
+ self valueOfEnableMovingUpOrDown value:false.
+ self valueOfEnableMovingIn value:false.
+ self valueOfEnableMovingOut value:false.
+ self hasValidSingleSelection value:false.
+ self hasValidSelection value:state.
! !
!MenuEditor methodsFor:'event handling'!
@@ -1680,43 +1607,29 @@
!MenuEditor methodsFor:'help'!
-defaultInfoLabel
-
- specClass isNil ifTrue: [^'No menu class defined'].
- ^specClass printString, ' >> ', self treeView selectorName
-
-!
-
openTutorial
self openTutorial: 'tools/MenuEditor/TOP.html'.
! !
+!MenuEditor methodsFor:'initialization'!
+
+initialize
+ "initialize value holders for the menu item properties"
+
+ |holder|
+
+ super initialize.
+
+ aspects at:#seperatorSelection put:(holder := SelectionInList new).
+ holder list: Item separatorList.
+ holder addDependent:self.
+
+! !
+
!MenuEditor methodsFor:'private'!
-checkMenuItemModified
- "check menu item modification"
-
- self valueOfEnablingCommitButtons value
- ifTrue:
- [
- ((YesNoBox title:'Menu item was modified!!\Save it?\' withCRs)
- noText:'No';
- yesText:'Yes';
- showAtPointer;
- accepted)
- ifFalse:
- [
- self valueOfEnablingCommitButtons value: false.
- isModified := false.
- ^true
- ].
- self accept
- ].
- ^true
-!
-
helpKey
|node|
@@ -1733,12 +1646,6 @@
!MenuEditor methodsFor:'queries'!
-didInstall
- "returns true if the menu was installed"
-
- ^didInstall
-!
-
isHelpToolSelected
"returns true if current selection is help tool"
@@ -1818,14 +1725,9 @@
aspects do: [:holder| holder addDependent:self].
!
-tabSelection
-
- ^tabSelection ? 0
-!
-
tabSelection: aSelection
- |sel|
+ |sel|
tabSelection = aSelection ifTrue:[
^ self
].
@@ -1858,114 +1760,25 @@
buildFrom:aClass andSelector:aSelector
- |oldClass newClass|
+ |oldClass|
self valueOfEnablingCommitButtons value: false.
oldClass := self specClass.
self specClass:aClass.
- newClass := self specClass.
-
- (self isStandAlone and:[oldClass ~= newClass]) ifTrue:[
- self helpTool helpSpecFrom:newClass
- ].
- self treeView buildFrom: newClass andSelector: aSelector.
-
- aClass notNil & aSelector notNil
- ifTrue:
- [
- |className message|
- aClass isClass ifTrue: [className := aClass name].
- aClass isString ifTrue: [className := aClass].
- message := className, ' ', aSelector.
- self addToHistory: message -> #loadFromMessage:
- ].
-
+ specSelector := aSelector.
+
+ (self isStandAlone and:[oldClass ~= specClass]) ifTrue:[
+ self helpTool helpSpecFrom:specClass
+ ].
+ self treeView buildFrom: specClass andSelector: specSelector.
+
+ self updateHistory.
self updateInfoLabel.
self treeView selection: 2.
self menuChanged
!
-checkModified
- "check menu modification
- "
- isModified
- ifTrue:
- [
- ((YesNoBox title:'Menu was modified!!')
- noText:'Cancel';
- yesText:'Waste it and proceed';
- showAtPointer;
- accepted) ifFalse: [^false].
- isModified := false
- ].
- ^true
-
-
-!
-
-closeRequest
- "close request"
-
- (self checkMenuItemModified and: [self checkModified]) ifTrue: [super closeRequest]
-
-
-
-
-
-!
-
-initialize
- "initialize value holders for the menu item properties"
-
- |holder|
-
- super initialize.
- aspects := IdentityDictionary new.
- tabSelection := 0.
-
- #(
- label
- accessCharacterPos
- argument
- submenuChannel
- enabled
- value
- nameKey
- indication
- translateLabel
- isButton
- shortcutKey
- startGroup
- retriever
- iconAndLabel
- icon
- isVisible
-
- ) do:[:aKey|
- aspects at:aKey put:(holder := ValueHolder new).
- holder addDependent: self
- ].
-
- aspects at:#seperatorSelection put:(holder := SelectionInList new).
- holder list: Item separatorList.
- holder addDependent:self.
-
-!
-
-loadFromMessage: aMessage
-
- (((aMessage size > 0) and: [self checkMenuItemModified]) and: [self checkModified])
- ifTrue:
- [
- |readStream aClass aSelector|
- readStream := aMessage readStream.
- aClass := Smalltalk at: (readStream upTo: $ ) asSymbol.
- aSelector := readStream upToEnd asSymbol.
- self buildFrom: aClass andSelector: aSelector
- ]
-!
-
openModalOnClass:aClass andSelector:aSelector
specClass := Association key:aClass value:aSelector.
@@ -1986,9 +1799,6 @@
super postBuildWith:builder.
- didInstall := false.
- isModified := false.
-
specClass isAssociation ifTrue:[
cls := specClass key.
sel := specClass value.
@@ -2013,12 +1823,13 @@
ifFalse: [specCanvas raise]
! !
-!MenuEditor methodsFor:'user interactions'!
+!MenuEditor methodsFor:'user actions'!
accept
"invoked by button 'OK' and by save requests of menu item changes"
|node|
+
node := self treeView selectedNode.
node notNil
ifTrue:
@@ -2031,11 +1842,13 @@
]
ifFalse:
[
- self treeView updateNode: (node contents buildFromAspects: aspects)
+ node contents buildFromAspects: aspects.
+ node changed.
+ specSelector := self treeView selectorName.
]
].
self valueOfEnablingCommitButtons value:false.
- isModified := true
+ modified := true
!
cancel
@@ -2050,82 +1863,39 @@
node contents toAspects:aspects
].
self valueOfEnablingCommitButtons value: false.
- isModified := false
+ modified := false
!
-doBrowseAppClass
- "open a browser on the class"
-
- |cls|
-
- (cls := self resolveName: self specClass) notNil
- ifTrue:
- [
- SystemBrowser openInClass:cls class selector: self treeView selectorName
- ]
- ifFalse:
- [
- self information:'No valid class defined!!'.
- ]
-!
-
-doDefineClass
-
- aspects at:#classNameChannel put:(self specClass asValue).
-
- (self openDialogInterface:#classDefineSpec) ifTrue:[
- self specClass:((aspects at:#classNameChannel) value)
- ].
-
+doNew
+
+ self buildFrom: nil andSelector: self treeView selectorName
!
-doEditImage
-
- |cls resourceClass resourceSelector imageResourceMessage readStream|
-
- cls := self resolveName: self specClass.
- cls isNil ifTrue:[
- ^ self information:'No valid class defined!!'.
+doPickAMenu
+
+ |view|
+
+ view := Screen current viewFromUser.
+
+ (view isNil or:[view == Screen current rootView]) ifTrue:[
+ ^ self
].
- (aspects at:#icon) value size > 0
- ifTrue: [resourceSelector := (aspects at:#icon) value]
- ifFalse: [resourceSelector := #stxIcon].
- (aspects at:#retriever) value size > 0
- ifTrue: [resourceClass := (aspects at:#retriever) value]
- ifFalse: [resourceClass := cls withAllSuperclasses detect: [:cls| cls class implements: resourceSelector] ifNone: [cls]].
-
- (imageResourceMessage := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil
- ifTrue:
- [
- readStream := imageResourceMessage readStream.
- resourceClass := (readStream upTo: $ ) asSymbol.
- resourceSelector := readStream upToEnd asSymbol.
- resourceClass size > 0 ifTrue: [(aspects at:#retriever) value: resourceClass].
- resourceSelector size > 0 ifTrue: [(aspects at:#icon) value: resourceSelector. self valueOfEnablingCommitButtons value: true]
- ]
+ view specClass == MenuPanelSpec ifTrue:[
+ ^ self treeView buildFromMenu: view asMenu
+ ].
+ ^ nil
!
-doFromClass
-
- self loadFromMessage:
- (ResourceSelectionBrowser
- request: 'Load Menu From Class'
- onSuperclass: nil
- andClass: specClass
- andSelector: self treeView selectorName
- withResourceTypes: #(menu))
-!
-
-doInstallSpec
- |cls selector treeView menu spec mthd category code|
+doSave
+ |cls treeView menu spec mthd category code|
cls := self resolveName:(self specClass).
cls isNil ifTrue:[
^ self information:'No valid class defined!!'.
].
- treeView := self treeView.
- selector := treeView selectorName.
+
+ treeView := self treeView.
menu := treeView asMenu.
menu isNil ifTrue:[
@@ -2139,7 +1909,7 @@
"/ if that method already exists, do not overwrite the category
category := 'menu specs'.
- (mthd := cls class compiledMethodAt:selector) notNil ifTrue:[
+ (mthd := cls class compiledMethodAt:specSelector) notNil ifTrue:[
category := mthd category.
].
@@ -2147,13 +1917,13 @@
, cls name , ' class methodsFor:' , category storeString
, Character excla asString , '\\'
- , selector , '\'
+ , specSelector , '\'
, ' "this window spec was automatically generated by the ST/X MenuEditor"\\'
, ' "do not manually edit this - the builder may not be able to\'
, ' handle the specification if its corrupted."\\'
, ' "\'
- , ' MenuEditor new openOnClass:' , cls name , ' andSelector:#' , selector , '\'
- , ' (Menu new fromLiteralArrayEncoding:(' , cls name , ' ' , selector , ')) startUp\'
+ , ' MenuEditor new openOnClass:' , cls name , ' andSelector:#' , specSelector , '\'
+ , ' (Menu new fromLiteralArrayEncoding:(' , cls name , ' ' , specSelector , ')) startUp\'
, ' "\'.
code := code
@@ -2173,36 +1943,24 @@
self isStandAlone ifTrue:[
self helpTool installHelpSpecInto:(self specClass)
].
- didInstall := true.
- isModified := false.
+ self updateHistory.
+ hasSaved := true.
+ modified := false.
!
-doNew
-
- self buildFrom:nil andSelector: self treeView selectorName
-!
-
-doPickAMenu
-
- |view|
-
- view := Screen current viewFromUser.
-
- (view isNil or:[view == Screen current rootView]) ifTrue:[
- ^ self
- ].
- view specClass == MenuPanelSpec ifTrue:[
- ^ self treeView buildFromMenu: view asMenu
- ].
- ^ nil
+doSaveAs
+
+ super doSaveAs.
+
+ self treeView selectorName: specSelector
!
doStepDown
"shift selected menu item one step down"
self treeView selectedNodeChangeSequenceOrder:1.
- isModified := true.
+ modified := true.
@@ -2213,7 +1971,7 @@
"move selected menu item into next submenu"
self treeView selectedNodeBecomeChildOfNext.
- isModified := true.
+ modified := true.
@@ -2225,14 +1983,14 @@
"move selected menu item out from parent submenu"
self treeView selectedNodeBecomeSisterOfParent.
- isModified := true.
+ modified := true.
!
doStepUp
"shift selected menu item one step up"
self treeView selectedNodeChangeSequenceOrder:-1.
- isModified := true.
+ modified := true.
! !
!MenuEditor::Item class methodsFor:'constants'!
@@ -2478,20 +2236,42 @@
!MenuEditor::Item methodsFor:'queries'!
+iconFor: aNode
+
+ aNode hasChildren
+ ifTrue:
+ [
+ ^MenuEditor submenuImage
+ ]
+ ifFalse:
+ [
+ submenuChannel notNil
+ ifTrue:
+ [
+ ^MenuEditor linkSubmenuImage
+ ]
+ ifFalse:
+ [
+ self isSeparator
+ ifTrue: [^MenuEditor menuSeparatorImage]
+ ifFalse: [^MenuEditor menuItemImage]
+ ]
+ ]
+!
+
isSeparator
"returns true if item is a seperator"
^self separatorType notNil
-! !
-
-!MenuEditor::TreeView class methodsFor:'defaults'!
-
-defaultMenuMessage
- "this message is the default yo be sent to the menuHolder to get a menu"
-
- ^#menu
-
-
+!
+
+treeViewLabel
+
+ ^label asBoldText,
+ (value notNil ifTrue: [': [',
+ value ,
+ (argument notNil ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']),
+ ']'] ifFalse: [''])
! !
!MenuEditor::TreeView class methodsFor:'documentation'!
@@ -2512,36 +2292,16 @@
! !
-!MenuEditor::TreeView class methodsFor:'initialization'!
-
-initialize
-
- super initialize.
-
- Images := nil
-! !
-
-!MenuEditor::TreeView class methodsFor:'resources'!
-
-images
- "returns an IdentityDictionary containing a list of images and keys used
- "
- ^ Images ?
- (Images := IdentityDictionary new
- at: #menuItemImage put: MenuEditor menuItemImage;
- at: #menuSeparatorImage put: MenuEditor menuSeparatorImage;
- at: #submenuImage put: MenuEditor submenuImage;
- at: #linkSubmenuImage put: MenuEditor linkSubmenuImage;
- yourself)
-
-
-
-! !
-
!MenuEditor::TreeView methodsFor:'accessing'!
selectorName
- ^ (listOfNodes first contents label) asSymbol
+
+ ^(listOfNodes first contents label) asSymbol
+!
+
+selectorName: aSymbol
+
+ listOfNodes first contents label: aSymbol
! !
!MenuEditor::TreeView methodsFor:'building'!
@@ -2572,12 +2332,18 @@
node := self nodeLabel:cls.
].
+ node expand.
+ model root:node.
node hasChildren ifFalse:[
- node add:(self nodeLabel:'Item 1')
+ |n|
+ n := self nodeLabel:'Item 1'.
+ n parent: node.
+ node add: n.
+ node icon: nil.
+ model recomputeList
].
- node expand.
- model root:node.
+
!
@@ -2602,7 +2368,6 @@
node := self nodeLabel: anItem label.
node contents buildFromMenuItem:anItem.
- node name: node contents label.
self subMenu: anItem submenu parent:node.
^node.
@@ -2681,20 +2446,6 @@
]
]
]
-!
-
-figureFor:aNode
- "access figure for a node"
-
- aNode hasChildren
- ifFalse:
- [
- |item|
- (item := aNode contents) submenuChannel notNil ifTrue:[^images at: #linkSubmenuImage].
- item isSeparator ifTrue:[^images at: #menuSeparatorImage].
- ^images at: #menuItemImage
- ].
- ^images at: #submenuImage
! !
!MenuEditor::TreeView methodsFor:'event handling'!
@@ -2715,37 +2466,18 @@
!MenuEditor::TreeView methodsFor:'initialization'!
-fetchImageResources
- "initialize heavily used device resources - to avoid rendering
- images again and again later; returns maximum extent of the images used."
-
- |defaultExtent imageWidth imageHeight maxWidth maxHeight|
-
- defaultExtent := super fetchImageResources.
- maxHeight := defaultExtent y.
- maxWidth := defaultExtent x.
-
- images do:
- [:anIcon|
- (imageWidth := anIcon widthOn:self) > maxWidth ifTrue:[maxWidth := imageWidth].
- (imageHeight := anIcon heightOn:self) > maxHeight ifTrue:[maxHeight := imageHeight].
- ].
- ^maxWidth@maxHeight
-
-!
-
initialize
super initialize.
- images := IdentityDictionary new.
-
- self class images associationsDo:[:imageAsso|images at: imageAsso key put:(imageAsso value onDevice:device)].
self multipleSelectOk:true.
self showDirectoryIndicator: true.
self showDirectoryIndicatorForRoot: false.
- self selectConditionBlock: [:i|self application checkMenuItemModified].
+ self selectConditionBlock: [:i|self application checkMenuItemModified].
self validateDoubleClickBlock: [:node| node ~~ listOfNodes first].
+
+ self model iconAction: [:aNode| aNode contents iconFor: aNode].
+ self model labelAction: [:aNode| aNode contents treeViewLabel]
! !
!MenuEditor::TreeView methodsFor:'menus'!
@@ -2753,8 +2485,8 @@
doCopy
self hasSelection ifTrue:[
- CopyBuffer := OrderedCollection new.
- self selectionDo:[:i| CopyBuffer add:((listOfNodes at:i) copy)]
+ self application clipboard: OrderedCollection new.
+ self selectionDo:[:i| self application clipboard add:((listOfNodes at:i) copy)]
]
!
@@ -2780,6 +2512,7 @@
|node|
node := self nodeLabel:'Submenu'.
+ node parent: self selectedNode.
node add:(self nodeLabel:'Item 1').
self addElement:node
!
@@ -2806,8 +2539,8 @@
doPaste
- (CopyBuffer notNil and:[self selectedNode notNil]) ifTrue:[
- self addElement:(CopyBuffer collect:[:el| el copy])
+ (self application clipboard notNil and:[self selectedNode notNil]) ifTrue:[
+ self addElement:(self application clipboard collect:[:el| el copy])
].
! !
@@ -2818,19 +2551,31 @@
self checkMenuItemModified
ifTrue:
- [
+ [
+ self selectedNodeAdd: aNode.
(aNode isCollection not and: [aNode name = 'Item'])
ifTrue:
[
- |label|
+ |label|
label := aNode name, ' ',
- (self selectedNode parent notNil ifTrue:
- [(((self selectedNode children size = 0 ifTrue: [self selectedNode parent children] ifFalse: [self selectedNode children]) select: [:node|
- |lab| lab := node contents label. ((node children size = 0) & node contents submenuChannel isNil & (lab ~= '-') & (lab ~= '=') & (lab ~= ''))]) size + 1) printString] ifFalse: ['1']).
- aNode name: label.
- aNode contents label: label.
- ].
- self selectedNodeAdd: aNode.
+ (self selectedNode parent notNil
+ ifTrue:
+ [
+ (((self selectedNode children size = 0
+ ifTrue: [self selectedNode parent children]
+ ifFalse: [self selectedNode children]) select:
+ [:node|
+ |lab|
+ lab := node contents label.
+ ((node children size = 0) &
+ node contents submenuChannel isNil &
+ (lab ~= '-') & (lab ~= '=') & (lab ~= ''))
+ ]) size) printString]
+ ifFalse: ['1']).
+
+ aNode name: label string asBoldText.
+ aNode contents label: label string.
+ ].
aNode isCollection ifFalse: [self selectNode: aNode] ifTrue: [self selection: (aNode collect: [:node| self indexOfNode: node])].
self setModified.
]
@@ -2838,12 +2583,12 @@
checkMenuItemModified
- ^self topView application checkMenuItemModified
+ ^self topView application checkItemModified
!
nodeLabel:aLabel
- ^TreeItem name:aLabel contents: (MenuEditor::Item new label:aLabel)
+ ^TreeItem new contents: (MenuEditor::Item new label:aLabel)
!
selectedNodeAdd:something
@@ -2869,36 +2614,11 @@
setModified
- self topView application isModified: true.
+ self topView application modified: true.
self topView application updateEnabledChannels
! !
-!MenuEditor::TreeView methodsFor:'selection'!
-
-updateNode: aNode
-
- |name treeItem index|
-
- name := aNode label.
- treeItem := listOfNodes detect: [:n| n contents = aNode] ifNone: [1].
- index := self indexOfNode: treeItem.
- treeItem name: name.
- self redrawLine: index.
-! !
-
-!MenuEditor::TreeView methodsFor:'startup / release'!
-
-destroy
- "destroy images"
-
- super destroy.
-
- Images := nil
-
-
-! !
-
!MenuEditor class methodsFor:'documentation'!
version