Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12983


Ignore:
Timestamp:
10/06/15 16:41:59 (9 years ago)
Author:
pfleck
Message:

#2486
Allows pasting of multiple values that extend the current data limits (rows and/or columns).
In case, additional rows and columns are added with the default value of the column's type.

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r12676 r12983  
    383383      ClearSorting();
    384384    }
    385     private string[,] SplitClipboardString(string clipboardText) {
     385    protected string[,] SplitClipboardString(string clipboardText) {
    386386      if (clipboardText.EndsWith(Environment.NewLine))
    387387        clipboardText = clipboardText.Remove(clipboardText.Length - Environment.NewLine.Length);  //remove last newline constant
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs

    r12676 r12983  
    142142
    143143
    144     //protected override void PasteValuesToDataGridView() {
    145     //  base.PasteValuesToDataGridView();
    146     //  dataGridView.Refresh();
    147     //}
     144    protected override void PasteValuesToDataGridView() {
     145      string[,] values = SplitClipboardString(Clipboard.GetText());
     146      int rowIndex = 0;
     147      int columnIndex = 0;
     148      if (dataGridView.CurrentCell != null) {
     149        rowIndex = dataGridView.CurrentCell.RowIndex;
     150        columnIndex = dataGridView.CurrentCell.ColumnIndex;
     151      }
     152      if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex;
     153      if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex;
     154
     155      ReplaceTransaction(() => {
     156        Content.PreProcessingData.InTransaction(() => {
     157          for (int row = 0; row < values.GetLength(1); row++) {
     158            for (int col = 0; col < values.GetLength(0); col++) {
     159              Content.SetValue(values[col, row], row + rowIndex, col + columnIndex);
     160            }
     161          }
     162        });
     163      });
     164
     165      ClearSorting();
     166      //UpdateData(); // rownames are created on DataGrid creation. Therefore, no update possible, yet.
     167    }
    148168
    149169    protected override void SetEnabledStateOfControls() {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridContent.cs

    r12676 r12983  
    7575      }
    7676      set {
    77         //not supported
     77        throw new NotSupportedException();
    7878      }
    7979    }
     
    8484      }
    8585      set {
    86         //not supported
     86        throw new NotSupportedException();
    8787      }
    8888    }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/TransactionalPreprocessingData.cs

    r12012 r12983  
    9898    public override void SetCell<T>(int columnIndex, int rowIndex, T value) {
    9999      SaveSnapshot(DataPreprocessingChangedEventType.ChangeItem, columnIndex, rowIndex);
     100
     101      for (int i = Rows; i <= rowIndex; i++)
     102        InsertRow(i);
     103      for (int i = Columns; i <= columnIndex; i++)
     104        InsertColumn<T>(i.ToString(), i);
     105
    100106      variableValues[columnIndex][rowIndex] = value;
    101107      if (!IsInTransaction)
     
    116122
    117123    public override bool VariableHasType<T>(int columnIndex) {
    118       return variableValues[columnIndex] is List<T>;
     124      return columnIndex >= variableValues.Count || variableValues[columnIndex] is List<T>;
    119125    }
    120126
     
    242248    public override void InsertColumn<T>(string variableName, int columnIndex) {
    243249      SaveSnapshot(DataPreprocessingChangedEventType.DeleteColumn, columnIndex, -1);
    244       variableValues.Insert(columnIndex, new List<T>(Rows));
     250      variableValues.Insert(columnIndex, new List<T>(Enumerable.Repeat(default(T), Rows)));
    245251      variableNames.Insert(columnIndex, variableName);
    246252      if (!IsInTransaction)
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r12676 r12983  
    6363      var inputVariables = oldProblemData.InputVariables.ToDictionary(x => x.Value, x => x);
    6464      foreach (var variable in problemData.InputVariables) {
    65         bool isChecked = oldProblemData.InputVariables.ItemChecked(inputVariables[variable.Value]);
     65        bool isChecked = oldProblemData.InputVariables.Contains(variable) && oldProblemData.InputVariables.ItemChecked(inputVariables[variable.Value]);
    6666        problemData.InputVariables.SetItemCheckedState(variable, isChecked);
    6767      }
Note: See TracChangeset for help on using the changeset viewer.