001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.plugins.streetside.history.commands;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import java.util.List;
007import java.util.concurrent.ConcurrentSkipListSet;
008
009import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
010import org.openstreetmap.josm.plugins.streetside.utils.StreetsideUtils;
011
012/**
013 * Command joined when joining two images into the same sequence.
014 *
015 * @author nokutu
016 *
017 */
018public class CommandUnjoin extends StreetsideExecutableCommand {
019
020  private final StreetsideAbstractImage a;
021  private final StreetsideAbstractImage b;
022
023  /**
024   * Main constructor.
025   *
026   * @param images
027   *          The two images that are going to be unjoined. Must be of exactly
028   *          size 2.
029   * @throws IllegalArgumentException
030   *           if the List size is different from 2.
031   */
032  public CommandUnjoin(List<StreetsideAbstractImage> images) {
033    super(new ConcurrentSkipListSet<>(images));
034    a = images.get(0);
035    b = images.get(1);
036    if (images.size() != 2)
037      throw new IllegalArgumentException();
038  }
039
040  @Override
041  public void execute() {
042    this.redo();
043  }
044
045  @Override
046  public void undo() {
047    StreetsideUtils.join(a, b);
048  }
049
050  @Override
051  public void redo() {
052    StreetsideUtils.unjoin(a, b);
053  }
054
055  @Override
056  public void sum(StreetsideCommand command) {
057  }
058
059  @Override
060  public String toString() {
061    // TODO: tr( RRH
062    return tr("2 images unjoined");
063  }
064}