MenuEditor.st
changeset 1653 1798c7bcb787
parent 1645 714b89cb8ff7
child 1656 f5c0716efd78
--- a/MenuEditor.st	Tue Nov 05 15:24:24 2002 +0100
+++ b/MenuEditor.st	Fri Nov 08 11:45:48 2002 +0100
@@ -3095,8 +3095,11 @@
     menuItem := MenuItem labeled:(self rawLabel).
 
     MenuEditor aspects do:[:aKey|
-        value := aMenuItem perform:aKey.
-        value ifNotNil:[ self aspectAt:aKey put:value ]
+        value := self validateValue:(aMenuItem perform:aKey).
+
+        value notNil ifTrue:[
+            self aspectAt:aKey put:value.
+        ].
     ].
 !
 
@@ -3214,6 +3217,19 @@
     menuItem := MenuItem label:(self class defaultLabel).
 ! !
 
+!MenuEditor::Item methodsFor:'private'!
+
+validateValue:aValue
+    "if we pick a menupanel, the values of an item can be
+     a block model, ....
+    "
+    aValue notNil ifTrue:[
+        aValue isBlock      ifTrue:[ ^ #block ].
+        aValue isValueModel ifTrue:[ ^ #valueModel ].
+    ].
+    ^ aValue
+! !
+
 !MenuEditor::Item methodsFor:'queries'!
 
 isAction
@@ -3985,12 +4001,13 @@
     super aspectAt:aKey put:aValue.
 !
 
-getDelayedAttributesFrom:aMenuItem
+getDelayedAttributesFrom:anItem
+
     menuItem rawLabel:'Delayed'.
 
-    menuItem   submenuChannel:(aMenuItem submenuChannel).
-    menuItem horizontalLayout:(aMenuItem horizontalLayout).
-    menuItem   keepLinkedMenu:(aMenuItem keepLinkedMenu).
+    menuItem   submenuChannel:(self validateValue:(anItem submenuChannel)).
+    menuItem horizontalLayout:(self validateValue:(anItem horizontalLayout)).
+    menuItem horizontalLayout:(self validateValue:(anItem keepLinkedMenu)).
 !
 
 setDelayedAttributesTo:aMenuItem
@@ -4171,32 +4188,36 @@
     |expanded item menu|
 
     self criticalDo:[
-	self isRootItem ifTrue:[ expanded := true ]
-		       ifFalse:[ expanded := isExpanded ].
-
-	self removeAll.
-	self rawLabel:aString.
-
-	aMenu ifNotNil:[
-	    aMenu isCollection ifTrue:[ menu := Menu new fromLiteralArrayEncoding:aMenu ]
-			      ifFalse:[ menu := aMenu ].
-
-	    menu numberOfItems == 0 ifTrue:[
-		menu := nil
-	    ].
-	].
-	menu ifNotNil:[
-	    isExpanded := false.        "/ discard change notifications
-	    children   := OrderedCollection new.
-
-	    menu itemsDo:[:el|
-		item := self class menuItem:el.
-		item parent:self.
-		children add:item.
-	    ].
-	    expanded ifTrue:[ self expand ].
-	].
-	isExpanded := expanded.
+        self isRootItem ifTrue:[ expanded := true ]
+                       ifFalse:[ expanded := isExpanded ].
+
+        self removeAll.
+        self rawLabel:aString.
+
+        menu := aMenu value.
+
+        (menu isNil or:[menu isString]) ifTrue:[
+            menu := nil
+        ] ifFalse:[
+            aMenu isCollection ifTrue:[ menu := Menu new fromLiteralArrayEncoding:aMenu ]
+                              ifFalse:[ menu := aMenu ].
+
+            menu numberOfItems == 0 ifTrue:[
+                menu := nil
+            ].
+        ].
+        menu ifNotNil:[
+            isExpanded := false.        "/ discard change notifications
+            children   := OrderedCollection new.
+
+            menu itemsDo:[:el|
+                item := self class menuItem:el.
+                item parent:self.
+                children add:item.
+            ].
+            expanded ifTrue:[ self expand ].
+        ].
+        isExpanded := expanded.
     ].        
     self changed
 !
@@ -4247,7 +4268,11 @@
 
 getDelayedAttributesFrom:aMenuItem
 
-    self menu:(aMenuItem submenu) labeled:nil.
+    |menu|
+
+    menu := self validateValue:(aMenuItem submenu value).
+
+    self menu:menu labeled:nil.
     menuItem horizontalLayout:(aMenuItem horizontalLayout).
 !