[8378] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[422] | 2 | package org.openstreetmap.josm.gui;
|
---|
| 3 |
|
---|
[2530] | 4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
[404] | 5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
[8721] | 6 | import static org.openstreetmap.josm.tools.I18n.trc;
|
---|
[404] | 7 |
|
---|
[4843] | 8 | import java.awt.Component;
|
---|
[7075] | 9 | import java.awt.GraphicsEnvironment;
|
---|
[1416] | 10 | import java.awt.event.KeyEvent;
|
---|
[8072] | 11 | import java.util.ArrayList;
|
---|
[5958] | 12 | import java.util.HashMap;
|
---|
[8072] | 13 | import java.util.List;
|
---|
[8404] | 14 | import java.util.Locale;
|
---|
[5958] | 15 | import java.util.Map;
|
---|
[404] | 16 |
|
---|
[486] | 17 | import javax.swing.JCheckBoxMenuItem;
|
---|
[404] | 18 | import javax.swing.JMenu;
|
---|
| 19 | import javax.swing.JMenuBar;
|
---|
| 20 | import javax.swing.JMenuItem;
|
---|
[4590] | 21 | import javax.swing.JPopupMenu;
|
---|
| 22 | import javax.swing.JSeparator;
|
---|
[450] | 23 | import javax.swing.KeyStroke;
|
---|
[4590] | 24 | import javax.swing.event.MenuEvent;
|
---|
| 25 | import javax.swing.event.MenuListener;
|
---|
[404] | 26 |
|
---|
[486] | 27 | import org.openstreetmap.josm.Main;
|
---|
[404] | 28 | import org.openstreetmap.josm.actions.AboutAction;
|
---|
[1130] | 29 | import org.openstreetmap.josm.actions.AddNodeAction;
|
---|
[404] | 30 | import org.openstreetmap.josm.actions.AlignInCircleAction;
|
---|
| 31 | import org.openstreetmap.josm.actions.AlignInLineAction;
|
---|
| 32 | import org.openstreetmap.josm.actions.AutoScaleAction;
|
---|
[2689] | 33 | import org.openstreetmap.josm.actions.ChangesetManagerToggleAction;
|
---|
[2530] | 34 | import org.openstreetmap.josm.actions.CloseChangesetAction;
|
---|
[404] | 35 | import org.openstreetmap.josm.actions.CombineWayAction;
|
---|
| 36 | import org.openstreetmap.josm.actions.CopyAction;
|
---|
[4380] | 37 | import org.openstreetmap.josm.actions.CopyCoordinatesAction;
|
---|
[996] | 38 | import org.openstreetmap.josm.actions.CreateCircleAction;
|
---|
[3704] | 39 | import org.openstreetmap.josm.actions.CreateMultipolygonAction;
|
---|
[768] | 40 | import org.openstreetmap.josm.actions.DeleteAction;
|
---|
[10173] | 41 | import org.openstreetmap.josm.actions.DeleteLayerAction;
|
---|
[5965] | 42 | import org.openstreetmap.josm.actions.DialogsToggleAction;
|
---|
[1380] | 43 | import org.openstreetmap.josm.actions.DistributeAction;
|
---|
[404] | 44 | import org.openstreetmap.josm.actions.DownloadAction;
|
---|
[8212] | 45 | import org.openstreetmap.josm.actions.DownloadNotesInViewAction;
|
---|
[10816] | 46 | import org.openstreetmap.josm.actions.DownloadOsmInViewAction;
|
---|
[2923] | 47 | import org.openstreetmap.josm.actions.DownloadPrimitiveAction;
|
---|
[1810] | 48 | import org.openstreetmap.josm.actions.DownloadReferrersAction;
|
---|
[404] | 49 | import org.openstreetmap.josm.actions.DuplicateAction;
|
---|
| 50 | import org.openstreetmap.josm.actions.ExitAction;
|
---|
[4840] | 51 | import org.openstreetmap.josm.actions.ExpertToggleAction;
|
---|
[4086] | 52 | import org.openstreetmap.josm.actions.FollowLineAction;
|
---|
[2621] | 53 | import org.openstreetmap.josm.actions.FullscreenToggleAction;
|
---|
[404] | 54 | import org.openstreetmap.josm.actions.GpxExportAction;
|
---|
| 55 | import org.openstreetmap.josm.actions.HelpAction;
|
---|
[1811] | 56 | import org.openstreetmap.josm.actions.HistoryInfoAction;
|
---|
[4408] | 57 | import org.openstreetmap.josm.actions.HistoryInfoWebAction;
|
---|
[1700] | 58 | import org.openstreetmap.josm.actions.InfoAction;
|
---|
[4408] | 59 | import org.openstreetmap.josm.actions.InfoWebAction;
|
---|
[2621] | 60 | import org.openstreetmap.josm.actions.JoinAreasAction;
|
---|
[466] | 61 | import org.openstreetmap.josm.actions.JoinNodeWayAction;
|
---|
[768] | 62 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
[3327] | 63 | import org.openstreetmap.josm.actions.JumpToAction;
|
---|
[1890] | 64 | import org.openstreetmap.josm.actions.MergeLayerAction;
|
---|
[422] | 65 | import org.openstreetmap.josm.actions.MergeNodesAction;
|
---|
[1890] | 66 | import org.openstreetmap.josm.actions.MergeSelectionAction;
|
---|
[1639] | 67 | import org.openstreetmap.josm.actions.MirrorAction;
|
---|
[3327] | 68 | import org.openstreetmap.josm.actions.MoveAction;
|
---|
[3266] | 69 | import org.openstreetmap.josm.actions.MoveNodeAction;
|
---|
[404] | 70 | import org.openstreetmap.josm.actions.NewAction;
|
---|
[1146] | 71 | import org.openstreetmap.josm.actions.OpenFileAction;
|
---|
[1416] | 72 | import org.openstreetmap.josm.actions.OpenLocationAction;
|
---|
| 73 | import org.openstreetmap.josm.actions.OrthogonalizeAction;
|
---|
[5965] | 74 | import org.openstreetmap.josm.actions.OrthogonalizeAction.Undo;
|
---|
[404] | 75 | import org.openstreetmap.josm.actions.PasteAction;
|
---|
[10766] | 76 | import org.openstreetmap.josm.actions.PasteAtSourcePositionAction;
|
---|
[558] | 77 | import org.openstreetmap.josm.actions.PasteTagsAction;
|
---|
[5965] | 78 | import org.openstreetmap.josm.actions.PreferenceToggleAction;
|
---|
[404] | 79 | import org.openstreetmap.josm.actions.PreferencesAction;
|
---|
[3431] | 80 | import org.openstreetmap.josm.actions.PurgeAction;
|
---|
[404] | 81 | import org.openstreetmap.josm.actions.RedoAction;
|
---|
[7624] | 82 | import org.openstreetmap.josm.actions.ReportBugAction;
|
---|
[5857] | 83 | import org.openstreetmap.josm.actions.RestartAction;
|
---|
[404] | 84 | import org.openstreetmap.josm.actions.ReverseWayAction;
|
---|
| 85 | import org.openstreetmap.josm.actions.SaveAction;
|
---|
| 86 | import org.openstreetmap.josm.actions.SaveAsAction;
|
---|
[8071] | 87 | import org.openstreetmap.josm.actions.SearchNotesDownloadAction;
|
---|
[404] | 88 | import org.openstreetmap.josm.actions.SelectAllAction;
|
---|
[6544] | 89 | import org.openstreetmap.josm.actions.SelectNonBranchingWaySequencesAction;
|
---|
[4685] | 90 | import org.openstreetmap.josm.actions.SessionSaveAsAction;
|
---|
[1416] | 91 | import org.openstreetmap.josm.actions.ShowStatusReportAction;
|
---|
[2575] | 92 | import org.openstreetmap.josm.actions.SimplifyWayAction;
|
---|
[404] | 93 | import org.openstreetmap.josm.actions.SplitWayAction;
|
---|
[12834] | 94 | import org.openstreetmap.josm.actions.TaggingPresetSearchAction;
|
---|
[858] | 95 | import org.openstreetmap.josm.actions.UnGlueAction;
|
---|
[6253] | 96 | import org.openstreetmap.josm.actions.UnJoinNodeWayAction;
|
---|
[404] | 97 | import org.openstreetmap.josm.actions.UndoAction;
|
---|
| 98 | import org.openstreetmap.josm.actions.UnselectAllAction;
|
---|
[1434] | 99 | import org.openstreetmap.josm.actions.UpdateDataAction;
|
---|
[2682] | 100 | import org.openstreetmap.josm.actions.UpdateModifiedAction;
|
---|
[1670] | 101 | import org.openstreetmap.josm.actions.UpdateSelectionAction;
|
---|
[404] | 102 | import org.openstreetmap.josm.actions.UploadAction;
|
---|
[2250] | 103 | import org.openstreetmap.josm.actions.UploadSelectionAction;
|
---|
[3837] | 104 | import org.openstreetmap.josm.actions.ViewportFollowToggleAction;
|
---|
[2530] | 105 | import org.openstreetmap.josm.actions.WireframeToggleAction;
|
---|
[768] | 106 | import org.openstreetmap.josm.actions.ZoomInAction;
|
---|
| 107 | import org.openstreetmap.josm.actions.ZoomOutAction;
|
---|
[547] | 108 | import org.openstreetmap.josm.actions.audio.AudioBackAction;
|
---|
[768] | 109 | import org.openstreetmap.josm.actions.audio.AudioFasterAction;
|
---|
[547] | 110 | import org.openstreetmap.josm.actions.audio.AudioFwdAction;
|
---|
| 111 | import org.openstreetmap.josm.actions.audio.AudioNextAction;
|
---|
| 112 | import org.openstreetmap.josm.actions.audio.AudioPlayPauseAction;
|
---|
| 113 | import org.openstreetmap.josm.actions.audio.AudioPrevAction;
|
---|
[563] | 114 | import org.openstreetmap.josm.actions.audio.AudioSlowerAction;
|
---|
[404] | 115 | import org.openstreetmap.josm.actions.search.SearchAction;
|
---|
[9347] | 116 | import org.openstreetmap.josm.gui.dialogs.MenuItemSearchDialog;
|
---|
[3710] | 117 | import org.openstreetmap.josm.gui.io.RecentlyOpenedFilesMenu;
|
---|
[10345] | 118 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
|
---|
| 119 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
|
---|
[5086] | 120 | import org.openstreetmap.josm.gui.mappaint.MapPaintMenu;
|
---|
[6426] | 121 | import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference;
|
---|
| 122 | import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
|
---|
[8863] | 123 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSearchPrimitiveDialog;
|
---|
[12846] | 124 | import org.openstreetmap.josm.spi.preferences.Config;
|
---|
[1084] | 125 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
[3671] | 126 |
|
---|
[422] | 127 | /**
|
---|
[1130] | 128 | * This is the JOSM main menu bar. It is overwritten to initialize itself and provide all menu
|
---|
| 129 | * entries as member variables (sort of collect them).
|
---|
[1169] | 130 | *
|
---|
[422] | 131 | * It also provides possibilities to attach new menu entries (used by plugins).
|
---|
[1169] | 132 | *
|
---|
[422] | 133 | * @author Immanuel.Scholz
|
---|
| 134 | */
|
---|
| 135 | public class MainMenu extends JMenuBar {
|
---|
| 136 |
|
---|
[8836] | 137 | public enum WINDOW_MENU_GROUP { ALWAYS, TOGGLE_DIALOG, VOLATILE }
|
---|
[8510] | 138 |
|
---|
[1130] | 139 | /* File menu */
|
---|
[6830] | 140 | /** File / New Layer **/
|
---|
[1130] | 141 | public final NewAction newAction = new NewAction();
|
---|
[6830] | 142 | /** File / Open... **/
|
---|
[1146] | 143 | public final OpenFileAction openFile = new OpenFileAction();
|
---|
[6830] | 144 | /** File / Open Recent > **/
|
---|
[3710] | 145 | public final RecentlyOpenedFilesMenu recentlyOpened = new RecentlyOpenedFilesMenu();
|
---|
[6830] | 146 | /** File / Open Location... **/
|
---|
[1146] | 147 | public final OpenLocationAction openLocation = new OpenLocationAction();
|
---|
[9443] | 148 | /** File / Delete Layer **/
|
---|
| 149 | public final DeleteLayerAction deleteLayerAction = new DeleteLayerAction();
|
---|
[6830] | 150 | /** File / Save **/
|
---|
[6180] | 151 | public final SaveAction save = SaveAction.getInstance();
|
---|
[6830] | 152 | /** File / Save As... **/
|
---|
[6180] | 153 | public final SaveAsAction saveAs = SaveAsAction.getInstance();
|
---|
[6830] | 154 | /** File / Session > Save Session As... **/
|
---|
[6180] | 155 | public SessionSaveAsAction sessionSaveAs;
|
---|
[6830] | 156 | /** File / Export to GPX... **/
|
---|
[6180] | 157 | public final GpxExportAction gpxExport = new GpxExportAction();
|
---|
[6830] | 158 | /** File / Download from OSM... **/
|
---|
[1130] | 159 | public final DownloadAction download = new DownloadAction();
|
---|
[10816] | 160 | /** File / Download in current view **/
|
---|
| 161 | public final DownloadOsmInViewAction downloadInView = new DownloadOsmInViewAction();
|
---|
[6830] | 162 | /** File / Download object... **/
|
---|
[2923] | 163 | public final DownloadPrimitiveAction downloadPrimitive = new DownloadPrimitiveAction();
|
---|
[8212] | 164 | /** File / Download notes in current view **/
|
---|
| 165 | public final DownloadNotesInViewAction downloadNotesInView = DownloadNotesInViewAction.newActionWithNoteIcon();
|
---|
[8071] | 166 | /** File / Search Notes... **/
|
---|
| 167 | public final SearchNotesDownloadAction searchNotes = new SearchNotesDownloadAction();
|
---|
[6830] | 168 | /** File / Download parent ways/relations... **/
|
---|
[1810] | 169 | public final DownloadReferrersAction downloadReferrers = new DownloadReferrersAction();
|
---|
[6830] | 170 | /** File / Close open changesets... **/
|
---|
[2115] | 171 | public final CloseChangesetAction closeChangesetAction = new CloseChangesetAction();
|
---|
[6830] | 172 | /** File / Update data **/
|
---|
[1434] | 173 | public final JosmAction update = new UpdateDataAction();
|
---|
[6830] | 174 | /** File / Update selection **/
|
---|
[1670] | 175 | public final JosmAction updateSelection = new UpdateSelectionAction();
|
---|
[6830] | 176 | /** File / Update modified **/
|
---|
[2682] | 177 | public final JosmAction updateModified = new UpdateModifiedAction();
|
---|
[6830] | 178 | /** File / Upload data **/
|
---|
[1130] | 179 | public final JosmAction upload = new UploadAction();
|
---|
[6830] | 180 | /** File / Upload selection **/
|
---|
[2250] | 181 | public final JosmAction uploadSelection = new UploadSelectionAction();
|
---|
[6830] | 182 | /** File / Restart **/
|
---|
[6180] | 183 | public final RestartAction restart = new RestartAction();
|
---|
[6830] | 184 | /** File / Exit **/
|
---|
[6180] | 185 | public final ExitAction exit = new ExitAction();
|
---|
[1023] | 186 |
|
---|
[1130] | 187 | /* Edit menu */
|
---|
[6830] | 188 | /** Edit / Undo... */
|
---|
[1130] | 189 | public final UndoAction undo = new UndoAction();
|
---|
[6830] | 190 | /** Edit / Redo */
|
---|
[1130] | 191 | public final RedoAction redo = new RedoAction();
|
---|
[6830] | 192 | /** Edit / Copy */
|
---|
[6180] | 193 | public final CopyAction copy = new CopyAction();
|
---|
[6830] | 194 | /** Edit / Copy Coordinates */
|
---|
[4380] | 195 | public final JosmAction copyCoordinates = new CopyCoordinatesAction();
|
---|
[6830] | 196 | /** Edit / Paste */
|
---|
[3969] | 197 | public final PasteAction paste = new PasteAction();
|
---|
[10766] | 198 | /** Edit / Paste at source */
|
---|
| 199 | private final PasteAtSourcePositionAction pasteAtSource = new PasteAtSourcePositionAction();
|
---|
[6830] | 200 | /** Edit / Paste Tags */
|
---|
[6180] | 201 | public final PasteTagsAction pasteTags = new PasteTagsAction();
|
---|
[6830] | 202 | /** Edit / Duplicate */
|
---|
[6180] | 203 | public final DuplicateAction duplicate = new DuplicateAction();
|
---|
[6830] | 204 | /** Edit / Delete */
|
---|
[6180] | 205 | public final DeleteAction delete = new DeleteAction();
|
---|
[6830] | 206 | /** Edit / Purge... */
|
---|
[3431] | 207 | public final JosmAction purge = new PurgeAction();
|
---|
[6830] | 208 | /** Edit / Merge layer */
|
---|
[6180] | 209 | public final MergeLayerAction merge = new MergeLayerAction();
|
---|
[6830] | 210 | /** Edit / Merge selection */
|
---|
[6180] | 211 | public final MergeSelectionAction mergeSelected = new MergeSelectionAction();
|
---|
[6830] | 212 | /** Edit / Search... */
|
---|
[6180] | 213 | public final SearchAction search = new SearchAction();
|
---|
[6830] | 214 | /** Edit / Preferences */
|
---|
[6180] | 215 | public final PreferencesAction preferences = new PreferencesAction();
|
---|
[1023] | 216 |
|
---|
[1130] | 217 | /* View menu */
|
---|
[6830] | 218 | /** View / Wireframe View */
|
---|
[3894] | 219 | public final WireframeToggleAction wireFrameToggleAction = new WireframeToggleAction();
|
---|
[6830] | 220 | /** View / Advanced info */
|
---|
[3704] | 221 | public final InfoAction info = new InfoAction();
|
---|
[6830] | 222 | /** View / Advanced info (web) */
|
---|
[4408] | 223 | public final InfoWebAction infoweb = new InfoWebAction();
|
---|
[6830] | 224 | /** View / History */
|
---|
[3704] | 225 | public final HistoryInfoAction historyinfo = new HistoryInfoAction();
|
---|
[6830] | 226 | /** View / History (web) */
|
---|
[4408] | 227 | public final HistoryInfoWebAction historyinfoweb = new HistoryInfoWebAction();
|
---|
[6830] | 228 | /** View / "Zoom to"... actions */
|
---|
[8399] | 229 | public final Map<String, AutoScaleAction> autoScaleActions = new HashMap<>();
|
---|
[6830] | 230 | /** View / Jump to position */
|
---|
[6394] | 231 | public final JumpToAction jumpToAct = new JumpToAction();
|
---|
[1023] | 232 |
|
---|
[1130] | 233 | /* Tools menu */
|
---|
[6830] | 234 | /** Tools / Split Way */
|
---|
[6412] | 235 | public final SplitWayAction splitWay = new SplitWayAction();
|
---|
[6830] | 236 | /** Tools / Combine Way */
|
---|
[6412] | 237 | public final CombineWayAction combineWay = new CombineWayAction();
|
---|
[6830] | 238 | /** Tools / Reverse Ways */
|
---|
[6412] | 239 | public final ReverseWayAction reverseWay = new ReverseWayAction();
|
---|
[6830] | 240 | /** Tools / Simplify Way */
|
---|
[6412] | 241 | public final SimplifyWayAction simplifyWay = new SimplifyWayAction();
|
---|
[6830] | 242 | /** Tools / Align Nodes in Circle */
|
---|
[6412] | 243 | public final AlignInCircleAction alignInCircle = new AlignInCircleAction();
|
---|
[6830] | 244 | /** Tools / Align Nodes in Line */
|
---|
[6412] | 245 | public final AlignInLineAction alignInLine = new AlignInLineAction();
|
---|
[6830] | 246 | /** Tools / Distribute Nodes */
|
---|
[6412] | 247 | public final DistributeAction distribute = new DistributeAction();
|
---|
[6830] | 248 | /** Tools / Orthogonalize Shape */
|
---|
[2268] | 249 | public final OrthogonalizeAction ortho = new OrthogonalizeAction();
|
---|
[6398] | 250 | /** Orthogonalize undo. Action is not shown in the menu. Only triggered by shortcut */
|
---|
[6412] | 251 | public final Undo orthoUndo = new Undo();
|
---|
[6830] | 252 | /** Tools / Mirror */
|
---|
[6412] | 253 | public final MirrorAction mirror = new MirrorAction();
|
---|
[6830] | 254 | /** Tools / Follow line */
|
---|
[6412] | 255 | public final FollowLineAction followLine = new FollowLineAction();
|
---|
[6830] | 256 | /** Tools / Add Node... */
|
---|
[6412] | 257 | public final AddNodeAction addNode = new AddNodeAction();
|
---|
[6830] | 258 | /** Tools / Move Node... */
|
---|
[6412] | 259 | public final MoveNodeAction moveNode = new MoveNodeAction();
|
---|
[6830] | 260 | /** Tools / Create Circle */
|
---|
[6412] | 261 | public final CreateCircleAction createCircle = new CreateCircleAction();
|
---|
[6830] | 262 | /** Tools / Merge Nodes */
|
---|
[6412] | 263 | public final MergeNodesAction mergeNodes = new MergeNodesAction();
|
---|
[6830] | 264 | /** Tools / Join Node to Way */
|
---|
[7131] | 265 | public final JoinNodeWayAction joinNodeWay = JoinNodeWayAction.createJoinNodeToWayAction();
|
---|
| 266 | /** Tools / Join Way to Node */
|
---|
| 267 | public final JoinNodeWayAction moveNodeOntoWay = JoinNodeWayAction.createMoveNodeOntoWayAction();
|
---|
[6830] | 268 | /** Tools / Disconnect Node from Way */
|
---|
[6412] | 269 | public final UnJoinNodeWayAction unJoinNodeWay = new UnJoinNodeWayAction();
|
---|
[6830] | 270 | /** Tools / Unglue Ways */
|
---|
[6412] | 271 | public final UnGlueAction unglueNodes = new UnGlueAction();
|
---|
[6830] | 272 | /** Tools / Join overlapping Areas */
|
---|
[6412] | 273 | public final JoinAreasAction joinAreas = new JoinAreasAction();
|
---|
[6830] | 274 | /** Tools / Create multipolygon */
|
---|
[6597] | 275 | public final CreateMultipolygonAction createMultipolygon = new CreateMultipolygonAction(false);
|
---|
[6830] | 276 | /** Tools / Update multipolygon */
|
---|
[6597] | 277 | public final CreateMultipolygonAction updateMultipolygon = new CreateMultipolygonAction(true);
|
---|
[450] | 278 |
|
---|
[6180] | 279 | /* Selection menu */
|
---|
[6830] | 280 | /** Selection / Select All */
|
---|
[6180] | 281 | public final SelectAllAction selectAll = new SelectAllAction();
|
---|
[6830] | 282 | /** Selection / Unselect All */
|
---|
[6180] | 283 | public final UnselectAllAction unselectAll = new UnselectAllAction();
|
---|
[6830] | 284 | /** Selection / Non-branching way sequences */
|
---|
[6544] | 285 | public final SelectNonBranchingWaySequencesAction nonBranchingWaySequences = new SelectNonBranchingWaySequencesAction();
|
---|
[6180] | 286 |
|
---|
[1130] | 287 | /* Audio menu */
|
---|
[6830] | 288 | /** Audio / Play/Pause */
|
---|
[1130] | 289 | public final JosmAction audioPlayPause = new AudioPlayPauseAction();
|
---|
[6830] | 290 | /** Audio / Next marker */
|
---|
[1130] | 291 | public final JosmAction audioNext = new AudioNextAction();
|
---|
[6830] | 292 | /** Audio / Previous Marker */
|
---|
[1130] | 293 | public final JosmAction audioPrev = new AudioPrevAction();
|
---|
[6830] | 294 | /** Audio / Forward */
|
---|
[1130] | 295 | public final JosmAction audioFwd = new AudioFwdAction();
|
---|
[6830] | 296 | /** Audio / Back */
|
---|
[1130] | 297 | public final JosmAction audioBack = new AudioBackAction();
|
---|
[6830] | 298 | /** Audio / Faster */
|
---|
[1130] | 299 | public final JosmAction audioFaster = new AudioFasterAction();
|
---|
[6830] | 300 | /** Audio / Slower */
|
---|
[1130] | 301 | public final JosmAction audioSlower = new AudioSlowerAction();
|
---|
[547] | 302 |
|
---|
[6180] | 303 | /* Windows Menu */
|
---|
[6830] | 304 | /** Windows / Changeset Manager */
|
---|
[6180] | 305 | public final ChangesetManagerToggleAction changesetManager = new ChangesetManagerToggleAction();
|
---|
[6830] | 306 |
|
---|
[1130] | 307 | /* Help menu */
|
---|
[6830] | 308 | /** Help / Help */
|
---|
[1130] | 309 | public final HelpAction help = new HelpAction();
|
---|
[6830] | 310 | /** Help / About */
|
---|
[6180] | 311 | public final AboutAction about = new AboutAction();
|
---|
[6830] | 312 | /** Help / Show Status Report */
|
---|
[6180] | 313 | public final ShowStatusReportAction statusreport = new ShowStatusReportAction();
|
---|
[7624] | 314 | /** Help / Report bug */
|
---|
| 315 | public final ReportBugAction reportbug = new ReportBugAction();
|
---|
[1023] | 316 |
|
---|
[6180] | 317 | /**
|
---|
| 318 | * fileMenu contains I/O actions
|
---|
| 319 | */
|
---|
[8792] | 320 | public final JMenu fileMenu = addMenu("File", /* I18N: mnemonic: F */ trc("menu", "File"), KeyEvent.VK_F, 0, ht("/Menu/File"));
|
---|
[6180] | 321 | /**
|
---|
| 322 | * editMenu contains editing actions
|
---|
| 323 | */
|
---|
[8792] | 324 | public final JMenu editMenu = addMenu("Edit", /* I18N: mnemonic: E */ trc("menu", "Edit"), KeyEvent.VK_E, 1, ht("/Menu/Edit"));
|
---|
[6180] | 325 | /**
|
---|
| 326 | * viewMenu contains display actions (zoom, map styles, etc.)
|
---|
| 327 | */
|
---|
[8792] | 328 | public final JMenu viewMenu = addMenu("View", /* I18N: mnemonic: V */ trc("menu", "View"), KeyEvent.VK_V, 2, ht("/Menu/View"));
|
---|
[6082] | 329 | /**
|
---|
| 330 | * toolsMenu contains different geometry manipulation actions from JOSM core (most used)
|
---|
| 331 | * The plugins should use other menus
|
---|
| 332 | */
|
---|
[8792] | 333 | public final JMenu toolsMenu = addMenu("Tools", /* I18N: mnemonic: T */ trc("menu", "Tools"), KeyEvent.VK_T, 3, ht("/Menu/Tools"));
|
---|
[6082] | 334 | /**
|
---|
| 335 | * moreToolsMenu contains geometry-related actions from all the plugins
|
---|
| 336 | * @since 6082 (moved from Utilsplugin2)
|
---|
| 337 | */
|
---|
[8836] | 338 | // CHECKSTYLE.OFF: LineLength
|
---|
[8792] | 339 | public final JMenu moreToolsMenu = addMenu("More tools", /* I18N: mnemonic: M */ trc("menu", "More tools"), KeyEvent.VK_M, 4, ht("/Menu/MoreTools"));
|
---|
[6082] | 340 | /**
|
---|
| 341 | * dataMenu contains plugin actions that are related to certain tagging schemes (addressing opening hours),
|
---|
| 342 | * importing external data and using external web APIs
|
---|
[6830] | 343 | * @since 6082
|
---|
| 344 | */
|
---|
[8792] | 345 | public final JMenu dataMenu = addMenu("Data", /* I18N: mnemonic: D */ trc("menu", "Data"), KeyEvent.VK_D, 5, ht("/Menu/Data"));
|
---|
[6180] | 346 | /**
|
---|
[6082] | 347 | * selectionMenu contains all actions related to selecting different objects
|
---|
| 348 | * @since 6082 (moved from Utilsplugin2)
|
---|
| 349 | */
|
---|
[8792] | 350 | public final JMenu selectionMenu = addMenu("Selection", /* I18N: mnemonic: N */ trc("menu", "Selection"), KeyEvent.VK_N, 6, ht("/Menu/Selection"));
|
---|
[6180] | 351 | /**
|
---|
| 352 | * presetsMenu contains presets actions (search, presets tree)
|
---|
| 353 | */
|
---|
[8792] | 354 | public final JMenu presetsMenu = addMenu("Presets", /* I18N: mnemonic: P */ trc("menu", "Presets"), KeyEvent.VK_P, 7, ht("/Menu/Presets"));
|
---|
[6097] | 355 | /**
|
---|
[6830] | 356 | * submenu in Imagery menu that contains plugin-managed additional imagery layers
|
---|
[6097] | 357 | * @since 6097
|
---|
| 358 | */
|
---|
| 359 | public final JMenu imagerySubMenu = new JMenu(tr("More..."));
|
---|
[6180] | 360 | /**
|
---|
| 361 | * imageryMenu contains all imagery-related actions
|
---|
| 362 | */
|
---|
[9261] | 363 | public final ImageryMenu imageryMenu = addMenu(new ImageryMenu(imagerySubMenu), /* untranslated name */ "Imagery", KeyEvent.VK_I, 8, ht("/Menu/Imagery"));
|
---|
[8721] | 364 | // CHECKSTYLE.ON: LineLength
|
---|
[6180] | 365 | /**
|
---|
[6082] | 366 | * gpsMenu contains all plugin actions that are related
|
---|
| 367 | * to using GPS data, including opening, uploading and real-time tracking
|
---|
[6830] | 368 | * @since 6082
|
---|
[6082] | 369 | */
|
---|
[8792] | 370 | public final JMenu gpsMenu = addMenu("GPS", /* I18N: mnemonic: G */ trc("menu", "GPS"), KeyEvent.VK_G, 9, ht("/Menu/GPS"));
|
---|
[4590] | 371 | /** the window menu is split into several groups. The first is for windows that can be opened from
|
---|
| 372 | * this menu any time, e.g. the changeset editor. The second group is for toggle dialogs and the third
|
---|
| 373 | * group is for currently open windows that cannot be toggled, e.g. relation editors. It's recommended
|
---|
| 374 | * to use WINDOW_MENU_GROUP to determine the group integer.
|
---|
| 375 | */
|
---|
[11769] | 376 | public final JMenu windowMenu = addMenu("Windows", /* I18N: mnemonic: W */ trc("menu", "Windows"), KeyEvent.VK_W, 10, ht("/ToggleDialogs"));
|
---|
[4590] | 377 |
|
---|
[6180] | 378 | /**
|
---|
| 379 | * audioMenu contains all audio-related actions. Be careful, this menu is not guaranteed to be displayed at all
|
---|
| 380 | */
|
---|
[8840] | 381 | public JMenu audioMenu;
|
---|
[6180] | 382 | /**
|
---|
| 383 | * helpMenu contains JOSM general actions (Help, About, etc.)
|
---|
| 384 | */
|
---|
[8792] | 385 | public final JMenu helpMenu = addMenu("Help", /* I18N: mnemonic: H */ trc("menu", "Help"), KeyEvent.VK_H, 11, ht("/Menu/Help"));
|
---|
[4668] | 386 |
|
---|
[6246] | 387 | private static final int defaultMenuPos = 11;
|
---|
[422] | 388 |
|
---|
[3327] | 389 | public final JosmAction moveUpAction = new MoveAction(MoveAction.Direction.UP);
|
---|
| 390 | public final JosmAction moveDownAction = new MoveAction(MoveAction.Direction.DOWN);
|
---|
| 391 | public final JosmAction moveLeftAction = new MoveAction(MoveAction.Direction.LEFT);
|
---|
| 392 | public final JosmAction moveRightAction = new MoveAction(MoveAction.Direction.RIGHT);
|
---|
| 393 |
|
---|
[3388] | 394 | public final TaggingPresetSearchAction presetSearchAction = new TaggingPresetSearchAction();
|
---|
[6738] | 395 | public final TaggingPresetSearchPrimitiveDialog.Action presetSearchPrimitiveAction = new TaggingPresetSearchPrimitiveDialog.Action();
|
---|
[5965] | 396 | public final DialogsToggleAction dialogsToggleAction = new DialogsToggleAction();
|
---|
[8840] | 397 | public FullscreenToggleAction fullscreenToggleAction;
|
---|
[4590] | 398 |
|
---|
| 399 | /** this menu listener hides unnecessary JSeparators in a menu list but does not remove them.
|
---|
| 400 | * If at a later time the separators are required, they will be made visible again. Intended
|
---|
| 401 | * usage is make menus not look broken if separators are used to group the menu and some of
|
---|
| 402 | * these groups are empty.
|
---|
| 403 | */
|
---|
[6889] | 404 | public static final MenuListener menuSeparatorHandler = new MenuListener() {
|
---|
[4590] | 405 | @Override
|
---|
[10173] | 406 | public void menuCanceled(MenuEvent e) {
|
---|
| 407 | // Do nothing
|
---|
| 408 | }
|
---|
[8510] | 409 |
|
---|
[4590] | 410 | @Override
|
---|
[10173] | 411 | public void menuDeselected(MenuEvent e) {
|
---|
| 412 | // Do nothing
|
---|
| 413 | }
|
---|
[8510] | 414 |
|
---|
[4590] | 415 | @Override
|
---|
| 416 | public void menuSelected(MenuEvent a) {
|
---|
[8510] | 417 | if (!(a.getSource() instanceof JMenu))
|
---|
[4590] | 418 | return;
|
---|
| 419 | final JPopupMenu m = ((JMenu) a.getSource()).getPopupMenu();
|
---|
[8510] | 420 | for (int i = 0; i < m.getComponentCount()-1; i++) {
|
---|
| 421 | if (!(m.getComponent(i) instanceof JSeparator)) {
|
---|
[4590] | 422 | continue;
|
---|
| 423 | }
|
---|
| 424 | // hide separator if the next menu item is one as well
|
---|
| 425 | ((JSeparator) m.getComponent(i)).setVisible(!(m.getComponent(i+1) instanceof JSeparator));
|
---|
| 426 | }
|
---|
| 427 | // hide separator at the end of the menu
|
---|
[8510] | 428 | if (m.getComponent(m.getComponentCount()-1) instanceof JSeparator) {
|
---|
[4590] | 429 | ((JSeparator) m.getComponent(m.getComponentCount()-1)).setVisible(false);
|
---|
| 430 | }
|
---|
| 431 | }
|
---|
| 432 | };
|
---|
[6830] | 433 |
|
---|
[6088] | 434 | /**
|
---|
[9347] | 435 | * @return the default position of new top-level menus
|
---|
[6088] | 436 | * @since 6088
|
---|
| 437 | */
|
---|
[6830] | 438 | public int getDefaultMenuPos() {
|
---|
| 439 | return defaultMenuPos;
|
---|
[6088] | 440 | }
|
---|
[4590] | 441 |
|
---|
[1130] | 442 | /**
|
---|
[5089] | 443 | * Add a JosmAction at the end of a menu.
|
---|
[1169] | 444 | *
|
---|
[1130] | 445 | * This method handles all the shortcut handling. It also makes sure that actions that are
|
---|
[5089] | 446 | * handled by the OS are not duplicated on the menu.
|
---|
| 447 | * @param menu the menu to add the action to
|
---|
| 448 | * @param action the action that should get a menu item
|
---|
| 449 | * @return the created menu item
|
---|
[1130] | 450 | */
|
---|
[1180] | 451 | public static JMenuItem add(JMenu menu, JosmAction action) {
|
---|
[4843] | 452 | return add(menu, action, false);
|
---|
| 453 | }
|
---|
| 454 |
|
---|
[5089] | 455 | /**
|
---|
| 456 | * Add a JosmAction at the end of a menu.
|
---|
| 457 | *
|
---|
| 458 | * This method handles all the shortcut handling. It also makes sure that actions that are
|
---|
| 459 | * handled by the OS are not duplicated on the menu.
|
---|
| 460 | * @param menu the menu to add the action to
|
---|
| 461 | * @param action the action that should get a menu item
|
---|
| 462 | * @param isExpert whether the entry should only be visible if the expert mode is activated
|
---|
| 463 | * @return the created menu item
|
---|
| 464 | */
|
---|
[4843] | 465 | public static JMenuItem add(JMenu menu, JosmAction action, boolean isExpert) {
|
---|
[5089] | 466 | return add(menu, action, isExpert, null);
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | /**
|
---|
| 470 | * Add a JosmAction at the end of a menu.
|
---|
| 471 | *
|
---|
| 472 | * This method handles all the shortcut handling. It also makes sure that actions that are
|
---|
| 473 | * handled by the OS are not duplicated on the menu.
|
---|
| 474 | * @param menu the menu to add the action to
|
---|
| 475 | * @param action the action that should get a menu item
|
---|
| 476 | * @param isExpert whether the entry should only be visible if the expert mode is activated
|
---|
| 477 | * @param index an integer specifying the position at which to add the action
|
---|
| 478 | * @return the created menu item
|
---|
| 479 | */
|
---|
| 480 | public static JMenuItem add(JMenu menu, JosmAction action, boolean isExpert, Integer index) {
|
---|
[8380] | 481 | if (action.getShortcut().isAutomatic())
|
---|
[4590] | 482 | return null;
|
---|
[5089] | 483 | final JMenuItem menuitem;
|
---|
| 484 | if (index == null) {
|
---|
| 485 | menuitem = menu.add(action);
|
---|
| 486 | } else {
|
---|
| 487 | menuitem = menu.insert(action, index);
|
---|
| 488 | }
|
---|
[4843] | 489 | if (isExpert) {
|
---|
| 490 | ExpertToggleAction.addVisibilitySwitcher(menuitem);
|
---|
| 491 | }
|
---|
| 492 | KeyStroke ks = action.getShortcut().getKeyStroke();
|
---|
| 493 | if (ks != null) {
|
---|
| 494 | menuitem.setAccelerator(ks);
|
---|
| 495 | }
|
---|
[6082] | 496 | // some menus are hidden before they are populated with some items by plugins
|
---|
| 497 | if (!menu.isVisible()) menu.setVisible(true);
|
---|
[4590] | 498 | return menuitem;
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | /**
|
---|
[5089] | 502 | * Add the JosmAction {@code actionToBeInserted} directly below {@code existingMenuEntryAction}.
|
---|
| 503 | *
|
---|
| 504 | * This method handles all the shortcut handling. It also makes sure that actions that are
|
---|
| 505 | * handled by the OS are not duplicated on the menu.
|
---|
| 506 | * @param menu the menu to add the action to
|
---|
| 507 | * @param actionToBeInserted the action that should get a menu item directly below {@code existingMenuEntryAction}
|
---|
| 508 | * @param isExpert whether the entry should only be visible if the expert mode is activated
|
---|
[8540] | 509 | * @param existingMenuEntryAction an action already added to the menu {@code menu},
|
---|
| 510 | * the action {@code actionToBeInserted} is added directly below
|
---|
[5089] | 511 | * @return the created menu item
|
---|
| 512 | */
|
---|
| 513 | public static JMenuItem addAfter(JMenu menu, JosmAction actionToBeInserted, boolean isExpert, JosmAction existingMenuEntryAction) {
|
---|
| 514 | int i = 0;
|
---|
| 515 | for (Component c : menu.getMenuComponents()) {
|
---|
| 516 | if (c instanceof JMenuItem && ((JMenuItem) c).getAction() == existingMenuEntryAction) {
|
---|
| 517 | break;
|
---|
| 518 | }
|
---|
| 519 | i++;
|
---|
| 520 | }
|
---|
| 521 | return add(menu, actionToBeInserted, isExpert, i + 1);
|
---|
| 522 | }
|
---|
| 523 |
|
---|
| 524 | /**
|
---|
[4590] | 525 | * Add a JosmAction to a menu.
|
---|
| 526 | *
|
---|
| 527 | * This method handles all the shortcut handling. It also makes sure that actions that are
|
---|
| 528 | * handled by the OS are not duplicated on the menu.
|
---|
[9246] | 529 | * @param <E> group item enum type
|
---|
[4590] | 530 | * @param menu to add the action to
|
---|
[5089] | 531 | * @param action the action that should get a menu item
|
---|
[4590] | 532 | * @param group the item should be added to. Groups are split by a separator.
|
---|
| 533 | * 0 is the first group, -1 will add the item to the end.
|
---|
[6180] | 534 | * @return The created menu item
|
---|
[4590] | 535 | */
|
---|
| 536 | public static <E extends Enum<E>> JMenuItem add(JMenu menu, JosmAction action, Enum<E> group) {
|
---|
[8380] | 537 | if (action.getShortcut().isAutomatic())
|
---|
[4590] | 538 | return null;
|
---|
| 539 | int i = getInsertionIndexForGroup(menu, group.ordinal());
|
---|
| 540 | JMenuItem menuitem = (JMenuItem) menu.add(new JMenuItem(action), i);
|
---|
| 541 | KeyStroke ks = action.getShortcut().getKeyStroke();
|
---|
| 542 | if (ks != null) {
|
---|
| 543 | menuitem.setAccelerator(ks);
|
---|
[1130] | 544 | }
|
---|
[1180] | 545 | return menuitem;
|
---|
[1130] | 546 | }
|
---|
[2372] | 547 |
|
---|
[4590] | 548 | /**
|
---|
| 549 | * Add a JosmAction to a menu and automatically prints accelerator if available.
|
---|
| 550 | * Also adds a checkbox that may be toggled.
|
---|
[9246] | 551 | * @param <E> group enum item type
|
---|
[4590] | 552 | * @param menu to add the action to
|
---|
[5089] | 553 | * @param action the action that should get a menu item
|
---|
[4590] | 554 | * @param group the item should be added to. Groups are split by a separator. Use
|
---|
| 555 | * one of the enums that are defined for some of the menus to tell in which
|
---|
| 556 | * group the item should go.
|
---|
[6180] | 557 | * @return The created menu item
|
---|
[4590] | 558 | */
|
---|
| 559 | public static <E extends Enum<E>> JCheckBoxMenuItem addWithCheckbox(JMenu menu, JosmAction action, Enum<E> group) {
|
---|
| 560 | int i = getInsertionIndexForGroup(menu, group.ordinal());
|
---|
| 561 | final JCheckBoxMenuItem mi = (JCheckBoxMenuItem) menu.add(new JCheckBoxMenuItem(action), i);
|
---|
| 562 | final KeyStroke ks = action.getShortcut().getKeyStroke();
|
---|
| 563 | if (ks != null) {
|
---|
| 564 | mi.setAccelerator(ks);
|
---|
| 565 | }
|
---|
| 566 | return mi;
|
---|
| 567 | }
|
---|
| 568 |
|
---|
[9243] | 569 | /**
|
---|
| 570 | * Finds the correct insertion index for a given group and adds separators if necessary
|
---|
| 571 | * @param menu menu
|
---|
| 572 | * @param group group number
|
---|
| 573 | * @return correct insertion index
|
---|
| 574 | */
|
---|
[4590] | 575 | private static int getInsertionIndexForGroup(JMenu menu, int group) {
|
---|
[8510] | 576 | if (group < 0)
|
---|
[4590] | 577 | return -1;
|
---|
| 578 | // look for separator that *ends* the group (or stop at end of menu)
|
---|
| 579 | int i;
|
---|
[8510] | 580 | for (i = 0; i < menu.getItemCount() && group >= 0; i++) {
|
---|
| 581 | if (menu.getItem(i) == null) {
|
---|
[4590] | 582 | group--;
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
| 585 | // insert before separator that ends the group
|
---|
[8510] | 586 | if (group < 0) {
|
---|
[4590] | 587 | i--;
|
---|
| 588 | }
|
---|
| 589 | // not enough separators have been found, add them
|
---|
[8510] | 590 | while (group > 0) {
|
---|
[4590] | 591 | menu.addSeparator();
|
---|
| 592 | group--;
|
---|
| 593 | i++;
|
---|
| 594 | }
|
---|
| 595 | return i;
|
---|
| 596 | }
|
---|
| 597 |
|
---|
[8792] | 598 | /**
|
---|
| 599 | * Creates a menu and adds it on the given position to the main menu.
|
---|
| 600 | *
|
---|
| 601 | * @param name the untranslated name (used as identifier for shortcut registration)
|
---|
| 602 | * @param translatedName the translated menu name (use {@code I18n.trc("menu", name)} to allow better internationalization
|
---|
| 603 | * @param mnemonicKey the mnemonic key to register
|
---|
| 604 | * @param position the position in the main menu
|
---|
| 605 | * @param relativeHelpTopic the relative help topic
|
---|
| 606 | * @return the newly created menu
|
---|
| 607 | */
|
---|
| 608 | public JMenu addMenu(String name, String translatedName, int mnemonicKey, int position, String relativeHelpTopic) {
|
---|
| 609 | final JMenu menu = new JMenu(translatedName);
|
---|
[7075] | 610 | if (!GraphicsEnvironment.isHeadless()) {
|
---|
[7463] | 611 | MenuScroller.setScrollerFor(menu);
|
---|
[7075] | 612 | }
|
---|
[4593] | 613 | return addMenu(menu, name, mnemonicKey, position, relativeHelpTopic);
|
---|
[3737] | 614 | }
|
---|
| 615 |
|
---|
[8792] | 616 | /**
|
---|
| 617 | * Adds the given menu on the given position to the main menu.
|
---|
[9246] | 618 | * @param <T> menu type
|
---|
[8792] | 619 | *
|
---|
| 620 | * @param menu the menu to add
|
---|
| 621 | * @param name the untranslated name (used as identifier for shortcut registration)
|
---|
| 622 | * @param mnemonicKey the mnemonic key to register
|
---|
| 623 | * @param position the position in the main menu
|
---|
| 624 | * @param relativeHelpTopic the relative help topic
|
---|
| 625 | * @return the given {@code }menu}
|
---|
| 626 | */
|
---|
[6180] | 627 | public <T extends JMenu> T addMenu(T menu, String name, int mnemonicKey, int position, String relativeHelpTopic) {
|
---|
[9204] | 628 | Shortcut.registerShortcut("menu:" + name, tr("Menu: {0}", name), mnemonicKey,
|
---|
[4975] | 629 | Shortcut.MNEMONIC).setMnemonic(menu);
|
---|
[1498] | 630 | add(menu, position);
|
---|
[2323] | 631 | menu.putClientProperty("help", relativeHelpTopic);
|
---|
[1498] | 632 | return menu;
|
---|
[1130] | 633 | }
|
---|
[1023] | 634 |
|
---|
[6180] | 635 | /**
|
---|
[10340] | 636 | * Initialize the main menu.
|
---|
| 637 | * @since 10340
|
---|
[6180] | 638 | */
|
---|
[10340] | 639 | public void initialize() {
|
---|
[6082] | 640 | moreToolsMenu.setVisible(false);
|
---|
| 641 | dataMenu.setVisible(false);
|
---|
| 642 | gpsMenu.setVisible(false);
|
---|
[6830] | 643 |
|
---|
[1130] | 644 | add(fileMenu, newAction);
|
---|
[1146] | 645 | add(fileMenu, openFile);
|
---|
[3710] | 646 | fileMenu.add(recentlyOpened);
|
---|
[1146] | 647 | add(fileMenu, openLocation);
|
---|
[9443] | 648 | add(fileMenu, deleteLayerAction);
|
---|
[1130] | 649 | fileMenu.addSeparator();
|
---|
| 650 | add(fileMenu, save);
|
---|
| 651 | add(fileMenu, saveAs);
|
---|
[6129] | 652 | sessionSaveAs = new SessionSaveAsAction();
|
---|
[8801] | 653 | ExpertToggleAction.addVisibilitySwitcher(fileMenu.add(sessionSaveAs));
|
---|
[4843] | 654 | add(fileMenu, gpxExport, true);
|
---|
[1130] | 655 | fileMenu.addSeparator();
|
---|
| 656 | add(fileMenu, download);
|
---|
[10816] | 657 | add(fileMenu, downloadInView, true);
|
---|
[2923] | 658 | add(fileMenu, downloadPrimitive);
|
---|
[8071] | 659 | add(fileMenu, searchNotes);
|
---|
[8212] | 660 | add(fileMenu, downloadNotesInView);
|
---|
[1810] | 661 | add(fileMenu, downloadReferrers);
|
---|
[2253] | 662 | add(fileMenu, update);
|
---|
| 663 | add(fileMenu, updateSelection);
|
---|
[2682] | 664 | add(fileMenu, updateModified);
|
---|
[2253] | 665 | fileMenu.addSeparator();
|
---|
[1130] | 666 | add(fileMenu, upload);
|
---|
[2250] | 667 | add(fileMenu, uploadSelection);
|
---|
[4843] | 668 | Component sep = new JPopupMenu.Separator();
|
---|
| 669 | fileMenu.add(sep);
|
---|
| 670 | ExpertToggleAction.addVisibilitySwitcher(sep);
|
---|
| 671 | add(fileMenu, closeChangesetAction, true);
|
---|
[2253] | 672 | fileMenu.addSeparator();
|
---|
[5857] | 673 | add(fileMenu, restart);
|
---|
[1130] | 674 | add(fileMenu, exit);
|
---|
[422] | 675 |
|
---|
[1130] | 676 | add(editMenu, undo);
|
---|
[12641] | 677 | MainApplication.undoRedo.addCommandQueueListener(undo);
|
---|
[1130] | 678 | add(editMenu, redo);
|
---|
[12641] | 679 | MainApplication.undoRedo.addCommandQueueListener(redo);
|
---|
[1130] | 680 | editMenu.addSeparator();
|
---|
| 681 | add(editMenu, copy);
|
---|
[4843] | 682 | add(editMenu, copyCoordinates, true);
|
---|
[1130] | 683 | add(editMenu, paste);
|
---|
[10766] | 684 | add(editMenu, pasteAtSource, true);
|
---|
[1130] | 685 | add(editMenu, pasteTags);
|
---|
| 686 | add(editMenu, duplicate);
|
---|
[1219] | 687 | add(editMenu, delete);
|
---|
[4843] | 688 | add(editMenu, purge, true);
|
---|
[1130] | 689 | editMenu.addSeparator();
|
---|
[8510] | 690 | add(editMenu, merge);
|
---|
| 691 | add(editMenu, mergeSelected);
|
---|
[1890] | 692 | editMenu.addSeparator();
|
---|
[1130] | 693 | add(editMenu, search);
|
---|
[6738] | 694 | add(editMenu, presetSearchPrimitiveAction);
|
---|
[1130] | 695 | editMenu.addSeparator();
|
---|
| 696 | add(editMenu, preferences);
|
---|
[486] | 697 |
|
---|
[2530] | 698 | // -- wireframe toggle action
|
---|
| 699 | final JCheckBoxMenuItem wireframe = new JCheckBoxMenuItem(wireFrameToggleAction);
|
---|
[1130] | 700 | viewMenu.add(wireframe);
|
---|
[2530] | 701 | wireframe.setAccelerator(wireFrameToggleAction.getShortcut().getKeyStroke());
|
---|
[4175] | 702 | wireFrameToggleAction.addButtonModel(wireframe.getModel());
|
---|
[2530] | 703 |
|
---|
[5086] | 704 | viewMenu.add(new MapPaintMenu());
|
---|
[1219] | 705 | viewMenu.addSeparator();
|
---|
| 706 | add(viewMenu, new ZoomInAction());
|
---|
| 707 | add(viewMenu, new ZoomOutAction());
|
---|
| 708 | viewMenu.addSeparator();
|
---|
[2689] | 709 | for (String mode : AutoScaleAction.MODES) {
|
---|
[5958] | 710 | AutoScaleAction autoScaleAction = new AutoScaleAction(mode);
|
---|
| 711 | autoScaleActions.put(mode, autoScaleAction);
|
---|
[1219] | 712 | add(viewMenu, autoScaleAction);
|
---|
| 713 | }
|
---|
[397] | 714 |
|
---|
[3837] | 715 | // -- viewport follow toggle action
|
---|
| 716 | ViewportFollowToggleAction viewportFollowToggleAction = new ViewportFollowToggleAction();
|
---|
| 717 | final JCheckBoxMenuItem vft = new JCheckBoxMenuItem(viewportFollowToggleAction);
|
---|
[4843] | 718 | ExpertToggleAction.addVisibilitySwitcher(vft);
|
---|
[3837] | 719 | viewMenu.add(vft);
|
---|
| 720 | vft.setAccelerator(viewportFollowToggleAction.getShortcut().getKeyStroke());
|
---|
| 721 | viewportFollowToggleAction.addButtonModel(vft.getModel());
|
---|
| 722 |
|
---|
[8510] | 723 | if (Main.platform.canFullscreen()) {
|
---|
[3954] | 724 | // -- fullscreen toggle action
|
---|
[4139] | 725 | fullscreenToggleAction = new FullscreenToggleAction();
|
---|
[4266] | 726 | final JCheckBoxMenuItem fullscreen = new JCheckBoxMenuItem(fullscreenToggleAction);
|
---|
| 727 | viewMenu.addSeparator();
|
---|
| 728 | viewMenu.add(fullscreen);
|
---|
| 729 | fullscreen.setAccelerator(fullscreenToggleAction.getShortcut().getKeyStroke());
|
---|
| 730 | fullscreenToggleAction.addButtonModel(fullscreen.getModel());
|
---|
[1498] | 731 | }
|
---|
[5965] | 732 |
|
---|
| 733 | // -- dialogs panel toggle action
|
---|
| 734 | final JCheckBoxMenuItem dialogsToggle = new JCheckBoxMenuItem(dialogsToggleAction);
|
---|
| 735 | dialogsToggle.setAccelerator(dialogsToggleAction.getShortcut().getKeyStroke());
|
---|
| 736 | dialogsToggleAction.addButtonModel(dialogsToggle.getModel());
|
---|
| 737 | viewMenu.add(dialogsToggle);
|
---|
| 738 |
|
---|
[6398] | 739 | add(viewMenu, jumpToAct, true);
|
---|
[3678] | 740 | viewMenu.addSeparator();
|
---|
| 741 | add(viewMenu, info);
|
---|
[4408] | 742 | add(viewMenu, infoweb);
|
---|
[3678] | 743 | add(viewMenu, historyinfo);
|
---|
[4840] | 744 | add(viewMenu, historyinfoweb);
|
---|
| 745 | viewMenu.addSeparator();
|
---|
[9006] | 746 | viewMenu.add(new PreferenceToggleAction(tr("Main toolbar"),
|
---|
| 747 | tr("Toggles the visibility of the main toolbar (i.e., the horizontal toolbar)"),
|
---|
| 748 | "toolbar.visible", true).getCheckbox());
|
---|
[5092] | 749 | viewMenu.add(new PreferenceToggleAction(tr("Edit toolbar"),
|
---|
| 750 | tr("Toggles the visibility of the edit toolbar (i.e., the vertical tool)"),
|
---|
| 751 | "sidetoolbar.visible", true).getCheckbox());
|
---|
[4840] | 752 | // -- expert mode toggle action
|
---|
[4843] | 753 | final JCheckBoxMenuItem expertItem = new JCheckBoxMenuItem(ExpertToggleAction.getInstance());
|
---|
[4840] | 754 | viewMenu.add(expertItem);
|
---|
[4843] | 755 | ExpertToggleAction.getInstance().addButtonModel(expertItem.getModel());
|
---|
[1498] | 756 |
|
---|
[3388] | 757 | add(presetsMenu, presetSearchAction);
|
---|
[6738] | 758 | add(presetsMenu, presetSearchPrimitiveAction);
|
---|
[6426] | 759 | add(presetsMenu, PreferencesAction.forPreferenceSubTab(tr("Preset preferences"),
|
---|
| 760 | tr("Click to open the tagging presets tab in the preferences"), TaggingPresetPreference.class));
|
---|
[4411] | 761 | presetsMenu.addSeparator();
|
---|
[6426] | 762 |
|
---|
| 763 | add(imageryMenu, PreferencesAction.forPreferenceTab(tr("Imagery preferences"),
|
---|
| 764 | tr("Click to open the imagery tab in the preferences"), ImageryPreference.class));
|
---|
[6830] | 765 |
|
---|
[6082] | 766 | add(selectionMenu, selectAll);
|
---|
| 767 | add(selectionMenu, unselectAll);
|
---|
[6544] | 768 | add(selectionMenu, nonBranchingWaySequences);
|
---|
[3388] | 769 |
|
---|
[1130] | 770 | add(toolsMenu, splitWay);
|
---|
| 771 | add(toolsMenu, combineWay);
|
---|
| 772 | toolsMenu.addSeparator();
|
---|
| 773 | add(toolsMenu, reverseWay);
|
---|
[2575] | 774 | add(toolsMenu, simplifyWay);
|
---|
[1130] | 775 | toolsMenu.addSeparator();
|
---|
| 776 | add(toolsMenu, alignInCircle);
|
---|
| 777 | add(toolsMenu, alignInLine);
|
---|
[1380] | 778 | add(toolsMenu, distribute);
|
---|
[1130] | 779 | add(toolsMenu, ortho);
|
---|
[4843] | 780 | add(toolsMenu, mirror, true);
|
---|
[1130] | 781 | toolsMenu.addSeparator();
|
---|
[4843] | 782 | add(toolsMenu, followLine, true);
|
---|
[6412] | 783 | add(toolsMenu, addNode, true);
|
---|
| 784 | add(toolsMenu, moveNode, true);
|
---|
[1130] | 785 | add(toolsMenu, createCircle);
|
---|
| 786 | toolsMenu.addSeparator();
|
---|
| 787 | add(toolsMenu, mergeNodes);
|
---|
| 788 | add(toolsMenu, joinNodeWay);
|
---|
[7131] | 789 | add(toolsMenu, moveNodeOntoWay);
|
---|
[6253] | 790 | add(toolsMenu, unJoinNodeWay);
|
---|
[1130] | 791 | add(toolsMenu, unglueNodes);
|
---|
[3704] | 792 | toolsMenu.addSeparator();
|
---|
[2575] | 793 | add(toolsMenu, joinAreas);
|
---|
[3704] | 794 | add(toolsMenu, createMultipolygon);
|
---|
[6597] | 795 | add(toolsMenu, updateMultipolygon);
|
---|
[422] | 796 |
|
---|
[4590] | 797 | // -- changeset manager toggle action
|
---|
[6180] | 798 | final JCheckBoxMenuItem mi = MainMenu.addWithCheckbox(windowMenu, changesetManager,
|
---|
[4590] | 799 | MainMenu.WINDOW_MENU_GROUP.ALWAYS);
|
---|
[6180] | 800 | changesetManager.addButtonModel(mi.getModel());
|
---|
[4590] | 801 |
|
---|
[12846] | 802 | if (!Config.getPref().getBoolean("audio.menuinvisible", false)) {
|
---|
[5661] | 803 | showAudioMenu(true);
|
---|
[1130] | 804 | }
|
---|
[6070] | 805 |
|
---|
[12846] | 806 | Config.getPref().addPreferenceChangeListener(e -> {
|
---|
[10611] | 807 | if ("audio.menuinvisible".equals(e.getKey())) {
|
---|
| 808 | showAudioMenu(!Boolean.parseBoolean(e.getNewValue().toString()));
|
---|
[5661] | 809 | }
|
---|
| 810 | });
|
---|
[547] | 811 |
|
---|
[9347] | 812 | add(helpMenu, new MenuItemSearchDialog.Action());
|
---|
| 813 | helpMenu.addSeparator();
|
---|
[9320] | 814 | add(helpMenu, statusreport);
|
---|
| 815 | add(helpMenu, reportbug);
|
---|
[7624] | 816 | helpMenu.addSeparator();
|
---|
[1498] | 817 |
|
---|
[9320] | 818 | add(helpMenu, help);
|
---|
[1130] | 819 | add(helpMenu, about);
|
---|
[1808] | 820 |
|
---|
[4590] | 821 | windowMenu.addMenuListener(menuSeparatorHandler);
|
---|
| 822 |
|
---|
[10345] | 823 | new PresetsMenuEnabler(presetsMenu);
|
---|
[422] | 824 | }
|
---|
[6070] | 825 |
|
---|
[8072] | 826 | /**
|
---|
| 827 | * Search main menu for items with {@code textToFind} in title.
|
---|
| 828 | * @param textToFind The text to find
|
---|
[9347] | 829 | * @param skipPresets whether to skip the {@link #presetsMenu} in the search
|
---|
[8072] | 830 | * @return not null list of found menu items.
|
---|
| 831 | */
|
---|
[9347] | 832 | public List<JMenuItem> findMenuItems(String textToFind, boolean skipPresets) {
|
---|
| 833 | // Explicitly use default locale in this case, because we're looking for translated strings
|
---|
[8404] | 834 | textToFind = textToFind.toLowerCase(Locale.getDefault());
|
---|
[8072] | 835 | List<JMenuItem> result = new ArrayList<>();
|
---|
[9347] | 836 | for (int i = 0; i < getMenuCount(); i++) {
|
---|
| 837 | if (getMenu(i) != null && (!skipPresets || presetsMenu != getMenu(i))) {
|
---|
| 838 | findMenuItems(getMenu(i), textToFind, result);
|
---|
[8072] | 839 | }
|
---|
| 840 | }
|
---|
| 841 | return result;
|
---|
| 842 | }
|
---|
| 843 |
|
---|
| 844 | /**
|
---|
| 845 | * Recursive walker for menu items. Only menu items with action are selected. If menu item
|
---|
| 846 | * contains {@code textToFind} it's appended to result.
|
---|
| 847 | * @param menu menu in which search will be performed
|
---|
| 848 | * @param textToFind The text to find
|
---|
[9347] | 849 | * @param result resulting list of menu items
|
---|
[8072] | 850 | */
|
---|
[8870] | 851 | private static void findMenuItems(final JMenu menu, final String textToFind, final List<JMenuItem> result) {
|
---|
[8510] | 852 | for (int i = 0; i < menu.getItemCount(); i++) {
|
---|
[8072] | 853 | JMenuItem menuItem = menu.getItem(i);
|
---|
| 854 | if (menuItem == null) continue;
|
---|
| 855 |
|
---|
[9347] | 856 | // Explicitly use default locale in this case, because we're looking for translated strings
|
---|
[8404] | 857 | if (menuItem.getAction() != null && menuItem.getText().toLowerCase(Locale.getDefault()).contains(textToFind)) {
|
---|
[8072] | 858 | result.add(menuItem);
|
---|
| 859 | }
|
---|
| 860 |
|
---|
| 861 | // Go recursive if needed
|
---|
| 862 | if (menuItem instanceof JMenu) {
|
---|
| 863 | findMenuItems((JMenu) menuItem, textToFind, result);
|
---|
| 864 | }
|
---|
| 865 | }
|
---|
| 866 | }
|
---|
| 867 |
|
---|
[5661] | 868 | protected void showAudioMenu(boolean showMenu) {
|
---|
| 869 | if (showMenu && audioMenu == null) {
|
---|
[8792] | 870 | audioMenu = addMenu("Audio", /* I18N: mnemonic: U */ trc("menu", "Audio"), KeyEvent.VK_U, defaultMenuPos, ht("/Menu/Audio"));
|
---|
[5661] | 871 | add(audioMenu, audioPlayPause);
|
---|
| 872 | add(audioMenu, audioNext);
|
---|
| 873 | add(audioMenu, audioPrev);
|
---|
| 874 | add(audioMenu, audioFwd);
|
---|
| 875 | add(audioMenu, audioBack);
|
---|
| 876 | add(audioMenu, audioSlower);
|
---|
| 877 | add(audioMenu, audioFaster);
|
---|
| 878 | validate();
|
---|
| 879 | } else if (!showMenu && audioMenu != null) {
|
---|
| 880 | remove(audioMenu);
|
---|
| 881 | audioMenu.removeAll();
|
---|
| 882 | audioMenu = null;
|
---|
| 883 | validate();
|
---|
| 884 | }
|
---|
| 885 | }
|
---|
[1808] | 886 |
|
---|
[10345] | 887 | static class PresetsMenuEnabler implements ActiveLayerChangeListener {
|
---|
[9078] | 888 | private final JMenu presetsMenu;
|
---|
[8510] | 889 |
|
---|
[8836] | 890 | PresetsMenuEnabler(JMenu presetsMenu) {
|
---|
[1808] | 891 | this.presetsMenu = presetsMenu;
|
---|
[12636] | 892 | MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this);
|
---|
[1808] | 893 | }
|
---|
[9059] | 894 |
|
---|
[5965] | 895 | @Override
|
---|
[10345] | 896 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
|
---|
| 897 | presetsMenu.setEnabled(e.getSource().getEditLayer() != null);
|
---|
[1808] | 898 | }
|
---|
| 899 | }
|
---|
[422] | 900 | }
|
---|