Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Data/Command/InsertRowCommand.cs @ 6133

Last change on this file since 6133 was 6133, checked in by gkronber, 14 years ago

#1471: imported generic parts of DataImporter from private code base

File size: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Xml;
6using System.Windows.Forms;
7using HeuristicLab.DataImporter.Data.CommandBase;
8using HeuristicLab.DataImporter.Data.Model;
9using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
10
11namespace HeuristicLab.DataImporter.Data.Command {
12  [StorableClass]
13  public class InsertRowCommand : ColumnGroupCommandBase {
14    [Storable]
15    private int position;
16
17    private ICollection<int> oldSortedColumnIndices;
18    private IEnumerable<SortOrder> oldSortOrder;
19
20    private InsertRowCommand()
21      : base(null, string.Empty) {
22    }
23
24    public InsertRowCommand(DataSet dataSet, string columnGroupName, int position)
25      : base(dataSet, columnGroupName) {
26      this.position = position;
27    }
28
29    public override void Execute() {
30      base.Execute();
31      ColumnGroup.InsertRow(position, ColumnGroup.GetEmptyRow());
32      oldSortedColumnIndices = new List<int>(ColumnGroup.SortedColumnIndexes);
33      oldSortOrder = ColumnGroup.SortOrdersForColumns.ToList();
34      ColumnGroup.FireChanged();
35      this.ColumnGroup = null;
36    }
37
38    public override void UndoExecute() {
39      base.UndoExecute();
40      ColumnGroup.DeleteRow(position);
41      ColumnGroup.SortOrdersForColumns = oldSortOrder;
42      ColumnGroup.SortedColumnIndexes = oldSortedColumnIndices;
43      oldSortedColumnIndices = null;
44      oldSortOrder = null;
45      ColumnGroup.FireChanged();
46      this.ColumnGroup = null;
47    }
48
49    public override string Description {
50      get { return "Empty row inserted"; }
51    }
52  }
53}
Note: See TracBrowser for help on using the repository browser.