Changeset 1814 in josm for trunk/src/org/openstreetmap/josm/corrector
- Timestamp:
- 2009-07-19T19:04:49+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/corrector
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r1762 r1814 115 115 roleCorrectionMap.put(way, new ArrayList<RoleCorrection>()); 116 116 117 for (Relation relation : Main. ds.relations) {117 for (Relation relation : Main.main.getCurrentDataSet().relations) { 118 118 int position = 0; 119 119 for (RelationMember member : relation.members) { -
trunk/src/org/openstreetmap/josm/corrector/RoleCorrectionTableModel.java
r1001 r1814 6 6 import java.util.List; 7 7 8 import org.openstreetmap.josm. data.osm.visitor.NameVisitor;8 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 9 9 10 10 public class RoleCorrectionTableModel extends 11 CorrectionTableModel<RoleCorrection> { 12 13 private static NameVisitor nameVisitor = new NameVisitor(); 11 CorrectionTableModel<RoleCorrection> { 12 private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 14 13 15 14 public RoleCorrectionTableModel(List<RoleCorrection> roleCorrections) { … … 41 40 switch (colIndex) { 42 41 case 0: 43 roleCorrection.relation.visit(nameVisitor); 44 return nameVisitor.name; 42 return NAME_FORMATTER.getName(roleCorrection.relation); 45 43 case 1: 46 44 return roleCorrection.member.role; -
trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java
r1617 r1814 25 25 import org.openstreetmap.josm.data.osm.Node; 26 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 27 28 import org.openstreetmap.josm.data.osm.Relation; 28 import org.openstreetmap.josm.data.osm.RelationMember;29 29 import org.openstreetmap.josm.data.osm.Way; 30 import org.openstreetmap.josm.data.osm.visitor.NameVisitor;31 30 import org.openstreetmap.josm.gui.JMultilineLabel; 31 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 32 32 import org.openstreetmap.josm.tools.GBC; 33 import org.openstreetmap.josm.tools.ImageProvider; 33 34 34 35 public abstract class TagCorrector<P extends OsmPrimitive> { 36 private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 35 37 36 38 public abstract Collection<Command> execute(P primitive, P oldprimitive) 37 39 throws UserCancelException; 38 40 39 41 private String[] applicationOptions = new String[] { 40 tr("Apply selected changes"),41 tr("Don't apply changes"),42 tr("Cancel")42 tr("Apply selected changes"), 43 tr("Don't apply changes"), 44 tr("Cancel") 43 45 }; 44 46 … … 56 58 } 57 59 58 if (!hasCorrections) 60 if (!hasCorrections) { 59 61 for (List<RoleCorrection> roleCorrectionList : roleCorrectionMap 60 62 .values()) { … … 64 66 } 65 67 } 68 } 66 69 67 70 if (hasCorrections) { … … 72 75 new HashMap<OsmPrimitive, RoleCorrectionTable>(); 73 76 74 NameVisitor nameVisitor = new NameVisitor();77 //NameVisitor nameVisitor = new NameVisitor(); 75 78 76 79 final JPanel p = new JPanel(new GridBagLayout()); … … 87 90 for (OsmPrimitive primitive : tagCorrectionsMap.keySet()) { 88 91 final List<TagCorrection> tagCorrections = tagCorrectionsMap 89 90 91 if (tagCorrections.isEmpty()) 92 .get(primitive); 93 94 if (tagCorrections.isEmpty()) { 92 95 continue; 93 94 primitive.visit(nameVisitor); 96 } 95 97 96 98 final JLabel propertiesLabel = new JLabel(tr("Properties of ")); … … 98 100 99 101 final JLabel primitiveLabel = new JLabel( 100 nameVisitor.name + ":", nameVisitor.icon, JLabel.LEFT); 102 NAME_FORMATTER.getName(primitive) + ":", 103 ImageProvider.get(OsmPrimitiveType.from(primitive)), 104 JLabel.LEFT 105 ); 101 106 p.add(primitiveLabel, GBC.eol()); 102 107 … … 111 116 for (OsmPrimitive primitive : roleCorrectionMap.keySet()) { 112 117 final List<RoleCorrection> roleCorrections = roleCorrectionMap 113 114 if (roleCorrections.isEmpty()) 118 .get(primitive); 119 if (roleCorrections.isEmpty()) { 115 120 continue; 116 117 primitive.visit(nameVisitor); 121 } 118 122 119 123 final JLabel rolesLabel = new JLabel( … … 122 126 123 127 final JLabel primitiveLabel = new JLabel( 124 nameVisitor.name + ":", nameVisitor.icon, JLabel.LEFT); 128 NAME_FORMATTER.getName(primitive), 129 ImageProvider.get(OsmPrimitiveType.from(primitive)), 130 JLabel.LEFT 131 ); 125 132 p.add(primitiveLabel, GBC.eol()); 126 133 … … 145 152 // create the clone 146 153 OsmPrimitive clone = null; 147 if (primitive instanceof Way) clone = new Way((Way)primitive); 148 else if (primitive instanceof Node) clone = new Node((Node)primitive); 149 else if (primitive instanceof Relation) clone = new Relation((Relation)primitive); 154 if (primitive instanceof Way) { 155 clone = new Way((Way)primitive); 156 } else if (primitive instanceof Node) { 157 clone = new Node((Node)primitive); 158 } else if (primitive instanceof Relation) { 159 clone = new Relation((Relation)primitive); 160 } 150 161 151 162 // use this structure to remember keys that have been set already so that … … 157 168 if (tagTableMap.get(primitive).getCorrectionTableModel().getApply(i)) { 158 169 TagCorrection tagCorrection = tagCorrections.get(i); 159 if (tagCorrection.isKeyChanged() && !keysChanged.contains(tagCorrection.oldKey)) clone.remove(tagCorrection.oldKey); 170 if (tagCorrection.isKeyChanged() && !keysChanged.contains(tagCorrection.oldKey)) { 171 clone.remove(tagCorrection.oldKey); 172 } 160 173 clone.put(tagCorrection.newKey, tagCorrection.newValue); 161 174 keysChanged.add(tagCorrection.newKey); … … 164 177 165 178 // save the clone 166 if (!keysChanged.isEmpty()) commands.add(new ChangeCommand(primitive, clone)); 179 if (!keysChanged.isEmpty()) { 180 commands.add(new ChangeCommand(primitive, clone)); 181 } 167 182 } 168 183 for (OsmPrimitive primitive : roleCorrectionMap.keySet()) { 169 184 List<RoleCorrection> roleCorrections = roleCorrectionMap 170 185 .get(primitive); 171 186 172 187 for (int i = 0; i < roleCorrections.size(); i++) { … … 177 192 } 178 193 } 179 } else if (answer != JOptionPane.NO_OPTION) {194 } else if (answer != JOptionPane.NO_OPTION) 180 195 throw new UserCancelException(); 181 }182 196 return commands; 183 197 }
Note:
See TracChangeset
for help on using the changeset viewer.