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