Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Data/Command/RenameColumnGroupCommand.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.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Xml;
6using HeuristicLab.DataImporter.Data.Model;
7using HeuristicLab.DataImporter.Data.CommandBase;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9
10namespace HeuristicLab.DataImporter.Data.Command {
11  [StorableClass]
12  public class RenameColumnGroupCommand : ColumnGroupCommandBase {
13    [Storable]
14    private string newName;
15
16    private string oldName;
17
18    private RenameColumnGroupCommand()
19      : base(null, string.Empty) {
20    }
21
22    public RenameColumnGroupCommand(DataSet dataSet, string columnGroupName, string newName)
23      : base(dataSet, columnGroupName) {
24      this.newName = newName;
25    }
26
27    public override string Description {
28      get { return "Rename ColumnGroup"; }
29    }
30
31    public override void Execute() {
32      base.Execute();
33      oldName = ColumnGroup.Name;
34      ColumnGroup.Name = newName;
35      ColumnGroup.FireChanged();
36      this.ColumnGroup = null;
37    }
38
39    public override void UndoExecute() {
40      base.UndoExecute();
41      ColumnGroup ColumnGroup = this.DataSet.ColumnGroups.Where(cg => cg.Name == newName).First();
42      ColumnGroup.Name = oldName;
43      oldName = null;
44      ColumnGroup.FireChanged();
45      this.ColumnGroup = null;
46    }
47  }
48}
Note: See TracBrowser for help on using the repository browser.