Changeset 3302 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-06-03T20:40:04+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r3281 r3302 52 52 import javax.swing.table.DefaultTableModel; 53 53 import javax.swing.table.TableModel; 54 import javax.swing.table.TableColumnModel; 54 55 import javax.swing.text.JTextComponent; 55 56 … … 337 338 Main.map.mapView.getEditLayer(), 338 339 relation, 339 ( Collection<RelationMember>) membershipData.getValueAt(row, 1)).setVisible(true);340 ((MemberInfo) membershipData.getValueAt(row, 1)).role).setVisible(true); 340 341 } 341 342 … … 472 473 private final JLabel selectSth = new JLabel("<html><p>" 473 474 + tr("Please select the objects you want to change properties for.") + "</p></html>"); 475 476 class MemberInfo { 477 List<RelationMember> role = new ArrayList<RelationMember>(); 478 List<Integer> position = new ArrayList<Integer>(); 479 void add(RelationMember r, Integer p) 480 { 481 role.add(r); 482 position.add(p); 483 } 484 } 474 485 475 486 /** … … 511 522 // setting up the membership table 512 523 513 membershipData.setColumnIdentifiers(new String[]{tr("Member Of"),tr("Role") });524 membershipData.setColumnIdentifiers(new String[]{tr("Member Of"),tr("Role"),tr("Position")}); 514 525 membershipTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 515 526 membershipTable.addMouseListener(new PopupMenuLauncher() { … … 528 539 }); 529 540 530 membershipTable.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() { 541 TableColumnModel mod = membershipTable.getColumnModel(); 542 mod.getColumn(0).setCellRenderer(new DefaultTableCellRenderer() { 531 543 @Override public Component getTableCellRendererComponent(JTable table, Object value, 532 544 boolean isSelected, boolean hasFocus, int row, int column) { … … 544 556 }); 545 557 546 m embershipTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer() {558 mod.getColumn(1).setCellRenderer(new DefaultTableCellRenderer() { 547 559 @SuppressWarnings("unchecked") 548 560 @Override public Component getTableCellRendererComponent(JTable table, Object value, … … 552 564 if (c instanceof JLabel) { 553 565 JLabel label = (JLabel)c; 554 Collection<RelationMember> col = (Collection<RelationMember>) value;566 MemberInfo col = (MemberInfo) value; 555 567 556 568 String text = null; 557 for (RelationMember r : col ) {569 for (RelationMember r : col.role) { 558 570 if (text == null) { 559 571 text = r.getRole(); … … 573 585 } 574 586 }); 587 588 mod.getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { 589 @SuppressWarnings("unchecked") 590 @Override public Component getTableCellRendererComponent(JTable table, Object value, 591 boolean isSelected, boolean hasFocus, int row, int column) { 592 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); 593 boolean isFiltered = (((Relation)table.getValueAt(row, 0))).isFiltered(); 594 if (c instanceof JLabel) { 595 JLabel label = (JLabel)c; 596 MemberInfo col = (MemberInfo) table.getValueAt(row, 1); 597 598 String text = ""; 599 for (Integer p : col.position) { 600 if (text.length() != 0) 601 text += ","; 602 text += String.valueOf(p); 603 } 604 605 label.setText(text); 606 if (isFiltered) { 607 label.setFont(label.getFont().deriveFont(Font.ITALIC)); 608 } 609 } 610 return c; 611 } 612 }); 613 mod.getColumn(2).setPreferredWidth(20); 614 mod.getColumn(1).setPreferredWidth(40); 615 mod.getColumn(0).setPreferredWidth(200); 575 616 576 617 // combine both tables and wrap them in a scrollPane … … 803 844 membershipData.setRowCount(0); 804 845 805 Map<Relation, Collection<RelationMember>> roles = new HashMap<Relation, Collection<RelationMember>>();846 Map<Relation, MemberInfo> roles = new HashMap<Relation, MemberInfo>(); 806 847 for (OsmPrimitive primitive: newSelection) { 807 848 for (OsmPrimitive ref: primitive.getReferrers()) { 808 849 if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) { 809 850 Relation r = (Relation) ref; 810 Collection<RelationMember> members = new ArrayList<RelationMember>(); 811 roles.put(r, members); 851 MemberInfo mi = mi = new MemberInfo(); 852 roles.put(r, mi); 853 int i = 1; 812 854 for (RelationMember m : r.getMembers()) { 813 855 if (m.getMember() == primitive) { 814 m embers.add(m);856 mi.add(m, i); 815 857 } 858 ++i; 816 859 } 817 860 }
Note:
See TracChangeset
for help on using the changeset viewer.