#region License Information /* HeuristicLab * Copyright (C) 2002-2013 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 HeuristicLab.DataImporter.Data.CommandBase; using HeuristicLab.DataImporter.Data.Model; using HEAL.Attic; namespace HeuristicLab.DataImporter.Data.Command { [StorableType("B43F2226-4344-4767-8F11-B3B1BB8C4D39")] public class DeleteRowsCommand : ColumnGroupCommandBase { [Storable] private List rowIndexes; private List oldrows; [StorableConstructor] protected DeleteRowsCommand(StorableConstructorFlag _) : base(_) { } 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"; } } } }