Changeset 5089 in josm for trunk/src/org
- Timestamp:
- 2012-03-16T14:26:05+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r5086 r5089 257 257 258 258 /** 259 * Add a JosmAction toa menu.259 * Add a JosmAction at the end of a menu. 260 260 * 261 261 * This method handles all the shortcut handling. It also makes sure that actions that are 262 * handled by the OS are not duplicated on the menu. Menu item will be added at the end of263 * the menu.264 * @param menu to add the action to265 * @ param the action that should get amenu item262 * handled by the OS are not duplicated on the menu. 263 * @param menu the menu to add the action to 264 * @param action the action that should get a menu item 265 * @return the created menu item 266 266 */ 267 267 public static JMenuItem add(JMenu menu, JosmAction action) { … … 269 269 } 270 270 271 /** 272 * Add a JosmAction at the end of a menu. 273 * 274 * This method handles all the shortcut handling. It also makes sure that actions that are 275 * handled by the OS are not duplicated on the menu. 276 * @param menu the menu to add the action to 277 * @param action the action that should get a menu item 278 * @param isExpert whether the entry should only be visible if the expert mode is activated 279 * @return the created menu item 280 */ 271 281 public static JMenuItem add(JMenu menu, JosmAction action, boolean isExpert) { 282 return add(menu, action, isExpert, null); 283 } 284 285 /** 286 * Add a JosmAction at the end of a menu. 287 * 288 * This method handles all the shortcut handling. It also makes sure that actions that are 289 * handled by the OS are not duplicated on the menu. 290 * @param menu the menu to add the action to 291 * @param action the action that should get a menu item 292 * @param isExpert whether the entry should only be visible if the expert mode is activated 293 * @param index an integer specifying the position at which to add the action 294 * @return the created menu item 295 */ 296 public static JMenuItem add(JMenu menu, JosmAction action, boolean isExpert, Integer index) { 272 297 if (action.getShortcut().getAutomatic()) 273 298 return null; 274 JMenuItem menuitem = menu.add(action); 299 final JMenuItem menuitem; 300 if (index == null) { 301 menuitem = menu.add(action); 302 } else { 303 menuitem = menu.insert(action, index); 304 } 275 305 if (isExpert) { 276 306 ExpertToggleAction.addVisibilitySwitcher(menuitem); … … 281 311 } 282 312 return menuitem; 313 } 314 315 /** 316 * Add the JosmAction {@code actionToBeInserted} directly below {@code existingMenuEntryAction}. 317 * 318 * This method handles all the shortcut handling. It also makes sure that actions that are 319 * handled by the OS are not duplicated on the menu. 320 * @param menu the menu to add the action to 321 * @param actionToBeInserted the action that should get a menu item directly below {@code existingMenuEntryAction} 322 * @param isExpert whether the entry should only be visible if the expert mode is activated 323 * @param existingMenuEntryAction an action already added to the menu {@code menu}, the action {@code actionToBeInserted} is added directly below 324 * @return the created menu item 325 */ 326 public static JMenuItem addAfter(JMenu menu, JosmAction actionToBeInserted, boolean isExpert, JosmAction existingMenuEntryAction) { 327 int i = 0; 328 for (Component c : menu.getMenuComponents()) { 329 if (c instanceof JMenuItem && ((JMenuItem) c).getAction() == existingMenuEntryAction) { 330 break; 331 } 332 i++; 333 } 334 return add(menu, actionToBeInserted, isExpert, i + 1); 283 335 } 284 336 … … 289 341 * handled by the OS are not duplicated on the menu. 290 342 * @param menu to add the action to 291 * @param the action that should get a menu item343 * @param action the action that should get a menu item 292 344 * @param group the item should be added to. Groups are split by a separator. 293 345 * 0 is the first group, -1 will add the item to the end. … … 309 361 * Also adds a checkbox that may be toggled. 310 362 * @param menu to add the action to 311 * @param the action that should get a menu item363 * @param action the action that should get a menu item 312 364 * @param group the item should be added to. Groups are split by a separator. Use 313 365 * one of the enums that are defined for some of the menus to tell in which
Note:
See TracChangeset
for help on using the changeset viewer.