1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Xml;
|
---|
6 | using System.Windows.Forms;
|
---|
7 | using HeuristicLab.DataImporter.Data.CommandBase;
|
---|
8 | using HeuristicLab.DataImporter.Data.Model;
|
---|
9 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
10 |
|
---|
11 | namespace 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 | }
|
---|