- Timestamp:
- 2012-02-21T19:26:54+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SaveAction.java
r4982 r5014 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 7 import java.awt.event.KeyEvent; … … 20 20 */ 21 21 public class SaveAction extends SaveActionBase { 22 private static SaveAction instance = new SaveAction(); 22 23 23 24 /** … … 25 26 * @param layer Save this layer. 26 27 */ 27 p ublicSaveAction() {28 private SaveAction() { 28 29 super(tr("Save"), "save", tr("Save the current data."), 29 30 Shortcut.registerShortcut("system:save", tr("File: {0}", tr("Save")), KeyEvent.VK_S, Shortcut.CTRL)); 30 31 putValue("help", ht("/Action/Save")); 31 32 } 33 34 public static SaveAction getInstance() { 35 return instance; 36 } 37 32 38 33 39 @Override public File getFile(Layer layer) { -
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r4911 r5014 10 10 import java.util.LinkedList; 11 11 import java.util.List; 12 12 13 import javax.swing.JFileChooser; 13 14 import javax.swing.JOptionPane; … … 33 34 @Override 34 35 public void actionPerformed(ActionEvent e) { 35 if (!isEnabled()) { 36 return; 37 } 36 if (!isEnabled()) 37 return; 38 38 boolean saved = doSave(); 39 39 if (saved) { … … 60 60 } 61 61 62 public boolean doSave(Layer layer, File file) {62 public static boolean doSave(Layer layer, File file) { 63 63 if(!checkSaveConditions(layer)) 64 64 return false; … … 66 66 } 67 67 68 private boolean doInternalSave(Layer layer, File file) {68 private static boolean doInternalSave(Layer layer, File file) { 69 69 if (file == null) 70 70 return false; … … 104 104 * @return <code>true</code>, if it is safe to save. 105 105 */ 106 public boolean checkSaveConditions(Layer layer) {106 public static boolean checkSaveConditions(Layer layer) { 107 107 if (layer instanceof GpxLayer) 108 108 return ((GpxLayer)layer).data != null; … … 153 153 * @return <code>true</code>, if a save result in an empty data set. 154 154 */ 155 private boolean isDataSetEmpty(OsmDataLayer layer) {155 private static boolean isDataSetEmpty(OsmDataLayer layer) { 156 156 for (OsmPrimitive osm : layer.data.allNonDeletedPrimitives()) 157 157 if (!osm.isDeleted() || !osm.isNewOrUndeleted()) -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r4982 r5014 120 120 public final RecentlyOpenedFilesMenu recentlyOpened = new RecentlyOpenedFilesMenu(); 121 121 public final OpenLocationAction openLocation = new OpenLocationAction(); 122 public final JosmAction save = new SaveAction();122 public final JosmAction save = SaveAction.getInstance(); 123 123 public final JosmAction saveAs = new SaveAsAction(); 124 124 public JosmAction sessionLoad; -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java
r4310 r5014 48 48 try { 49 49 parentMonitor.subTask(tr("Saving layer to ''{0}'' ...", layerInfo.getFile().toString())); 50 if (! new SaveAction().doSave(layerInfo.getLayer(), layerInfo.getFile())) {50 if (!SaveAction.doSave(layerInfo.getLayer(), layerInfo.getFile())) { 51 51 setFailed(true); 52 52 return; -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r5003 r5014 29 29 import javax.swing.ImageIcon; 30 30 import javax.swing.JComponent; 31 import javax.swing.JButton; 31 32 import javax.swing.JDialog; 32 33 import javax.swing.JLabel; … … 44 45 import org.openstreetmap.josm.data.APIDataSet; 45 46 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 46 import org.openstreetmap.josm.gui.SideButton;47 47 import org.openstreetmap.josm.gui.io.SaveLayersModel.Mode; 48 48 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 94 94 } 95 95 96 private SideButton saveAndProceedActionButton = null;96 private JButton saveAndProceedActionButton = null; 97 97 98 98 /** … … 107 107 saveAndProceedAction = new SaveAndProceedAction(); 108 108 model.addPropertyChangeListener(saveAndProceedAction); 109 pnl.add(saveAndProceedActionButton = new SideButton(saveAndProceedAction));109 pnl.add(saveAndProceedActionButton = new JButton(saveAndProceedAction)); 110 110 111 111 discardAndProceedAction = new DiscardAndProceedAction(); 112 112 model.addPropertyChangeListener(discardAndProceedAction); 113 pnl.add(new SideButton(discardAndProceedAction));113 pnl.add(new JButton(discardAndProceedAction)); 114 114 115 115 cancelAction = new CancelAction(); 116 pnl.add(new SideButton(cancelAction));116 pnl.add(new JButton(cancelAction)); 117 117 118 118 JPanel pnl2 = new JPanel(); -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r4230 r5014 366 366 367 367 public void actionPerformed(ActionEvent e) { 368 new SaveAction().doSave(layer);368 SaveAction.getInstance().doSave(layer); 369 369 } 370 370 } -
trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java
r4721 r5014 19 19 import java.io.UnsupportedEncodingException; 20 20 import java.io.Writer; 21 import java.net.MalformedURLException; 21 22 import java.net.URI; 22 23 import java.net.URL; 23 import java.net.MalformedURLException;24 24 import java.util.Collection; 25 25 import java.util.Collections; … … 35 35 import javax.swing.SwingConstants; 36 36 37 import org.w3c.dom.Element;38 39 37 import org.openstreetmap.josm.actions.SaveAction; 40 38 import org.openstreetmap.josm.gui.layer.Layer; … … 46 44 import org.openstreetmap.josm.tools.GBC; 47 45 import org.openstreetmap.josm.tools.ImageProvider; 46 import org.w3c.dom.Element; 48 47 49 48 public class OsmDataSessionExporter implements SessionLayerExporter { … … 75 74 76 75 public void actionPerformed(ActionEvent e) { 77 new SaveAction().doSave(layer);76 SaveAction.getInstance().doSave(layer); 78 77 updateEnabledState(); 79 78 }
Note:
See TracChangeset
for help on using the changeset viewer.