    001// License: GPL. For details, see LICENSE file.
    002package org.openstreetmap.josm.plugins.streetside.history.commands;
    003
    004import static org.openstreetmap.josm.tools.I18n.trn;
    005
    006import java.util.Set;
    007
    008import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
    009import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    010
    011
    012/**
    013 * Imports a set of images stored locally.
    014 *
    015 * @author nokutu
    016 *
    017 */
    018public class CommandImport extends StreetsideExecutableCommand {
    019
    020  /**
    021   * Main constructor.
    022   *
    023   * @param images
    024   *          The set of images that are going to be added. Might be in the same
    025   *          sequence or not.
    026   */
    027  public CommandImport(Set<StreetsideAbstractImage> images) {
    028    super(images);
    029  }
    030
    031  @Override
    032  public void execute() {
    033    StreetsideLayer.getInstance().getData().addAll(this.images);
    034  }
    035
    036  @Override
    037  public void undo() {
    038    for (StreetsideAbstractImage img : this.images) {
    039      StreetsideLayer.getInstance().getData().getImages().remove(img);
    040    }
    041    StreetsideLayer.invalidateInstance();
    042  }
    043
    044  @Override
    045  public void redo() {
    046    this.execute();
    047  }
    048
    049  @Override
    050  public void sum(StreetsideCommand command) {
    051  }
    052
    053  @Override
    054  public String toString() {
    055    // TODO: trn( RRH
    056    return trn("Imported {0} image", "Imported {0} images", this.images.size(),
    057        this.images.size());
    058  }
    059}