Changeset 1670 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2009-06-15T20:22:46+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r1639 r1670 62 62 import org.openstreetmap.josm.actions.UnselectAllAction; 63 63 import org.openstreetmap.josm.actions.UpdateDataAction; 64 import org.openstreetmap.josm.actions.UpdateSelectionAction; 64 65 import org.openstreetmap.josm.actions.UploadAction; 65 66 import org.openstreetmap.josm.actions.ZoomInAction; … … 94 95 public final DownloadAction download = new DownloadAction(); 95 96 public final JosmAction update = new UpdateDataAction(); 97 public final JosmAction updateSelection = new UpdateSelectionAction(); 96 98 public final JosmAction upload = new UploadAction(); 97 99 public final JosmAction exit = new ExitAction(); … … 194 196 add(fileMenu, upload); 195 197 add(fileMenu, update); 198 add(fileMenu, updateSelection); 196 199 fileMenu.addSeparator(); 197 200 add(fileMenu, exit); -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r1647 r1670 17 17 18 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.io.OsmTransferException; 19 20 import org.xml.sax.SAXException; 20 21 … … 109 110 x.printStackTrace(); 110 111 errorMessage = x.getMessage(); 112 } catch(OsmTransferException x) { 113 x.printStackTrace(); 114 if (x.getCause() != null) { 115 errorMessage = x.getCause().getMessage(); 116 } else { 117 errorMessage = x.getMessage(); 118 } 111 119 } finally { 112 120 closeDialog(); … … 134 142 * is called. finish() is called in any case. 135 143 */ 136 protected abstract void realRun() throws SAXException, IOException; 144 protected abstract void realRun() throws SAXException, IOException, OsmTransferException; 137 145 138 146 /** … … 158 166 Main.pleaseWaitDlg.dispose(); 159 167 } 160 if (errorMessage != null && !silent) 168 if (errorMessage != null && !silent) { 161 169 JOptionPane.showMessageDialog(Main.parent, errorMessage); 170 } 162 171 } 163 172 }; 164 173 165 174 // make sure, this is called in the dispatcher thread ASAP 166 if (EventQueue.isDispatchThread()) 175 if (EventQueue.isDispatchThread()) { 167 176 runnable.run(); 168 else177 } else { 169 178 EventQueue.invokeAndWait(runnable); 179 } 170 180 171 181 } catch (InterruptedException e) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1624 r1670 36 36 import org.openstreetmap.josm.data.osm.Node; 37 37 import org.openstreetmap.josm.data.osm.OsmPrimitive; 38 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 38 39 import org.openstreetmap.josm.data.osm.Relation; 39 40 import org.openstreetmap.josm.data.osm.RelationMember; … … 44 45 import org.openstreetmap.josm.gui.dialogs.ConflictDialog; 45 46 import org.openstreetmap.josm.io.OsmServerObjectReader; 47 import org.openstreetmap.josm.io.OsmTransferException; 46 48 import org.openstreetmap.josm.tools.GBC; 47 49 import org.openstreetmap.josm.tools.Shortcut; … … 145 147 String key = propertyData.getValueAt(i, 0).toString(); 146 148 String value = propertyData.getValueAt(i, 1).toString(); 147 if (key.length() > 0 && value.length() > 0) clone.put(key, value); 149 if (key.length() > 0 && value.length() > 0) { 150 clone.put(key, value); 151 } 148 152 } 149 153 refreshTables(); … … 175 179 { 176 180 sel = new ArrayList<OsmPrimitive>(cnt); 177 for (int i : memberTable.getSelectedRows()) 181 for (int i : memberTable.getSelectedRows()) { 178 182 sel.add((OsmPrimitive)memberTable.getValueAt(i, 1)); 183 } 179 184 } 180 185 else … … 182 187 cnt = memberTable.getRowCount(); 183 188 sel = new ArrayList<OsmPrimitive>(cnt); 184 for (int i = 0; i < cnt; ++i) 189 for (int i = 0; i < cnt; ++i) { 185 190 sel.add((OsmPrimitive)memberTable.getValueAt(i, 1)); 191 } 186 192 } 187 193 Main.ds.setSelected(sel); … … 239 245 240 246 buttonPanel.add(createButton(marktr("Add Selected"),"addselected", 241 tr("Add all currently selected objects as members"), KeyEvent.VK_D, new ActionListener() { 247 tr("Add all currently selected objects as members"), KeyEvent.VK_D, new ActionListener() { 242 248 public void actionPerformed(ActionEvent e) { 243 249 addSelected(); … … 246 252 247 253 buttonPanel.add(createButton(marktr("Remove Selected"),"removeselected", 248 tr("Remove all currently selected objects from relation"), KeyEvent.VK_S, new ActionListener() { 254 tr("Remove all currently selected objects from relation"), KeyEvent.VK_S, new ActionListener() { 249 255 public void actionPerformed(ActionEvent e) { 250 256 deleteSelected(); … … 259 265 260 266 buttonPanel.add(createButton(marktr("Remove"),"remove", 261 tr("Remove the member in the current table row from this relation"), KeyEvent.VK_M, new ActionListener() { 267 tr("Remove the member in the current table row from this relation"), KeyEvent.VK_M, new ActionListener() { 262 268 public void actionPerformed(ActionEvent e) { 263 269 int[] rows = memberTable.getSelectedRows(); … … 273 279 274 280 buttonPanel.add(createButton(marktr("Download Members"),"downloadincomplete", 275 tr("Download all incomplete ways and nodes in relation"), KeyEvent.VK_K, new ActionListener() { 281 tr("Download all incomplete ways and nodes in relation"), KeyEvent.VK_K, new ActionListener() { 276 282 public void actionPerformed(ActionEvent e) { 277 283 downloadRelationMembers(); … … 303 309 protected void buttonAction(ActionEvent evt) { 304 310 String a = evt.getActionCommand(); 305 if(applyChangesText.equals(a)) 311 if(applyChangesText.equals(a)) { 306 312 applyChanges(); 313 } 307 314 308 315 setVisible(false); … … 348 355 break; 349 356 } else if (m.member instanceof Relation) { 350 if (m.member == this.relation) 357 if (m.member == this.relation) { 351 358 break; 359 } 352 360 m = ((Relation)m.member).lastMember(); 353 361 depth++; … … 366 374 break; 367 375 } else if (m.member instanceof Relation) { 368 if (m.member == this.relation) 376 if (m.member == this.relation) { 369 377 break; 378 } 370 379 m = ((Relation)(m.member)).firstMember(); 371 380 depth++; … … 374 383 } 375 384 } 376 if (way2 != null) 385 if (way2 != null) { 377 386 break; 387 } 378 388 } 379 389 } … … 404 414 } 405 415 406 // end of section to determine linkedness. 416 // end of section to determine linkedness. 407 417 408 418 memberData.addRow(new Object[]{em.role, em.member, linked ? tr("yes") : tr("no")}); … … 416 426 private SideButton createButton(String name, String iconName, String tooltip, int mnemonic, ActionListener actionListener) { 417 427 return 418 428 new SideButton(name, iconName, "relationEditor", 419 429 tooltip, 420 430 Shortcut.registerShortcut("relationeditor:"+iconName, … … 422 432 mnemonic, 423 433 Shortcut.GROUP_MNEMONIC), 424 actionListener 425 434 actionListener 435 ); 426 436 } 427 437 … … 483 493 for (RelationMember rm : clone.members) { 484 494 if (rm != null) { 485 while (m[i] != null) i++; 495 while (m[i] != null) { 496 i++; 497 } 486 498 m[i++] = rm; 487 499 } … … 509 521 } 510 522 if (download) { 511 OsmServerObjectReader reader = new OsmServerObjectReader(clone.id, Osm ServerObjectReader.TYPE_REL, true);523 OsmServerObjectReader reader = new OsmServerObjectReader(clone.id, OsmPrimitiveType.RELATION, true); 512 524 try { 513 525 DataSet dataSet = reader.parseOsm(); … … 515 527 final MergeVisitor visitor = new MergeVisitor(Main.main 516 528 .editLayer().data, dataSet); 517 for (final OsmPrimitive osm : dataSet.allPrimitives()) 529 for (final OsmPrimitive osm : dataSet.allPrimitives()) { 518 530 osm.visit(visitor); 531 } 519 532 visitor.fixReferences(); 520 533 521 534 // copy the merged layer's data source info 522 for (DataSource src : dataSet.dataSources) 535 for (DataSource src : dataSet.dataSources) { 523 536 Main.main.editLayer().data.dataSources.add(src); 537 } 524 538 Main.main.editLayer().fireDataChange(); 525 539 … … 530 544 JOptionPane.showMessageDialog(Main.parent, 531 545 tr("There were conflicts during import.")); 532 if (!dlg.isVisible()) 546 if (!dlg.isVisible()) { 533 547 dlg.action 534 535 } 536 537 } catch (SAXException e) {548 .actionPerformed(new ActionEvent(this, 0, "")); 549 } 550 } 551 } catch(OsmTransferException e) { 538 552 e.printStackTrace(); 539 JOptionPane.showMessageDialog(this,tr("Error parsing server response.")+": "+e.getMessage(), 540 tr("Error"), JOptionPane.ERROR_MESSAGE); 541 } catch (IOException e) { 542 e.printStackTrace(); 543 JOptionPane.showMessageDialog(this,tr("Cannot connect to server.")+": "+e.getMessage(), 544 tr("Error"), JOptionPane.ERROR_MESSAGE); 553 if (e.getCause() != null) { 554 if (e.getCause() instanceof SAXException) { 555 JOptionPane.showMessageDialog(this,tr("Error parsing server response.")+": "+e.getCause().getMessage(), 556 tr("Error"), JOptionPane.ERROR_MESSAGE); 557 } else if(e.getCause() instanceof IOException) { 558 JOptionPane.showMessageDialog(this,tr("Cannot connect to server.")+": "+e.getCause().getMessage(), 559 tr("Error"), JOptionPane.ERROR_MESSAGE); 560 } 561 } else { 562 JOptionPane.showMessageDialog(this,tr("Error when communicating with server.")+": "+e.getMessage(), 563 tr("Error"), JOptionPane.ERROR_MESSAGE); 564 } 545 565 } 546 566 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r1646 r1670 51 51 import org.openstreetmap.josm.data.osm.Node; 52 52 import org.openstreetmap.josm.data.osm.OsmPrimitive; 53 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 53 54 import org.openstreetmap.josm.data.osm.Relation; 54 55 import org.openstreetmap.josm.data.osm.Way; … … 77 78 public final int[] normal = new int[3]; 78 79 public final int[] deleted = new int[3]; 79 public final String[] names = {"node", "way", "relation"}; 80 public final String[] names = { 81 OsmPrimitiveType.NODE.getAPIName(), 82 OsmPrimitiveType.WAY.getAPIName(), 83 OsmPrimitiveType.RELATION.getAPIName() 84 }; 80 85 81 86 private void inc(final OsmPrimitive osm, final int i) { 82 87 normal[i]++; 83 if (osm.deleted) 88 if (osm.deleted) { 84 89 deleted[i]++; 90 } 85 91 } 86 92 … … 201 207 202 208 SimplePaintVisitor painter; 203 if (Main.pref.getBoolean("draw.wireframe")) 209 if (Main.pref.getBoolean("draw.wireframe")) { 204 210 painter = new SimplePaintVisitor(); 205 else211 } else { 206 212 painter = new MapPaintVisitor(); 213 } 207 214 painter.setGraphics(g); 208 215 painter.setNavigatableComponent(mv); … … 216 223 tool += undeletedSize(data.nodes)+" "+trn("node", "nodes", undeletedSize(data.nodes))+", "; 217 224 tool += undeletedSize(data.ways)+" "+trn("way", "ways", undeletedSize(data.ways)); 218 if (data.version != null) tool += ", " + tr("version {0}", data.version); 225 if (data.version != null) { 226 tool += ", " + tr("version {0}", data.version); 227 } 219 228 File f = getAssociatedFile(); 220 if (f != null) 229 if (f != null) { 221 230 tool = "<html>"+tool+"<br>"+f.getPath()+"</html>"; 231 } 222 232 return tool; 223 233 } 224 234 225 235 @Override public void mergeFrom(final Layer from) { 226 final MergeVisitor visitor = new MergeVisitor(data,((OsmDataLayer)from).data); 227 for (final OsmPrimitive osm : ((OsmDataLayer)from).data.allPrimitives()) { 228 // i++; 229 // if(i%100 == 0) { 230 // double perc = (((double)i) / ((double)max) * 100.0); 231 // System.out.format(" " + (int)perc + "%%"); 232 // } 236 mergeFrom(((OsmDataLayer)from).data); 237 } 238 239 /** 240 * merges the primitives in dataset <code>from</code> into the dataset of 241 * this layer 242 * 243 * @param from the source data set 244 */ 245 public void mergeFrom(final DataSet from) { 246 final MergeVisitor visitor = new MergeVisitor(data,from); 247 for (final OsmPrimitive osm : from.allPrimitives()) { 233 248 osm.visit(visitor); 234 249 } 235 250 visitor.fixReferences(); 236 // System.out.println("");237 251 238 252 Area a = data.getDataSourceArea(); 239 240 // copy the merged layer's data source info; 253 254 // copy the merged layer's data source info; 241 255 // only add source rectangles if they are not contained in the 242 256 // layer already. 243 for (DataSource src : ((OsmDataLayer)from).data.dataSources) {244 if (a == null || !a.contains(src.bounds.asRect())) 257 for (DataSource src : from.dataSources) { 258 if (a == null || !a.contains(src.bounds.asRect())) { 245 259 data.dataSources.add(src); 246 } 247 260 } 261 } 262 248 263 // copy the merged layer's API version, downgrade if required 249 264 if (data.version == null) { 250 data.version = ((OsmDataLayer)from).data.version;265 data.version = from.version; 251 266 } else { 252 if ("0.5".equals(data.version) ^ "0.5".equals( ((OsmDataLayer)from).data.version)) {253 System.err.println("Warning: mixing 0.6 and 0.5 data results in version 0.5"); 267 if ("0.5".equals(data.version) ^ "0.5".equals(from.version)) { 268 System.err.println(tr("Warning: mixing 0.6 and 0.5 data results in version 0.5")); 254 269 data.version = "0.5"; 255 270 } … … 263 278 final ConflictDialog dlg = Main.map.conflictDialog; 264 279 dlg.add(visitor.conflicts); 265 JOptionPane.showMessageDialog(Main.parent,tr("There were conflicts during import.")); 266 if (!dlg.isVisible()) 280 JOptionPane.showMessageDialog(Main.parent,tr("There were {0} conflicts during import.", visitor.conflicts.size())); 281 if (!dlg.isVisible()) { 267 282 dlg.action.actionPerformed(new ActionEvent(this, 0, "")); 283 } 268 284 } 269 285 … … 274 290 @Override public void visitBoundingBox(final BoundingXYVisitor v) { 275 291 for (final Node n : data.nodes) 276 if (!n.deleted && !n.incomplete) 292 if (!n.deleted && !n.incomplete) { 277 293 v.visit(n); 294 } 278 295 } 279 296 … … 299 316 if (processed != null) { 300 317 final Set<OsmPrimitive> processedSet = new HashSet<OsmPrimitive>(processed); 301 for (final Iterator<Node> it = data.nodes.iterator(); it.hasNext();) 318 for (final Iterator<Node> it = data.nodes.iterator(); it.hasNext();) { 302 319 cleanIterator(it, processedSet); 303 for (final Iterator<Way> it = data.ways.iterator(); it.hasNext();) 320 } 321 for (final Iterator<Way> it = data.ways.iterator(); it.hasNext();) { 304 322 cleanIterator(it, processedSet); 305 for (final Iterator<Relation> it = data.relations.iterator(); it.hasNext();) 323 } 324 for (final Iterator<Relation> it = data.relations.iterator(); it.hasNext();) { 306 325 cleanIterator(it, processedSet); 326 } 307 327 } 308 328 … … 330 350 return; 331 351 osm.modified = false; 332 if (osm.deleted) 352 if (osm.deleted) { 333 353 it.remove(); 354 } 334 355 } 335 356 … … 342 363 return; 343 364 this.modified = modified; 344 for (final ModifiedChangedListener l : listenerModified) 365 for (final ModifiedChangedListener l : listenerModified) { 345 366 l.modifiedChanged(modified, this); 367 } 346 368 } 347 369 … … 352 374 int size = 0; 353 375 for (final OsmPrimitive osm : list) 354 if (!osm.deleted) 376 if (!osm.deleted) { 355 377 size++; 378 } 356 379 return size; 357 380 } … … 359 382 @Override public Object getInfoComponent() { 360 383 final DataCountVisitor counter = new DataCountVisitor(); 361 for (final OsmPrimitive osm : data.allPrimitives()) 384 for (final OsmPrimitive osm : data.allPrimitives()) { 362 385 osm.visit(counter); 386 } 363 387 final JPanel p = new JPanel(new GridBagLayout()); 364 388 p.add(new JLabel(tr("{0} consists of:", name)), GBC.eol()); 365 389 for (int i = 0; i < counter.normal.length; ++i) { 366 390 String s = counter.normal[i]+" "+trn(counter.names[i],counter.names[i]+"s",counter.normal[i]); 367 if (counter.deleted[i] > 0) 391 if (counter.deleted[i] > 0) { 368 392 s += tr(" ({0} deleted.)",counter.deleted[i]); 393 } 369 394 p.add(new JLabel(s, ImageProvider.get("data", counter.names[i]), JLabel.HORIZONTAL), GBC.eop().insets(15,0,0,0)); 370 395 } … … 375 400 376 401 @Override public Component[] getMenuEntries() { 377 if (Main.applet) {402 if (Main.applet) 378 403 return new Component[]{ 379 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), 380 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), 381 new JSeparator(), 382 new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)), 383 new JSeparator(), 384 new JMenuItem(new LayerListPopup.InfoAction(this))}; 385 } 404 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), 405 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), 406 new JSeparator(), 407 new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)), 408 new JSeparator(), 409 new JMenuItem(new LayerListPopup.InfoAction(this))}; 386 410 return new Component[]{ 387 411 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), … … 409 433 HashSet<Node> doneNodes = new HashSet<Node>(); 410 434 for (Way w : data.ways) { 411 if (w.incomplete || w.deleted) continue; 435 if (w.incomplete || w.deleted) { 436 continue; 437 } 412 438 GpxTrack trk = new GpxTrack(); 413 439 gpxData.tracks.add(trk); 414 440 415 if (w.get("name") != null) 441 if (w.get("name") != null) { 416 442 trk.attr.put("name", w.get("name")); 443 } 417 444 418 445 ArrayList<WayPoint> trkseg = null; … … 429 456 doneNodes.add(n); 430 457 } 431 WayPoint wpt = new WayPoint(n.getCoor()); 458 WayPoint wpt = new WayPoint(n.getCoor()); 432 459 if (!n.isTimestampEmpty()) 433 460 { … … 442 469 // records them? 443 470 for (Node n : data.nodes) { 444 if (n.incomplete || n.deleted || doneNodes.contains(n)) continue; 471 if (n.incomplete || n.deleted || doneNodes.contains(n)) { 472 continue; 473 } 445 474 WayPoint wpt = new WayPoint(n.getCoor()); 446 475 if (!n.isTimestampEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.