Changeset 169 in josm for src


Ignore:
Timestamp:
2006-11-28T19:58:41+01:00 (17 years ago)
Author:
imi
Message:
  • added "new empty map" action
  • added osm-server.version property (set the OSM server verion. For expert users only)
  • added first support for ongoing 0.4 server api
  • fixed Class-Path manifest attribute for plugins (" " is Seperator)
Location:
src/org/openstreetmap/josm
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/Main.java

    r159 r169  
    168168                toolBar.add(menu.upload);
    169169                toolBar.addSeparator();
     170                toolBar.add(menu.newAction);
    170171                toolBar.add(menu.open);
    171172                toolBar.add(menu.save);
     
    323324        }
    324325
     326        public static boolean breakBecauseUnsavedChanges() {
     327            if (map != null) {
     328                boolean modified = false;
     329                boolean uploadedModified = false;
     330                for (final Layer l : map.mapView.getAllLayers()) {
     331                        if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) {
     332                                modified = true;
     333                                uploadedModified = ((OsmDataLayer)l).uploadedModified;
     334                                break;
     335                        }
     336                }
     337                if (modified) {
     338                        final String msg = uploadedModified ? "\n"+tr("Hint: Some changes came from uploading new data to the server.") : "";
     339                        final int answer = JOptionPane.showConfirmDialog(
     340                                        parent, tr("There are unsaved changes. Discard the changes and continue?")+msg,
     341                                        tr("Unsaved Changes"), JOptionPane.YES_NO_OPTION);
     342                        if (answer != JOptionPane.YES_OPTION)
     343                                return true;
     344                }
     345            }
     346            return false;
     347    }
     348       
    325349        private static void downloadFromParamString(final boolean rawGps, String s) {
    326350                if (s.startsWith("http:")) {
  • src/org/openstreetmap/josm/actions/PreferencesAction.java

    r168 r169  
    3636                JPanel prefPanel = new JPanel(new GridBagLayout());
    3737                prefPanel.add(prefDlg, GBC.eol().fill(GBC.BOTH));
    38                
     38
    3939                JOptionPane pane = new JOptionPane(prefPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    4040                JDialog dlg = pane.createDialog(Main.parent, tr("Preferences"));
     41               
     42                if (dlg.getWidth() > 600)
     43                        dlg.setSize(600, dlg.getHeight());
     44                if (dlg.getHeight() > 450)
     45                        dlg.setSize(dlg.getWidth(), 450);
     46
    4147                dlg.setVisible(true);
    4248                if (pane.getValue() instanceof Integer && (Integer)pane.getValue() == JOptionPane.OK_OPTION)
  • src/org/openstreetmap/josm/gui/MainApplication.java

    r159 r169  
    2020
    2121import org.openstreetmap.josm.Main;
    22 import org.openstreetmap.josm.gui.layer.Layer;
    23 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2422import org.openstreetmap.josm.plugins.PluginException;
    2523import org.openstreetmap.josm.plugins.PluginInformation;
     
    4240                mainFrame.addWindowListener(new WindowAdapter(){
    4341                        @Override public void windowClosing(final WindowEvent arg0) {
    44                                 if (Main.map != null) {
    45                                         boolean modified = false;
    46                                         boolean uploadedModified = false;
    47                                         for (final Layer l : Main.map.mapView.getAllLayers()) {
    48                                                 if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) {
    49                                                         modified = true;
    50                                                         uploadedModified = ((OsmDataLayer)l).uploadedModified;
    51                                                         break;
    52                                                 }
    53                                         }
    54                                         if (modified) {
    55                                                 final String msg = uploadedModified ? "\n"+tr("Hint: Some changes came from uploading new data to the server.") : "";
    56                                                 final int answer = JOptionPane.showConfirmDialog(
    57                                                                 Main.parent, tr("There are unsaved changes. Really quit?")+msg,
    58                                                                 tr("Unsaved Changes"), JOptionPane.YES_NO_OPTION);
    59                                                 if (answer != JOptionPane.YES_OPTION)
    60                                                         return;
    61                                         }
    62                                 }
     42                                if (Main.breakBecauseUnsavedChanges())
     43                                        return;
    6344                                System.exit(0);
    6445                        }
  • src/org/openstreetmap/josm/gui/MainMenu.java

    r167 r169  
    1616import org.openstreetmap.josm.actions.GpxExportAction;
    1717import org.openstreetmap.josm.actions.HelpAction;
     18import org.openstreetmap.josm.actions.NewAction;
    1819import org.openstreetmap.josm.actions.OpenAction;
    1920import org.openstreetmap.josm.actions.PreferencesAction;
     
    3738        public final UndoAction undo = new UndoAction();
    3839        public final RedoAction redo = new RedoAction();
     40        public final NewAction newAction = new NewAction();
    3941        public final OpenAction open = new OpenAction();
    4042        public final DownloadAction download = new DownloadAction();
     
    6264        public MainMenu() {
    6365                fileMenu.setMnemonic('F');
     66                fileMenu.add(newAction);
    6467                fileMenu.add(open);
    6568                fileMenu.add(save);
  • src/org/openstreetmap/josm/gui/MapView.java

    r153 r169  
    113113                        if (editLayer != null) {
    114114                                editLayer.mergeFrom(layer);
     115                                if (autoScale)
     116                                        recalculateCenterScale();
    115117                                repaint();
    116118                                return;
  • src/org/openstreetmap/josm/io/OsmReader.java

    r160 r169  
    1414
    1515
     16import org.openstreetmap.josm.Main;
    1617import org.openstreetmap.josm.data.coor.LatLon;
    1718import org.openstreetmap.josm.data.osm.DataSet;
     
    100101                                        if (atts == null)
    101102                                                throw new SAXException(tr("Unknown version"));
    102                                         if (!"0.3".equals(atts.getValue("version")))
     103                                        if (!Main.pref.get("osm-server.version", "0.3").equals(atts.getValue("version")))
    103104                                                throw new SAXException(tr("Unknown version")+": "+atts.getValue("version"));
    104105                                } else if (qName.equals("node")) {
  • src/org/openstreetmap/josm/io/OsmServerWriter.java

    r153 r169  
    153153                        OsmPrimitive osm, boolean addBody) {
    154154                try {
    155                         URL url = new URL(Main.pref.get("osm-server.url") + "/0.3/" + urlSuffix + "/" + osm.id);
     155                        String version = Main.pref.get("osm-server.version", "0.3");
     156                        URL url = new URL(
     157                                        Main.pref.get("osm-server.url") +
     158                                        "/" + version +
     159                                        "/" + urlSuffix +
     160                                        "/" + ((version.equals("0.4") && osm.id==0) ? "create":osm.id));
    156161                        System.out.println("upload to: "+url);
    157                         activeConnection = (HttpURLConnection) url.openConnection();
     162                        activeConnection = (HttpURLConnection)url.openConnection();
    158163                        activeConnection.setConnectTimeout(15000);
    159164                        activeConnection.setRequestMethod(requestMethod);
  • src/org/openstreetmap/josm/io/OsmWriter.java

    r167 r169  
    55import java.util.Map.Entry;
    66
     7import org.openstreetmap.josm.Main;
    78import org.openstreetmap.josm.data.osm.DataSet;
    89import org.openstreetmap.josm.data.osm.Node;
     
    3334        public abstract static class Osm implements OsmWriterInterface {
    3435                public void header(PrintWriter out) {
    35                         out.println("<osm version='0.3' generator='JOSM'>");
     36                        out.print("<osm version='");
     37                        out.print(Main.pref.get("osm-server.version", "0.3"));
     38                        out.println("' generator='JOSM'>");
    3639                }
    3740                public void footer(PrintWriter out) {
  • src/org/openstreetmap/josm/plugins/PluginInformation.java

    r167 r169  
    4848                        String classPath = attr.getValue("Class-Path");
    4949                        if (classPath != null) {
    50                                 for (String s : classPath.split(classPath.contains(";") ? ";" : ":")) {
    51                                         if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.:"))
     50                                String[] cp = classPath.split(" ");
     51                                StringBuilder entry = new StringBuilder();
     52                                for (String s : cp) {
     53                                        entry.append(s);
     54                                        if (s.endsWith("\\")) {
     55                                                entry.setLength(entry.length()-1);
     56                                                entry.append("%20"); // append the split character " " as html-encode
     57                                                continue;
     58                                        }
     59                                        s = entry.toString();
     60                                        entry = new StringBuilder();
     61                                        if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.\\:"))
    5262                                                s = file.getParent() + File.separator + s;
    5363                                        libraries.add(new URL(getURLString(s)));
Note: See TracChangeset for help on using the changeset viewer.