- Timestamp:
- 2008-06-13T00:44:36+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationEditor.java
r627 r653 13 13 import java.beans.PropertyChangeEvent; 14 14 import java.beans.PropertyChangeListener; 15 import java.io.IOException; 15 16 import java.util.ArrayList; 16 17 import java.util.Map.Entry; 17 18 18 19 import javax.swing.JButton; 20 import javax.swing.JDialog; 19 21 import javax.swing.JFrame; 20 22 import javax.swing.JLabel; … … 32 34 import org.openstreetmap.josm.command.AddCommand; 33 35 import org.openstreetmap.josm.command.ChangeCommand; 36 import org.openstreetmap.josm.data.osm.DataSet; 37 import org.openstreetmap.josm.data.osm.DataSource; 34 38 import org.openstreetmap.josm.data.osm.OsmPrimitive; 35 39 import org.openstreetmap.josm.data.osm.Relation; 36 40 import org.openstreetmap.josm.data.osm.RelationMember; 41 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 37 42 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 43 import org.openstreetmap.josm.io.OsmServerObjectReader; 38 44 import org.openstreetmap.josm.tools.GBC; 39 45 import org.openstreetmap.josm.tools.ImageProvider; 46 import org.xml.sax.SAXException; 40 47 41 48 /** … … 238 245 } 239 246 })); 247 buttonPanel.add(createButton(marktr("Download Members"),"down", tr("Download all incomplete ways and nodes in relation"), KeyEvent.VK_L, new ActionListener() { 248 public void actionPerformed(ActionEvent e) { 249 downloadRelationMembers(); 250 refreshTables(); 251 } 252 })); 253 254 240 255 bothTables.add(buttonPanel, GBC.eop().fill(GBC.HORIZONTAL)); 241 256 … … 285 300 refreshTables(); 286 301 } 302 private void downloadRelationMembers() { 303 304 boolean download = false; 305 for (RelationMember member : clone.members) { 306 if (member.member.incomplete) { 307 download = true; 308 break; 309 } 310 } 311 if (download) { 312 OsmServerObjectReader reader = new OsmServerObjectReader(); 313 try { 314 DataSet dataSet = reader.parseOsm(clone.id, 315 OsmServerObjectReader.TYPE_REL, true); 316 if (dataSet != null) { 317 final MergeVisitor visitor = new MergeVisitor(Main.main 318 .editLayer().data, dataSet); 319 for (final OsmPrimitive osm : dataSet.allPrimitives()) 320 osm.visit(visitor); 321 visitor.fixReferences(); 322 323 // copy the merged layer's data source info 324 for (DataSource src : dataSet.dataSources) 325 Main.main.editLayer().data.dataSources.add(src); 326 Main.main.editLayer().fireDataChange(); 327 328 if (visitor.conflicts.isEmpty()) 329 return; 330 final ConflictDialog dlg = Main.map.conflictDialog; 331 dlg.add(visitor.conflicts); 332 JOptionPane.showMessageDialog(Main.parent, 333 tr("There were conflicts during import.")); 334 if (!dlg.isVisible()) 335 dlg.action 336 .actionPerformed(new ActionEvent(this, 0, "")); 337 } 338 339 } catch (SAXException e) { 340 e.printStackTrace(); 341 JOptionPane.showMessageDialog(this,tr("Error parsing server response.")+": "+e.getMessage(), tr("Error"), JOptionPane.ERROR_MESSAGE); 342 } catch (IOException e) { 343 e.printStackTrace(); 344 JOptionPane.showMessageDialog(this,tr("Cannot connect to server.")+": "+e.getMessage(), tr("Error"), JOptionPane.ERROR_MESSAGE); 345 } 346 } 347 348 } 287 349 }
Note:
See TracChangeset
for help on using the changeset viewer.