Changeset 938 in josm for trunk/src


Ignore:
Timestamp:
2008-09-09T08:43:09+02:00 (16 years ago)
Author:
stoecker
Message:

added patches from bug #682 (proxy settings) and #1519 (NMEA)

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r931 r938  
    1313import java.util.LinkedList;
    1414import java.util.Map;
     15import java.util.Properties;
    1516import java.util.SortedMap;
    1617import java.util.StringTokenizer;
     
    1920
    2021import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.gui.preferences.ProxyPreferences;
    2123import org.openstreetmap.josm.tools.ColorHelper;
    2224
     
    213215        public void save() {
    214216                try {
     217                        setSystemProperties();
    215218                        final PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir() + "preferences"), false);
    216219                        for (final Entry<String, String> e : properties.entrySet()) {
     
    241244                        throw new IOException("Malformed config file at lines " + errLines);
    242245                }
     246                setSystemProperties();
    243247        }
    244248
     
    377381                return def;
    378382        }
     383
     384        private void setSystemProperties() {
     385                Properties sysProp = System.getProperties();
     386                if (getBoolean(ProxyPreferences.PROXY_ENABLE)) {
     387                        sysProp.put("proxySet", "true");
     388                        sysProp.put("http.proxyHost", get(ProxyPreferences.PROXY_HOST));
     389                        sysProp.put("proxyPort", get(ProxyPreferences.PROXY_PORT));
     390                        if (!getBoolean(ProxyPreferences.PROXY_ANONYMOUS)) {
     391                                sysProp.put("proxyUser", get(ProxyPreferences.PROXY_USER));
     392                                sysProp.put("proxyPassword", get(ProxyPreferences.PROXY_PASS));
     393                        }
     394                } else {
     395                        sysProp.put("proxySet", "false");
     396                        sysProp.remove("http.proxyHost");
     397                        sysProp.remove("proxyPort");
     398                        sysProp.remove("proxyUser");
     399                        sysProp.remove("proxyPassword");
     400                }
     401                System.setProperties(sysProp);
     402        }
    379403}
  • trunk/src/org/openstreetmap/josm/gui/preferences/FilePreferences.java

    r627 r938  
    66import javax.swing.Box;
    77import javax.swing.JCheckBox;
     8import javax.swing.JSeparator;
     9import javax.swing.SwingConstants;
    810
    911import org.openstreetmap.josm.Main;
     
    2123       
    2224        public void addGui(PreferenceDialog gui) {
     25                gui.connection.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
    2326                keepBackup.setSelected(Main.pref.getBoolean("save.keepbackup"));
    2427                keepBackup.setToolTipText(tr("When saving, keep backup files ending with a ~"));
    2528                gui.connection.add(keepBackup, GBC.eol().insets(20,0,0,0));
    26                 gui.connection.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
    2729    }
    2830
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java

    r804 r938  
    105105                settings.add(new ServerAccessPreference());
    106106                settings.add(new FilePreferences());
     107                settings.add(new ProxyPreferences());
    107108                settings.add(new ProjectionPreference());
    108109                settings.add(new TaggingPresetPreference());
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r814 r938  
    162162
    163163        private LatLon parseLatLon(String[] e) throws NumberFormatException {
    164                 String widthNorth = e[GPRMC.WIDTH_NORTH.position];
    165                 String lengthEast = e[GPRMC.LENGTH_EAST.position];
     164                String widthNorth = e[GPRMC.WIDTH_NORTH.position].trim();
     165                String lengthEast = e[GPRMC.LENGTH_EAST.position].trim();
    166166                if ("".equals(widthNorth) || "".equals(lengthEast)) {
    167167                        return null;
    168168                }
    169169
    170                 int latdeg = Integer.parseInt(widthNorth.substring(0, 2));
    171                 double latmin = Double.parseDouble(widthNorth.substring(2));
     170                // The format is xxDDLL.LLLL
     171                // xx optional whitespace
     172                // DD (int) degres
     173                // LL.LLLL (double) latidude
     174                int latdegsep = widthNorth.indexOf('.') - 2;
     175                if (latdegsep < 0) {
     176                        return null;
     177                }
     178                int latdeg = Integer.parseInt(widthNorth.substring(0, latdegsep));
     179                double latmin = Double.parseDouble(widthNorth.substring(latdegsep));
    172180                double lat = latdeg + latmin / 60;
    173181                if ("S".equals(e[GPRMC.WIDTH_NORTH_NAME.position])) {
     
    175183                }       
    176184
    177                 int londeg = Integer.parseInt(lengthEast.substring(0, 3));
    178                 double lonmin = Double.parseDouble(lengthEast.substring(3));
     185                int londegsep = lengthEast.indexOf('.') - 2;
     186                if (londegsep < 0) {
     187                        return null;
     188                }
     189                int londeg = Integer.parseInt(lengthEast.substring(0, londegsep));
     190                double lonmin = Double.parseDouble(lengthEast.substring(londegsep));
    179191                double lon = londeg + lonmin / 60;
    180192                if ("W".equals(e[GPRMC.LENGTH_EAST_NAME.position])) {
Note: See TracChangeset for help on using the changeset viewer.