source: josm/trunk/src/org/openstreetmap/josm/gui/MainMenu.java

Last change on this file was 18814, checked in by taylor.smock, 8 months ago

Fix #23105: Add action to select shared/common child objects (patch by Woazboat, modified)

Modifications are as follows:

  • Basic test added
  • Icon added (copied and modified from selectall.svg)
  • default methods for IPrimitive.getChildren were moved to the appropriate locations
  • Lint cleanups in modified files

Additional notes:

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