Changeset 79 in josm for src/org


Ignore:
Timestamp:
2006-04-03T22:25:02+02:00 (18 years ago)
Author:
imi
Message:
  • fixed bug in osm import (now reject id=0)
  • added WMS server layer (not finished)
  • added save state for dialogs
Location:
src/org/openstreetmap/josm
Files:
4 added
1 deleted
25 edited

Legend:

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

    r78 r79  
    3535import org.openstreetmap.josm.actions.UndoAction;
    3636import org.openstreetmap.josm.actions.UploadAction;
     37import org.openstreetmap.josm.actions.WmsServerAction;
    3738import org.openstreetmap.josm.data.Preferences;
    3839import org.openstreetmap.josm.data.osm.DataSet;
    39 import org.openstreetmap.josm.data.projection.Epsg4263;
     40import org.openstreetmap.josm.data.projection.Epsg4326;
    4041import org.openstreetmap.josm.data.projection.Projection;
    4142import org.openstreetmap.josm.gui.MapFrame;
     
    8384
    8485        private OpenAction openAction;
    85 
    8686        private DownloadAction downloadAction;
     87    private Action wmsServerAction;
    8788       
    8889        /**
     
    101102                downloadAction = new DownloadAction();
    102103                Action uploadAction = new UploadAction();
    103                 openAction = new OpenAction();
     104                wmsServerAction = new WmsServerAction();
     105        openAction = new OpenAction();
    104106                Action saveAction = new SaveAction();
    105107                Action gpxExportAction = new GpxExportAction(null);
     
    124126
    125127               
    126                 JMenu connectionMenu = new JMenu("Connection");
    127                 connectionMenu.setMnemonic('C');
    128                 connectionMenu.add(downloadAction);
    129                 connectionMenu.add(uploadAction);
    130                 mainMenu.add(connectionMenu);
     128                JMenu layerMenu = new JMenu("Layer");
     129                layerMenu.setMnemonic('L');
     130                layerMenu.add(downloadAction);
     131                layerMenu.add(uploadAction);
     132        layerMenu.addSeparator();
     133        //layerMenu.add(new JCheckBoxMenuItem(wmsServerAction));
     134                mainMenu.add(layerMenu);
    131135               
    132136                JMenu editMenu = new JMenu("Edit");
     
    149153                toolBar.add(downloadAction);
    150154                toolBar.add(uploadAction);
     155                //toolBar.add(new IconToggleButton(wmsServerAction));
    151156                toolBar.addSeparator();
    152157                toolBar.add(openAction);
     
    242247                        e.printStackTrace();
    243248                        JOptionPane.showMessageDialog(null, "The projection could not be read from preferences. Using EPSG:4263.");
    244                         proj = new Epsg4263();
     249                        proj = new Epsg4326();
    245250                }
    246251               
     
    320325                        mapFrame.setVisible(true);
    321326                }
     327        //TODO: This is really hacky to unselect the action when the layer gets
     328        // deleted. The whole mapView/mapFrame/layer concept needs refactoring!
     329                if (mapFrame == null && (Boolean)wmsServerAction.getValue(Action.SELECTED_KEY))
     330                        wmsServerAction.putValue(Action.SELECTED_KEY, false);
    322331        }
    323332        /**
  • src/org/openstreetmap/josm/actions/DiskAccessAction.java

    r78 r79  
    2929        protected boolean isDataSetEmpty() {
    3030                for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives())
    31                         if (osm.id > 0)
     31                        if (!osm.isDeleted() || osm.id > 0)
    3232                                return false;
    3333                return true;
  • src/org/openstreetmap/josm/actions/DownloadAction.java

    r77 r79  
    356356                                        closeDialog();
    357357                                        x.printStackTrace();
    358                                         JOptionPane.showMessageDialog(Main.main, x.getMessage());
     358                                        JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage());
    359359                                } catch (JDOMException x) {
    360360                                        closeDialog();
    361361                                        x.printStackTrace();
    362                                         JOptionPane.showMessageDialog(Main.main, x.getMessage());
     362                                        JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage());
    363363                                } catch (FileNotFoundException x) {
    364364                                        closeDialog();
    365365                                        x.printStackTrace();
    366                                         JOptionPane.showMessageDialog(Main.main,
    367                                                         "URL nicht gefunden: " + x.getMessage());
     366                                        JOptionPane.showMessageDialog(Main.main, "URL not found: " + x.getMessage());
    368367                                } catch (IOException x) {
    369368                                        closeDialog();
  • src/org/openstreetmap/josm/actions/GpxExportAction.java

    r78 r79  
    107107               
    108108                Main.pref.put("lastAddAuthor", author.isSelected());
    109                 if (!authorName.getText().isEmpty())
     109                if (authorName.getText().length() != 0)
    110110                        Main.pref.put("lastAuthorName", authorName.getText());
    111                 if (!copyright.getText().isEmpty())
     111                if (copyright.getText().length() != 0)
    112112                        Main.pref.put("lastCopyright", copyright.getText());
    113113               
     
    160160                                email.setText(b ? Main.pref.get("osm-server.username") : "");
    161161
    162                                 boolean authorSet = !authorName.getText().isEmpty();
     162                                boolean authorSet = authorName.getText().length() != 0;
    163163                                enableCopyright(copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b && authorSet);
    164164                        }
     
    168168                KeyAdapter authorNameListener = new KeyAdapter(){
    169169                                        @Override public void keyReleased(KeyEvent e) {
    170                                                 boolean b = !authorName.getText().isEmpty() && author.isSelected();
     170                                                boolean b = authorName.getText().length()!=0 && author.isSelected();
    171171                                                enableCopyright(copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b);
    172172                                        }
     
    193193                                                break;
    194194                                        }
    195                                         license += license.isEmpty() ? urls[i] : ", "+urls[i];
     195                                        license += license.length()==0 ? urls[i] : ", "+urls[i];
    196196                                }
    197197                                copyright.setText(license);
     
    212212                warning.setText(enable ? warningGpl : "<html><font size='-2'>&nbsp;</html");
    213213
    214                 if (enable && copyrightYear.getText().isEmpty()) {
     214                if (enable && copyrightYear.getText().length()==0) {
    215215                        copyrightYear.setText(enable ? Integer.toString(Calendar.getInstance().get(Calendar.YEAR)) : "");
    216216                } else if (!enable)
    217217                        copyrightYear.setText("");
    218218
    219                 if (enable && copyright.getText().isEmpty()) {
     219                if (enable && copyright.getText().length()==0) {
    220220                        copyright.setText(enable ? Main.pref.get("lastCopyright", "http://creativecommons.org/licenses/by-sa/2.5") : "");
    221221                        copyright.setCaretPosition(0);
  • src/org/openstreetmap/josm/actions/OpenAction.java

    r78 r79  
    8181                                                dataSet = OsmReader.parseDataSet(new FileReader(filename));
    8282                                        } catch (SAXException x) {
    83                                                 if (x.getMessage().equals("Unknown version: null")) {
     83                                                if (x.getMessage().equals("Unknown version null")) {
    8484                                                        int answer = JOptionPane.showConfirmDialog(Main.main,
    8585                                                                        fn+" seems to be an old 0.2 API XML file.\n" +
     
    112112                } catch (SAXException x) {
    113113                        x.printStackTrace();
    114                         JOptionPane.showMessageDialog(Main.main, x.getMessage());
     114                        JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage());
    115115                } catch (JDOMException x) {
    116116                        x.printStackTrace();
    117                         JOptionPane.showMessageDialog(Main.main, x.getMessage());
     117                        JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage());
    118118                } catch (IOException x) {
    119119                        x.printStackTrace();
  • src/org/openstreetmap/josm/data/Preferences.java

    r78 r79  
    135135                properties.clear();
    136136                properties.put("laf", "javax.swing.plaf.metal.MetalLookAndFeel");
    137                 properties.put("projection", "org.openstreetmap.josm.data.projection.Epsg4263");
     137                properties.put("projection", "org.openstreetmap.josm.data.projection.Epsg4326");
    138138                properties.put("osm-server.url", "http://www.openstreetmap.org/api");
    139139                properties.put("color.node", ColorHelper.color2html(Color.red));
  • src/org/openstreetmap/josm/data/coor/EastNorth.java

    r72 r79  
    2424        @Override
    2525        public String toString() {
    26                 return "(EastNorth e="+x+", n="+y+")";
     26                return "EastNorth[e="+x+", n="+y+"]";
    2727        }
    2828}
  • src/org/openstreetmap/josm/data/coor/LatLon.java

    r71 r79  
    4141                        lon() < -Projection.MAX_LON || lon() > Projection.MAX_LON;
    4242        }
     43
     44    @Override
     45    public String toString() {
     46        return "LatLon[lat="+lat()+",lon="+lon()+"]";
     47    }
    4348}
  • src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java

    r78 r79  
    3838                if (name == null) {
    3939                        if (ls.incomplete)
    40                                 name = ""+ls.id;
     40                                name = ls.id == 0 ? "new" : ""+ls.id;
    4141                        else
    42                                 name = ls.id+" ("+ls.from.coor.lat()+","+ls.from.coor.lon()+") -> ("+ls.to.coor.lat()+","+ls.to.coor.lon()+")";
     42                                name = (ls.id==0?"":ls.id+" ")+"("+ls.from.coor.lat()+","+ls.from.coor.lon()+") -> ("+ls.to.coor.lat()+","+ls.to.coor.lon()+")";
    4343                }
    4444                icon = ImageProvider.get("data", "segment");
     
    5252                name = n.get("name");
    5353                if (name == null)
    54                         name = n.id+" ("+n.coor.lat()+","+n.coor.lon()+")";
     54                        name = (n.id==0?"":""+n.id)+" ("+n.coor.lat()+","+n.coor.lon()+")";
    5555                icon = ImageProvider.get("data", "node");
    5656        }
  • src/org/openstreetmap/josm/data/projection/Mercator.java

    r73 r79  
    3131                return "Mercator";
    3232        }
     33
     34    public String getCacheDirectoryName() {
     35        return "mercator";
     36    }
    3337}
  • src/org/openstreetmap/josm/data/projection/Projection.java

    r78 r79  
    2020         */
    2121        public static final Projection[] allProjections = new Projection[]{
    22                 new Epsg4263(),
     22                new Epsg4326(),
    2323                new Mercator()
    2424        };
     
    4242         */
    4343        String toString();
     44   
     45    /**
     46     * Get a filename compatible string (for the cache directory)
     47     */
     48    String getCacheDirectoryName();
    4449}
  • src/org/openstreetmap/josm/gui/IconToggleButton.java

    r30 r79  
    55
    66import javax.swing.Action;
    7 import javax.swing.JComponent;
    87import javax.swing.JToggleButton;
    98
     
    1918         * Construct the toggle button with the given action.
    2019         */
    21         public IconToggleButton(JComponent acceleratorReceiver, Action action) {
     20        public IconToggleButton(Action action) {
    2221                super(action);
    2322                setText(null);
  • src/org/openstreetmap/josm/gui/MapFrame.java

    r68 r79  
    6868                // toolbar
    6969                toolBarActions.setFloatable(false);
    70                 toolBarActions.add(new IconToggleButton(this, new ZoomAction(this)));
     70                toolBarActions.add(new IconToggleButton(new ZoomAction(this)));
    7171                final SelectionAction selectionAction = new SelectionAction(this);
    72                 toolBarActions.add(new IconToggleButton(this, selectionAction));
    73                 toolBarActions.add(new IconToggleButton(this, new MoveAction(this)));
    74                 toolBarActions.add(new IconToggleButton(this, new AddNodeAction(this)));
    75                 toolBarActions.add(new IconToggleButton(this, new AddLineSegmentAction(this)));
    76                 toolBarActions.add(new IconToggleButton(this, new AddWayAction(this, selectionAction)));
    77                 toolBarActions.add(new IconToggleButton(this, new DeleteAction(this)));
     72                toolBarActions.add(new IconToggleButton(selectionAction));
     73                toolBarActions.add(new IconToggleButton(new MoveAction(this)));
     74                toolBarActions.add(new IconToggleButton(new AddNodeAction(this)));
     75                toolBarActions.add(new IconToggleButton(new AddLineSegmentAction(this)));
     76                toolBarActions.add(new IconToggleButton(new AddWayAction(this, selectionAction)));
     77                toolBarActions.add(new IconToggleButton(new DeleteAction(this)));
    7878
    7979                // all map modes in one button group
     
    8686                // autoScale
    8787                toolBarActions.addSeparator();
    88                 final JToggleButton autoScaleButton = new IconToggleButton(this, new AutoScaleAction(this));
     88                final JToggleButton autoScaleButton = new IconToggleButton(new AutoScaleAction(this));
    8989                toolBarActions.add(autoScaleButton);
    9090                autoScaleButton.setText(null);
     
    111111
    112112        private void addIconToggle(JPanel toggleDialogs, ToggleDialog dlg) {
    113                 toolBarActions.add(new IconToggleButton(this, dlg.action));
     113        toolBarActions.add(new IconToggleButton(dlg.action));
    114114                toggleDialogs.add(dlg);
    115115        }
  • src/org/openstreetmap/josm/gui/MapView.java

    r78 r79  
    2020import org.openstreetmap.josm.gui.layer.Layer;
    2121import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     22import org.openstreetmap.josm.gui.layer.WmsServerLayer;
    2223import org.openstreetmap.josm.gui.layer.OsmDataLayer.ModifiedChangedListener;
    2324
     
    108109
    109110                // add as a new layer
    110                 layers.add(0,layer);
     111        if (layer instanceof WmsServerLayer)
     112            layers.add(layers.size(), layer);
     113        else
     114            layers.add(0, layer);
    111115
    112116                for (LayerChangeListener l : listeners)
  • src/org/openstreetmap/josm/gui/PreferenceDialog.java

    r78 r79  
    6868                                pwd = null;
    6969                        Main.pref.put("osm-server.password", pwd);
     70                        Main.pref.put("wmsServerBaseUrl", wmsServerBaseUrl.getText());
    7071                        Main.pref.put("csvImportString", csvImportString.getText());
    7172                        Main.pref.put("drawRawGpsLines", drawRawGpsLines.isSelected());
     
    106107         * ComboBox with all look and feels.
    107108         */
    108         JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels());
     109    private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels());
    109110        /**
    110111         * Combobox with all projections available
    111112         */
    112         JComboBox projectionCombo = new JComboBox(Projection.allProjections);
     113    private JComboBox projectionCombo = new JComboBox(Projection.allProjections);
    113114        /**
    114115         * The main tab panel.
     
    119120         * Editfield for the Base url to the REST API from OSM.
    120121         */
    121         JTextField osmDataServer = new JTextField(20);
     122    private JTextField osmDataServer = new JTextField(20);
    122123        /**
    123124         * Editfield for the username to the OSM account.
    124125         */
    125         JTextField osmDataUsername = new JTextField(20);
     126    private JTextField osmDataUsername = new JTextField(20);
    126127        /**
    127128         * Passwordfield for the userpassword of the REST API.
    128129         */
    129         JPasswordField osmDataPassword = new JPasswordField(20);
     130    private JPasswordField osmDataPassword = new JPasswordField(20);
     131    /**
     132     * Base url of the WMS server. Holds everything except the bbox= argument.
     133     */
     134        private JTextField wmsServerBaseUrl = new JTextField(20);
    130135        /**
    131136         * Comma seperated import string specifier or <code>null</code> if the first
    132137         * data line should be interpreted as one.
    133138         */
    134         JTextField csvImportString = new JTextField(20);
     139    private JTextField csvImportString = new JTextField(20);
    135140        /**
    136141         * The checkbox stating whether nodes should be merged together.
    137142         */
    138         JCheckBox drawRawGpsLines = new JCheckBox("Draw lines between raw gps points.");
     143    private JCheckBox drawRawGpsLines = new JCheckBox("Draw lines between raw gps points.");
    139144        /**
    140145         * The checkbox stating whether raw gps lines should be forced.
    141146         */
    142         JCheckBox forceRawGpsLines = new JCheckBox("Force lines if no line segments imported.");
    143 
    144         JTable colors;
     147    private JCheckBox forceRawGpsLines = new JCheckBox("Force lines if no line segments imported.");
     148
     149    private JTable colors;
    145150       
    146151       
     
    199204                osmDataUsername.setText(Main.pref.get("osm-server.username"));
    200205                osmDataPassword.setText(Main.pref.get("osm-server.password"));
    201                 csvImportString.setText(Main.pref.get("csvImportString"));
     206        wmsServerBaseUrl.setText(Main.pref.get("wmsServerBaseUrl", "http://wms.jpl.nasa.gov/wms.cgi?request=GetMap&width=512&height=512&layers=global_mosaic&styles=&srs=EPSG:4326&format=image/jpeg&"));
     207        csvImportString.setText(Main.pref.get("csvImportString"));
    202208                drawRawGpsLines.setSelected(Main.pref.getBoolean("drawRawGpsLines"));
    203209                forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information.");
     
    258264                osmDataUsername.setToolTipText("Login name (email) to the OSM account.");
    259265                osmDataPassword.setToolTipText("Login password to the OSM account. Leave blank to not store any password.");
     266        wmsServerBaseUrl.setToolTipText("The base URL to the server retrieving WMS background pictures from.");
    260267                csvImportString.setToolTipText("<html>Import string specification. lat/lon and time are imported.<br>" +
    261268                                "<b>lat</b>: The latitude coordinate<br>" +
     
    297304                warning.setFont(warning.getFont().deriveFont(Font.ITALIC));
    298305                con.add(warning, GBC.eop().fill(GBC.HORIZONTAL));
     306                con.add(new JLabel("WMS server base url (everything except bbox-parameter)"), GBC.eol());
     307                con.add(wmsServerBaseUrl, GBC.eop().fill(GBC.HORIZONTAL));
     308                con.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
    299309                con.add(new JLabel("CSV import specification (empty: read from first line in data)"), GBC.eol());
    300310                con.add(csvImportString, GBC.eop().fill(GBC.HORIZONTAL));
  • src/org/openstreetmap/josm/gui/WorldChooser.java

    r73 r79  
    7676                                return "WorldChooser";
    7777                        }
     78            public String getCacheDirectoryName() {
     79                throw new UnsupportedOperationException();
     80            }
    7881                };
    7982                setMinimumSize(new Dimension(350, 350/2));
  • src/org/openstreetmap/josm/gui/dialogs/LayerList.java

    r78 r79  
    1212import java.util.Collection;
    1313
     14import javax.swing.AbstractAction;
     15import javax.swing.Action;
    1416import javax.swing.DefaultListCellRenderer;
    1517import javax.swing.DefaultListModel;
     
    4244public class LayerList extends ToggleDialog implements LayerChangeListener {
    4345
    44         /**
     46        public final static class DeleteLayerAction extends AbstractAction {
     47
     48        private final JList layers;
     49        private final Layer layer;
     50
     51        public DeleteLayerAction(JList layers, Layer layer) {
     52            super("Delete", ImageProvider.get("dialogs", "delete"));
     53            putValue(SHORT_DESCRIPTION, "Delete the selected layer.");
     54            this.layers = layers;
     55            this.layer = layer;
     56        }
     57
     58        public void actionPerformed(ActionEvent e) {
     59                if (layers.getModel().getSize() == 1) {
     60                        Main.main.setMapFrame(null);
     61                        Main.main.ds = new DataSet();
     62                } else {
     63                    int sel = layers.getSelectedIndex();
     64                if (layer != null)
     65                    Main.main.getMapFrame().mapView.removeLayer(layer);
     66                else
     67                    Main.main.getMapFrame().mapView.removeLayer((Layer)layers.getSelectedValue());
     68                if (sel >= layers.getModel().getSize())
     69                    sel = layers.getModel().getSize()-1;
     70                if (layers.getSelectedValue() == null)
     71                    layers.setSelectedIndex(sel);
     72                }
     73        }
     74    }
     75
     76    public final static class ShowHideLayerAction extends AbstractAction {
     77        private final Layer layer;
     78        private final JList layers;
     79
     80        public ShowHideLayerAction(JList layers, Layer layer) {
     81            super("Show/Hide", ImageProvider.get("dialogs", "showhide"));
     82            putValue(SHORT_DESCRIPTION, "Toggle visible state of the selected layer.");
     83            this.layer = layer;
     84            this.layers = layers;
     85        }
     86
     87        public void actionPerformed(ActionEvent e) {
     88            Layer l = layer == null ? (Layer)layers.getSelectedValue() : layer;
     89            l.visible = !l.visible;
     90                Main.main.getMapFrame().mapView.repaint();
     91                layers.repaint();
     92        }
     93    }
     94
     95    /**
    4596         * The data model for the list component.
    4697         */
     
    71122         * Button for delete layer.
    72123         */
    73         private JButton deleteButton = new JButton(ImageProvider.get("dialogs", "delete"));
     124        private Action deleteAction = new DeleteLayerAction(layers, null);
    74125
    75126        /**
     
    77128         */
    78129        public LayerList(MapFrame mapFrame) {
    79                 super("Layers", "List of all layers", "layerlist", "Open a list of all loaded layers.", "L", KeyEvent.VK_L);
     130                super("Layers", "List of all layers", "layerlist", "Open a list of all loaded layers.", "L", KeyEvent.VK_L, "layerlist");
    80131                setPreferredSize(new Dimension(320,100));
    81132                add(new JScrollPane(layers), BorderLayout.CENTER);
     
    117168                                int index = layers.locationToIndex(e.getPoint());
    118169                                Layer layer = (Layer)layers.getModel().getElementAt(index);
    119                                 LayerListPopup menu = new LayerListPopup(layer);
     170                                LayerListPopup menu = new LayerListPopup(layers, layer);
    120171                                menu.show(LayerList.this, e.getX(), e.getY());
    121172                        }
     
    158209                buttonPanel.add(downButton);
    159210               
    160                 JButton visible = new JButton(ImageProvider.get("dialogs", "showhide"));
    161                 visible.setToolTipText("Toggle visible state of the selected layer.");
    162                 visible.addActionListener(new ActionListener(){
    163                         public void actionPerformed(ActionEvent e) {
    164                                 Layer l = (Layer)layers.getSelectedValue();
    165                                 l.visible = !l.visible;
    166                                 mapView.repaint();
    167                                 layers.repaint();
    168                         }
    169                 });
    170                 buttonPanel.add(visible);
    171 
    172                 deleteButton.setToolTipText("Delete the selected layer.");
    173                 deleteButton.addActionListener(new ActionListener(){
    174                         public void actionPerformed(ActionEvent e) {
    175                                 if (model.size() == 1) {
    176                                         Main.main.setMapFrame(null);
    177                                         Main.main.ds = new DataSet();
    178                                 } else {
    179                                         int sel = layers.getSelectedIndex();
    180                                         mapView.removeLayer((Layer)layers.getSelectedValue());
    181                                         if (sel >= model.getSize())
    182                                                 sel = model.getSize()-1;
    183                                         layers.setSelectedIndex(sel);
    184                                 }
    185                         }
    186                 });
    187                 buttonPanel.add(deleteButton);
     211                JButton showHideButton = new JButton(new ShowHideLayerAction(layers, null));
     212        showHideButton.setText("");
     213        buttonPanel.add(showHideButton);
     214               
     215        JButton deleteButton = new JButton(deleteAction);
     216        deleteButton.setText("");
     217        buttonPanel.add(deleteButton);
    188218
    189219                mergeButton.setToolTipText("Merge the selected layer into the layer directly below.");
     
    216246                upButton.setEnabled(sel > 0);
    217247                downButton.setEnabled(sel < model.getSize()-1);
    218                 deleteButton.setEnabled(!model.isEmpty());
     248                deleteAction.setEnabled(!model.isEmpty());
    219249        }
    220250
  • src/org/openstreetmap/josm/gui/dialogs/LayerListPopup.java

    r78 r79  
    66
    77import javax.swing.JColorChooser;
     8import javax.swing.JList;
    89import javax.swing.JMenuItem;
    910import javax.swing.JOptionPane;
    1011import javax.swing.JPopupMenu;
    11 import javax.swing.JSeparator;
    1212
    1313import org.openstreetmap.josm.Main;
     
    1717import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1818import org.openstreetmap.josm.gui.layer.RawGpsDataLayer;
     19import org.openstreetmap.josm.gui.layer.WmsServerLayer;
    1920import org.openstreetmap.josm.tools.ColorHelper;
    2021import org.openstreetmap.josm.tools.ImageProvider;
     
    2526public class LayerListPopup extends JPopupMenu {
    2627
    27         public LayerListPopup(final Layer layer) {
     28        public LayerListPopup(final JList layers, final Layer layer) {
     29        add(new LayerList.ShowHideLayerAction(layers, layer));
     30        add(new LayerList.DeleteLayerAction(layers, layer));
     31        addSeparator();
     32       
    2833                if (layer instanceof OsmDataLayer)
    2934                        add(new JMenuItem(new SaveAction()));
    3035
    31                 add(new JMenuItem(new GpxExportAction(layer)));
    32                
     36        if (!(layer instanceof WmsServerLayer))
     37            add(new JMenuItem(new GpxExportAction(layer)));
    3338
    3439                if (layer instanceof RawGpsDataLayer) {
     
    5661                }
    5762
    58                 add(new JSeparator());
    59                
     63        if (!(layer instanceof WmsServerLayer))
     64            addSeparator();
     65
    6066                JMenuItem info = new JMenuItem("Info", ImageProvider.get("info"));
    6167                info.addActionListener(new ActionListener(){
  • src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r71 r79  
    213213         */
    214214        public PropertiesDialog(MapFrame mapFrame) {
    215                 super("Properties", "Properties Dialog", "properties", "Property for selected objects.", "P", KeyEvent.VK_P);
     215                super("Properties", "Properties Dialog", "properties", "Property for selected objects.", "P", KeyEvent.VK_P, "propertiesdialog");
    216216                mv = mapFrame.mapView;
    217217
  • src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r71 r79  
    5151         */
    5252        public SelectionListDialog(MapFrame mapFrame) {
    53                 super("Current Selection", "Selection List", "selectionlist", "Open a selection list window.", "E", KeyEvent.VK_E);
     53                super("Current Selection", "Selection List", "selectionlist", "Open a selection list window.", "E", KeyEvent.VK_E, "selectionlist");
    5454                setPreferredSize(new Dimension(320,150));
    5555                displaylist.setCellRenderer(new OsmPrimitivRenderer());
  • src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r68 r79  
    22
    33import java.awt.BorderLayout;
     4import java.awt.EventQueue;
    45import java.awt.event.ActionEvent;
    56import java.awt.event.KeyEvent;
    67
    78import javax.swing.AbstractButton;
     9import javax.swing.Action;
    810import javax.swing.BorderFactory;
    911import javax.swing.JLabel;
     
    1113import javax.swing.KeyStroke;
    1214
     15import org.openstreetmap.josm.Main;
    1316import org.openstreetmap.josm.actions.JosmAction;
    1417
     
    2932         * Create a new ToggleDialog.
    3033         * @param title The title of the dialog.
     34     * @param prefName Name of the base preference setting string (prefix)
     35     *      with the final . (e.g.: "layerlist.")
    3136         */
    32         public ToggleDialog(String title, String name, String iconName, String tooltip, String shortCutName, int shortCut) {
     37        public ToggleDialog(String title, String name, String iconName, String tooltip, String shortCutName, int shortCut, final String prefName) {
    3338                action = new JosmAction(name, "dialogs/"+iconName, tooltip, "Alt-"+shortCutName, KeyStroke.getKeyStroke(shortCut, KeyEvent.ALT_MASK)){
    3439                        public void actionPerformed(ActionEvent e) {
    3540                                boolean show = !isVisible();
    36                                 if (e.getSource() instanceof AbstractButton)
     41                                if (e != null && e.getSource() instanceof AbstractButton)
    3742                                        show = ((AbstractButton)e.getSource()).isSelected();
    3843                                setVisible(show);
     44                Main.pref.put(prefName+"visible", show);
    3945                        }
    4046                };
     
    4450                setVisible(false);
    4551                setBorder(BorderFactory.createEtchedBorder());
     52                if (Main.pref.getBoolean(prefName+"visible")) {
     53                    EventQueue.invokeLater(new Runnable(){
     54                        public void run() {
     55                            action.putValue(Action.SELECTED_KEY, true);
     56                            action.actionPerformed(null);
     57                        }
     58                    });
     59        }
    4660        }
    4761}
  • src/org/openstreetmap/josm/io/GpxWriter.java

    r78 r79  
    465465                                LatLon ll = p.latlon;
    466466                                out.print("      <trkpt lat='"+ll.lat()+"' lon='"+ll.lon()+"'");
    467                                 if (p.time != null && !p.time.isEmpty()) {
     467                                if (p.time != null && p.time.length()!=0) {
    468468                                        out.println(">");
    469469                                        out.println("        <time>"+p.time+"</time>");
  • src/org/openstreetmap/josm/io/OsmReader.java

    r72 r79  
    7474                                        throw new SAXException("Unknown version.");
    7575                                if (!"0.3".equals(atts.getValue("version")))
    76                                         throw new SAXException("Unknown version: "+atts.getValue("version"));
     76                                        throw new SAXException("Unknown version "+atts.getValue("version"));
    7777                        } else if (qName.equals("node")) {
    7878                                Node n = new Node(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon")));
     
    9393                                if (current instanceof Way) {
    9494                                        long id = getLong(atts, "id");
     95                                        if (id == 0)
     96                                                throw new SAXException("Incomplete line segment with id=0");
    9597                                        LineSegment ls = lineSegments.get(id);
    9698                                        if (ls == null) {
     
    105107                        }
    106108                } catch (NumberFormatException x) {
     109            x.printStackTrace(); // SAXException does not chain correctly
    107110                        throw new SAXException(x.getMessage(), x);
    108111                } catch (NullPointerException x) {
     
    122125         * Read out the common attributes from atts and put them into this.current.
    123126         */
    124         private void readCommon(Attributes atts) {
     127        private void readCommon(Attributes atts) throws SAXException {
    125128                current.id = getLong(atts, "id");
     129                if (current.id == 0)
     130                        throw new SAXException("Illegal object with id=0");
    126131                String action = atts.getValue("action");
    127132                if ("delete".equals(action))
  • src/org/openstreetmap/josm/io/OsmServerWriter.java

    r78 r79  
    6666        public void visit(Node n) {
    6767                if (n.id == 0 && !n.isDeleted()) {
     68                        n.put("created_by", "JOSM");
    6869                        sendRequest("PUT", "node", n, true);
    6970                } else if (n.isDeleted()) {
     
    8081        public void visit(LineSegment ls) {
    8182                if (ls.id == 0 && !ls.isDeleted()) {
     83                        ls.put("created_by", "JOSM");
    8284                        sendRequest("PUT", "segment", ls, true);
    8385                } else if (ls.isDeleted()) {
     
    9496        public void visit(Way w) {
    9597                if (w.id == 0 && !w.isDeleted()) {
     98                        w.put("created_by", "JOSM");
    9699                        sendRequest("PUT", "way", w, true);
    97100                } else if (w.isDeleted()) {
  • src/org/openstreetmap/josm/tools/ImageProvider.java

    r75 r79  
    44import java.awt.GraphicsConfiguration;
    55import java.awt.GraphicsEnvironment;
     6import java.awt.Image;
     7import java.awt.Toolkit;
    68import java.awt.Transparency;
    79import java.awt.image.BufferedImage;
     
    3739         * The icon cache
    3840         */
    39         private static Map<URL, ImageIcon> cache = new HashMap<URL, ImageIcon>();
     41        private static Map<URL, Image> cache = new HashMap<URL, Image>();
    4042       
    4143        /**
     
    4446         * @param subdir        The position of the directory, e.g. "layer"
    4547         * @param name          The icons name (without the ending of ".png")
    46          * @return      The requested ImageIcon.
     48         * @return The requested Image.
    4749         */
    4850        public static ImageIcon get(String subdir, String name) {
    4951                if (subdir != "")
    5052                        subdir += "/";
    51                 URL path = Main.class.getResource("/images/"+subdir+name+".png");
     53        String ext = name.indexOf('.') != -1 ? "" : ".png";
     54                URL path = Main.class.getResource("/images/"+subdir+name+ext);
    5255                if (path == null)
    53                         throw new NullPointerException("/images/"+subdir+name+".png not found");
    54                 ImageIcon icon = cache.get(path);
    55                 if (icon == null) {
    56                         icon = new ImageIcon(path);
    57                         cache.put(path, icon);
     56                        throw new NullPointerException("/images/"+subdir+name+ext+" not found");
     57                Image img = cache.get(path);
     58                if (img == null) {
     59                        img = Toolkit.getDefaultToolkit().createImage(path);
     60                        cache.put(path, img);
    5861                }
    59                 return icon;
     62                return new ImageIcon(img);
    6063        }
    6164
Note: See TracChangeset for help on using the changeset viewer.