Changeset 79 in josm
- Timestamp:
- 2006-04-03T22:25:02+02:00 (19 years ago)
- Files:
-
- 10 added
- 1 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r78 r79 35 35 import org.openstreetmap.josm.actions.UndoAction; 36 36 import org.openstreetmap.josm.actions.UploadAction; 37 import org.openstreetmap.josm.actions.WmsServerAction; 37 38 import org.openstreetmap.josm.data.Preferences; 38 39 import org.openstreetmap.josm.data.osm.DataSet; 39 import org.openstreetmap.josm.data.projection.Epsg4 263;40 import org.openstreetmap.josm.data.projection.Epsg4326; 40 41 import org.openstreetmap.josm.data.projection.Projection; 41 42 import org.openstreetmap.josm.gui.MapFrame; … … 83 84 84 85 private OpenAction openAction; 85 86 86 private DownloadAction downloadAction; 87 private Action wmsServerAction; 87 88 88 89 /** … … 101 102 downloadAction = new DownloadAction(); 102 103 Action uploadAction = new UploadAction(); 103 openAction = new OpenAction(); 104 wmsServerAction = new WmsServerAction(); 105 openAction = new OpenAction(); 104 106 Action saveAction = new SaveAction(); 105 107 Action gpxExportAction = new GpxExportAction(null); … … 124 126 125 127 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); 131 135 132 136 JMenu editMenu = new JMenu("Edit"); … … 149 153 toolBar.add(downloadAction); 150 154 toolBar.add(uploadAction); 155 //toolBar.add(new IconToggleButton(wmsServerAction)); 151 156 toolBar.addSeparator(); 152 157 toolBar.add(openAction); … … 242 247 e.printStackTrace(); 243 248 JOptionPane.showMessageDialog(null, "The projection could not be read from preferences. Using EPSG:4263."); 244 proj = new Epsg4 263();249 proj = new Epsg4326(); 245 250 } 246 251 … … 320 325 mapFrame.setVisible(true); 321 326 } 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); 322 331 } 323 332 /** -
src/org/openstreetmap/josm/actions/DiskAccessAction.java
r78 r79 29 29 protected boolean isDataSetEmpty() { 30 30 for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives()) 31 if ( osm.id > 0)31 if (!osm.isDeleted() || osm.id > 0) 32 32 return false; 33 33 return true; -
src/org/openstreetmap/josm/actions/DownloadAction.java
r77 r79 356 356 closeDialog(); 357 357 x.printStackTrace(); 358 JOptionPane.showMessageDialog(Main.main, x.getMessage());358 JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage()); 359 359 } catch (JDOMException x) { 360 360 closeDialog(); 361 361 x.printStackTrace(); 362 JOptionPane.showMessageDialog(Main.main, x.getMessage());362 JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage()); 363 363 } catch (FileNotFoundException x) { 364 364 closeDialog(); 365 365 x.printStackTrace(); 366 JOptionPane.showMessageDialog(Main.main, 367 "URL nicht gefunden: " + x.getMessage()); 366 JOptionPane.showMessageDialog(Main.main, "URL not found: " + x.getMessage()); 368 367 } catch (IOException x) { 369 368 closeDialog(); -
src/org/openstreetmap/josm/actions/GpxExportAction.java
r78 r79 107 107 108 108 Main.pref.put("lastAddAuthor", author.isSelected()); 109 if ( !authorName.getText().isEmpty())109 if (authorName.getText().length() != 0) 110 110 Main.pref.put("lastAuthorName", authorName.getText()); 111 if ( !copyright.getText().isEmpty())111 if (copyright.getText().length() != 0) 112 112 Main.pref.put("lastCopyright", copyright.getText()); 113 113 … … 160 160 email.setText(b ? Main.pref.get("osm-server.username") : ""); 161 161 162 boolean authorSet = !authorName.getText().isEmpty();162 boolean authorSet = authorName.getText().length() != 0; 163 163 enableCopyright(copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b && authorSet); 164 164 } … … 168 168 KeyAdapter authorNameListener = new KeyAdapter(){ 169 169 @Override public void keyReleased(KeyEvent e) { 170 boolean b = !authorName.getText().isEmpty()&& author.isSelected();170 boolean b = authorName.getText().length()!=0 && author.isSelected(); 171 171 enableCopyright(copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b); 172 172 } … … 193 193 break; 194 194 } 195 license += license. isEmpty()? urls[i] : ", "+urls[i];195 license += license.length()==0 ? urls[i] : ", "+urls[i]; 196 196 } 197 197 copyright.setText(license); … … 212 212 warning.setText(enable ? warningGpl : "<html><font size='-2'> </html"); 213 213 214 if (enable && copyrightYear.getText(). isEmpty()) {214 if (enable && copyrightYear.getText().length()==0) { 215 215 copyrightYear.setText(enable ? Integer.toString(Calendar.getInstance().get(Calendar.YEAR)) : ""); 216 216 } else if (!enable) 217 217 copyrightYear.setText(""); 218 218 219 if (enable && copyright.getText(). isEmpty()) {219 if (enable && copyright.getText().length()==0) { 220 220 copyright.setText(enable ? Main.pref.get("lastCopyright", "http://creativecommons.org/licenses/by-sa/2.5") : ""); 221 221 copyright.setCaretPosition(0); -
src/org/openstreetmap/josm/actions/OpenAction.java
r78 r79 81 81 dataSet = OsmReader.parseDataSet(new FileReader(filename)); 82 82 } catch (SAXException x) { 83 if (x.getMessage().equals("Unknown version :null")) {83 if (x.getMessage().equals("Unknown version null")) { 84 84 int answer = JOptionPane.showConfirmDialog(Main.main, 85 85 fn+" seems to be an old 0.2 API XML file.\n" + … … 112 112 } catch (SAXException x) { 113 113 x.printStackTrace(); 114 JOptionPane.showMessageDialog(Main.main, x.getMessage());114 JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage()); 115 115 } catch (JDOMException x) { 116 116 x.printStackTrace(); 117 JOptionPane.showMessageDialog(Main.main, x.getMessage());117 JOptionPane.showMessageDialog(Main.main, "Error while parsing: "+x.getMessage()); 118 118 } catch (IOException x) { 119 119 x.printStackTrace(); -
src/org/openstreetmap/josm/data/Preferences.java
r78 r79 135 135 properties.clear(); 136 136 properties.put("laf", "javax.swing.plaf.metal.MetalLookAndFeel"); 137 properties.put("projection", "org.openstreetmap.josm.data.projection.Epsg4 263");137 properties.put("projection", "org.openstreetmap.josm.data.projection.Epsg4326"); 138 138 properties.put("osm-server.url", "http://www.openstreetmap.org/api"); 139 139 properties.put("color.node", ColorHelper.color2html(Color.red)); -
src/org/openstreetmap/josm/data/coor/EastNorth.java
r72 r79 24 24 @Override 25 25 public String toString() { 26 return " (EastNorth e="+x+", n="+y+")";26 return "EastNorth[e="+x+", n="+y+"]"; 27 27 } 28 28 } -
src/org/openstreetmap/josm/data/coor/LatLon.java
r71 r79 41 41 lon() < -Projection.MAX_LON || lon() > Projection.MAX_LON; 42 42 } 43 44 @Override 45 public String toString() { 46 return "LatLon[lat="+lat()+",lon="+lon()+"]"; 47 } 43 48 } -
src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java
r78 r79 38 38 if (name == null) { 39 39 if (ls.incomplete) 40 name = ""+ls.id;40 name = ls.id == 0 ? "new" : ""+ls.id; 41 41 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()+")"; 43 43 } 44 44 icon = ImageProvider.get("data", "segment"); … … 52 52 name = n.get("name"); 53 53 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()+")"; 55 55 icon = ImageProvider.get("data", "node"); 56 56 } -
src/org/openstreetmap/josm/data/projection/Mercator.java
r73 r79 31 31 return "Mercator"; 32 32 } 33 34 public String getCacheDirectoryName() { 35 return "mercator"; 36 } 33 37 } -
src/org/openstreetmap/josm/data/projection/Projection.java
r78 r79 20 20 */ 21 21 public static final Projection[] allProjections = new Projection[]{ 22 new Epsg4 263(),22 new Epsg4326(), 23 23 new Mercator() 24 24 }; … … 42 42 */ 43 43 String toString(); 44 45 /** 46 * Get a filename compatible string (for the cache directory) 47 */ 48 String getCacheDirectoryName(); 44 49 } -
src/org/openstreetmap/josm/gui/IconToggleButton.java
r30 r79 5 5 6 6 import javax.swing.Action; 7 import javax.swing.JComponent;8 7 import javax.swing.JToggleButton; 9 8 … … 19 18 * Construct the toggle button with the given action. 20 19 */ 21 public IconToggleButton( JComponent acceleratorReceiver,Action action) {20 public IconToggleButton(Action action) { 22 21 super(action); 23 22 setText(null); -
src/org/openstreetmap/josm/gui/MapFrame.java
r68 r79 68 68 // toolbar 69 69 toolBarActions.setFloatable(false); 70 toolBarActions.add(new IconToggleButton( this,new ZoomAction(this)));70 toolBarActions.add(new IconToggleButton(new ZoomAction(this))); 71 71 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))); 78 78 79 79 // all map modes in one button group … … 86 86 // autoScale 87 87 toolBarActions.addSeparator(); 88 final JToggleButton autoScaleButton = new IconToggleButton( this,new AutoScaleAction(this));88 final JToggleButton autoScaleButton = new IconToggleButton(new AutoScaleAction(this)); 89 89 toolBarActions.add(autoScaleButton); 90 90 autoScaleButton.setText(null); … … 111 111 112 112 private void addIconToggle(JPanel toggleDialogs, ToggleDialog dlg) { 113 toolBarActions.add(new IconToggleButton(this,dlg.action));113 toolBarActions.add(new IconToggleButton(dlg.action)); 114 114 toggleDialogs.add(dlg); 115 115 } -
src/org/openstreetmap/josm/gui/MapView.java
r78 r79 20 20 import org.openstreetmap.josm.gui.layer.Layer; 21 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 import org.openstreetmap.josm.gui.layer.WmsServerLayer; 22 23 import org.openstreetmap.josm.gui.layer.OsmDataLayer.ModifiedChangedListener; 23 24 … … 108 109 109 110 // 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); 111 115 112 116 for (LayerChangeListener l : listeners) -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r78 r79 68 68 pwd = null; 69 69 Main.pref.put("osm-server.password", pwd); 70 Main.pref.put("wmsServerBaseUrl", wmsServerBaseUrl.getText()); 70 71 Main.pref.put("csvImportString", csvImportString.getText()); 71 72 Main.pref.put("drawRawGpsLines", drawRawGpsLines.isSelected()); … … 106 107 * ComboBox with all look and feels. 107 108 */ 108 109 private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 109 110 /** 110 111 * Combobox with all projections available 111 112 */ 112 113 private JComboBox projectionCombo = new JComboBox(Projection.allProjections); 113 114 /** 114 115 * The main tab panel. … … 119 120 * Editfield for the Base url to the REST API from OSM. 120 121 */ 121 122 private JTextField osmDataServer = new JTextField(20); 122 123 /** 123 124 * Editfield for the username to the OSM account. 124 125 */ 125 126 private JTextField osmDataUsername = new JTextField(20); 126 127 /** 127 128 * Passwordfield for the userpassword of the REST API. 128 129 */ 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); 130 135 /** 131 136 * Comma seperated import string specifier or <code>null</code> if the first 132 137 * data line should be interpreted as one. 133 138 */ 134 139 private JTextField csvImportString = new JTextField(20); 135 140 /** 136 141 * The checkbox stating whether nodes should be merged together. 137 142 */ 138 143 private JCheckBox drawRawGpsLines = new JCheckBox("Draw lines between raw gps points."); 139 144 /** 140 145 * The checkbox stating whether raw gps lines should be forced. 141 146 */ 142 143 144 147 private JCheckBox forceRawGpsLines = new JCheckBox("Force lines if no line segments imported."); 148 149 private JTable colors; 145 150 146 151 … … 199 204 osmDataUsername.setText(Main.pref.get("osm-server.username")); 200 205 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")); 202 208 drawRawGpsLines.setSelected(Main.pref.getBoolean("drawRawGpsLines")); 203 209 forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information."); … … 258 264 osmDataUsername.setToolTipText("Login name (email) to the OSM account."); 259 265 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."); 260 267 csvImportString.setToolTipText("<html>Import string specification. lat/lon and time are imported.<br>" + 261 268 "<b>lat</b>: The latitude coordinate<br>" + … … 297 304 warning.setFont(warning.getFont().deriveFont(Font.ITALIC)); 298 305 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)); 299 309 con.add(new JLabel("CSV import specification (empty: read from first line in data)"), GBC.eol()); 300 310 con.add(csvImportString, GBC.eop().fill(GBC.HORIZONTAL)); -
src/org/openstreetmap/josm/gui/WorldChooser.java
r73 r79 76 76 return "WorldChooser"; 77 77 } 78 public String getCacheDirectoryName() { 79 throw new UnsupportedOperationException(); 80 } 78 81 }; 79 82 setMinimumSize(new Dimension(350, 350/2)); -
src/org/openstreetmap/josm/gui/dialogs/LayerList.java
r78 r79 12 12 import java.util.Collection; 13 13 14 import javax.swing.AbstractAction; 15 import javax.swing.Action; 14 16 import javax.swing.DefaultListCellRenderer; 15 17 import javax.swing.DefaultListModel; … … 42 44 public class LayerList extends ToggleDialog implements LayerChangeListener { 43 45 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 /** 45 96 * The data model for the list component. 46 97 */ … … 71 122 * Button for delete layer. 72 123 */ 73 private JButton deleteButton = new JButton(ImageProvider.get("dialogs", "delete"));124 private Action deleteAction = new DeleteLayerAction(layers, null); 74 125 75 126 /** … … 77 128 */ 78 129 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"); 80 131 setPreferredSize(new Dimension(320,100)); 81 132 add(new JScrollPane(layers), BorderLayout.CENTER); … … 117 168 int index = layers.locationToIndex(e.getPoint()); 118 169 Layer layer = (Layer)layers.getModel().getElementAt(index); 119 LayerListPopup menu = new LayerListPopup(layer );170 LayerListPopup menu = new LayerListPopup(layers, layer); 120 171 menu.show(LayerList.this, e.getX(), e.getY()); 121 172 } … … 158 209 buttonPanel.add(downButton); 159 210 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); 188 218 189 219 mergeButton.setToolTipText("Merge the selected layer into the layer directly below."); … … 216 246 upButton.setEnabled(sel > 0); 217 247 downButton.setEnabled(sel < model.getSize()-1); 218 delete Button.setEnabled(!model.isEmpty());248 deleteAction.setEnabled(!model.isEmpty()); 219 249 } 220 250 -
src/org/openstreetmap/josm/gui/dialogs/LayerListPopup.java
r78 r79 6 6 7 7 import javax.swing.JColorChooser; 8 import javax.swing.JList; 8 9 import javax.swing.JMenuItem; 9 10 import javax.swing.JOptionPane; 10 11 import javax.swing.JPopupMenu; 11 import javax.swing.JSeparator;12 12 13 13 import org.openstreetmap.josm.Main; … … 17 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 18 import org.openstreetmap.josm.gui.layer.RawGpsDataLayer; 19 import org.openstreetmap.josm.gui.layer.WmsServerLayer; 19 20 import org.openstreetmap.josm.tools.ColorHelper; 20 21 import org.openstreetmap.josm.tools.ImageProvider; … … 25 26 public class LayerListPopup extends JPopupMenu { 26 27 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 28 33 if (layer instanceof OsmDataLayer) 29 34 add(new JMenuItem(new SaveAction())); 30 35 31 add(new JMenuItem(new GpxExportAction(layer))); 32 36 if (!(layer instanceof WmsServerLayer)) 37 add(new JMenuItem(new GpxExportAction(layer))); 33 38 34 39 if (layer instanceof RawGpsDataLayer) { … … 56 61 } 57 62 58 add(new JSeparator()); 59 63 if (!(layer instanceof WmsServerLayer)) 64 addSeparator(); 65 60 66 JMenuItem info = new JMenuItem("Info", ImageProvider.get("info")); 61 67 info.addActionListener(new ActionListener(){ -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r71 r79 213 213 */ 214 214 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"); 216 216 mv = mapFrame.mapView; 217 217 -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r71 r79 51 51 */ 52 52 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"); 54 54 setPreferredSize(new Dimension(320,150)); 55 55 displaylist.setCellRenderer(new OsmPrimitivRenderer()); -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r68 r79 2 2 3 3 import java.awt.BorderLayout; 4 import java.awt.EventQueue; 4 5 import java.awt.event.ActionEvent; 5 6 import java.awt.event.KeyEvent; 6 7 7 8 import javax.swing.AbstractButton; 9 import javax.swing.Action; 8 10 import javax.swing.BorderFactory; 9 11 import javax.swing.JLabel; … … 11 13 import javax.swing.KeyStroke; 12 14 15 import org.openstreetmap.josm.Main; 13 16 import org.openstreetmap.josm.actions.JosmAction; 14 17 … … 29 32 * Create a new ToggleDialog. 30 33 * @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.") 31 36 */ 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) { 33 38 action = new JosmAction(name, "dialogs/"+iconName, tooltip, "Alt-"+shortCutName, KeyStroke.getKeyStroke(shortCut, KeyEvent.ALT_MASK)){ 34 39 public void actionPerformed(ActionEvent e) { 35 40 boolean show = !isVisible(); 36 if (e .getSource() instanceof AbstractButton)41 if (e != null && e.getSource() instanceof AbstractButton) 37 42 show = ((AbstractButton)e.getSource()).isSelected(); 38 43 setVisible(show); 44 Main.pref.put(prefName+"visible", show); 39 45 } 40 46 }; … … 44 50 setVisible(false); 45 51 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 } 46 60 } 47 61 } -
src/org/openstreetmap/josm/io/GpxWriter.java
r78 r79 465 465 LatLon ll = p.latlon; 466 466 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) { 468 468 out.println(">"); 469 469 out.println(" <time>"+p.time+"</time>"); -
src/org/openstreetmap/josm/io/OsmReader.java
r72 r79 74 74 throw new SAXException("Unknown version."); 75 75 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")); 77 77 } else if (qName.equals("node")) { 78 78 Node n = new Node(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon"))); … … 93 93 if (current instanceof Way) { 94 94 long id = getLong(atts, "id"); 95 if (id == 0) 96 throw new SAXException("Incomplete line segment with id=0"); 95 97 LineSegment ls = lineSegments.get(id); 96 98 if (ls == null) { … … 105 107 } 106 108 } catch (NumberFormatException x) { 109 x.printStackTrace(); // SAXException does not chain correctly 107 110 throw new SAXException(x.getMessage(), x); 108 111 } catch (NullPointerException x) { … … 122 125 * Read out the common attributes from atts and put them into this.current. 123 126 */ 124 private void readCommon(Attributes atts) {127 private void readCommon(Attributes atts) throws SAXException { 125 128 current.id = getLong(atts, "id"); 129 if (current.id == 0) 130 throw new SAXException("Illegal object with id=0"); 126 131 String action = atts.getValue("action"); 127 132 if ("delete".equals(action)) -
src/org/openstreetmap/josm/io/OsmServerWriter.java
r78 r79 66 66 public void visit(Node n) { 67 67 if (n.id == 0 && !n.isDeleted()) { 68 n.put("created_by", "JOSM"); 68 69 sendRequest("PUT", "node", n, true); 69 70 } else if (n.isDeleted()) { … … 80 81 public void visit(LineSegment ls) { 81 82 if (ls.id == 0 && !ls.isDeleted()) { 83 ls.put("created_by", "JOSM"); 82 84 sendRequest("PUT", "segment", ls, true); 83 85 } else if (ls.isDeleted()) { … … 94 96 public void visit(Way w) { 95 97 if (w.id == 0 && !w.isDeleted()) { 98 w.put("created_by", "JOSM"); 96 99 sendRequest("PUT", "way", w, true); 97 100 } else if (w.isDeleted()) { -
src/org/openstreetmap/josm/tools/ImageProvider.java
r75 r79 4 4 import java.awt.GraphicsConfiguration; 5 5 import java.awt.GraphicsEnvironment; 6 import java.awt.Image; 7 import java.awt.Toolkit; 6 8 import java.awt.Transparency; 7 9 import java.awt.image.BufferedImage; … … 37 39 * The icon cache 38 40 */ 39 private static Map<URL, Image Icon> cache = new HashMap<URL, ImageIcon>();41 private static Map<URL, Image> cache = new HashMap<URL, Image>(); 40 42 41 43 /** … … 44 46 * @param subdir The position of the directory, e.g. "layer" 45 47 * @param name The icons name (without the ending of ".png") 46 * @return The requested ImageIcon.48 * @return The requested Image. 47 49 */ 48 50 public static ImageIcon get(String subdir, String name) { 49 51 if (subdir != "") 50 52 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); 52 55 if (path == null) 53 throw new NullPointerException("/images/"+subdir+name+ ".pngnot found");54 Image Icon icon= cache.get(path);55 if (i con== null) {56 i con = new ImageIcon(path);57 cache.put(path, i con);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); 58 61 } 59 return icon;62 return new ImageIcon(img); 60 63 } 61 64
Note:
See TracChangeset
for help on using the changeset viewer.