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()));
   }
 }
  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));
      }
    }
  }