Changeset 35628 in osm for applications/editors/josm


Ignore:
Timestamp:
2020-10-29T00:14:21+01:00 (4 years ago)
Author:
simon04
Message:

EditLevel0LAction: move nodes

Location:
applications/editors/josm/plugins/comfort0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/comfort0/src/net/simon04/comfort0/EditLevel0LAction.java

    r35627 r35628  
    2222import org.openstreetmap.josm.command.ChangePropertyCommand;
    2323import org.openstreetmap.josm.command.Command;
     24import org.openstreetmap.josm.command.MoveCommand;
    2425import org.openstreetmap.josm.command.SequenceCommand;
    2526import org.openstreetmap.josm.data.UndoRedoHandler;
    2627import org.openstreetmap.josm.data.osm.DataSet;
     28import org.openstreetmap.josm.data.osm.Node;
    2729import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2830import org.openstreetmap.josm.data.osm.PrimitiveData;
     
    140142                commands.add(command);
    141143            }
     144
     145            if (fromDataSet instanceof Node && !Objects.equals(((Node) fromDataSet).getCoor(), ((Node) newInstance).getCoor())) {
     146                final MoveCommand command = new MoveCommand(((Node) fromDataSet), ((Node) newInstance).getCoor());
     147                commands.add(command);
     148            }
    142149        }
    143150        if (commands.isEmpty()) {
  • applications/editors/josm/plugins/comfort0/test/unit/net/simon04/comfort0/EditLevel0LActionTest.java

    r35627 r35628  
    44import static org.hamcrest.CoreMatchers.instanceOf;
    55import static org.hamcrest.CoreMatchers.is;
     6import static org.hamcrest.CoreMatchers.notNullValue;
    67import static org.hamcrest.CoreMatchers.nullValue;
    78import static org.hamcrest.MatcherAssert.assertThat;
     
    1314import org.junit.Test;
    1415import org.openstreetmap.josm.command.ChangePropertyCommand;
     16import org.openstreetmap.josm.command.MoveCommand;
    1517import org.openstreetmap.josm.command.PseudoCommand;
    1618import org.openstreetmap.josm.command.SequenceCommand;
     
    3436    @Rule
    3537    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules().preferences();
     38    public JOSMTestRules test = new JOSMTestRules().preferences().projection();
    3739
    3840    private SequenceCommand buildChangeCommands(DataSet dataSet) throws ParseException {
     
    4446    }
    4547
    46     private ChangePropertyCommand buildChangeCommand(DataSet dataSet) throws ParseException {
     48    private <T extends PseudoCommand> T buildChangeCommand(DataSet dataSet, Class<T> type) throws ParseException {
    4749        SequenceCommand commands = buildChangeCommands(dataSet);
    4850        assertThat(commands.getChildren(), hasSize(1));
    4951        final PseudoCommand command = commands.getChildren().iterator().next();
    50         assertThat(command, instanceOf(ChangePropertyCommand.class));
    51         return (ChangePropertyCommand) command;
     52        assertThat(command, instanceOf(type));
     53        return type.cast(command);
    5254    }
    5355
     
    5860        final DataSet dataSet = new DataSet(node);
    5961
    60         ChangePropertyCommand command = buildChangeCommand(dataSet);
     62        ChangePropertyCommand command = buildChangeCommand(dataSet, ChangePropertyCommand.class);
    6163        assertThat(command.getTags(), is(new TagMap("name", "Neu Broderstorf", "traffic_sign", "city_limit")));
    6264
     
    6668
    6769        node.put("fixme", "delete me!");
    68         command = buildChangeCommand(dataSet);
     70        command = buildChangeCommand(dataSet, ChangePropertyCommand.class);
    6971        assertThat(command.getTags(), is(new TagMap("name", "Neu Broderstorf", "traffic_sign", "city_limit")));
    7072        node.remove("fixme");
    7173
    7274        node.setCoor(new LatLon(55.0900666, 13.2539381));
    73         assertThat(buildChangeCommands(dataSet), nullValue()); // TODO
     75        assertThat(buildChangeCommand(dataSet, MoveCommand.class), notNullValue());
    7476    }
    7577}
Note: See TracChangeset for help on using the changeset viewer.