private void writeModifiedFeaturesAndStartEditing(
     final IProgressMonitor monitor,
     final SelectionParameter parameters,
     final UndoableComposite commands) {
   EditToolHandler handler = parameters.handler;
   EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
   if (hasDirtyGeom(handler)) {
     commands.addCommand(handler.getCommand(handler.getAcceptBehaviours()));
     commands.addCommand(new DeselectEditGeomCommand(handler, editBlackboard.getGeoms()));
   }
 }
  private void runSelectionStrategies(
      IProgressMonitor monitor, FeatureIterator<SimpleFeature> reader) {
    List<SelectionStrategy> strategies = parameters.selectionStrategies;
    UndoableComposite compositeCommand = new UndoableComposite();
    compositeCommand.setName(Messages.SelectGeometryCommand_name);

    SimpleFeature firstFeature = reader.next();
    for (SelectionStrategy selectionStrategy : strategies) {
      selectionStrategy.run(monitor, compositeCommand, parameters, firstFeature, true);
    }

    while (reader.hasNext()) {
      SimpleFeature nextFeature = reader.next();
      for (SelectionStrategy selectionStrategy : strategies) {
        selectionStrategy.run(monitor, compositeCommand, parameters, nextFeature, false);
      }
    }

    this.command = compositeCommand;
  }
  public void run(
      IProgressMonitor monitor, SelectionParameter parameters, UndoableComposite commands) {
    EditToolHandler handler = parameters.handler;
    EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());

    if (!parameters.event.isModifierDown(MapMouseEvent.MOD1_DOWN_MASK)
        && !parameters.event.isShiftDown()
        && parameters.permitClear) {
      writeModifiedFeaturesAndStartEditing(monitor, parameters, commands);

      commands.addCommand(handler.getContext().getEditFactory().createNullEditFeatureCommand());
      commands.addCommand(new ClearEditBlackboardCommand(handler, editBlackboard));
      commands.addCommand(new SetEditStateCommand(handler, EditState.NONE));
    }

    if (typeToCreate != null) {
      if (typeToCreate == ShapeType.POINT) {
        commands.addCommand(
            new StartEditingCommand(
                handler, parameters.event, typeToCreate, handler.getCurrentState()));
        commands.addCommand(handler.getCommand(handler.getAcceptBehaviours()));
      } else {
        commands.addCommand(
            new StartEditingCommand(handler, parameters.event, typeToCreate, EditState.CREATING));
      }
    }
  }