Ignore:
Timestamp:
2015-08-15T12:30:24+02:00 (9 years ago)
Author:
nokutu
Message:

More tests for history record system.

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r31490 r31500  
    6767
    6868  /**
    69    * Removes an image from the database.
    70    *
    71    * @param image
     69   * Removes an image from the database. From the ArrayList in this object and
     70   * from its {@link MapillarySequence}.
     71   *
     72   * @param image
     73   *          The {@link MapillaryAbstractImage} that is going to be deleted.
    7274   */
    7375  public synchronized void remove(MapillaryAbstractImage image) {
    74     if (MapillaryMainDialog.getInstance().getImage() != null) {
     76    if (Main.main != null
     77        && MapillaryMainDialog.getInstance().getImage() != null) {
    7578      MapillaryMainDialog.getInstance().setImage(null);
    7679      MapillaryMainDialog.getInstance().updateImage();
     
    8891   *
    8992   * @param images
     93   *          The set of {@link MapillaryAbstractImage} objects that are going
     94   *          to be removed.
    9095   */
    9196  public synchronized void remove(List<MapillaryAbstractImage> images) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandDelete.java

    r31490 r31500  
    1010
    1111/**
     12 * Command used to delete a set of images.
     13 *
    1214 * @author nokutu
    1315 *
     
    1820
    1921  /**
     22   * Main constructor.
     23   *
    2024   * @param images
     25   *          The set of images that are going to be deleted.
    2126   */
    2227  public CommandDelete(List<MapillaryAbstractImage> images) {
     
    2732  @Override
    2833  public void sum(MapillaryCommand command) {
    29     // Ignored
    3034  }
    3135
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandImport.java

    r31491 r31500  
    2222   *
    2323   * @param images
     24   *          The set of images that are going to be added. Might be in the same
     25   *          sequence or not.
    2426   */
    2527  public CommandImport(List<MapillaryAbstractImage> images) {
     
    4749  @Override
    4850  public void sum(MapillaryCommand command) {
    49     // IGNORE
    5051  }
    5152
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandJoin.java

    r31490 r31500  
    66
    77import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    8 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    98import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    109
     
    2120   *
    2221   * @param images
     22   *          The two images that are going to be joined. Must be of exactly
     23   *          size 2. The first one joins to the second one.
     24   * @throws IllegalArgumentException
     25   *           if the List size is different from 2.
    2326   */
    2427  public CommandJoin(List<MapillaryAbstractImage> images) {
    2528    super(images);
     29    if (images.size() != 2)
     30      throw new IllegalArgumentException();
    2631  }
    2732
     
    3338  @Override
    3439  public void undo() {
    35     MapillaryUtils.unjoin((MapillaryImportedImage) this.images.get(0),
    36         (MapillaryImportedImage) this.images.get(1));
     40    MapillaryUtils.unjoin(this.images.get(0), this.images.get(1));
    3741  }
    3842
    3943  @Override
    4044  public void redo() {
    41     MapillaryUtils.join((MapillaryImportedImage) this.images.get(0),
    42         (MapillaryImportedImage) this.images.get(1));
     45    MapillaryUtils.join(this.images.get(0), this.images.get(1));
    4346  }
    4447
    4548  @Override
    4649  public void sum(MapillaryCommand command) {
    47     // TODO Auto-generated method stub
    48 
    4950  }
    5051
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandUnjoin.java

    r31490 r31500  
    66
    77import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    8 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    98import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    109
     
    2120   *
    2221   * @param images
     22   *          The two images that are going to be unjoined. Must be of exactly
     23   *          size 2.
     24   * @throws IllegalArgumentException
     25   *           if the List size is different from 2.
    2326   */
    2427  public CommandUnjoin(List<MapillaryAbstractImage> images) {
    2528    super(images);
     29    if (images.size() != 2)
     30      throw new IllegalArgumentException();
    2631  }
    2732
     
    3338  @Override
    3439  public void undo() {
    35     MapillaryUtils.join((MapillaryImportedImage) this.images.get(0),
    36         (MapillaryImportedImage) this.images.get(1));
     40    MapillaryUtils.join(this.images.get(0), this.images.get(1));
    3741  }
    3842
    3943  @Override
    4044  public void redo() {
    41     MapillaryUtils.unjoin((MapillaryImportedImage) this.images.get(0),
    42         (MapillaryImportedImage) this.images.get(1));
     45    MapillaryUtils.unjoin(this.images.get(0), this.images.get(1));
    4346  }
    4447
    4548  @Override
    4649  public void sum(MapillaryCommand command) {
    47     // IGNORE
    4850  }
    4951
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/MapillaryExecutableCommand.java

    r31490 r31500  
    1717   *
    1818   * @param images
     19   *          The set of images affected by the command.
    1920   */
    2021  public MapillaryExecutableCommand(List<MapillaryAbstractImage> images) {
     
    2324
    2425  /**
    25    * Executes the command.
     26   * Executes the command. It is run when the command is added to the history
     27   * record.
    2628   */
    2729  public abstract void execute();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r31495 r31500  
    1919import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    2020import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    21 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    2221import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    2322import org.openstreetmap.josm.plugins.mapillary.MapillarySequence;
     
    137136   * Joins two images into the same sequence.
    138137   *
    139    * @param img1
    140    * @param img2
    141    */
    142   public synchronized static void join(MapillaryImportedImage img1,
    143       MapillaryImportedImage img2) {
    144     MapillaryImportedImage firstImage = img1;
    145     MapillaryImportedImage secondImage = img2;
    146 
    147     if (img1.next() != null) {
    148       firstImage = img2;
    149       secondImage = img1;
     138   * @param mapillaryAbstractImage
     139   * @param mapillaryAbstractImage2
     140   */
     141  public synchronized static void join(MapillaryAbstractImage mapillaryAbstractImage,
     142      MapillaryAbstractImage mapillaryAbstractImage2) {
     143    MapillaryAbstractImage firstImage = mapillaryAbstractImage;
     144    MapillaryAbstractImage secondImage = mapillaryAbstractImage2;
     145
     146    if (mapillaryAbstractImage.next() != null) {
     147      firstImage = mapillaryAbstractImage2;
     148      secondImage = mapillaryAbstractImage;
    150149    }
    151150    if (firstImage.getSequence() == null) {
     
    157156      MapillarySequence seq = new MapillarySequence();
    158157      seq.add(secondImage);
    159       img2.setSequence(seq);
     158      mapillaryAbstractImage2.setSequence(seq);
    160159    }
    161160
     
    171170   * Separates two images belonging to the same sequence.
    172171   *
    173    * @param img1
    174    * @param img2
    175    */
    176   public synchronized static void unjoin(MapillaryImportedImage img1,
    177       MapillaryImportedImage img2) {
    178     MapillaryImportedImage firstImage = img1;
    179     MapillaryImportedImage secondImage = img2;
    180 
    181     if (img1.next() != img2) {
    182       firstImage = img2;
    183       secondImage = img1;
     172   * @param mapillaryAbstractImage
     173   * @param mapillaryAbstractImage2
     174   */
     175  public synchronized static void unjoin(MapillaryAbstractImage mapillaryAbstractImage,
     176      MapillaryAbstractImage mapillaryAbstractImage2) {
     177    MapillaryAbstractImage firstImage = mapillaryAbstractImage;
     178    MapillaryAbstractImage secondImage = mapillaryAbstractImage2;
     179
     180    if (mapillaryAbstractImage.next() != mapillaryAbstractImage2) {
     181      firstImage = mapillaryAbstractImage2;
     182      secondImage = mapillaryAbstractImage;
    184183    }
    185184
Note: See TracChangeset for help on using the changeset viewer.