#region License Information
/* HeuristicLab
* Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using HeuristicLab.DataImporter.Data.CommandBase;
using HeuristicLab.DataImporter.Data.Model;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.DataImporter.Data.Command {
[StorableClass]
public class DeleteRowsCommand : ColumnGroupCommandBase {
[Storable]
private List rowIndexes;
private List oldrows;
private DeleteRowsCommand()
: base(null, string.Empty) {
this.oldrows = new List();
}
public DeleteRowsCommand(DataSet dataSet, string columnGroupName, IEnumerable rowIndexes)
: base(dataSet, columnGroupName) {
this.rowIndexes = new List(rowIndexes);
this.oldrows = new List();
}
public override void Execute() {
base.Execute();
foreach (int pos in this.rowIndexes.Reverse()) {
oldrows.Insert(0, ColumnGroup.GetRow(pos));
ColumnGroup.DeleteRow(pos);
}
ColumnGroup.FireChanged();
this.ColumnGroup = null;
}
public override void UndoExecute() {
base.UndoExecute();
for (int i = 0; i < rowIndexes.Count; i++)
ColumnGroup.InsertRow(this.rowIndexes[i], this.oldrows[i]);
oldrows.Clear();
ColumnGroup.FireChanged();
this.ColumnGroup = null;
}
public override string Description {
get { return "Delete Rows"; }
}
}
}