Changeset 99 in josm
- Timestamp:
- 2006-04-27T01:29:55+02:00 (19 years ago)
- Files:
-
- 10 added
- 25 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
.classpath
r86 r99 7 7 <classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/> 8 8 <classpathentry kind="lib" path="lib/MinML2.jar"/> 9 <classpathentry sourcepath="C:/projects/metadata-extractor/src" kind="lib" path="lib/metadata-extractor-2.3.1.jar"/> 9 10 <classpathentry kind="output" path="bin"/> 10 11 </classpath> -
src/org/openstreetmap/josm/Main.java
r98 r99 100 100 public void layerRemoved(final Layer oldLayer) {} 101 101 }); 102 if (map.mapView.editLayer != null) 103 map.mapView.editLayer.listenerCommands.add(redoUndoListener); 102 104 } 103 105 redoUndoListener.commandChanged(0,0); … … 206 208 * Use this to register shortcuts to 207 209 */ 208 public static JPanel panel= new JPanel(new BorderLayout());210 public static final JPanel contentPane = new JPanel(new BorderLayout()); 209 211 210 212 … … 214 216 215 217 218 private static JPanel panel = new JPanel(new BorderLayout()); 219 216 220 protected final JMenuBar mainMenu = new JMenuBar(); 217 protected static final JPanel contentPane = new JPanel(new BorderLayout());218 221 protected static Rectangle bounds; 219 222 -
src/org/openstreetmap/josm/actions/DownloadAction.java
r98 r99 38 38 import org.openstreetmap.josm.gui.BookmarkList.Bookmark; 39 39 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 40 import org.openstreetmap.josm.gui.layer.RawGps DataLayer;41 import org.openstreetmap.josm.gui.layer.RawGps DataLayer.GpsPoint;40 import org.openstreetmap.josm.gui.layer.RawGpsLayer; 41 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 42 42 import org.openstreetmap.josm.io.OsmServerReader; 43 43 import org.openstreetmap.josm.tools.GBC; … … 104 104 return; 105 105 String name = latlon[0].getText() + " " + latlon[1].getText() + " x " + latlon[2].getText() + " " + latlon[3].getText(); 106 Main.main.addLayer(new RawGps DataLayer(rawData, name));106 Main.main.addLayer(new RawGpsLayer(rawData, name)); 107 107 } 108 108 … … 170 170 mv.getLatLon(0, mv.getHeight()), 171 171 mv.getLatLon(mv.getWidth(), 0))); 172 rawGps.setSelected(mv.getActiveLayer() instanceof RawGps DataLayer);172 rawGps.setSelected(mv.getActiveLayer() instanceof RawGpsLayer); 173 173 } 174 174 dlg.add(rawGps, GBC.eop()); -
src/org/openstreetmap/josm/actions/GpxExportAction.java
r98 r99 27 27 import org.openstreetmap.josm.Main; 28 28 import org.openstreetmap.josm.gui.layer.Layer; 29 import org.openstreetmap.josm.gui.layer.RawGps DataLayer;29 import org.openstreetmap.josm.gui.layer.RawGpsLayer; 30 30 import org.openstreetmap.josm.io.GpxWriter; 31 31 import org.openstreetmap.josm.tools.GBC; … … 118 118 authorName.getText(), email.getText(), copyright.getText(), 119 119 copyrightYear.getText(), keywords.getText()); 120 if (layer instanceof RawGps DataLayer)121 w.output(((RawGps DataLayer)layer).data);120 if (layer instanceof RawGpsLayer) 121 w.output(((RawGpsLayer)layer).data); 122 122 else 123 123 w.output(Main.ds); -
src/org/openstreetmap/josm/actions/GroupAction.java
r98 r99 52 52 public GroupAction(int shortCut, int modifiers) { 53 53 String idName = getClass().getName(); 54 Main. panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(shortCut, modifiers), idName);55 Main. panel.getActionMap().put(idName, this);54 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(shortCut, modifiers), idName); 55 Main.contentPane.getActionMap().put(idName, this); 56 56 shortCutName = ShortCutLabel.name(shortCut, modifiers); 57 57 addPropertyChangeListener(new PropertyChangeListener(){ -
src/org/openstreetmap/josm/actions/JosmAction.java
r98 r99 33 33 super(name, ImageProvider.get(iconName)); 34 34 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+" <font size='-2'>"+shortCutName+"</font> </html>"); 35 Main.panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortCut, name); 36 Main.panel.getActionMap().put(name, this); 35 //Main.panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortCut, name); 36 //Main.panel.getActionMap().put(name, this); 37 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortCut, name); 38 Main.contentPane.getActionMap().put(name, this); 37 39 } 38 40 -
src/org/openstreetmap/josm/actions/OpenAction.java
r98 r99 18 18 import org.openstreetmap.josm.data.osm.DataSet; 19 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 20 import org.openstreetmap.josm.gui.layer.RawGps DataLayer;21 import org.openstreetmap.josm.gui.layer.RawGps DataLayer.GpsPoint;20 import org.openstreetmap.josm.gui.layer.RawGpsLayer; 21 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 22 22 import org.openstreetmap.josm.io.GpxReader; 23 23 import org.openstreetmap.josm.io.OsmReader; … … 66 66 } else 67 67 throw new IllegalStateException(); 68 Main.main.addLayer(new RawGps DataLayer(data, filename.getName()));68 Main.main.addLayer(new RawGpsLayer(data, filename.getName())); 69 69 } else { 70 70 DataSet dataSet; … … 102 102 } catch (SAXException x) { 103 103 x.printStackTrace(); 104 JOptionPane.showMessageDialog(Main.parent, "Error while parsing : "+x.getMessage());104 JOptionPane.showMessageDialog(Main.parent, "Error while parsing "+fn+": "+x.getMessage()); 105 105 } catch (JDOMException x) { 106 106 x.printStackTrace(); 107 JOptionPane.showMessageDialog(Main.parent, "Error while parsing : "+x.getMessage());107 JOptionPane.showMessageDialog(Main.parent, "Error while parsing "+fn+": "+x.getMessage()); 108 108 } catch (IOException x) { 109 109 x.printStackTrace(); -
src/org/openstreetmap/josm/actions/UploadAction.java
r98 r99 39 39 40 40 public void actionPerformed(ActionEvent e) { 41 41 if (Main.map == null) { 42 JOptionPane.showMessageDialog(Main.parent, "Nothing to upload. Get some data first."); 43 return; 44 } 45 42 46 String osmDataServer = Main.pref.get("osm-server.url"); 43 47 //TODO: Remove this in later versions (temporary only) -
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r98 r99 1 1 package org.openstreetmap.josm.actions.mapmode; 2 2 3 import java.awt.Cursor; 3 4 import java.awt.event.KeyEvent; 4 5 import java.awt.event.MouseEvent; … … 53 54 super.enterMode(); 54 55 Main.map.mapView.addMouseListener(this); 56 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); 55 57 } 56 58 … … 58 60 super.exitMode(); 59 61 Main.map.mapView.removeMouseListener(this); 62 Main.map.mapView.setCursor(Cursor.getDefaultCursor()); 60 63 } 61 64 -
src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java
r98 r99 14 14 import org.openstreetmap.josm.command.AddCommand; 15 15 import org.openstreetmap.josm.command.ChangeCommand; 16 import org.openstreetmap.josm.command.Command;17 16 import org.openstreetmap.josm.command.DeleteCommand; 18 17 import org.openstreetmap.josm.data.SelectionChangedListener; … … 64 63 @Override public void enterMode() { 65 64 super.enterMode(); 66 Command c = null;67 65 way = makeWay(); 68 if (way != null) { 69 c = new AddCommand(way); 70 Main.ds.setSelected(way); 71 Main.main.editLayer().add(c); 72 } else 73 Main.ds.clearSelection(); 66 Main.ds.setSelected(way); 74 67 Main.map.mapView.addMouseListener(this); 75 68 } … … 147 140 } 148 141 142 Way wayToAdd = null; 143 boolean reordered = false; 149 144 if (numberOfSelectedWays > 0) { 150 145 String ways = "way" + (numberOfSelectedWays==1?" has":"s have"); … … 155 150 if (osm instanceof Way) 156 151 segmentSet.addAll(((Way)osm).segments); 152 } else if (numberOfSelectedWays == 1) { 153 answer = JOptionPane.showConfirmDialog(Main.parent, "Do you want to add all other selected segments to the one selected way?", "Add segments to way?", JOptionPane.YES_NO_OPTION); 154 if (answer == JOptionPane.YES_OPTION) { 155 for (OsmPrimitive osm : selection) { 156 if (osm instanceof Way) { 157 wayToAdd = (Way)osm; 158 answer = JOptionPane.showConfirmDialog(Main.parent, "Reorder all line segments?", "Reorder?", JOptionPane.YES_NO_CANCEL_OPTION); 159 if (answer == JOptionPane.CANCEL_OPTION) 160 return wayToAdd; 161 if (answer == JOptionPane.YES_OPTION) { 162 segmentSet.addAll(wayToAdd.segments); 163 reordered = true; 164 } else 165 segmentSet.removeAll(wayToAdd.segments); 166 break; 167 } 168 } 169 } 157 170 } 158 171 } … … 193 206 } 194 207 208 if (wayToAdd != null) { 209 Way w = new Way(wayToAdd); 210 if (reordered) 211 w.segments.clear(); 212 w.segments.addAll(sortedSegments); 213 Main.main.editLayer().add(new ChangeCommand(wayToAdd, w)); 214 return wayToAdd; 215 } 216 195 217 if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(Main.parent, "Create a new way out of "+sortedSegments.size()+" segments?", "Create new way", JOptionPane.YES_NO_OPTION)) 196 218 return null; … … 198 220 Way w = new Way(); 199 221 w.segments.addAll(sortedSegments); 222 223 if (way != null) 224 Main.main.editLayer().add(new AddCommand(way)); 200 225 return w; 201 226 } -
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r93 r99 88 88 * @param color The color of the node. 89 89 */ 90 p rivatevoid drawNode(Node n, Color color) {90 public void drawNode(Node n, Color color) { 91 91 Point p = nc.getPoint(n.eastNorth); 92 92 g.setColor(color); -
src/org/openstreetmap/josm/data/projection/Mercator.java
r86 r99 1 1 package org.openstreetmap.josm.data.projection; 2 2 3 import org.openstreetmap.josm.data.coor.EastNorth; 3 4 import org.openstreetmap.josm.data.coor.LatLon; 4 import org.openstreetmap.josm.data.coor.EastNorth;5 5 6 6 /** -
src/org/openstreetmap/josm/data/projection/Projection.java
r79 r99 1 1 package org.openstreetmap.josm.data.projection; 2 2 3 import org.openstreetmap.josm.data.coor.EastNorth; 3 4 import org.openstreetmap.josm.data.coor.LatLon; 4 import org.openstreetmap.josm.data.coor.EastNorth;5 5 6 6 /** -
src/org/openstreetmap/josm/gui/IconToggleButton.java
r93 r99 40 40 41 41 public void propertyChange(PropertyChangeEvent evt) { 42 if (evt.getPropertyName().equals("active")) 42 if (evt.getPropertyName().equals("active")) { 43 43 setSelected((Boolean)evt.getNewValue()); 44 requestFocusInWindow(); 45 } 44 46 } 45 47 } -
src/org/openstreetmap/josm/gui/MapFrame.java
r98 r99 133 133 */ 134 134 public void setVisibleDialogs() { 135 for (Component c : toggleDialogs.getComponents()) 136 if (c instanceof ToggleDialog) 137 c.setVisible(Main.pref.getBoolean(((ToggleDialog)c).prefName+".visible")); 135 for (Component c : toggleDialogs.getComponents()) { 136 if (c instanceof ToggleDialog) { 137 boolean sel = Main.pref.getBoolean(((ToggleDialog)c).prefName+".visible"); 138 ((ToggleDialog)c).action.button.setSelected(sel); 139 c.setVisible(sel); 140 } 141 } 138 142 } 139 143 -
src/org/openstreetmap/josm/gui/MapView.java
r98 r99 6 6 import java.awt.event.ComponentAdapter; 7 7 import java.awt.event.ComponentEvent; 8 import java.awt.event.MouseAdapter; 9 import java.awt.event.MouseEvent; 10 import java.beans.PropertyChangeEvent; 11 import java.beans.PropertyChangeListener; 8 12 import java.util.ArrayList; 9 13 import java.util.Collection; … … 12 16 13 17 import javax.swing.JOptionPane; 18 import javax.swing.JSlider; 19 import javax.swing.event.ChangeEvent; 20 import javax.swing.event.ChangeListener; 14 21 15 22 import org.openstreetmap.josm.Main; … … 76 83 private final AutoScaleAction autoScaleAction; 77 84 85 86 private final class Scaler extends JSlider implements PropertyChangeListener, ChangeListener { 87 boolean hovered = false; 88 public Scaler() { 89 super(0, 20); 90 addMouseListener(new MouseAdapter(){ 91 @Override public void mouseEntered(MouseEvent e) { 92 hovered = true; 93 } 94 @Override public void mouseExited(MouseEvent e) { 95 hovered = false; 96 } 97 }); 98 MapView.this.addPropertyChangeListener(this); 99 addChangeListener(this); 100 } 101 public void propertyChange(PropertyChangeEvent evt) { 102 if (evt.getPropertyName().equals("scale") && !getModel().getValueIsAdjusting()) 103 setValue(zoom()); 104 } 105 public void stateChanged(ChangeEvent e) { 106 if (!hovered) 107 return; 108 EastNorth pos = world; 109 for (int zoom = 0; zoom < getValue(); ++zoom) 110 pos = new EastNorth(pos.east()/2, pos.north()/2); 111 if (MapView.this.getWidth() < MapView.this.getHeight()) 112 zoomTo(center, pos.east()*2/(MapView.this.getWidth()-20)); 113 else 114 zoomTo(center, pos.north()*2/(MapView.this.getHeight()-20)); 115 } 116 } 117 78 118 public MapView(AutoScaleAction autoScaleAction) { 79 119 this.autoScaleAction = autoScaleAction; … … 91 131 } 92 132 }); 133 Scaler zoomScaler = new Scaler(); 134 zoomScaler.setOpaque(false); 135 add(zoomScaler); 136 zoomScaler.setBounds(0,0, 100, 30); 93 137 } 94 138 … … 182 226 if (x1 > 0 || y1 > 0 || x2 < getWidth() || y2 < getHeight()) 183 227 g.drawRect(x1, y1, x2-x1+1, y2-y1+1); 228 super.paint(g); 184 229 } 185 230 -
src/org/openstreetmap/josm/gui/NavigatableComponent.java
r93 r99 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.data.coor.EastNorth; 10 11 import org.openstreetmap.josm.data.coor.LatLon; 11 import org.openstreetmap.josm.data.coor.EastNorth;12 import org.openstreetmap.josm.data.osm.Segment;13 12 import org.openstreetmap.josm.data.osm.Node; 14 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.data.osm.Segment; 15 15 import org.openstreetmap.josm.data.osm.Way; 16 16 import org.openstreetmap.josm.data.projection.Projection; … … 24 24 public class NavigatableComponent extends JComponent { 25 25 26 public static final EastNorth world = Main.proj.latlon2eastNorth(new LatLon(Projection.MAX_LAT, Projection.MAX_LON)); 27 26 28 /** 27 29 * The scale factor in x or y-units per pixel. This means, if scale = 10, … … 35 37 protected EastNorth center; 36 38 39 public NavigatableComponent() { 40 setLayout(null); 41 } 42 43 /** 44 * Return the OSM-conform zoom factor (0 for whole world, 1 for half, 2 for quarter...) 45 */ 46 public int zoom() { 47 double sizex = scale * getWidth(); 48 double sizey = scale * getHeight(); 49 for (int zoom = 0; zoom <= 32; zoom++, sizex *= 2, sizey *= 2) 50 if (sizex > world.east() || sizey > world.north()) 51 return zoom; 52 return 32; 53 } 54 37 55 /** 38 56 * Return the current scale value. -
src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r98 r99 82 82 } catch (FileNotFoundException x) { 83 83 x.printStackTrace(); 84 errorMessage = " URL not found: " + x.getMessage();84 errorMessage = "Not found: " + x.getMessage(); 85 85 } catch (IOException x) { 86 86 x.printStackTrace(); -
src/org/openstreetmap/josm/gui/SelectionManager.java
r94 r99 6 6 import java.awt.Point; 7 7 import java.awt.Rectangle; 8 import java.awt.event.ActionEvent; 8 9 import java.awt.event.InputEvent; 10 import java.awt.event.KeyEvent; 9 11 import java.awt.event.MouseEvent; 10 12 import java.awt.event.MouseListener; … … 15 17 import java.util.LinkedList; 16 18 19 import javax.swing.AbstractAction; 20 import javax.swing.JComponent; 21 import javax.swing.KeyStroke; 22 17 23 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm.data.osm.Segment;19 24 import org.openstreetmap.josm.data.osm.Node; 20 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 import org.openstreetmap.josm.data.osm.Segment; 21 27 import org.openstreetmap.josm.data.osm.Way; 22 28 … … 121 127 eventSource.addMouseMotionListener(this); 122 128 selectionEndedListener.addPropertyChangeListener(this); 129 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "SelectionManager"); 130 Main.contentPane.getActionMap().put("SelectionManager", new AbstractAction(){ 131 public void actionPerformed(ActionEvent e) { 132 if (mousePos != null && mousePosStart != null) 133 paintRect(); 134 mousePosStart = null; 135 mousePos = null; 136 } 137 }); 123 138 } 124 139 /** … … 132 147 eventSource.removeMouseMotionListener(this); 133 148 selectionEndedListener.removePropertyChangeListener(this); 149 Main.contentPane.getInputMap().remove(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); 150 Main.contentPane.getActionMap().remove("SelectionManager"); 134 151 } 135 152 … … 327 344 } 328 345 329 330 /**331 * Does nothing. Only to satisfy MouseListener332 */333 346 public void mouseClicked(MouseEvent e) {} 334 /**335 * Does nothing. Only to satisfy MouseListener336 */337 347 public void mouseEntered(MouseEvent e) {} 338 /**339 * Does nothing. Only to satisfy MouseListener340 */341 348 public void mouseExited(MouseEvent e) {} 342 /**343 * Does nothing. Only to satisfy MouseMotionListener344 */345 349 public void mouseMoved(MouseEvent e) {} 346 347 350 } -
src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r98 r99 38 38 public void layerRemoved(Layer oldLayer) {} 39 39 }); 40 if (mapFrame.mapView.editLayer != null) 41 mapFrame.mapView.editLayer.listenerCommands.add(this); 42 40 43 tree.setRootVisible(false); 41 44 tree.setShowsRootHandles(true); -
src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r98 r99 6 6 import java.awt.event.ActionEvent; 7 7 import java.awt.event.ActionListener; 8 import java.io.File; 8 9 import java.util.Collection; 10 import java.util.LinkedList; 9 11 10 12 import javax.swing.Icon; 11 13 import javax.swing.JColorChooser; 14 import javax.swing.JFileChooser; 12 15 import javax.swing.JMenuItem; 13 16 import javax.swing.JOptionPane; 14 17 import javax.swing.JPopupMenu; 18 import javax.swing.filechooser.FileFilter; 15 19 16 20 import org.openstreetmap.josm.Main; … … 31 35 * @author imi 32 36 */ 33 public class RawGps DataLayer extends Layer {37 public class RawGpsLayer extends Layer { 34 38 35 39 private static Icon icon; … … 51 55 public final Collection<Collection<GpsPoint>> data; 52 56 53 public RawGps DataLayer(Collection<Collection<GpsPoint>> data, String name) {57 public RawGpsLayer(Collection<Collection<GpsPoint>> data, String name) { 54 58 super(name); 55 59 this.data = data; … … 103 107 104 108 @Override public void mergeFrom(Layer from) { 105 RawGps DataLayer layer = (RawGpsDataLayer)from;109 RawGpsLayer layer = (RawGpsLayer)from; 106 110 data.addAll(layer.data); 107 111 } 108 112 109 113 @Override public boolean isMergable(Layer other) { 110 return other instanceof RawGps DataLayer;114 return other instanceof RawGpsLayer; 111 115 } 112 116 … … 153 157 menu.add(color); 154 158 159 JMenuItem tagimage = new JMenuItem("Import images", ImageProvider.get("tagimages")); 160 tagimage.addActionListener(new ActionListener(){ 161 public void actionPerformed(ActionEvent e) { 162 JFileChooser fc = new JFileChooser(Main.pref.get("tagimages.lastdirectory")); 163 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 164 fc.setMultiSelectionEnabled(true); 165 fc.setAcceptAllFileFilterUsed(false); 166 fc.setFileFilter(new FileFilter(){ 167 @Override public boolean accept(File f) { 168 return f.isDirectory() || f.getName().toLowerCase().endsWith(".jpg"); 169 } 170 @Override public String getDescription() { 171 return "JPEG images (*.jpg)"; 172 } 173 }); 174 fc.showOpenDialog(Main.parent); 175 File[] sel = fc.getSelectedFiles(); 176 if (sel == null || sel.length == 0) 177 return; 178 LinkedList<File> files = new LinkedList<File>(); 179 addRecursiveFiles(files, sel); 180 Main.pref.put("tagimages.lastdirectory", fc.getCurrentDirectory().getPath()); 181 GeoImageLayer.create(files, RawGpsLayer.this); 182 } 183 184 private void addRecursiveFiles(LinkedList<File> files, File[] sel) { 185 for (File f : sel) { 186 if (f.isDirectory()) 187 addRecursiveFiles(files, f.listFiles()); 188 else if (f.getName().toLowerCase().endsWith(".jpg")) 189 files.add(f); 190 } 191 } 192 }); 193 menu.add(tagimage); 194 155 195 menu.addSeparator(); 156 196 menu.add(new LayerListPopup.InfoAction(this)); -
src/org/openstreetmap/josm/io/GpxWriter.java
r86 r99 23 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 24 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm.gui.layer.RawGps DataLayer.GpsPoint;25 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 26 26 import org.openstreetmap.josm.tools.XmlWriter; 27 27 -
src/org/openstreetmap/josm/io/OsmConnection.java
r98 r99 8 8 9 9 import javax.swing.BoundedRangeModel; 10 import javax.swing.JCheckBox; 10 11 import javax.swing.JLabel; 11 12 import javax.swing.JOptionPane; … … 29 30 protected JLabel currentAction; 30 31 protected BoundedRangeModel progress; 31 32 32 33 private static OsmAuth authentication; 33 34 /** … … 38 39 Authenticator.setDefault(authentication = new OsmAuth()); 39 40 } 40 41 41 42 /** 42 * The authentication class handling the login requests. 43 */ 44 private static class OsmAuth extends Authenticator { 45 /** 46 * Set to true, when the autenticator tried the password once. 47 */ 48 boolean passwordtried = false; 49 /** 50 * Whether the user cancelled the password dialog 51 */ 52 boolean authCancelled = false; 53 54 @Override protected PasswordAuthentication getPasswordAuthentication() { 55 String username = Main.pref.get("osm-server.username"); 56 String password = Main.pref.get("osm-server.password"); 57 if (passwordtried || username.equals("") || password.equals("")) { 58 JPanel p = new JPanel(new GridBagLayout()); 59 p.add(new JLabel("Username"), GBC.std().insets(0,0,10,0)); 60 JTextField usernameField = new JTextField(username, 20); 61 p.add(usernameField, GBC.eol()); 62 p.add(new JLabel("Password"), GBC.std().insets(0,0,10,0)); 63 JPasswordField passwordField = new JPasswordField(password, 20); 64 p.add(passwordField, GBC.eol()); 65 JLabel warning = new JLabel("Warning: The password is transferred unencrypted."); 66 warning.setFont(warning.getFont().deriveFont(Font.ITALIC)); 67 p.add(warning, GBC.eol()); 68 int choice = JOptionPane.showConfirmDialog(Main.parent, p, "Enter Password", JOptionPane.OK_CANCEL_OPTION); 69 if (choice == JOptionPane.CANCEL_OPTION) { 70 authCancelled = true; 71 return null; 72 } 73 username = usernameField.getText(); 74 password = String.valueOf(passwordField.getPassword()); 75 if (username.equals("")) 76 return null; 77 } 78 passwordtried = true; 79 return new PasswordAuthentication(username, password.toCharArray()); 80 } 81 } 43 * The authentication class handling the login requests. 44 */ 45 private static class OsmAuth extends Authenticator { 46 /** 47 * Set to true, when the autenticator tried the password once. 48 */ 49 boolean passwordtried = false; 50 /** 51 * Whether the user cancelled the password dialog 52 */ 53 boolean authCancelled = false; 54 55 @Override protected PasswordAuthentication getPasswordAuthentication() { 56 String username = Main.pref.get("osm-server.username"); 57 String password = Main.pref.get("osm-server.password"); 58 if (passwordtried || username.equals("") || password.equals("")) { 59 JPanel p = new JPanel(new GridBagLayout()); 60 if (!username.equals("") && !password.equals("")) 61 p.add(new JLabel("Incorrect password or username."), GBC.eop()); 62 p.add(new JLabel("Username"), GBC.std().insets(0,0,10,0)); 63 JTextField usernameField = new JTextField(username, 20); 64 p.add(usernameField, GBC.eol()); 65 p.add(new JLabel("Password"), GBC.std().insets(0,0,10,0)); 66 JPasswordField passwordField = new JPasswordField(password, 20); 67 p.add(passwordField, GBC.eol()); 68 JLabel warning = new JLabel("Warning: The password is transferred unencrypted."); 69 warning.setFont(warning.getFont().deriveFont(Font.ITALIC)); 70 p.add(warning, GBC.eop()); 71 72 JCheckBox savePassword = new JCheckBox("Save user and password (unencrypted)", !username.equals("") && !password.equals("")); 73 p.add(savePassword, GBC.eop()); 74 75 int choice = JOptionPane.showConfirmDialog(Main.parent, p, "Enter Password", JOptionPane.OK_CANCEL_OPTION); 76 if (choice == JOptionPane.CANCEL_OPTION) { 77 authCancelled = true; 78 return null; 79 } 80 username = usernameField.getText(); 81 password = String.valueOf(passwordField.getPassword()); 82 if (savePassword.isSelected()) { 83 Main.pref.put("osm-server.username", username); 84 Main.pref.put("osm-server.password", password); 85 } 86 if (username.equals("")) 87 return null; 88 } 89 passwordtried = true; 90 return new PasswordAuthentication(username, password.toCharArray()); 91 } 92 } 82 93 83 94 /** … … 88 99 authentication.passwordtried = false; 89 100 } 90 101 91 102 /** 92 103 * @return Whether the connection was cancelled. … … 99 110 this.currentAction = currentAction; 100 111 this.progress = progress; 101 112 } 102 113 103 114 public void cancel() { 104 115 currentAction.setText("Aborting..."); 105 106 107 108 109 110 111 116 cancel = true; 117 if (activeConnection != null) { 118 activeConnection.setConnectTimeout(1); 119 activeConnection.setReadTimeout(1); 120 activeConnection.disconnect(); 121 } 122 } 112 123 } -
src/org/openstreetmap/josm/io/OsmServerReader.java
r97 r99 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.gui.layer.RawGps DataLayer.GpsPoint;13 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 14 14 import org.xml.sax.SAXException; 15 15 -
src/org/openstreetmap/josm/io/RawCsvReader.java
r93 r99 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.gui.layer.RawGps DataLayer.GpsPoint;14 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 15 15 16 16 /** … … 28 28 this.in = new BufferedReader(in); 29 29 } 30 30 31 31 public Collection<GpsPoint> parse() throws JDOMException, IOException { 32 32 Collection<GpsPoint> data = new LinkedList<GpsPoint>(); … … 36 36 if (formatStr == null) 37 37 throw new JDOMException("Could not detect data format string."); 38 38 39 39 // get delimiter 40 40 String delim = ","; … … 45 45 } 46 46 } 47 47 48 48 // convert format string 49 49 ArrayList<String> format = new ArrayList<String>(); 50 for (StringTokenizer st = new StringTokenizer(formatStr, delim); st.hasMoreTokens();) 51 format.add(st.nextToken()); 50 for (StringTokenizer st = new StringTokenizer(formatStr, delim); st.hasMoreTokens();) { 51 String token = st.nextToken(); 52 if (!token.equals("lat") && !token.equals("lon") && !token.equals("time")) 53 token = "ignore"; 54 format.add(token); 55 } 52 56 53 57 // test for completness … … 57 61 throw new JDOMException("Format string is incomplete. Need at least 'lat' and 'lon' specification"); 58 62 } 59 63 60 64 int lineNo = 0; 61 65 try { -
src/org/openstreetmap/josm/io/RawGpsReader.java
r78 r99 11 11 import org.jdom.input.SAXBuilder; 12 12 import org.openstreetmap.josm.data.coor.LatLon; 13 import org.openstreetmap.josm.gui.layer.RawGps DataLayer.GpsPoint;13 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 14 14 15 15 /**
Note:
See TracChangeset
for help on using the changeset viewer.