Changeset 30271 in osm for applications/editors/josm
- Timestamp:
- 2014-02-10T01:54:34+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/undelete/src/org/openstreetmap/josm/plugins/undelete/UndeleteAction.java
r30207 r30271 9 9 import java.util.Collections; 10 10 import java.util.List; 11 12 import javax.swing.JOptionPane; 11 13 12 14 import org.openstreetmap.josm.Main; … … 28 30 import org.openstreetmap.josm.data.osm.history.HistoryRelation; 29 31 import org.openstreetmap.josm.data.osm.history.HistoryWay; 32 import org.openstreetmap.josm.gui.Notification; 30 33 import org.openstreetmap.josm.gui.history.HistoryLoadTask; 31 34 import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask; 32 35 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 36 import org.openstreetmap.josm.gui.util.GuiHelper; 33 37 import org.openstreetmap.josm.tools.Shortcut; 34 38 … … 105 109 106 110 HistoryNode hNode = (HistoryNode) hPrimitive2; 107 node.setCoor(hNode.getCoords()); 111 if (hNode != null) { 112 node.setCoor(hNode.getCoords()); 113 } 108 114 109 115 primitive = node; … … 121 127 // hWay.getNumNodes())); 122 128 List<PrimitiveId> nodeIds = new ArrayList<PrimitiveId>(); 123 for (Long i : hWay.getNodes()) { 124 nodeIds.add(new SimplePrimitiveId(i, OsmPrimitiveType.NODE)); 129 if (hWay != null) { 130 for (Long i : hWay.getNodes()) { 131 nodeIds.add(new SimplePrimitiveId(i, OsmPrimitiveType.NODE)); 132 } 125 133 } 126 134 undelete(false, nodeIds, way); … … 136 144 HistoryRelation hRel = (HistoryRelation) hPrimitive2; 137 145 138 List<RelationMember> members = new ArrayList<RelationMember>(hRel.getNumMembers()); 139 for (RelationMemberData m : hRel.getMembers()) { 140 OsmPrimitive p = layer.data.getPrimitiveById(m.getMemberId(), m.getMemberType()); 141 if (p == null) { 142 switch (m.getMemberType()) { 143 case NODE: 144 p = new Node(m.getMemberId()); 145 break; 146 case CLOSEDWAY: 147 case WAY: 148 p = new Way(m.getMemberId()); 149 break; 150 case MULTIPOLYGON: 151 case RELATION: 152 p = new Relation(m.getMemberId()); 153 break; 154 } 155 layer.data.addPrimitive(p); 156 } 157 members.add(new RelationMember(m.getRole(), p)); 146 if (hRel != null) { 147 List<RelationMember> members = new ArrayList<RelationMember>(hRel.getNumMembers()); 148 for (RelationMemberData m : hRel.getMembers()) { 149 OsmPrimitive p = layer.data.getPrimitiveById(m.getMemberId(), m.getMemberType()); 150 if (p == null) { 151 switch (m.getMemberType()) { 152 case NODE: 153 p = new Node(m.getMemberId()); 154 break; 155 case CLOSEDWAY: 156 case WAY: 157 p = new Way(m.getMemberId()); 158 break; 159 case MULTIPOLYGON: 160 case RELATION: 161 p = new Relation(m.getMemberId()); 162 break; 163 } 164 layer.data.addPrimitive(p); 165 } 166 members.add(new RelationMember(m.getRole(), p)); 167 } 168 169 rel.setMembers(members); 158 170 } 159 160 rel.setMembers(members);161 171 162 172 primitive = rel; 163 173 } 164 174 165 primitive.setChangesetId((int) hPrimitive1.getChangesetId()); 166 primitive.setTimestamp(hPrimitive1.getTimestamp()); 167 primitive.setUser(hPrimitive1.getUser()); 168 primitive.setVisible(hPrimitive1.isVisible()); 169 primitive.setKeys(hPrimitive2.getTags()); 170 primitive.setModified(true); 171 172 layer.data.addPrimitive(primitive); 175 if (hPrimitive2 != null) { 176 primitive.setChangesetId((int) hPrimitive1.getChangesetId()); 177 primitive.setTimestamp(hPrimitive1.getTimestamp()); 178 primitive.setUser(hPrimitive1.getUser()); 179 primitive.setVisible(hPrimitive1.isVisible()); 180 primitive.setKeys(hPrimitive2.getTags()); 181 primitive.setModified(true); 182 183 layer.data.addPrimitive(primitive); 184 } else { 185 final String msg = tr("Unable to undelete {0} {1}. Object has likely been redacted", type, id); 186 GuiHelper.runInEDT(new Runnable() { 187 @Override 188 public void run() { 189 new Notification(msg).setIcon(JOptionPane.WARNING_MESSAGE).show(); 190 } 191 }); 192 Main.warn(msg); 193 } 173 194 } 174 195 } catch (Throwable t) {
Note:
See TracChangeset
for help on using the changeset viewer.