Ticket #12352: DeleteLayerAction.patch
| File DeleteLayerAction.patch, 3.2 KB (added by , 10 years ago) |
|---|
-
new file src/org/openstreetmap/josm/actions/DeleteLayerAction.java
diff --git a/src/org/openstreetmap/josm/actions/DeleteLayerAction.java b/src/org/openstreetmap/josm/actions/DeleteLayerAction.java new file mode 100644 index 0000000..84301c4
- + 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.actions; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 6 7 import java.util.Arrays; 8 import java.awt.event.ActionEvent; 9 import java.awt.event.KeyEvent; 10 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.tools.Shortcut; 13 import org.openstreetmap.josm.gui.layer.Layer; 14 15 public final class DeleteLayerAction extends JosmAction { 16 17 /** 18 * Creates a {@link DeleteLayerAction} which will delete 19 * the active layer. 20 */ 21 public DeleteLayerAction() { 22 super(tr("Delete Layer"), "dialogs/delete", tr("Delete the active layer. Does not delete the associated file."), 23 Shortcut.registerShortcut("system:deletelayer", tr("File: {0}", tr("Delete Layer")), KeyEvent.VK_F4, Shortcut.CTRL), true); 24 putValue("help", ht("/Action/DeleteLayer")); 25 } 26 27 @Override 28 public void actionPerformed(ActionEvent e) { 29 Layer activeLayer = Main.main.getActiveLayer(); 30 if (activeLayer == null) return; 31 if (!Main.saveUnsavedModifications(Arrays.asList(activeLayer), false)) 32 return; 33 Main.main.removeLayer(activeLayer); 34 } 35 36 @Override 37 protected void updateEnabledState() { 38 setEnabled( 39 Main.isDisplayingMapView() 40 && Main.map.mapView.getActiveLayer() != null 41 ); 42 } 43 } -
src/org/openstreetmap/josm/gui/MainMenu.java
diff --git a/src/org/openstreetmap/josm/gui/MainMenu.java b/src/org/openstreetmap/josm/gui/MainMenu.java index 40ec6d0..6018fe0 100644
a b import org.openstreetmap.josm.actions.AlignInLineAction; 32 32 import org.openstreetmap.josm.actions.AutoScaleAction; 33 33 import org.openstreetmap.josm.actions.ChangesetManagerToggleAction; 34 34 import org.openstreetmap.josm.actions.CloseChangesetAction; 35 import org.openstreetmap.josm.actions.DeleteLayerAction; 35 36 import org.openstreetmap.josm.actions.CombineWayAction; 36 37 import org.openstreetmap.josm.actions.CopyAction; 37 38 import org.openstreetmap.josm.actions.CopyCoordinatesAction; … … public class MainMenu extends JMenuBar { 148 149 public final SaveAction save = SaveAction.getInstance(); 149 150 /** File / Save As... **/ 150 151 public final SaveAsAction saveAs = SaveAsAction.getInstance(); 152 /** File / Close Layer **/ 153 public final DeleteLayerAction deleteLayerAction = new DeleteLayerAction(); 151 154 /** File / Session > Save Session As... **/ 152 155 public SessionSaveAsAction sessionSaveAs; 153 156 /** File / Export to GPX... **/ … … public class MainMenu extends JMenuBar { 639 642 fileMenu.addSeparator(); 640 643 add(fileMenu, save); 641 644 add(fileMenu, saveAs); 645 add(fileMenu, deleteLayerAction); 642 646 sessionSaveAs = new SessionSaveAsAction(); 643 647 ExpertToggleAction.addVisibilitySwitcher(fileMenu.add(sessionSaveAs)); 644 648 add(fileMenu, gpxExport, true);
