Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9697


Ignore:
Timestamp:
07/05/13 10:50:47 (11 years ago)
Author:
mkommend
Message:

#2081: Updated branches from trunk and implemented all review comments.

Location:
branches/HeuristicLab.Data Path DataTypes
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj

    r9689 r9697  
    242242  </ItemGroup>
    243243  <ItemGroup>
    244     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    245       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    246       <Name>HeuristicLab.Data-3.3</Name>
    247       <Private>False</Private>
    248     </ProjectReference>
    249   </ItemGroup>
    250   <ItemGroup>
    251244    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
    252245      <Visible>False</Visible>
     
    264257      <Install>true</Install>
    265258    </BootstrapperPackage>
     259  </ItemGroup>
     260  <ItemGroup>
     261    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     262      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     263      <Name>HeuristicLab.Data-3.3</Name>
     264    </ProjectReference>
    266265  </ItemGroup>
    267266  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/Path Views/DirectoryValueView.cs

    r9680 r9697  
    4747    protected override void SetEnabledStateOfControls() {
    4848      base.SetEnabledStateOfControls();
    49       valueTextBox.ReadOnly = Locked || ReadOnly || Content == null || Content.CheckExistence;
     49      valueTextBox.Enabled = !Locked && !ReadOnly && Content != null;
     50      valueTextBox.ReadOnly = Locked || ReadOnly || Content == null;
    5051      openButton.Enabled = !Locked && !ReadOnly && Content != null;
    5152    }
     
    6465    protected virtual void openButton_Click(object sender, EventArgs e) {
    6566      if (folderBrowserDialog.ShowDialog(this) != DialogResult.OK) return;
    66 
    67       valueTextBox.Text = folderBrowserDialog.SelectedPath;
    68       valueTextBox.Focus();
    69       Validate();
     67      Content.Value = folderBrowserDialog.SelectedPath;
    7068    }
    7169  }
  • branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.cs

    r9680 r9697  
    2222using System;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Data.Views;
    2524using HeuristicLab.MainForm;
    2625
     
    5655    protected override void SetEnabledStateOfControls() {
    5756      base.SetEnabledStateOfControls();
    58       valueTextBox.Enabled = !Locked && !ReadOnly && Content != null && !Content.CheckExistence;
    59       valueTextBox.ReadOnly = Locked || ReadOnly || Content == null || Content.CheckExistence;
     57      valueTextBox.Enabled = !Locked && !ReadOnly && Content != null;
     58      valueTextBox.ReadOnly = Locked || ReadOnly || Content == null;
    6059      openButton.Enabled = !Locked && !ReadOnly && Content != null;
    6160    }
  • branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/Path Views/TextFileView.cs

    r9680 r9697  
    6868      saveButton.Enabled = !Locked && !ReadOnly && Content != null && ChangedFileContent;
    6969
    70       if (Content != null && File.Exists(Content.Value)) {
     70      if (Content != null && Content.Exists()) {
    7171        fileSystemWatcher.Filter = Path.GetFileName(Content.Value);
    7272        fileSystemWatcher.Path = Path.GetDirectoryName(Content.Value);
     
    7777    protected override void OnVisibleChanged(EventArgs e) {
    7878      //mkommend: necessary to update the textbox to detect intermediate file changes.
    79       if (Visible) UpdateTextBox();
     79      if (Visible && Content != null) UpdateTextBox();
    8080      base.OnVisibleChanged(e);
    8181    }
     
    228228    public static string ReadFile(string path) {
    229229      if (!File.Exists(path)) return null;
    230       //TODO handle IO Exceptions
    231230      string fileContent;
    232231      using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
     
    239238
    240239    public static void WriteFile(string path, string fileContent) {
    241       //TODO handle IO Exceptions
    242240      using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write)) {
    243241        using (StreamWriter streamWriter = new StreamWriter(fileStream)) {
  • branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs

    r9657 r9697  
    2323using System.ComponentModel;
    2424using System.Drawing;
    25 using System.Linq;
    2625using System.Text;
    2726using System.Windows.Forms;
     
    105104
    106105    protected virtual void UpdateRowHeaders() {
    107       for (int i = 0; i < dataGridView.RowCount; i++) {
    108         if (i < Content.ElementNames.Count())
    109           dataGridView.Rows[i].HeaderCell.Value = Content.ElementNames.ElementAt(i);
    110         else
    111           dataGridView.Rows[i].HeaderCell.Value = string.Empty;
     106      int i = 0;
     107      foreach (string elementName in Content.ElementNames) {
     108        dataGridView.Rows[i].HeaderCell.Value = elementName;
     109        i++;
     110      }
     111      for (; i < dataGridView.RowCount; i++) {
     112        dataGridView.Rows[i].HeaderCell.Value = string.Empty;
    112113      }
    113114    }
     
    124125        Invoke(new EventHandler<EventArgs<int>>(Content_ItemChanged), sender, e);
    125126      else {
     127        // if a resize of the array occurs and some other class handles the event and provides default values
     128        //then the itemChanged will occur before the reset event. hence the check was added
     129        if (dataGridView.RowCount <= e.Value) return;
    126130        dataGridView.Rows[e.Value].Cells[0].Value = Content.GetValue(e.Value);
    127131        Size size = dataGridView.Rows[e.Value].Cells[0].PreferredSize;
  • branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data/3.3/Path Types/PathValue.cs

    r9680 r9697  
    2121
    2222
    23 using System;
    2423using System.IO;
    2524using HeuristicLab.Common;
     
    3130  [StorableClass]
    3231  public abstract class PathValue : StringValue {
    33     [Storable]
    34     private bool checkExistence;
    35     public bool CheckExistence {
    36       get { return checkExistence; }
    37       set {
    38         if (ReadOnly) throw new NotSupportedException("CheckExistence cannot be set. PathValue is read-only.");
    39         if (value != checkExistence) {
    40           checkExistence = value;
    41           OnCheckExistenceChanged();
    42         }
    43       }
    44     }
    45 
    4632    public override string Value {
    4733      get { return base.Value; }
    4834      set {
    4935        if (value == null) value = string.Empty;
    50         if (checkExistence && !string.IsNullOrEmpty(value) && !File.Exists(value) && !Directory.Exists(value))
    51           throw new ArgumentException(string.Format("The given file {0} does not exists.", value));
    52         if (value[value.Length - 1] == Path.DirectorySeparatorChar)
    53           value = value.TrimEnd(Path.DirectorySeparatorChar);
    54         if (value[value.Length - 1] == Path.AltDirectorySeparatorChar)
    55           value = value.TrimEnd(Path.AltDirectorySeparatorChar);
     36        value = value.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
    5637        base.Value = value;
    5738      }
     
    6041    [StorableConstructor]
    6142    protected PathValue(bool deserializing) : base(deserializing) { }
    62     protected PathValue(PathValue original, Cloner cloner)
    63       : base(original, cloner) {
    64       checkExistence = original.checkExistence;
    65     }
     43    protected PathValue(PathValue original, Cloner cloner) : base(original, cloner) { }
    6644
    6745    protected PathValue()
    68       : base(string.Empty) {
    69       checkExistence = true;
    70     }
     46      : base(string.Empty) { }
    7147
    7248    public abstract bool Exists();
    73 
    74     protected override bool Validate(string value, out string errorMessage) {
    75       if (CheckExistence && !File.Exists(value) && !Directory.Exists(value)) {
    76         errorMessage = string.Format("The given path {0} does not exist.", value);
    77         return false;
    78       }
    79       return base.Validate(value, out errorMessage);
    80     }
    81 
    82     public event EventHandler CheckExistenceChanged;
    83     protected virtual void OnCheckExistenceChanged() {
    84       var handler = CheckExistenceChanged;
    85       if (handler != null)
    86         handler(this, EventArgs.Empty);
    87     }
    8849  }
    8950}
Note: See TracChangeset for help on using the changeset viewer.