- Timestamp:
- 2009-01-31T19:09:46+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r1268 r1353 59 59 import org.openstreetmap.josm.gui.MapFrame; 60 60 import org.openstreetmap.josm.gui.SideButton; 61 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;62 import org.openstreetmap.josm.gui.tagging.ForwardActionListener;63 import org.openstreetmap.josm.gui.tagging.TaggingCellRenderer;64 import org.openstreetmap.josm.gui.tagging.TaggingPreset;65 61 import org.openstreetmap.josm.tools.AutoCompleteComboBox; 66 62 import org.openstreetmap.josm.tools.GBC; … … 128 124 */ 129 125 void propertyEdit(int row) { 126 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 127 if (sel.isEmpty()) return; 128 130 129 String key = propertyData.getValueAt(row, 0).toString(); 131 130 objKey=key; 132 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 133 if (sel.isEmpty()) { 134 JOptionPane.showMessageDialog(Main.parent, tr("Please select the objects you want to change properties for.")); 135 return; 136 } 131 137 132 String msg = "<html>"+trn("This will change up to {0} object.", "This will change up to {0} objects.", sel.size(), sel.size())+"<br><br>("+tr("An empty value deletes the key.", key)+")</html>"; 138 133 … … 304 299 void add() { 305 300 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 306 if (sel.isEmpty()) { 307 JOptionPane.showMessageDialog(Main.parent, tr("Please select objects for which you want to change properties.")); 308 return; 309 } 301 if (sel.isEmpty()) return; 310 302 311 303 JPanel p = new JPanel(new BorderLayout()); … … 402 394 Main.ds.fireSelectionChanged(sel); 403 395 selectionChanged(sel); // update table 404 396 405 397 int rowCount = propertyTable.getRowCount(); 406 398 propertyTable.changeSelection((row < rowCount ? row : (rowCount-1)), 0, false, false); … … 439 431 public JComboBox taggingPresets = new JComboBox(); 440 432 433 /** 434 * The Add/Edit/Delete buttons (needed to be able to disable them) 435 */ 436 private final SideButton btnAdd; 437 private final SideButton btnEdit; 438 private final SideButton btnDel; 439 440 private final JLabel selectSth = new JLabel(tr("Please select the objects you want to change properties for.")); 441 441 442 442 /** … … 448 448 Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 150); 449 449 450 // ---------------------------------------451 // This drop-down is really deprecated but we offer people a chance to452 // activate it if they really want. Presets should be used from the453 // menu.454 if (TaggingPresetPreference.taggingPresets.size() > 0 &&455 Main.pref.getBoolean("taggingpreset.in-properties-dialog", false)) {456 Vector<ActionListener> allPresets = new Vector<ActionListener>();457 for (final TaggingPreset p : TaggingPresetPreference.taggingPresets)458 allPresets.add(new ForwardActionListener(this, p));459 460 TaggingPreset empty = new TaggingPreset();461 // empty.setName("this drop-down will be removed soon");462 allPresets.add(0, new ForwardActionListener(this, empty));463 taggingPresets.setModel(new DefaultComboBoxModel(allPresets));464 JPanel north = new JPanel(new GridBagLayout());465 north.add(getComponent(0),GBC.eol().fill(GBC.HORIZONTAL));466 north.add(taggingPresets,GBC.eol().fill(GBC.HORIZONTAL));467 add(north, BorderLayout.NORTH);468 }469 taggingPresets.addActionListener(new ActionListener(){470 public void actionPerformed(ActionEvent e) {471 TaggingPreset preset = ((ForwardActionListener)taggingPresets.getSelectedItem()).preset;472 preset.actionPerformed(e);473 taggingPresets.setSelectedItem(null);474 }475 });476 taggingPresets.setRenderer(new TaggingCellRenderer());477 478 450 // setting up the properties table 479 480 451 propertyData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")}); 481 452 propertyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); … … 548 519 JPanel bothTables = new JPanel(); 549 520 bothTables.setLayout(new GridBagLayout()); 521 bothTables.add(selectSth, GBC.eol().fill().insets(10, 10, 10, 10)); 550 522 bothTables.add(propertyTable.getTableHeader(), GBC.eol().fill(GBC.HORIZONTAL)); 551 523 bothTables.add(propertyTable, GBC.eol().fill(GBC.BOTH)); … … 601 573 { 602 574 int sel = propertyTable.getSelectedRow(); 603 if (e.getActionCommand().equals("Edit")) { 604 if(propertyTable.getRowCount() == 1) 605 sel = 0; 606 if (sel == -1) 607 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to edit.")); 608 else 609 propertyEdit(sel); 610 } else if (e.getActionCommand().equals("Delete")) { 611 if (sel == -1) 612 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete.")); 613 else 614 delete(sel); 615 } 575 // Although we might edit/delete the wrong tag here, chances are still better 576 // than just displaying an error message (which always "fails"). 577 if (e.getActionCommand().equals("Edit")) 578 propertyEdit(sel >= 0 ? sel : 0); 579 else if (e.getActionCommand().equals("Delete")) 580 delete(sel >= 0 ? sel : 0); 616 581 } 617 582 } … … 620 585 Shortcut s = Shortcut.registerShortcut("properties:add", tr("Add Properties"), KeyEvent.VK_B, 621 586 Shortcut.GROUP_MNEMONIC); 622 buttonPanel.add(new SideButton(marktr("Add"),"add","Properties", 623 tr("Add a new key/value pair to all objects"), s, buttonAction)); 587 this.btnAdd = new SideButton(marktr("Add"),"add","Properties", 588 tr("Add a new key/value pair to all objects"), s, buttonAction); 589 buttonPanel.add(this.btnAdd); 624 590 625 591 s = Shortcut.registerShortcut("properties:edit", tr("Edit Properties"), KeyEvent.VK_I, 626 592 Shortcut.GROUP_MNEMONIC); 627 buttonPanel.add(new SideButton(marktr("Edit"),"edit","Properties", 628 tr("Edit the value of the selected key for all objects"), s, buttonAction)); 593 this.btnEdit = new SideButton(marktr("Edit"),"edit","Properties", 594 tr("Edit the value of the selected key for all objects"), s, buttonAction); 595 buttonPanel.add(this.btnEdit); 629 596 630 597 s = Shortcut.registerShortcut("properties:delete", tr("Delete Properties"), KeyEvent.VK_Q, 631 598 Shortcut.GROUP_MNEMONIC); 632 buttonPanel.add(new SideButton(marktr("Delete"),"delete","Properties", 633 tr("Delete the selected key in all objects"), s, buttonAction)); 599 this.btnDel = new SideButton(marktr("Delete"),"delete","Properties", 600 tr("Delete the selected key in all objects"), s, buttonAction); 601 buttonPanel.add(this.btnDel); 634 602 add(buttonPanel, BorderLayout.SOUTH); 635 603 … … 652 620 653 621 // re-load property data 654 655 622 propertyData.setRowCount(0); 656 623 … … 681 648 } 682 649 650 boolean hasTags = !newSelection.isEmpty() && propertyData.getRowCount() > 0; 651 boolean hasSelection = !newSelection.isEmpty(); 652 btnAdd.setEnabled(hasSelection); 653 btnEdit.setEnabled(hasTags); 654 btnDel.setEnabled(hasTags); 655 propertyTable.setVisible(hasSelection); 656 propertyTable.getTableHeader().setVisible(hasSelection); 657 selectSth.setVisible(!hasSelection); 658 if(hasTags) propertyTable.changeSelection(0, 0, false, false); 659 683 660 // re-load membership data 684 661 // this is rather expensive since we have to walk through all members of all existing relationships. … … 708 685 709 686 membershipTable.getTableHeader().setVisible(membershipData.getRowCount() > 0); 687 membershipTable.setVisible(membershipData.getRowCount() > 0); 710 688 711 689 if(propertyData.getRowCount() != 0 || membershipData.getRowCount() != 0) { 712 setTitle(tr("Properties: {0} / Memberships: {1}", 690 setTitle(tr("Properties: {0} / Memberships: {1}", 713 691 propertyData.getRowCount(), membershipData.getRowCount()), true); 714 692 } else { 715 693 setTitle(tr("Properties / Memberships"), false); 716 694 } 717 718 695 } 719 696 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r1281 r1353 222 222 @Override public void mergeFrom(final Layer from) { 223 223 final MergeVisitor visitor = new MergeVisitor(data,((OsmDataLayer)from).data); 224 int i=0;224 // int i=0; 225 225 int max = ((OsmDataLayer)from).data.allPrimitives().size(); 226 226 227 System.out.format("Add/Merge data:");228 227 // System.out.format("Add/Merge data:"); 228 229 229 for (final OsmPrimitive osm : ((OsmDataLayer)from).data.allPrimitives()) { 230 i++;231 if(i%100 == 0) {232 double perc = (((double)i) / ((double)max) * 100.0);233 System.out.format(" " + (int)perc + "%%");234 }230 // i++; 231 // if(i%100 == 0) { 232 // double perc = (((double)i) / ((double)max) * 100.0); 233 // System.out.format(" " + (int)perc + "%%"); 234 // } 235 235 osm.visit(visitor); 236 236 } 237 237 visitor.fixReferences(); 238 System.out.println("");238 // System.out.println(""); 239 239 240 240 // copy the merged layer's data source info -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1284 r1353 52 52 public class OsmReader { 53 53 54 static long tagsN = 0;55 static long nodesN = 0;56 static long waysN = 0;57 static long relationsN = 0;58 static long membersN = 0;54 // static long tagsN = 0; 55 // static long nodesN = 0; 56 // static long waysN = 0; 57 // static long relationsN = 0; 58 // static long membersN = 0; 59 59 60 60 static InputStream currSource; … … 143 143 private OsmPrimitive current; 144 144 private String generator; 145 int n = 0;146 145 // int n = 0; 146 147 147 @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 148 148 try { 149 if(n%100000 == 0) {150 try {151 FileInputStream fis = (FileInputStream)currSource;152 FileChannel channel = fis.getChannel();153 double perc = (((double)channel.position()) / ((double)channel.size()) * 100.0);154 System.out.format(" " + (int)perc + "%%");155 }156 catch(java.lang.ClassCastException cce) {157 }158 catch(IOException e) {159 System.out.format("Error reading file position " + e);160 }161 }162 n++; 149 // if(n%100000 == 0) { 150 // try { 151 // FileInputStream fis = (FileInputStream)currSource; 152 // FileChannel channel = fis.getChannel(); 153 // double perc = (((double)channel.position()) / ((double)channel.size()) * 100.0); 154 // System.out.format(" " + (int)perc + "%%"); 155 // } 156 // catch(java.lang.ClassCastException cce) { 157 // } 158 // catch(IOException e) { 159 // System.out.format("Error reading file position " + e); 160 // } 161 // } 162 // n++; 163 163 164 164 if (qName.equals("osm")) { … … 213 213 214 214 } else if (qName.equals("node")) { 215 nodesN++;215 // nodesN++; 216 216 current = new Node(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon"))); 217 217 readCommon(atts, current); 218 218 nodes.put(current.id, (Node)current); 219 219 } else if (qName.equals("way")) { 220 waysN++;220 // waysN++; 221 221 current = new OsmPrimitiveData(); 222 222 readCommon(atts, current); … … 234 234 235 235 } else if (qName.equals("relation")) { 236 relationsN++;236 // relationsN++; 237 237 current = new OsmPrimitiveData(); 238 238 readCommon(atts, current); 239 239 relations.put((OsmPrimitiveData)current, new LinkedList<RelationMemberData>()); 240 240 } else if (qName.equals("member")) { 241 membersN++;241 // membersN++; 242 242 Collection<RelationMemberData> list = relations.get(current); 243 243 if (list == null) … … 257 257 258 258 } else if (qName.equals("tag")) { 259 tagsN++;259 // tagsN++; 260 260 current.put(atts.getValue("k"), atts.getValue("v")); 261 261 } … … 439 439 for (Way wy : ds.ways) 440 440 hm.put(wy.id, wy); 441 441 442 442 // pass 2 - sort out members 443 443 for (Entry<OsmPrimitiveData, Collection<RelationMemberData>> e : relations.entrySet()) { … … 490 490 osm.references = ref == null ? new DataSet() : ref; 491 491 492 492 493 493 currSource = source; 494 494 495 495 // phase 1: Parse nodes and read in raw ways 496 496 InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8")); 497 497 try { 498 498 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, osm.new Parser()); 499 } catch (ParserConfigurationException e1) {499 } catch (ParserConfigurationException e1) { 500 500 e1.printStackTrace(); // broken SAXException chaining 501 501 throw new SAXException(e1); 502 }503 502 } 503 504 504 Main.pleaseWaitDlg.currentAction.setText(tr("Prepare OSM data...")); 505 505 Main.pleaseWaitDlg.setIndeterminate(true); 506 506 507 System.out.println(""); 508 System.out.println("Parser finished: Tags " + tagsN + " Nodes " + nodesN + " Ways " + waysN + 509 " Relations " + relationsN + " Members " + membersN); 507 // System.out.println("Parser finished: Tags " + tagsN + " Nodes " + nodesN + " Ways " + waysN + 508 // " Relations " + relationsN + " Members " + membersN); 510 509 511 510 for (Node n : osm.nodes.values()) … … 525 524 o.id = 0; 526 525 527 System.out.println("Data loaded!");526 // System.out.println("Data loaded!"); 528 527 Main.pleaseWaitDlg.setIndeterminate(false); 529 528 Main.pleaseWaitDlg.progress.setValue(0); 530 529 531 530 return osm; 532 531 } -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r1238 r1353 42 42 protected InputStream getInputStreamRaw(String urlStr, PleaseWaitDialog pleaseWaitDlg) throws IOException { 43 43 44 System.out.println("download: "+urlStr);44 // System.out.println("download: "+urlStr); 45 45 initAuthentication(); 46 46 URL url = new URL(urlStr); … … 55 55 56 56 activeConnection.setConnectTimeout(15000); 57 57 58 58 try { 59 59 activeConnection.connect(); … … 62 62 throw new IOException(tr("Couldn't connect to the osm server. Please check your internet connection.")); 63 63 } 64 64 65 65 if (isAuthCancelled() && activeConnection.getResponseCode() == 401) 66 66 return null;
Note:
See TracChangeset
for help on using the changeset viewer.