Changeset 29391 in osm for applications/editors/josm/plugins
- Timestamp:
- 2013-03-24T18:39:50+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/UnGlueRelationAction.java
r29118 r29391 19 19 import org.openstreetmap.josm.data.osm.Node; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;22 21 import org.openstreetmap.josm.data.osm.Relation; 23 import org.openstreetmap.josm.data.osm.RelationMember;24 22 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm. gui.DefaultNameFormatter;23 import org.openstreetmap.josm.plugins.utilsplugin2.command.ChangeRelationMemberCommand; 26 24 import org.openstreetmap.josm.tools.Shortcut; 27 25 … … 89 87 } 90 88 91 /**92 * Change member in relation to another one93 */94 private class ChangeRelationMemberCommand extends Command {95 96 private final Relation relation;97 private final OsmPrimitive oldMember;98 private final OsmPrimitive newMember;99 100 public ChangeRelationMemberCommand(Relation relation, OsmPrimitive oldMember, OsmPrimitive newMember) {101 this.relation = relation;102 this.oldMember = oldMember;103 this.newMember = newMember;104 }105 106 private boolean replaceMembers(OsmPrimitive oldP, OsmPrimitive newP) {107 if (relation == null || oldMember == null || newMember == null) {108 return false;109 }110 LinkedList<RelationMember> newrms = new LinkedList<RelationMember>();111 for (RelationMember rm : relation.getMembers()) {112 if (rm.getMember() == oldP) {113 newrms.add(new RelationMember(rm.getRole(), newP));114 } else {115 newrms.add(rm);116 }117 }118 relation.setMembers(newrms);119 return true;120 }121 122 @Override123 public boolean executeCommand() {124 return replaceMembers(oldMember, newMember);125 }126 127 @Override128 public void fillModifiedData(Collection<OsmPrimitive> modified,129 Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {130 modified.add(relation);131 }132 133 @Override134 public void undoCommand() {135 replaceMembers(newMember, oldMember);136 }137 138 @Override139 public String getDescriptionText() {140 return tr("Change relation member for {0} {1}",141 OsmPrimitiveType.from(relation),142 relation.getDisplayName(DefaultNameFormatter.getInstance()));143 }144 }145 146 89 @Override 147 90 protected void updateEnabledState() {
Note:
See TracChangeset
for help on using the changeset viewer.