Changeset 1169 in josm for trunk/src/org/openstreetmap/josm/corrector
- Timestamp:
- 2008-12-23T15:07:05+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/corrector
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/corrector/CorrectionTable.java
r1001 r1169 13 13 extends JTable { 14 14 15 15 private static final int MAX_VISIBLE_LINES = 10; 16 16 17 17 public static class BoldRenderer extends JLabel implements 18 18 TableCellRenderer { 19 19 20 21 22 20 public Component getTableCellRendererComponent(JTable table, 21 Object value, boolean isSelected, boolean hasFocus, int row, 22 int column) { 23 23 24 25 24 Font f = getFont(); 25 setFont(new Font(f.getName(), f.getStyle() | Font.BOLD, f.getSize())); 26 26 27 27 setText((String)value); 28 28 29 30 31 29 return this; 30 } 31 } 32 32 33 33 private static BoldRenderer boldRenderer = null; 34 34 35 36 35 protected CorrectionTable(TM correctionTableModel) { 36 super(correctionTableModel); 37 37 38 39 38 final int correctionsSize = correctionTableModel.getCorrections().size(); 39 final int lines = correctionsSize > MAX_VISIBLE_LINES ? MAX_VISIBLE_LINES 40 40 : correctionsSize; 41 42 43 41 setPreferredScrollableViewportSize(new Dimension(400, lines 42 * getRowHeight())); 43 getColumnModel().getColumn(correctionTableModel.getApplyColumn()) 44 44 .setPreferredWidth(40); 45 46 45 setRowSelectionAllowed(false); 46 } 47 47 48 49 50 51 52 53 54 55 48 public TableCellRenderer getCellRenderer(int row, int column) { 49 if (getCorrectionTableModel().isBoldCell(row, column)) { 50 if (boldRenderer == null) 51 boldRenderer = new BoldRenderer(); 52 return boldRenderer; 53 } 54 return super.getCellRenderer(row, column); 55 } 56 56 57 57 @SuppressWarnings("unchecked") 58 58 public TM getCorrectionTableModel() { 59 60 59 return (TM)getModel(); 60 } 61 61 62 62 } -
trunk/src/org/openstreetmap/josm/corrector/CorrectionTableModel.java
r1001 r1169 12 12 AbstractTableModel { 13 13 14 15 16 14 private List<C> corrections; 15 private boolean[] apply; 16 private int applyColumn; 17 17 18 public CorrectionTableModel(List<C> corrections) { 19 super(); 20 this.corrections = corrections; 21 apply = new boolean[this.corrections.size()]; 22 Arrays.fill(apply, true); 23 applyColumn = getColumnCount() - 1; 24 } 25 26 abstract public int getColumnCount(); 27 28 abstract protected boolean isBoldCell(int row, int column); 29 abstract public String getCorrectionColumnName(int colIndex); 30 abstract public Object getCorrectionValueAt(int rowIndex, int colIndex); 31 32 public List<C> getCorrections() { 33 return corrections; 34 } 35 36 public int getApplyColumn() { 37 return applyColumn; 38 } 39 40 public boolean getApply(int i) { 41 return apply[i]; 18 public CorrectionTableModel(List<C> corrections) { 19 super(); 20 this.corrections = corrections; 21 apply = new boolean[this.corrections.size()]; 22 Arrays.fill(apply, true); 23 applyColumn = getColumnCount() - 1; 42 24 } 43 25 44 public int getRowCount() { 45 return corrections.size(); 26 abstract public int getColumnCount(); 27 28 abstract protected boolean isBoldCell(int row, int column); 29 abstract public String getCorrectionColumnName(int colIndex); 30 abstract public Object getCorrectionValueAt(int rowIndex, int colIndex); 31 32 public List<C> getCorrections() { 33 return corrections; 46 34 } 47 35 48 @Override 49 public Class<?> getColumnClass(int columnIndex) { 50 if (columnIndex == applyColumn) 51 return Boolean.class; 52 return String.class; 36 public int getApplyColumn() { 37 return applyColumn; 53 38 } 54 39 55 @Override 56 public String getColumnName(int columnIndex) { 57 if (columnIndex == applyColumn) 58 return tr("Apply?"); 59 60 return getCorrectionColumnName(columnIndex); 61 } 62 63 @Override 64 public boolean isCellEditable(int rowIndex, int columnIndex) { 65 return columnIndex == applyColumn; 40 public boolean getApply(int i) { 41 return apply[i]; 66 42 } 67 43 68 @Override 44 public int getRowCount() { 45 return corrections.size(); 46 } 47 48 @Override 49 public Class<?> getColumnClass(int columnIndex) { 50 if (columnIndex == applyColumn) 51 return Boolean.class; 52 return String.class; 53 } 54 55 @Override 56 public String getColumnName(int columnIndex) { 57 if (columnIndex == applyColumn) 58 return tr("Apply?"); 59 60 return getCorrectionColumnName(columnIndex); 61 } 62 63 @Override 64 public boolean isCellEditable(int rowIndex, int columnIndex) { 65 return columnIndex == applyColumn; 66 } 67 68 @Override 69 69 public void setValueAt(Object aValue, int rowIndex, int columnIndex) { 70 71 70 if (columnIndex == applyColumn && aValue instanceof Boolean) 71 apply[rowIndex] = (Boolean)aValue; 72 72 } 73 73 74 74 public Object getValueAt(int rowIndex, int colIndex) { 75 76 77 78 79 75 if (colIndex == applyColumn) 76 return apply[rowIndex]; 77 78 return getCorrectionValueAt(rowIndex, colIndex); 79 } 80 80 } -
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r1002 r1169 22 22 public class ReverseWayTagCorrector extends TagCorrector<Way> { 23 23 24 24 private static class PrefixSuffixSwitcher { 25 25 26 27 28 29 26 private final String a; 27 private final String b; 28 private final Pattern startPattern; 29 private final Pattern endPattern; 30 30 31 32 33 31 private final String SEPARATOR = "[:_]?"; 32 33 public PrefixSuffixSwitcher(String a, String b) { 34 34 this.a = a; 35 35 this.b = b; … … 40 40 SEPARATOR + "(" + a + "|" + b + ")$", 41 41 Pattern.CASE_INSENSITIVE); 42 42 } 43 43 44 45 46 47 44 public String apply(String text) { 45 Matcher m = startPattern.matcher(text); 46 if (!m.lookingAt()) 47 m = endPattern.matcher(text); 48 48 49 50 49 if (m.lookingAt()) { 50 String leftRight = m.group(1).toLowerCase(); 51 51 52 StringBuilder result = new StringBuilder(); 53 result.append(text.substring(0, m.start(1))); 54 result.append(leftRight.equals(a) ? b : a); 55 result.append(text.substring(m.end(1))); 56 57 return result.toString(); 58 } 59 return text; 60 } 61 } 52 StringBuilder result = new StringBuilder(); 53 result.append(text.substring(0, m.start(1))); 54 result.append(leftRight.equals(a) ? b : a); 55 result.append(text.substring(m.end(1))); 62 56 63 private static PrefixSuffixSwitcher[] prefixSuffixSwitchers = 64 new PrefixSuffixSwitcher[] {65 new PrefixSuffixSwitcher("left", "right"),66 new PrefixSuffixSwitcher("forward", "backward")67 }; 57 return result.toString(); 58 } 59 return text; 60 } 61 } 68 62 69 @Override 70 public Collection<Command> execute(Way way) throws UserCancelException { 71 Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap = 72 new HashMap<OsmPrimitive, List<TagCorrection>>(); 63 private static PrefixSuffixSwitcher[] prefixSuffixSwitchers = 64 new PrefixSuffixSwitcher[] { 65 new PrefixSuffixSwitcher("left", "right"), 66 new PrefixSuffixSwitcher("forward", "backward") 67 }; 73 68 74 ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 75 primitives.add(way); 76 primitives.addAll(way.nodes); 69 @Override 70 public Collection<Command> execute(Way way) throws UserCancelException { 71 Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap = 72 new HashMap<OsmPrimitive, List<TagCorrection>>(); 77 73 78 for (OsmPrimitive primitive : primitives) { 79 tagCorrectionsMap.put(primitive, new ArrayList<TagCorrection>()); 74 ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 75 primitives.add(way); 76 primitives.addAll(way.nodes); 80 77 81 for (String key : primitive.keySet()) { 82 String newKey = key; 83 String value = primitive.get(key); 84 String newValue = value; 78 for (OsmPrimitive primitive : primitives) { 79 tagCorrectionsMap.put(primitive, new ArrayList<TagCorrection>()); 85 80 86 if (key.equals("oneway")) { 87 if (value.equals("-1")) 88 newValue = OsmUtils.trueval; 89 else { 90 Boolean boolValue = OsmUtils.getOsmBoolean(value); 91 if (boolValue != null && boolValue.booleanValue()) { 92 newValue = "-1"; 93 } 94 } 95 } else { 96 for (PrefixSuffixSwitcher prefixSuffixSwitcher : prefixSuffixSwitchers) { 97 newKey = prefixSuffixSwitcher.apply(key); 98 if (!key.equals(newKey)) 99 break; 100 } 101 } 81 for (String key : primitive.keySet()) { 82 String newKey = key; 83 String value = primitive.get(key); 84 String newValue = value; 102 85 103 if (!key.equals(newKey) || !value.equals(newValue)) 104 tagCorrectionsMap.get(primitive).add( 105 new TagCorrection(key, value, newKey, newValue)); 106 } 107 } 86 if (key.equals("oneway")) { 87 if (value.equals("-1")) 88 newValue = OsmUtils.trueval; 89 else { 90 Boolean boolValue = OsmUtils.getOsmBoolean(value); 91 if (boolValue != null && boolValue.booleanValue()) { 92 newValue = "-1"; 93 } 94 } 95 } else { 96 for (PrefixSuffixSwitcher prefixSuffixSwitcher : prefixSuffixSwitchers) { 97 newKey = prefixSuffixSwitcher.apply(key); 98 if (!key.equals(newKey)) 99 break; 100 } 101 } 108 102 109 Map<OsmPrimitive, List<RoleCorrection>> roleCorrectionMap = 110 new HashMap<OsmPrimitive, List<RoleCorrection>>(); 111 roleCorrectionMap.put(way, new ArrayList<RoleCorrection>()); 103 if (!key.equals(newKey) || !value.equals(newValue)) 104 tagCorrectionsMap.get(primitive).add( 105 new TagCorrection(key, value, newKey, newValue)); 106 } 107 } 112 108 113 for (Relation relation : Main.ds.relations) { 114 for (RelationMember member : relation.members) { 115 if (!member.member.realEqual(way, true) 116 || member.role.length() == 0) 117 continue; 109 Map<OsmPrimitive, List<RoleCorrection>> roleCorrectionMap = 110 new HashMap<OsmPrimitive, List<RoleCorrection>>(); 111 roleCorrectionMap.put(way, new ArrayList<RoleCorrection>()); 118 112 119 boolean found = false; 120 String newRole = null; 121 for (PrefixSuffixSwitcher prefixSuffixSwitcher : prefixSuffixSwitchers) { 122 newRole = prefixSuffixSwitcher.apply(member.role); 123 if (!newRole.equals(member.role)) { 124 found = true; 125 break; 126 } 127 } 113 for (Relation relation : Main.ds.relations) { 114 for (RelationMember member : relation.members) { 115 if (!member.member.realEqual(way, true) 116 || member.role.length() == 0) 117 continue; 128 118 129 if (found) 130 roleCorrectionMap.get(way).add( 131 new RoleCorrection(relation, member, newRole)); 132 } 133 } 119 boolean found = false; 120 String newRole = null; 121 for (PrefixSuffixSwitcher prefixSuffixSwitcher : prefixSuffixSwitchers) { 122 newRole = prefixSuffixSwitcher.apply(member.role); 123 if (!newRole.equals(member.role)) { 124 found = true; 125 break; 126 } 127 } 134 128 135 return applyCorrections(tagCorrectionsMap, roleCorrectionMap, 136 tr("When reverting this way, following changes to properties " 137 + "of the way and its nodes are suggested in order " 138 + "to maintain data consistency.")); 139 } 129 if (found) 130 roleCorrectionMap.get(way).add( 131 new RoleCorrection(relation, member, newRole)); 132 } 133 } 134 135 return applyCorrections(tagCorrectionsMap, roleCorrectionMap, 136 tr("When reverting this way, following changes to properties " 137 + "of the way and its nodes are suggested in order " 138 + "to maintain data consistency.")); 139 } 140 140 } -
trunk/src/org/openstreetmap/josm/corrector/TagCorrection.java
r1000 r1169 4 4 public class TagCorrection implements Correction { 5 5 6 7 8 9 6 public final String oldKey; 7 public final String newKey; 8 public final String oldValue; 9 public final String newValue; 10 10 11 11 public TagCorrection(String oldKey, String oldValue, String newKey, 12 12 String newValue) { 13 14 15 16 17 13 this.oldKey = oldKey; 14 this.oldValue = oldValue; 15 this.newKey = newKey; 16 this.newValue = newValue; 17 } 18 18 19 20 21 19 public boolean isKeyChanged() { 20 return !newKey.equals(oldKey); 21 } 22 22 23 24 25 23 public boolean isValueChanged() { 24 return !newValue.equals(oldValue); 25 } 26 26 } -
trunk/src/org/openstreetmap/josm/corrector/TagCorrectionTable.java
r1000 r1169 7 7 CorrectionTable<TagCorrectionTableModel> { 8 8 9 10 11 9 public TagCorrectionTable(List<TagCorrection> tagCorrections) { 10 super(new TagCorrectionTableModel(tagCorrections)); 11 } 12 12 13 13 } -
trunk/src/org/openstreetmap/josm/corrector/TagCorrectionTableModel.java
r1000 r1169 8 8 public class TagCorrectionTableModel extends CorrectionTableModel<TagCorrection> { 9 9 10 11 12 10 public TagCorrectionTableModel(List<TagCorrection> tagCorrections) { 11 super(tagCorrections); 12 } 13 13 14 15 16 17 14 @Override 15 public int getColumnCount() { 16 return 5; 17 } 18 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 19 @Override 20 public String getCorrectionColumnName(int colIndex) { 21 switch (colIndex) { 22 case 0: 23 return tr("Old key"); 24 case 1: 25 return tr("Old value"); 26 case 2: 27 return tr("New key"); 28 case 3: 29 return tr("New value"); 30 } 31 return null; 32 } 33 33 34 34 public Object getCorrectionValueAt(int rowIndex, int colIndex) { 35 35 TagCorrection tagCorrection = getCorrections().get(rowIndex); 36 36 37 38 39 40 41 42 43 44 45 46 47 48 37 switch (colIndex) { 38 case 0: 39 return tagCorrection.oldKey; 40 case 1: 41 return tagCorrection.oldValue; 42 case 2: 43 return tagCorrection.newKey; 44 case 3: 45 return tagCorrection.newValue; 46 } 47 return null; 48 } 49 49 50 51 52 53 54 50 protected boolean isBoldCell(int row, int column) { 51 TagCorrection tagCorrection = getCorrections().get(row); 52 return (column == 2 && tagCorrection.isKeyChanged()) 53 || (column == 3 && tagCorrection.isValueChanged()); 54 } 55 55 56 56 } -
trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java
r1107 r1169 33 33 public abstract class TagCorrector<P extends OsmPrimitive> { 34 34 35 36 35 public abstract Collection<Command> execute(P primitive) 36 throws UserCancelException; 37 37 38 private String[] applicationOptions = new String[] { 39 tr("Apply selected changes"), 40 tr("Don't apply changes"), 41 tr("Cancel") 38 private String[] applicationOptions = new String[] { 39 tr("Apply selected changes"), 40 tr("Don't apply changes"), 41 tr("Cancel") 42 42 }; 43 44 protected Collection<Command> applyCorrections(45 Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap,46 Map<OsmPrimitive, List<RoleCorrection>> roleCorrectionMap,47 String description) throws UserCancelException {48 43 49 boolean hasCorrections = false; 50 for (List<TagCorrection> tagCorrectionList : tagCorrectionsMap.values()) { 51 if (!tagCorrectionList.isEmpty()) { 52 hasCorrections = true; 53 break; 54 } 55 } 44 protected Collection<Command> applyCorrections( 45 Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap, 46 Map<OsmPrimitive, List<RoleCorrection>> roleCorrectionMap, 47 String description) throws UserCancelException { 56 48 57 if (!hasCorrections) 58 for (List<RoleCorrection> roleCorrectionList : roleCorrectionMap 59 .values()) { 60 if (!roleCorrectionList.isEmpty()) { 61 hasCorrections = true; 62 break; 63 } 64 } 49 boolean hasCorrections = false; 50 for (List<TagCorrection> tagCorrectionList : tagCorrectionsMap.values()) { 51 if (!tagCorrectionList.isEmpty()) { 52 hasCorrections = true; 53 break; 54 } 55 } 65 56 66 if (hasCorrections) { 67 Collection<Command> commands = new ArrayList<Command>(); 68 Map<OsmPrimitive, TagCorrectionTable> tagTableMap = 69 new HashMap<OsmPrimitive, TagCorrectionTable>(); 70 Map<OsmPrimitive, RoleCorrectionTable> roleTableMap = 71 new HashMap<OsmPrimitive, RoleCorrectionTable>(); 57 if (!hasCorrections) 58 for (List<RoleCorrection> roleCorrectionList : roleCorrectionMap 59 .values()) { 60 if (!roleCorrectionList.isEmpty()) { 61 hasCorrections = true; 62 break; 63 } 64 } 72 65 73 NameVisitor nameVisitor = new NameVisitor(); 66 if (hasCorrections) { 67 Collection<Command> commands = new ArrayList<Command>(); 68 Map<OsmPrimitive, TagCorrectionTable> tagTableMap = 69 new HashMap<OsmPrimitive, TagCorrectionTable>(); 70 Map<OsmPrimitive, RoleCorrectionTable> roleTableMap = 71 new HashMap<OsmPrimitive, RoleCorrectionTable>(); 74 72 75 final JPanel p= newJPanel(new GridBagLayout());73 NameVisitor nameVisitor = new NameVisitor(); 76 74 77 final JMultilineLabel label1 = new JMultilineLabel(description); 78 label1.setMaxWidth(400); 79 p.add(label1, GBC.eop()); 75 final JPanel p = new JPanel(new GridBagLayout()); 80 76 81 final JMultilineLabel label2 = new JMultilineLabel( 82 tr("Please select which property changes you want to apply.")); 83 label2.setMaxWidth(400); 84 p.add(label2, GBC.eop()); 77 final JMultilineLabel label1 = new JMultilineLabel(description); 78 label1.setMaxWidth(400); 79 p.add(label1, GBC.eop()); 85 80 86 for (OsmPrimitive primitive : tagCorrectionsMap.keySet()) { 87 final List<TagCorrection> tagCorrections = tagCorrectionsMap 88 .get(primitive); 81 final JMultilineLabel label2 = new JMultilineLabel( 82 tr("Please select which property changes you want to apply.")); 83 label2.setMaxWidth(400); 84 p.add(label2, GBC.eop()); 89 85 90 if (tagCorrections.isEmpty()) 91 continue; 86 for (OsmPrimitive primitive : tagCorrectionsMap.keySet()) { 87 final List<TagCorrection> tagCorrections = tagCorrectionsMap 88 .get(primitive); 92 89 93 primitive.visit(nameVisitor); 90 if (tagCorrections.isEmpty()) 91 continue; 94 92 95 final JLabel propertiesLabel = new JLabel(tr("Properties of ")); 96 p.add(propertiesLabel, GBC.std()); 93 primitive.visit(nameVisitor); 97 94 98 final JLabel primitiveLabel = new JLabel( 99 nameVisitor.name + ":", nameVisitor.icon, JLabel.LEFT); 100 p.add(primitiveLabel, GBC.eol()); 95 final JLabel propertiesLabel = new JLabel(tr("Properties of ")); 96 p.add(propertiesLabel, GBC.std()); 101 97 102 final TagCorrectionTable table = new TagCorrectionTable( 103 tagCorrections); 104 final JScrollPane scrollPane = new JScrollPane(table); 105 p.add(scrollPane, GBC.eop()); 98 final JLabel primitiveLabel = new JLabel( 99 nameVisitor.name + ":", nameVisitor.icon, JLabel.LEFT); 100 p.add(primitiveLabel, GBC.eol()); 106 101 107 tagTableMap.put(primitive, table); 108 } 102 final TagCorrectionTable table = new TagCorrectionTable( 103 tagCorrections); 104 final JScrollPane scrollPane = new JScrollPane(table); 105 p.add(scrollPane, GBC.eop()); 109 106 110 for (OsmPrimitive primitive : roleCorrectionMap.keySet()) { 111 final List<RoleCorrection> roleCorrections = roleCorrectionMap 112 .get(primitive); 113 if (roleCorrections.isEmpty()) 114 continue; 107 tagTableMap.put(primitive, table); 108 } 115 109 116 primitive.visit(nameVisitor); 110 for (OsmPrimitive primitive : roleCorrectionMap.keySet()) { 111 final List<RoleCorrection> roleCorrections = roleCorrectionMap 112 .get(primitive); 113 if (roleCorrections.isEmpty()) 114 continue; 117 115 118 final JLabel rolesLabel = new JLabel( 119 tr("Roles in relations referring to")); 120 p.add(rolesLabel, GBC.std()); 116 primitive.visit(nameVisitor); 121 117 122 primitiveLabel = new JLabel(123 nameVisitor.name + ":", nameVisitor.icon, JLabel.LEFT);124 p.add(primitiveLabel, GBC.eol());118 final JLabel rolesLabel = new JLabel( 119 tr("Roles in relations referring to")); 120 p.add(rolesLabel, GBC.std()); 125 121 126 final RoleCorrectionTable table = new RoleCorrectionTable( 127 roleCorrections); 128 final JScrollPane scrollPane = new JScrollPane(table); 129 p.add(scrollPane, GBC.eop()); 122 final JLabel primitiveLabel = new JLabel( 123 nameVisitor.name + ":", nameVisitor.icon, JLabel.LEFT); 124 p.add(primitiveLabel, GBC.eol()); 130 125 131 roleTableMap.put(primitive, table); 132 } 126 final RoleCorrectionTable table = new RoleCorrectionTable( 127 roleCorrections); 128 final JScrollPane scrollPane = new JScrollPane(table); 129 p.add(scrollPane, GBC.eop()); 133 130 134 int answer = JOptionPane.showOptionDialog(Main.parent, p, 131 roleTableMap.put(primitive, table); 132 } 133 134 int answer = JOptionPane.showOptionDialog(Main.parent, p, 135 135 tr("Automatic tag correction"), JOptionPane.YES_NO_CANCEL_OPTION, 136 JOptionPane.PLAIN_MESSAGE, null, 136 JOptionPane.PLAIN_MESSAGE, null, 137 137 applicationOptions, applicationOptions[0]); 138 138 139 140 141 139 if (answer == JOptionPane.YES_OPTION) { 140 for (OsmPrimitive primitive : tagCorrectionsMap.keySet()) { 141 List<TagCorrection> tagCorrections = 142 142 tagCorrectionsMap.get(primitive); 143 143 144 144 // create the clone 145 145 OsmPrimitive clone = null; … … 147 147 else if (primitive instanceof Node) clone = new Node((Node)primitive); 148 148 else if (primitive instanceof Relation) clone = new Relation((Relation)primitive); 149 149 150 150 // use this structure to remember keys that have been set already so that 151 151 // they're not dropped by a later step 152 152 Set<String> keysChanged = new HashSet<String>(); 153 153 154 154 // apply all changes to this clone 155 156 157 158 159 160 161 162 163 155 for (int i = 0; i < tagCorrections.size(); i++) { 156 if (tagTableMap.get(primitive).getCorrectionTableModel().getApply(i)) { 157 TagCorrection tagCorrection = tagCorrections.get(i); 158 if (tagCorrection.isKeyChanged() && !keysChanged.contains(tagCorrection.oldKey)) clone.remove(tagCorrection.oldKey); 159 clone.put(tagCorrection.newKey, tagCorrection.newValue); 160 keysChanged.add(tagCorrection.newKey); 161 } 162 } 163 164 164 // save the clone 165 165 if (!keysChanged.isEmpty()) commands.add(new ChangeCommand(primitive, clone)); 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 166 } 167 for (OsmPrimitive primitive : roleCorrectionMap.keySet()) { 168 List<RoleCorrection> roleCorrections = roleCorrectionMap 169 .get(primitive); 170 for (int i = 0; i < roleCorrections.size(); i++) { 171 if (roleTableMap.get(primitive) 172 .getCorrectionTableModel().getApply(i)) { 173 RoleCorrection roleCorrection = roleCorrections 174 .get(i); 175 Relation newRelation = new Relation( 176 roleCorrection.relation); 177 for (RelationMember member : newRelation.members) 178 if (member.equals(roleCorrection.member)) 179 member.role = roleCorrection.newRole; 180 commands.add(new ChangeCommand( 181 roleCorrection.relation, newRelation)); 182 } 183 } 184 } 185 } else if (answer != JOptionPane.NO_OPTION) { 186 throw new UserCancelException(); 187 } 188 return commands; 189 } 190 190 191 192 191 return Collections.emptyList(); 192 } 193 193 }
Note:
See TracChangeset
for help on using the changeset viewer.