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