MenuEditor.st
changeset 548 93fea26562c8
parent 546 aac3f3c9383f
child 557 de8d8782486c
equal deleted inserted replaced
547:930b3df19305 548:93fea26562c8
   118     "
   118     "
   119 
   119 
   120   ^ super helpSpec addPairsFrom:#(
   120   ^ super helpSpec addPairsFrom:#(
   121 
   121 
   122 #accessCharaterPos
   122 #accessCharaterPos
   123 'The index of the access character position into the textual label (optional).'
   123 'Index of the access character position into the textual label (optional).'
       
   124 
       
   125 #addMenuItem
       
   126 'Adds a new menu item.'
       
   127 
       
   128 #addMenuSeparator
       
   129 'Adds a new menu separator.'
       
   130 
       
   131 #addSubMenu
       
   132 'Adds a new submenu.'
       
   133 
       
   134 #addSubMenuLink
       
   135 'Adds a new linked submenu.'
   124 
   136 
   125 #argument
   137 #argument
   126 '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 '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.'
   127 
   139 
   128 #enbled
   140 #enbled
   129 '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.'
   141 '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.'
       
   142 
       
   143 #fileLoad
       
   144 'Opens a dialog for selecting a menu spec.'
       
   145 
       
   146 #fileNew
       
   147 'Creates a new menu spec.'
       
   148 
       
   149 #fileSave
       
   150 'Saves current menu spec and if modified the help spec.'
   130 
   151 
   131 #icon
   152 #icon
   132 'Selector which returns an image to be displayed.'
   153 'Selector which returns an image to be displayed.'
   133 
   154 
   134 #iconAndLabel
   155 #iconAndLabel
   135 'Boolean flag to specify that both image and textual label shall be shown.'
   156 'Specifies that both image and textual label shall be shown.'
   136 
   157 
   137 #indication
   158 #indication
   138 '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.'
   159 'Indication field specifying 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.'
   139 
   160 
   140 #isVisible
   161 #isVisible
   141 ''
   162 'A value holder providing visibility of the menu item.'
   142 
   163 
   143 #label
   164 #label
   144 '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.'
   165 '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.'
   145 
   166 
   146 #menuSelector
   167 #menuSelector
   147 'The name of the selector under which the generated  menu should be installed and is accessable.'
   168 'Name of the selector under which the generated menu should be installed and is accessable.'
   148 
   169 
   149 #nameKey
   170 #nameKey
   150 'An unique identifier of the item (optional)'
   171 'Unique identifier of the item (optional).'
   151 
   172 
   152 #retriever
   173 #retriever
   153 '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.'
   174 'Name of the class implementing the image selector. This selector is specified by ''selector''. If no class is given, the current application should implement the specified image selector.'
   154 
   175 
   155 #seperatorList
   176 #seperatorList
   156 'The list of valid separators'
   177 'List of valid separators.'
   157 
   178 
   158 #shortcutKey
   179 #shortcutKey
   159 'The key to be pressed, to select the menu item from the keyboard (accelerator key).'
   180 'Key to be pressed to select the menu item from the keyboard (accelerator key).'
   160 
   181 
   161 #submenuChannel
   182 #submenuChannel
   162 '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.'
   183 'A value holder providing the submenu to be opened if item is selected.'
   163 
   184 
   164 #value
   185 #value
   165 '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.'
   186 'An action being 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.'
   166 
   187 
   167 )
   188 )
   168 ! !
   189 ! !
   169 
   190 
   170 !MenuEditor class methodsFor:'interface specs'!
   191 !MenuEditor class methodsFor:'interface specs'!
   978                     
   999                     
   979                      #(
  1000                      #(
   980                        #(#MenuItem
  1001                        #(#MenuItem
   981                           #'label:' 'New'
  1002                           #'label:' 'New'
   982                           #'value:' #doNew
  1003                           #'value:' #doNew
       
  1004                           #'activeHelpKey:' #fileNew
   983                       )
  1005                       )
   984                        #(#MenuItem
  1006                        #(#MenuItem
   985                           #'label:' '-'
  1007                           #'label:' '-'
   986                       )
  1008                       )
   987                        #(#MenuItem
  1009                        #(#MenuItem
   988                           #'label:' 'Load...'
  1010                           #'label:' 'Load...'
   989                           #'translateLabel:' true
  1011                           #'translateLabel:' true
   990                           #'value:' #doFromClass
  1012                           #'value:' #doFromClass
       
  1013                           #'activeHelpKey:' #fileLoad
   991                           #'enabled:' #isStandAlone
  1014                           #'enabled:' #isStandAlone
   992                       )
  1015                       )
   993                        #(#MenuItem
  1016                        #(#MenuItem
   994                           #'label:' '-'
  1017                           #'label:' '-'
   995                       )
  1018                       )
   996                        #(#MenuItem
  1019                        #(#MenuItem
   997                           #'label:' 'Save'
  1020                           #'label:' 'Save'
   998                           #'value:' #doInstallSpec
  1021                           #'value:' #doInstallSpec
       
  1022                           #'activeHelpKey:' #fileSave
   999                       )
  1023                       )
  1000                        #(#MenuItem
  1024                        #(#MenuItem
  1001                           #'label:' '-'
  1025                           #'label:' '-'
  1002                       )
  1026                       )
  1003                        #(#MenuItem
  1027                        #(#MenuItem
  1019                       )
  1043                       )
  1020                        #(#MenuItem
  1044                        #(#MenuItem
  1021                           #'label:' 'Exit'
  1045                           #'label:' 'Exit'
  1022                           #'translateLabel:' true
  1046                           #'translateLabel:' true
  1023                           #'value:' #closeRequest
  1047                           #'value:' #closeRequest
       
  1048                           #'activeHelpKey:' #fileExit
  1024                       )
  1049                       )
  1025                     ) nil
  1050                     ) nil
  1026                     nil
  1051                     nil
  1027                 )
  1052                 )
  1028             )
  1053             )
  1069      
  1094      
  1070        #(#Menu
  1095        #(#Menu
  1071           
  1096           
  1072            #(
  1097            #(
  1073              #(#MenuItem
  1098              #(#MenuItem
  1074                 #'label:' 'Item'
  1099                 #'label:' 'Menu Item'
  1075                 #'value:' #doCreateItem
  1100                 #'value:' #doCreateItem
  1076                 #'labelImage:' #(#ResourceRetriever #MenuEditor #menuItemImage 'Item')
  1101                 #'activeHelpKey:' #addMenuItem
  1077             )
  1102                 #'labelImage:' #(#ResourceRetriever #MenuEditor #menuItemImage 'Menu Item')
  1078              #(#MenuItem
  1103             )
  1079                 #'label:' 'Separator'
  1104              #(#MenuItem
       
  1105                 #'label:' 'Menu Separator'
  1080                 #'value:' #doCreateSep
  1106                 #'value:' #doCreateSep
  1081                 #'labelImage:' #(#ResourceRetriever #MenuEditor #menuSeparatorImage 'Separator')
  1107                 #'activeHelpKey:' #addMenuSeparator
       
  1108                 #'labelImage:' #(#ResourceRetriever #MenuEditor #menuSeparatorImage 'Menu Separator')
  1082             )
  1109             )
  1083              #(#MenuItem
  1110              #(#MenuItem
  1084                 #'label:' '-'
  1111                 #'label:' '-'
  1085             )
  1112             )
  1086              #(#MenuItem
  1113              #(#MenuItem
  1087                 #'label:' 'Submenu'
  1114                 #'label:' 'Submenu'
  1088                 #'value:' #doCreateMenu
  1115                 #'value:' #doCreateMenu
       
  1116                 #'activeHelpKey:' #addSubMenuLink
  1089                 #'labelImage:' #(#ResourceRetriever #MenuEditor #submenuImage 'Submenu')
  1117                 #'labelImage:' #(#ResourceRetriever #MenuEditor #submenuImage 'Submenu')
  1090             )
  1118             )
  1091              #(#MenuItem
  1119              #(#MenuItem
  1092                 #'label:' 'Submenu Link'
  1120                 #'label:' 'Submenu Link'
  1093                 #'value:' #doCreateLink
  1121                 #'value:' #doCreateLink
  1143           
  1171           
  1144            #(
  1172            #(
  1145              #(#MenuItem
  1173              #(#MenuItem
  1146                 #'label:' 'Cut'
  1174                 #'label:' 'Cut'
  1147                 #'value:' #doCut
  1175                 #'value:' #doCut
       
  1176                 #'activeHelpKey:' #editCut
  1148                 #'enabled:' #hasValidSelection
  1177                 #'enabled:' #hasValidSelection
  1149                 #'shortcutKeyCharacter:' #Cut
  1178                 #'shortcutKeyCharacter:' #Cut
  1150             )
  1179             )
  1151              #(#MenuItem
  1180              #(#MenuItem
  1152                 #'label:' 'Copy'
  1181                 #'label:' 'Copy'
  1153                 #'value:' #doCopy
  1182                 #'value:' #doCopy
       
  1183                 #'activeHelpKey:' #editCopy
  1154                 #'enabled:' #hasValidSelection
  1184                 #'enabled:' #hasValidSelection
  1155                 #'shortcutKeyCharacter:' #Copy
  1185                 #'shortcutKeyCharacter:' #Copy
  1156             )
  1186             )
  1157              #(#MenuItem
  1187              #(#MenuItem
  1158                 #'label:' 'Paste'
  1188                 #'label:' 'Paste'
  1159                 #'value:' #doPaste
  1189                 #'value:' #doPaste
       
  1190                 #'activeHelpKey:' #editPaste
  1160                 #'enabled:' #hasAnySingleSelection
  1191                 #'enabled:' #hasAnySingleSelection
  1161                 #'shortcutKeyCharacter:' #Paste
  1192                 #'shortcutKeyCharacter:' #Paste
  1162             )
  1193             )
  1163              #(#MenuItem
  1194              #(#MenuItem
  1164                 #'label:' '-'
  1195                 #'label:' '-'
  1165             )
  1196             )
  1166              #(#MenuItem
  1197              #(#MenuItem
  1167                 #'label:' 'Move Up'
  1198                 #'label:' 'Move Up'
  1168                 #'value:' #doStepUp
  1199                 #'value:' #doStepUp
       
  1200                 #'activeHelpKey:' #editMoveUp
  1169                 #'enabled:' #enabledStepOver
  1201                 #'enabled:' #enabledStepOver
  1170                 #'labelImage:' #(#ResourceRetriever #MenuEditor #upIcon 'Move Up')
  1202                 #'labelImage:' #(#ResourceRetriever #MenuEditor #upIcon 'Move Up')
  1171             )
  1203             )
  1172              #(#MenuItem
  1204              #(#MenuItem
  1173                 #'label:' 'Move Down'
  1205                 #'label:' 'Move Down'
  1174                 #'value:' #doStepDown
  1206                 #'value:' #doStepDown
       
  1207                 #'activeHelpKey:' #editMoveDown
  1175                 #'enabled:' #enabledStepOver
  1208                 #'enabled:' #enabledStepOver
  1176                 #'labelImage:' #(#ResourceRetriever #MenuEditor #downIcon 'Move Down')
  1209                 #'labelImage:' #(#ResourceRetriever #MenuEditor #downIcon 'Move Down')
  1177             )
  1210             )
  1178              #(#MenuItem
  1211              #(#MenuItem
  1179                 #'label:' 'Move In'
  1212                 #'label:' 'Move In'
  1180                 #'value:' #doStepIn
  1213                 #'value:' #doStepIn
       
  1214                 #'activeHelpKey:' #editMoveIn
  1181                 #'enabled:' #enabledStepIn
  1215                 #'enabled:' #enabledStepIn
  1182                 #'labelImage:' #(#ResourceRetriever #MenuEditor #downRightIcon 'Move In')
  1216                 #'labelImage:' #(#ResourceRetriever #MenuEditor #downRightIcon 'Move In')
  1183             )
  1217             )
  1184              #(#MenuItem
  1218              #(#MenuItem
  1185                 #'label:' 'Move Out'
  1219                 #'label:' 'Move Out'
  1186                 #'value:' #doStepOut
  1220                 #'value:' #doStepOut
       
  1221                 #'activeHelpKey:' #editMoveOut
  1187                 #'enabled:' #enabledStepOut
  1222                 #'enabled:' #enabledStepOut
  1188                 #'labelImage:' #(#ResourceRetriever #MenuEditor #leftDownIcon 'Move Out')
  1223                 #'labelImage:' #(#ResourceRetriever #MenuEditor #leftDownIcon 'Move Out')
  1189             )
  1224             )
  1190           ) nil
  1225           ) nil
  1191           nil
  1226           nil
  1212            #(
  1247            #(
  1213              #(#MenuItem
  1248              #(#MenuItem
  1214                 #'label:' 'New'
  1249                 #'label:' 'New'
  1215                 #'isButton:' true
  1250                 #'isButton:' true
  1216                 #'value:' #doNew
  1251                 #'value:' #doNew
       
  1252                 #'activeHelpKey:' #fileNew
  1217                 #'labelImage:' #(#ResourceRetriever nil #newIcon)
  1253                 #'labelImage:' #(#ResourceRetriever nil #newIcon)
  1218             )
  1254             )
  1219              #(#MenuItem
  1255              #(#MenuItem
  1220                 #'label:' 'Load'
  1256                 #'label:' 'Load'
  1221                 #'isButton:' true
  1257                 #'isButton:' true
  1222                 #'value:' #doFromClass
  1258                 #'value:' #doFromClass
       
  1259                 #'activeHelpKey:' #fileLoad
  1223                 #'labelImage:' #(#ResourceRetriever nil #loadIcon)
  1260                 #'labelImage:' #(#ResourceRetriever nil #loadIcon)
  1224             )
  1261             )
  1225              #(#MenuItem
  1262              #(#MenuItem
  1226                 #'label:' 'Save'
  1263                 #'label:' 'Save'
  1227                 #'isButton:' true
  1264                 #'isButton:' true
  1228                 #'value:' #doInstallSpec
  1265                 #'value:' #doInstallSpec
       
  1266                 #'activeHelpKey:' #fileSave
  1229                 #'labelImage:' #(#ResourceRetriever nil #saveIcon)
  1267                 #'labelImage:' #(#ResourceRetriever nil #saveIcon)
  1230             )
  1268             )
  1231              #(#MenuItem
  1269              #(#MenuItem
  1232                 #'label:' ''
  1270                 #'label:' ''
  1233             )
  1271             )
  1234              #(#MenuItem
  1272              #(#MenuItem
  1235                 #'label:' 'Create Item'
  1273                 #'label:' 'Add Item'
  1236                 #'isButton:' true
  1274                 #'isButton:' true
  1237                 #'value:' #doCreateItem
  1275                 #'value:' #doCreateItem
       
  1276                 #'activeHelpKey:' #addMenuItem
  1238                 #'enabled:' #hasAnySingleSelection
  1277                 #'enabled:' #hasAnySingleSelection
  1239                 #'labelImage:' #(#ResourceRetriever nil #menuItemImage)
  1278                 #'labelImage:' #(#ResourceRetriever nil #menuItemImage)
  1240             )
  1279             )
  1241              #(#MenuItem
  1280              #(#MenuItem
  1242                 #'label:' 'Create Separator'
  1281                 #'label:' 'Add Separator'
  1243                 #'isButton:' true
  1282                 #'isButton:' true
  1244                 #'value:' #doCreateSep
  1283                 #'value:' #doCreateSep
       
  1284                 #'activeHelpKey:' #addMenuSeparator
  1245                 #'enabled:' #hasAnySingleSelection
  1285                 #'enabled:' #hasAnySingleSelection
  1246                 #'labelImage:' #(#ResourceRetriever nil #menuSeparatorImage)
  1286                 #'labelImage:' #(#ResourceRetriever nil #menuSeparatorImage)
  1247             )
  1287             )
  1248              #(#MenuItem
  1288              #(#MenuItem
  1249                 #'label:' ''
  1289                 #'label:' ''
  1250             )
  1290             )
  1251              #(#MenuItem
  1291              #(#MenuItem
  1252                 #'label:' 'Create Menu'
  1292                 #'label:' 'Add Submenu'
  1253                 #'isButton:' true
  1293                 #'isButton:' true
  1254                 #'value:' #doCreateMenu
  1294                 #'value:' #doCreateMenu
       
  1295                 #'activeHelpKey:' #addSubMenu
  1255                 #'enabled:' #hasAnySingleSelection
  1296                 #'enabled:' #hasAnySingleSelection
  1256                 #'labelImage:' #(#ResourceRetriever nil #submenuImage)
  1297                 #'labelImage:' #(#ResourceRetriever nil #submenuImage)
  1257             )
  1298             )
  1258              #(#MenuItem
  1299              #(#MenuItem
  1259                 #'label:' 'Create Link'
  1300                 #'label:' 'Add Linked Submenu'
  1260                 #'isButton:' true
  1301                 #'isButton:' true
  1261                 #'value:' #doCreateLink
  1302                 #'value:' #doCreateLink
       
  1303                 #'activeHelpKey:' #addSubMenuLink
  1262                 #'enabled:' #hasAnySingleSelection
  1304                 #'enabled:' #hasAnySingleSelection
  1263                 #'labelImage:' #(#ResourceRetriever nil #linkSubmenuImage)
  1305                 #'labelImage:' #(#ResourceRetriever nil #linkSubmenuImage)
  1264             )
  1306             )
  1265              #(#MenuItem
  1307              #(#MenuItem
  1266                 #'label:' ''
  1308                 #'label:' ''
  1267             )
  1309             )
  1268              #(#MenuItem
  1310              #(#MenuItem
  1269                 #'label:' 'Move Up'
  1311                 #'label:' 'Move Up'
  1270                 #'isButton:' true
  1312                 #'isButton:' true
  1271                 #'value:' #doStepUp
  1313                 #'value:' #doStepUp
       
  1314                 #'activeHelpKey:' #editMoveUp
  1272                 #'enabled:' #enabledStepOver
  1315                 #'enabled:' #enabledStepOver
  1273                 #'labelImage:' #(#ResourceRetriever nil #upIcon)
  1316                 #'labelImage:' #(#ResourceRetriever nil #upIcon)
  1274             )
  1317             )
  1275              #(#MenuItem
  1318              #(#MenuItem
  1276                 #'label:' 'Move Down'
  1319                 #'label:' 'Move Down'
  1277                 #'isButton:' true
  1320                 #'isButton:' true
  1278                 #'value:' #doStepDown
  1321                 #'value:' #doStepDown
       
  1322                 #'activeHelpKey:' #editMoveDown
  1279                 #'enabled:' #enabledStepOver
  1323                 #'enabled:' #enabledStepOver
  1280                 #'labelImage:' #(#ResourceRetriever nil #downIcon)
  1324                 #'labelImage:' #(#ResourceRetriever nil #downIcon)
  1281             )
  1325             )
  1282              #(#MenuItem
  1326              #(#MenuItem
  1283                 #'label:' 'Move In'
  1327                 #'label:' 'Move In'
  1284                 #'isButton:' true
  1328                 #'isButton:' true
  1285                 #'value:' #doStepIn
  1329                 #'value:' #doStepIn
       
  1330                 #'activeHelpKey:' #editMoveIn
  1286                 #'enabled:' #enabledStepIn
  1331                 #'enabled:' #enabledStepIn
  1287                 #'labelImage:' #(#ResourceRetriever nil #downRightIcon)
  1332                 #'labelImage:' #(#ResourceRetriever nil #downRightIcon)
  1288             )
  1333             )
  1289              #(#MenuItem
  1334              #(#MenuItem
  1290                 #'label:' 'Move Out'
  1335                 #'label:' 'Move Out'
  1291                 #'isButton:' true
  1336                 #'isButton:' true
  1292                 #'value:' #doStepOut
  1337                 #'value:' #doStepOut
       
  1338                 #'activeHelpKey:' #editMoveOut
  1293                 #'enabled:' #enabledStepOut
  1339                 #'enabled:' #enabledStepOut
  1294                 #'labelImage:' #(#ResourceRetriever nil #leftDownIcon)
  1340                 #'labelImage:' #(#ResourceRetriever nil #leftDownIcon)
  1295             )
  1341             )
  1296           ) nil
  1342           ) nil
  1297           nil
  1343           nil
  2008     ]
  2054     ]
  2009 !
  2055 !
  2010 
  2056 
  2011 doFromClass
  2057 doFromClass
  2012 
  2058 
  2013     self loadFromInClassesOf: #Object
  2059     self loadFromMessage: 
       
  2060         (ResourceSelectionBrowser
       
  2061             request: 'Load Menu From Class'
       
  2062             onSuperclass: nil
       
  2063             andClass: specClass
       
  2064             andSelector: self treeView selectorName
       
  2065             withResourceTypes: #(menu))
  2014 !
  2066 !
  2015 
  2067 
  2016 doInstallSpec
  2068 doInstallSpec
  2017     |cls selector treeView menu spec mthd category code|
  2069     |cls selector treeView menu spec mthd category code|
  2018 
  2070 
  2128 doStepUp
  2180 doStepUp
  2129     "shift selected menu item one step up"
  2181     "shift selected menu item one step up"
  2130 
  2182 
  2131     self treeView selectedNodeChangeSequenceOrder:-1.
  2183     self treeView selectedNodeChangeSequenceOrder:-1.
  2132     isModified := true.
  2184     isModified := true.
  2133 !
       
  2134 
       
  2135 loadFromInClassesOf: aSuperclassOrSymbol
       
  2136 
       
  2137     self loadFromMessage: 
       
  2138         (ResourceSelectionBrowser
       
  2139             request: 'Load Menu From Class'
       
  2140             onSuperclass: aSuperclassOrSymbol
       
  2141             andClass: specClass
       
  2142             andSelector: self treeView selectorName
       
  2143             withResourceTypes: #(menu))
       
  2144 ! !
  2185 ! !
  2145 
  2186 
  2146 !MenuEditor::Item class methodsFor:'constants'!
  2187 !MenuEditor::Item class methodsFor:'constants'!
  2147 
  2188 
  2148 separatorList
  2189 separatorList