1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Xml;
|
---|
6 | using HeuristicLab.DataImporter.Data;
|
---|
7 | using HeuristicLab.DataImporter.Data.CommandBase;
|
---|
8 | using HeuristicLab.DataImporter.Data.Model;
|
---|
9 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
10 |
|
---|
11 |
|
---|
12 | namespace HeuristicLab.DataImporter.Command {
|
---|
13 | [StorableClass]
|
---|
14 | [ViewableCommandInfoAttribute("New ColumnGroup", 0, ColumnGroupState.None, "ColumnGroup Commands", Position = 0)]
|
---|
15 | public class AddNewColumnGroupCommand : DataSetCommandBase {
|
---|
16 | [Storable]
|
---|
17 | private string newColumnGroupName;
|
---|
18 |
|
---|
19 | private ColumnGroup newColumnGroup;
|
---|
20 |
|
---|
21 | private AddNewColumnGroupCommand()
|
---|
22 | : base(null) {
|
---|
23 | }
|
---|
24 |
|
---|
25 | public AddNewColumnGroupCommand(DataSet dataSet)
|
---|
26 | : base(dataSet) {
|
---|
27 | int i = 0;
|
---|
28 | string columnGroupName = "New ColumnGroup " + i;
|
---|
29 | while (dataSet.ColumnGroups.Any(cg => cg.Name == columnGroupName)) {
|
---|
30 | i++;
|
---|
31 | columnGroupName = "New ColumnGroup " + i;
|
---|
32 | }
|
---|
33 | this.newColumnGroupName = columnGroupName;
|
---|
34 | }
|
---|
35 |
|
---|
36 | private AddNewColumnGroupCommand(DataSet dataSet, string name)
|
---|
37 | : base(dataSet) {
|
---|
38 | this.newColumnGroupName = name;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public override string Description {
|
---|
42 | get { return "New column group"; }
|
---|
43 | }
|
---|
44 |
|
---|
45 | public override void Execute() {
|
---|
46 | base.Execute();
|
---|
47 | this.newColumnGroup = new ColumnGroup(newColumnGroupName);
|
---|
48 | this.DataSet.AddColumnGroup(newColumnGroup);
|
---|
49 | this.newColumnGroup.Active = true;
|
---|
50 | this.DataSet.FireChanged();
|
---|
51 | }
|
---|
52 |
|
---|
53 | public override void UndoExecute() {
|
---|
54 | base.UndoExecute();
|
---|
55 | this.DataSet.RemoveColumnGroup(newColumnGroup);
|
---|
56 | this.newColumnGroup = null;
|
---|
57 | this.DataSet.FireChanged();
|
---|
58 | }
|
---|
59 | }
|
---|
60 | } |
---|