Ignore:
Timestamp:
2009-06-06T22:25:31+02:00 (16 years ago)
Author:
stoecker
Message:

lots of updates due to josm changes

Location:
applications/editors/josm/plugins/wmsplugin/src
Files:
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java

    r15185 r15707  
    8585        if (urlWithPatterns) {
    8686            String proj = Main.proj.toCode();
    87             if(proj.equals("EPSG:3785")) // don't use mercator code
     87            if(Main.proj instanceof org.openstreetmap.josm.data.projection.Mercator) // don't use mercator code directly
    8888                proj = "EPSG:4326";
    8989
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java

    r15185 r15707  
    2323import javax.swing.JOptionPane;
    2424import javax.swing.JSeparator;
    25 import javax.swing.filechooser.FileFilter;
    2625
    2726import org.openstreetmap.josm.Main;
    28 import org.openstreetmap.josm.actions.ExtensionFileFilter;
     27import org.openstreetmap.josm.actions.DiskAccessAction;
    2928import org.openstreetmap.josm.data.Bounds;
    3029import org.openstreetmap.josm.data.coor.EastNorth;
     
    295294        }
    296295        public void actionPerformed(ActionEvent ev) {
    297             File f = openFileDialog(false);
     296            File f = DiskAccessAction.createAndOpenSaveFileChooser(
     297            tr("Save WMS layer"), ".wms");
    298298            try
    299299            {
     
    322322        }
    323323        public void actionPerformed(ActionEvent ev) {
    324             File f = openFileDialog(true);
     324            JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true,
     325            false, tr("Load WMS layer"));
     326            if(fc == null) return;
     327            File f = fc.getSelectedFile();
    325328            if (f == null) return;
    326329            try
     
    359362        }
    360363    }
    361 
    362     protected static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple) {
    363         String curDir = Main.pref.get("lastDirectory");
    364         if (curDir.equals(""))
    365             curDir = ".";
    366         JFileChooser fc = new JFileChooser(new File(curDir));
    367         fc.setMultiSelectionEnabled(multiple);
    368         for (int i = 0; i < ExtensionFileFilter.filters.length; ++i)
    369             fc.addChoosableFileFilter(ExtensionFileFilter.filters[i]);
    370         fc.setAcceptAllFileFilterUsed(true);
    371 
    372         int answer = open ? fc.showOpenDialog(Main.parent) : fc.showSaveDialog(Main.parent);
    373         if (answer != JFileChooser.APPROVE_OPTION)
    374             return null;
    375 
    376         if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
    377             Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
    378 
    379         if (!open) {
    380             File file = fc.getSelectedFile();
    381             if (file == null || (file.exists() && JOptionPane.YES_OPTION !=
    382                 JOptionPane.showConfirmDialog(Main.parent, tr("File exists. Overwrite?"), tr("Overwrite"), JOptionPane.YES_NO_OPTION)))
    383                 return null;
    384         }
    385 
    386         return fc;
    387     }
    388 
    389     public static File openFileDialog(boolean open) {
    390         JFileChooser fc = createAndOpenFileChooser(open, false);
    391         if (fc == null)
    392             return null;
    393 
    394         File file = fc.getSelectedFile();
    395 
    396         String fn = file.getPath();
    397         if (fn.indexOf('.') == -1) {
    398             FileFilter ff = fc.getFileFilter();
    399             if (ff instanceof ExtensionFileFilter)
    400                 fn = "." + ((ExtensionFileFilter)ff).defaultExtension;
    401             else
    402                 fn += ".osm";
    403             file = new File(fn);
    404         }
    405         return file;
    406     }
    407364}
Note: See TracChangeset for help on using the changeset viewer.