#region License Information /* HeuristicLab * Copyright (C) 2002-2011 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 System.Text; using System.Xml; using HeuristicLab.DataImporter.Data.CommandBase; using HeuristicLab.DataImporter.Data.Model; using HeuristicLab.DataImporter.Data; using HeuristicLab.DataImporter.Command.View; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.DataImporter.Command { [StorableClass] [ViewableCommandInfoAttribute("New ProgrammableColumn", 1, ColumnGroupState.Active, "Column Commands", Position = 10, OptionsView = typeof(ProgrammableColumnCommandView))] public class AddNewProgrammableColumnCommand : AddNewColumnCommandBase { private AddNewProgrammableColumnCommand() : base(null, string.Empty, string.Empty, typeof(ProgrammableColumn)) { } public AddNewProgrammableColumnCommand(DataSet dataSet, string columnGroupName) : this(dataSet, columnGroupName, "New ProgrammableColumn") { } public AddNewProgrammableColumnCommand(DataSet dataSet, string columnGroupName, string columnName) : base(dataSet, columnGroupName, columnName, typeof(ProgrammableColumn)) { } public override string Description { get { return "New programmable column"; } } [Storable] private string expression; public string Expression { get { return expression; } set { expression = value; } } public override void Execute() { this.UpdateColumnGroup(); NewColumn = new ProgrammableColumn(ColumnName, ColumnGroup); NewColumn.Resize(ColumnGroup.RowCount); try { ((ProgrammableColumn)NewColumn).Expression = expression; } catch (ParseException ex) { throw new CommandExecutionException("Error occured during parsing of expression.", ex, this); } ColumnGroup.AddColumn(NewColumn); ColumnGroup.FireChanged(); ColumnGroup = null; } } }