public void run(IProgressMonitor monitor) throws Exception {
    if (command != null) {
      // indicates a redo
      command.run(monitor);
    } else {
      IToolContext context = handler.getContext();
      ILayer editLayer = handler.getEditLayer();

      EditBlackboard editBlackboard = handler.getEditBlackboard(editLayer);
      editBlackboard.startBatchingEvents();
      BlockingSelectionAnim animation = new BlockingSelectionAnim(event.x, event.y);
      AnimationUpdater.runTimer(context.getMapDisplay(), animation);
      FeatureIterator<SimpleFeature> iter = getFeatureIterator();
      try {

        if (iter.hasNext()) {
          runSelectionStrategies(monitor, iter);
        } else {
          runDeselectionStrategies(monitor);
        }

        setAndRun(monitor, command);
      } finally {
        try {
          if (iter != null) {
            iter.close();
          }
        } finally {
          if (animation != null) {
            animation.setValid(false);
            animation = null;
          }
        }
        editBlackboard.fireBatchedEvents();
      }
    }
  }
  public void run(IProgressMonitor monitor) throws Exception {
    monitor.beginTask(Messages.AddFeaturesCommand_taskMessage, 10);
    monitor.worked(1);

    FeatureStore<SimpleFeatureType, SimpleFeature> store =
        layer.getResource(FeatureStore.class, new SubProgressMonitor(monitor, 2));
    String geomAttributeName = layer.getSchema().getGeometryDescriptor().getLocalName();
    String[] desiredProperties = new String[] {geomAttributeName};
    Query query = new DefaultQuery(layer.getSchema().getTypeName(), filter, desiredProperties);
    FeatureCollection<SimpleFeatureType, SimpleFeature> features = store.getFeatures(query);

    FeatureIterator<SimpleFeature> iter = features.features();
    try {
      commands = new ArrayList<UndoableMapCommand>();
      while (iter.hasNext()) {
        SimpleFeature feature = iter.next();
        commands.add(new SelectFeatureCommand(bb, feature));
      }

      float index = 0;
      float inc = (float) 7 / commands.size();
      for (UndoableMapCommand command : commands) {
        command.setMap(getMap());
        index += inc;
        SubProgressMonitor subProgressMonitor = new SubProgressMonitor(monitor, (int) index);
        command.run(subProgressMonitor);
        subProgressMonitor.done();
        if (index > 1) {
          index = 0;
        }
      }
    } finally {
      features.close(iter);
    }

    monitor.done();
  }
 private void setAndRun(IProgressMonitor monitor, UndoableMapCommand undoableComposite)
     throws Exception {
   undoableComposite.setMap(getMap());
   undoableComposite.run(monitor);
 }