Changeset 5014 in josm for trunk/src


Ignore:
Timestamp:
2012-02-21T19:26:54+01:00 (13 years ago)
Author:
xeen
Message:

fix #7429

Location:
trunk/src/org/openstreetmap/josm
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/SaveAction.java

    r4982 r5014  
    22package org.openstreetmap.josm.actions;
    33
     4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    66
    77import java.awt.event.KeyEvent;
     
    2020 */
    2121public class SaveAction extends SaveActionBase {
     22    private static SaveAction instance = new SaveAction();
    2223
    2324    /**
     
    2526     * @param layer Save this layer.
    2627     */
    27     public SaveAction() {
     28    private SaveAction() {
    2829        super(tr("Save"), "save", tr("Save the current data."),
    2930                Shortcut.registerShortcut("system:save", tr("File: {0}", tr("Save")), KeyEvent.VK_S, Shortcut.CTRL));
    3031        putValue("help", ht("/Action/Save"));
    3132    }
     33
     34    public static SaveAction getInstance() {
     35        return instance;
     36    }
     37
    3238
    3339    @Override public File getFile(Layer layer) {
  • trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java

    r4911 r5014  
    1010import java.util.LinkedList;
    1111import java.util.List;
     12
    1213import javax.swing.JFileChooser;
    1314import javax.swing.JOptionPane;
     
    3334    @Override
    3435    public void actionPerformed(ActionEvent e) {
    35         if (!isEnabled()) {
    36             return;
    37         }
     36        if (!isEnabled())
     37            return;
    3838        boolean saved = doSave();
    3939        if (saved) {
     
    6060    }
    6161
    62     public boolean doSave(Layer layer, File file) {
     62    public static boolean doSave(Layer layer, File file) {
    6363        if(!checkSaveConditions(layer))
    6464            return false;
     
    6666    }
    6767
    68     private boolean doInternalSave(Layer layer, File file) {
     68    private static boolean doInternalSave(Layer layer, File file) {
    6969        if (file == null)
    7070            return false;
     
    104104     * @return <code>true</code>, if it is safe to save.
    105105     */
    106     public boolean checkSaveConditions(Layer layer) {
     106    public static boolean checkSaveConditions(Layer layer) {
    107107        if (layer instanceof GpxLayer)
    108108            return ((GpxLayer)layer).data != null;
     
    153153     * @return <code>true</code>, if a save result in an empty data set.
    154154     */
    155     private boolean isDataSetEmpty(OsmDataLayer layer) {
     155    private static boolean isDataSetEmpty(OsmDataLayer layer) {
    156156        for (OsmPrimitive osm : layer.data.allNonDeletedPrimitives())
    157157            if (!osm.isDeleted() || !osm.isNewOrUndeleted())
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r4982 r5014  
    120120    public final RecentlyOpenedFilesMenu recentlyOpened = new RecentlyOpenedFilesMenu();
    121121    public final OpenLocationAction openLocation = new OpenLocationAction();
    122     public final JosmAction save = new SaveAction();
     122    public final JosmAction save = SaveAction.getInstance();
    123123    public final JosmAction saveAs = new SaveAsAction();
    124124    public JosmAction sessionLoad;
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java

    r4310 r5014  
    4848        try {
    4949            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())) {
    5151                setFailed(true);
    5252                return;
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r5003 r5014  
    2929import javax.swing.ImageIcon;
    3030import javax.swing.JComponent;
     31import javax.swing.JButton;
    3132import javax.swing.JDialog;
    3233import javax.swing.JLabel;
     
    4445import org.openstreetmap.josm.data.APIDataSet;
    4546import org.openstreetmap.josm.gui.ExceptionDialogUtil;
    46 import org.openstreetmap.josm.gui.SideButton;
    4747import org.openstreetmap.josm.gui.io.SaveLayersModel.Mode;
    4848import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    9494    }
    9595
    96     private SideButton saveAndProceedActionButton = null;
     96    private JButton saveAndProceedActionButton = null;
    9797
    9898    /**
     
    107107        saveAndProceedAction = new SaveAndProceedAction();
    108108        model.addPropertyChangeListener(saveAndProceedAction);
    109         pnl.add(saveAndProceedActionButton = new SideButton(saveAndProceedAction));
     109        pnl.add(saveAndProceedActionButton = new JButton(saveAndProceedAction));
    110110
    111111        discardAndProceedAction = new DiscardAndProceedAction();
    112112        model.addPropertyChangeListener(discardAndProceedAction);
    113         pnl.add(new SideButton(discardAndProceedAction));
     113        pnl.add(new JButton(discardAndProceedAction));
    114114
    115115        cancelAction = new CancelAction();
    116         pnl.add(new SideButton(cancelAction));
     116        pnl.add(new JButton(cancelAction));
    117117
    118118        JPanel pnl2 = new JPanel();
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r4230 r5014  
    366366
    367367        public void actionPerformed(ActionEvent e) {
    368             new SaveAction().doSave(layer);
     368            SaveAction.getInstance().doSave(layer);
    369369        }
    370370    }
  • trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java

    r4721 r5014  
    1919import java.io.UnsupportedEncodingException;
    2020import java.io.Writer;
     21import java.net.MalformedURLException;
    2122import java.net.URI;
    2223import java.net.URL;
    23 import java.net.MalformedURLException;
    2424import java.util.Collection;
    2525import java.util.Collections;
     
    3535import javax.swing.SwingConstants;
    3636
    37 import org.w3c.dom.Element;
    38 
    3937import org.openstreetmap.josm.actions.SaveAction;
    4038import org.openstreetmap.josm.gui.layer.Layer;
     
    4644import org.openstreetmap.josm.tools.GBC;
    4745import org.openstreetmap.josm.tools.ImageProvider;
     46import org.w3c.dom.Element;
    4847
    4948public class OsmDataSessionExporter implements SessionLayerExporter {
     
    7574
    7675        public void actionPerformed(ActionEvent e) {
    77             new SaveAction().doSave(layer);
     76            SaveAction.getInstance().doSave(layer);
    7877            updateEnabledState();
    7978        }
Note: See TracChangeset for help on using the changeset viewer.