MenuEditor.st
changeset 455 117dcae8b5e0
parent 441 b16598618359
child 469 28bcb1982ef9
equal deleted inserted replaced
454:8b016ffd83ce 455:117dcae8b5e0
   127     UIHelpTool openOnClass:MenuEditor    
   127     UIHelpTool openOnClass:MenuEditor    
   128     "
   128     "
   129 
   129 
   130   ^ super helpSpec addPairsFrom:#(
   130   ^ super helpSpec addPairsFrom:#(
   131 
   131 
       
   132 #aboutSTX
       
   133 'Open an InfoBox about running ST/X.'
       
   134 
       
   135 #aboutThisAppliaction
       
   136 'Open an InfoBox about release and author.'
       
   137 
   132 #accessCharaterPos
   138 #accessCharaterPos
   133 'The index of the access character position
   139 'The index of the access character position into the textual label (optional).'
   134 into the textual label (optional).'
       
   135 
   140 
   136 #argument
   141 #argument
   137 'An argument passed to the value method, if the value 
   142 'An argument passed to the value method, if the value  selector is a one- or two-arg selector (i.e. ends with '':''). The argument is passed as a string.'
   138 selector is a one- or two-arg selector (i.e. ends with '':'').
       
   139 The argument is passed as a string.'
       
   140 
   143 
   141 #enbled
   144 #enbled
   142 'This enabled field specifies the name of the aspect (-method or binding)
   145 'This enabled field specifies the name of the aspect (-method or binding) in your application, which returns a value holder holding a boolean, a block which evaluates to either true or false, a selector which returns either true or false or simply true or false. The value, true or false, specifies whether  the respective field can be selected, a value of true, or not, a value of false.'
   143 in your application, which returns a value holder holding a boolean,
   146 
   144 a block which evaluates to either true or false, a selector which returns
   147 #fileExit
   145 either true or false or simply true or false. The value, true or false,
   148 'Exit current application.'
   146 specifies whether  the respective field can be selected, a value of true,
   149 
   147 or not, a value of false.'
   150 #helpClassDocumentation
       
   151 'Open a HTML-browser with a class documentation for the current application.'
       
   152 
       
   153 #helpProgrammersGuide
       
   154 'Open a HTML-browser with a programmers guide.'
       
   155 
       
   156 #helpShowHelp
       
   157 'Toggle on/off displaying help texts.'
       
   158 
       
   159 #helpTutorial
       
   160 'Open a HTML-browser with tutorial for beginners.'
   148 
   161 
   149 #icon
   162 #icon
   150 'Selector which returns an image to be displayed.'
   163 'Selector which returns an image to be displayed.'
   151 
   164 
   152 #iconAndLabel
   165 #iconAndLabel
   153 'Boolean flag to specify that both image and textual label shall be shown.'
   166 'Boolean flag to specify that both image and textual label shall be shown.'
   154 
   167 
   155 #indication
   168 #indication
   156 'This indication field specifies the name of the aspect (-method or binding)
   169 'This indication field specifies the name of the aspect (-method or binding) in your application, a value holder holding a boolean, a block which evaluates to either true or false, a selector which returns either true or false or simply true or false. The value, true or false, specifies whether the shown indicator is switched on or off.'
   157 in your application, a value holder holding a boolean, a block which evaluates
       
   158 to either true or false, a selector which returns either true or false or
       
   159 simply true or false. The value, true or false, specifies whether the shown
       
   160 indicator is switched on or off.'
       
   161 
   170 
   162 #label
   171 #label
   163 'The label of the item. If the ''retriever/selector'' is set, 
   172 'The label of the item. If the ''retriever/selector'' is set,  and returns an image, the image is used as the displayed label.  Dependent on the state of the ''Image & Label'' flag, both the image and the label are shown.'
   164 and returns an image, the image is used as the displayed label. 
       
   165 Dependent on the state of the ''Image & Label'' flag, both
       
   166 the image and the label are shown.'
       
   167 
   173 
   168 #menuSelector
   174 #menuSelector
   169 'The name of the selector under which the generated 
   175 'The name of the selector under which the generated  menu should be installed and is accessable.'
   170 menu should be installed and is accessable.'
       
   171 
   176 
   172 #nameKey
   177 #nameKey
   173 'An unique identifier of the item (optional)'
   178 'An unique identifier of the item (optional)'
   174 
   179 
   175 #retriever
   180 #retriever
   176 'The name of the class, which implements the image selector. 
   181 'The name of the class, which implements the image selector.  This selector is specified by ''selector''. If no class is given,  the current application should implement the specified image selector.'
   177 This selector is specified by ''selector''. If no class is given, 
       
   178 the current application should implement the specified image selector.'
       
   179 
   182 
   180 #seperatorList
   183 #seperatorList
   181 'The list of valid separators'
   184 'The list of valid separators'
   182 
   185 
   183 #shortcutKey
   186 #shortcutKey
   184 'The key to be pressed, to select the menu item from the keyboard (accelerator key).'
   187 'The key to be pressed, to select the menu item from the keyboard (accelerator key).'
   185 
   188 
   186 #submenuChannel
   189 #submenuChannel
   187 'A value holder, which provides the submenu (Menu) to be opened
   190 'A value holder, which provides the submenu (Menu) to be opened if the item is selected. Useful if the items submenu is to be  changed dynamically.'
   188 if the item is selected. Useful if the items submenu is to be 
       
   189 changed dynamically.'
       
   190 
   191 
   191 #value
   192 #value
   192 'An action which can be either a block or a selector. Depending on the number
   193 'An action which can be either a block or a selector. Depending on the number of arguments to the action, the action will be called with the respective arguments. There can either zero, one or two arguments. The first argument to the action is the argument derived from the argument field and the second argument the selected item.'
   193 of arguments to the action, the action will be called with the respective arguments.
       
   194 There can either zero, one or two arguments. The first argument to the action is the
       
   195 argument derived from the argument field and the second argument the selected item.'
       
   196 
   194 
   197 )
   195 )
   198 ! !
   196 ! !
   199 
   197 
   200 !MenuEditor class methodsFor:'interface specs'!
   198 !MenuEditor class methodsFor:'interface specs'!
   309                           #'label:' '-'
   307                           #'label:' '-'
   310                       )
   308                       )
   311                        #(#MenuItem
   309                        #(#MenuItem
   312                           #'label:' 'Save'
   310                           #'label:' 'Save'
   313                           #'value:' #doInstallSpec
   311                           #'value:' #doInstallSpec
   314                       )
       
   315                        #(#MenuItem
       
   316                           #'label:' 'Save Help Spec'
       
   317                           #'value:' #doInstallHelp
       
   318                           #'enabled:' #isStandAlone
       
   319                       )
   312                       )
   320                        #(#MenuItem
   313                        #(#MenuItem
   321                           #'label:' '-'
   314                           #'label:' '-'
   322                       )
   315                       )
   323                        #(#MenuItem
   316                        #(#MenuItem
  1375 
  1368 
  1376     self noteBookView.
  1369     self noteBookView.
  1377     self helpTool dictionary:aDictionary
  1370     self helpTool dictionary:aDictionary
  1378 ! !
  1371 ! !
  1379 
  1372 
       
  1373 !MenuEditor methodsFor:'active help'!
       
  1374 
       
  1375 defaultInfoLabel
       
  1376 
       
  1377     ^(specClass ? 'No class defined') printString, ' << ', self treeView selectorName
       
  1378 ! !
       
  1379 
  1380 !MenuEditor methodsFor:'aspects'!
  1380 !MenuEditor methodsFor:'aspects'!
  1381 
  1381 
  1382 aspectFor:aKey
  1382 aspectFor:aKey
  1383     "returns aspect for a key or nil"
  1383     "returns aspect for a key or nil"
  1384 
  1384 
  1712         |className message|
  1712         |className message|
  1713         aClass isClass ifTrue: [className := aClass name].
  1713         aClass isClass ifTrue: [className := aClass name].
  1714         aClass isString ifTrue: [className := aClass].
  1714         aClass isString ifTrue: [className := aClass].
  1715         message := className, ' ', aSelector.
  1715         message := className, ' ', aSelector.
  1716         self addToHistory: message -> #loadFromMessage:.
  1716         self addToHistory: message -> #loadFromMessage:.
  1717         self valueOfInfoLabel value: className, ' << ', aSelector
  1717         self valueOfInfoLabel value: self defaultInfoLabel
  1718     ].
  1718     ].
  1719 
  1719 
  1720     self treeView selection: 2.
  1720     self treeView selection: 2.
  1721     self menuChanged
  1721     self menuChanged
  1722 
  1722 
  1938 doFromClass
  1938 doFromClass
  1939 
  1939 
  1940     self loadFromInClassesOf: #Object
  1940     self loadFromInClassesOf: #Object
  1941 !
  1941 !
  1942 
  1942 
  1943 doInstallHelp
       
  1944     "install help text
       
  1945     "
       
  1946     self isStandAlone ifTrue:[
       
  1947         self helpTool installHelpSpecInto:(self specClass)
       
  1948     ]
       
  1949 !
       
  1950 
       
  1951 doInstallSpec
  1943 doInstallSpec
  1952     |cls selector treeView menu spec mthd category code|
  1944     |cls selector treeView menu spec mthd category code|
  1953 
  1945 
  1954     cls := self resolveName:(self specClass).
  1946     cls := self resolveName:(self specClass).
  1955 
  1947 
  2000             , '\\'.
  1992             , '\\'.
  2001 
  1993 
  2002     code := code withCRs.
  1994     code := code withCRs.
  2003     (ReadStream on:code) fileIn.
  1995     (ReadStream on:code) fileIn.
  2004 
  1996 
  2005     "(cls compiledMethodAt:selector) isNil ifTrue:[
  1997     self isStandAlone ifTrue:[
  2006         code := self class generateCodeFor:cls menuSelector:selector.
  1998         self helpTool installHelpSpecInto:(self specClass)
  2007         code := code withCRs.
  1999     ].
  2008         (ReadStream on:code) fileIn.
       
  2009     ]."
       
  2010     didInstall := true.
  2000     didInstall := true.
  2011     isModified := false.
  2001     isModified := false.
  2012 
  2002 
  2013 !
  2003 !
  2014 
  2004