- Timestamp:
- 2020-01-07T20:03:45+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r15649 r15655 28 28 import javax.swing.AbstractAction; 29 29 import javax.swing.JCheckBoxMenuItem; 30 import javax.swing.JMenuItem;31 30 import javax.swing.JOptionPane; 32 31 import javax.swing.SwingUtilities; … … 61 60 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; 62 61 import org.openstreetmap.josm.gui.NavigatableComponent; 63 import org.openstreetmap.josm.gui.WindowMenu;64 62 import org.openstreetmap.josm.gui.draw.MapPath2D; 65 63 import org.openstreetmap.josm.gui.layer.Layer; … … 189 187 private JCheckBoxMenuItem addMenuItem() { 190 188 int n = MainApplication.getMenu().editMenu.getItemCount(); 191 for (int i = n-1; i > 0; i--) { 192 JMenuItem item = MainApplication.getMenu().editMenu.getItem(i); 193 if (item != null && item.getAction() != null && item.getAction() instanceof SnapChangeAction) { 194 MainApplication.getMenu().editMenu.remove(i); 195 } 196 } 197 return MainMenu.addWithCheckbox(MainApplication.getMenu().editMenu, snapChangeAction, WindowMenu.WINDOW_MENU_GROUP.VOLATILE); 189 return MainMenu.addWithCheckbox(MainApplication.getMenu().editMenu, snapChangeAction, n-5, false); 198 190 } 199 191 … … 1376 1368 super.destroy(); 1377 1369 finishDrawing(); 1370 MainApplication.getMenu().editMenu.remove(snapCheckboxMenuItem); 1378 1371 snapChangeAction.destroy(); 1379 1372 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r15649 r15655 27 27 28 28 import javax.swing.JCheckBoxMenuItem; 29 import javax.swing.JMenuItem;30 29 31 30 import org.openstreetmap.josm.actions.JosmAction; … … 51 50 import org.openstreetmap.josm.gui.MapFrame; 52 51 import org.openstreetmap.josm.gui.MapView; 53 import org.openstreetmap.josm.gui.WindowMenu;54 52 import org.openstreetmap.josm.gui.draw.MapViewPath; 55 53 import org.openstreetmap.josm.gui.draw.SymbolShape; … … 241 239 public void destroy() { 242 240 super.destroy(); 241 MainApplication.getMenu().editMenu.remove(dualAlignCheckboxMenuItem); 243 242 dualAlignChangeAction.destroy(); 244 243 } … … 246 245 private JCheckBoxMenuItem addDualAlignMenuItem() { 247 246 int n = MainApplication.getMenu().editMenu.getItemCount(); 248 for (int i = n-1; i > 0; i--) { 249 JMenuItem item = MainApplication.getMenu().editMenu.getItem(i); 250 if (item != null && item.getAction() != null && item.getAction() instanceof DualAlignChangeAction) { 251 MainApplication.getMenu().editMenu.remove(i); 252 } 253 } 254 return MainMenu.addWithCheckbox(MainApplication.getMenu().editMenu, dualAlignChangeAction, WindowMenu.WINDOW_MENU_GROUP.VOLATILE); 247 return MainMenu.addWithCheckbox(MainApplication.getMenu().editMenu, dualAlignChangeAction, n-5, false); 255 248 } 256 249 -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r15649 r15655 145 145 public class MainMenu extends JMenuBar { 146 146 147 /** 148 * The possible item groups of the Windows menu. 149 * @see MainMenu#addWithCheckbox 150 */ 151 public enum WINDOW_MENU_GROUP { 152 /** Entries always displayed, at the top */ 153 ALWAYS, 154 /** Entries displayed only for visible toggle dialogs */ 155 TOGGLE_DIALOG, 156 /** Volatile entries displayed at the end */ 157 VOLATILE 158 } 159 147 160 /* File menu */ 148 161 /** File / New Layer **/ … … 556 569 * @param menu to add the action to 557 570 * @param action the action that should get a menu item 558 * @param group the item should be added to. Groups are split by a separator. 559 * 0 is the first group, -1 will add the item to the end. 571 * @param group the item should be added to. Groups are split by a separator. null will add the item to the end. 560 572 * @return The created menu item 561 573 */ … … 563 575 if (action.getShortcut().isAutomatic()) 564 576 return null; 565 int i = g etInsertionIndexForGroup(menu, group.ordinal(), false);577 int i = group != null ? getInsertionIndexForGroup(menu, group.ordinal(), false) : -1; 566 578 JMenuItem menuitem = (JMenuItem) menu.add(new JMenuItem(action), i); 567 579 KeyStroke ks = action.getShortcut().getKeyStroke(); … … 595 607 * @param group the item should be added to. Groups are split by a separator. Use 596 608 * one of the enums that are defined for some of the menus to tell in which 597 * group the item should go. 609 * group the item should go. null will add the item to the end. 598 610 * @param isEntryExpert whether the entry should only be visible if the expert mode is activated 599 611 * @param isGroupSeparatorExpert whether the group separator should only be visible if the expert mode is activated … … 603 615 public static <E extends Enum<E>> JCheckBoxMenuItem addWithCheckbox(JMenu menu, JosmAction action, Enum<E> group, 604 616 boolean isEntryExpert, boolean isGroupSeparatorExpert) { 605 int i = getInsertionIndexForGroup(menu, group.ordinal(), isGroupSeparatorExpert); 617 int i = group != null ? getInsertionIndexForGroup(menu, group.ordinal(), isGroupSeparatorExpert) : -1; 618 return addWithCheckbox(menu, action, i, isEntryExpert); 619 } 620 621 /** 622 * Add a JosmAction to a menu and automatically prints accelerator if available. 623 * Also adds a checkbox that may be toggled. 624 * @param <E> group enum item type 625 * @param menu to add the action to 626 * @param action the action that should get a menu item 627 * @param i the item position in the menu. -1 will add the item to the end. 628 * @param isEntryExpert whether the entry should only be visible if the expert mode is activated 629 * @return The created menu item 630 * @since 15655 631 */ 632 public static <E extends Enum<E>> JCheckBoxMenuItem addWithCheckbox(JMenu menu, JosmAction action, int i, boolean isEntryExpert) { 606 633 final JCheckBoxMenuItem mi = new JCheckBoxMenuItem(action); 607 634 final KeyStroke ks = action.getShortcut().getKeyStroke(); … … 855 882 // -- changeset manager toggle action 856 883 final JCheckBoxMenuItem mi = MainMenu.addWithCheckbox(windowMenu, changesetManager, 857 W indowMenu.WINDOW_MENU_GROUP.ALWAYS, true, false);884 WINDOW_MENU_GROUP.ALWAYS, true, false); 858 885 changesetManager.addButtonModel(mi.getModel()); 859 886 -
trunk/src/org/openstreetmap/josm/gui/WindowMenu.java
r15649 r15655 18 18 */ 19 19 public class WindowMenu extends JMenu implements ContainerListener, ExpertModeChangeListener { 20 21 /**22 * The possible item groups of the Windows menu.23 * @see MainMenu#addWithCheckbox24 */25 public enum WINDOW_MENU_GROUP {26 /** Entries always displayed, at the top */27 ALWAYS,28 /** Entries displayed only for visible toggle dialogs */29 TOGGLE_DIALOG,30 /** Volatile entries displayed at the end */31 VOLATILE32 }33 20 34 21 /** -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r15650 r15655 54 54 import org.openstreetmap.josm.gui.ShowHideButtonListener; 55 55 import org.openstreetmap.josm.gui.SideButton; 56 import org.openstreetmap.josm.gui.WindowMenu;57 56 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; 58 57 import org.openstreetmap.josm.gui.help.HelpUtil; … … 286 285 windowMenuItem = MainMenu.addWithCheckbox(MainApplication.getMenu().windowMenu, 287 286 (JosmAction) getToggleAction(), 288 WindowMenu.WINDOW_MENU_GROUP.TOGGLE_DIALOG, isExpert, true);287 MainMenu.WINDOW_MENU_GROUP.TOGGLE_DIALOG, isExpert, true); 289 288 } 290 289 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r15649 r15655 60 60 import org.openstreetmap.josm.gui.MainMenu; 61 61 import org.openstreetmap.josm.gui.ScrollViewport; 62 import org.openstreetmap.josm.gui.WindowMenu;63 62 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 64 63 import org.openstreetmap.josm.gui.dialogs.relation.actions.AbstractRelationEditorAction; … … 766 765 }; 767 766 focusAction.putValue("relationEditor", re); 768 return MainMenu.add(MainApplication.getMenu().windowMenu, focusAction, WindowMenu.WINDOW_MENU_GROUP.VOLATILE);767 return MainMenu.add(MainApplication.getMenu().windowMenu, focusAction, MainMenu.WINDOW_MENU_GROUP.VOLATILE); 769 768 } 770 769 -
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
r15649 r15655 37 37 import org.openstreetmap.josm.gui.MainApplication; 38 38 import org.openstreetmap.josm.gui.MainMenu; 39 import org.openstreetmap.josm.gui.WindowMenu;40 39 import org.openstreetmap.josm.gui.util.WindowGeometry; 41 40 import org.openstreetmap.josm.gui.widgets.JosmEditorPane; … … 215 214 } 216 215 if (windowMenuItem == null && visible) { 217 windowMenuItem = MainMenu.add(menu.windowMenu, FOCUS_ACTION, WindowMenu.WINDOW_MENU_GROUP.VOLATILE);216 windowMenuItem = MainMenu.add(menu.windowMenu, FOCUS_ACTION, MainMenu.WINDOW_MENU_GROUP.VOLATILE); 218 217 } 219 218 }
Note:
See TracChangeset
for help on using the changeset viewer.