Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/13/13 13:49:03 (11 years ago)
Author:
mkommend
Message:

#2081: Merged path data types into stable.

Location:
stable
Files:
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Data.Views/3.3

    • Property svn:mergeinfo set to (toggle deleted branches)
      /trunk/sources/HeuristicLab.Data.Views/3.3mergedeligible
      /branches/Algorithms.GradientDescent/HeuristicLab.Data.Views/3.35516-5520
      /branches/Benchmarking/sources/HeuristicLab.Data.Views/3.36917-7005
      /branches/CloningRefactoring/HeuristicLab.Data.Views/3.34656-4721
      /branches/DataAnalysis Refactoring/HeuristicLab.Data.Views/3.35471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Data.Views/3.35815-6180
      /branches/DataAnalysis/HeuristicLab.Data.Views/3.34458-4459,​4462,​4464
      /branches/GP.Grammar.Editor/HeuristicLab.Data.Views/3.36284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Data.Views/3.35060
      /branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.39669-9706
      /branches/NET40/sources/HeuristicLab.Data.Views/3.35138-5162
      /branches/ParallelEngine/HeuristicLab.Data.Views/3.35175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Data.Views/3.37568-7810
      /branches/QAPAlgorithms/HeuristicLab.Data.Views/3.36350-6627
      /branches/Restructure trunk solution/HeuristicLab.Data.Views/3.36828
      /branches/RuntimeOptimizer/HeuristicLab.Data.Views/3.38943-9078
      /branches/ScatterSearch (trunk integration)/HeuristicLab.Data.Views/3.37787-8333
      /branches/SlaveShutdown/HeuristicLab.Data.Views/3.38944-8956
      /branches/SuccessProgressAnalysis/HeuristicLab.Data.Views/3.35370-5682
      /branches/Trunk/HeuristicLab.Data.Views/3.36829-6865
      /branches/UnloadJobs/HeuristicLab.Data.Views/3.39168-9215
      /branches/VNS/HeuristicLab.Data.Views/3.35594-5752
      /branches/histogram/HeuristicLab.Data.Views/3.35959-6341
  • stable/HeuristicLab.Data.Views/3.3/Path Views/DirectoryValueView.Designer.cs

    r9680 r9961  
    4848      this.openButton = new System.Windows.Forms.Button();
    4949      this.folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
    50       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    51       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    52       this.splitContainer.Panel1.SuspendLayout();
    53       this.splitContainer.Panel2.SuspendLayout();
    54       this.splitContainer.SuspendLayout();
     50      this.stringConvertibleValueView = new HeuristicLab.Data.Views.StringConvertibleValueView();
    5551      this.SuspendLayout();
    56       //
    57       // valueTextBox
    58       //
    59       this.errorProvider.SetIconAlignment(this.valueTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    60       this.errorProvider.SetIconPadding(this.valueTextBox, 2);
    61       this.valueTextBox.Location = new System.Drawing.Point(17, 2);
    62       this.valueTextBox.Size = new System.Drawing.Size(87, 20);
    63       //
    64       // valueLabel
    65       //
    66       this.valueLabel.Location = new System.Drawing.Point(3, 5);
    67       this.valueLabel.Size = new System.Drawing.Size(52, 13);
    68       this.valueLabel.Text = "Directory:";
    69       //
    70       // splitContainer
    71       //
    72       //
    73       // splitContainer.Panel2
    74       //
    75       this.splitContainer.Panel2.Controls.Add(this.openButton);
    76       this.splitContainer.Size = new System.Drawing.Size(194, 24);
    77       this.splitContainer.SplitterDistance = 56;
    7852      //
    7953      // openButton
     
    8155      this.openButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    8256      this.openButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
    83       this.openButton.Location = new System.Drawing.Point(110, 0);
     57      this.openButton.Location = new System.Drawing.Point(167, 0);
    8458      this.openButton.Name = "openButton";
    8559      this.openButton.Size = new System.Drawing.Size(24, 24);
     
    8862      this.openButton.Click += new System.EventHandler(this.openButton_Click);
    8963      //
     64      // stringConvertibleValueView
     65      //
     66      this.stringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     67            | System.Windows.Forms.AnchorStyles.Right)));
     68      this.stringConvertibleValueView.Caption = "StringConvertibleValue View";
     69      this.stringConvertibleValueView.Content = null;
     70      this.stringConvertibleValueView.LabelVisible = true;
     71      this.stringConvertibleValueView.Location = new System.Drawing.Point(4, 2);
     72      this.stringConvertibleValueView.Name = "stringConvertibleValueView";
     73      this.stringConvertibleValueView.ReadOnly = false;
     74      this.stringConvertibleValueView.Size = new System.Drawing.Size(157, 21);
     75      this.stringConvertibleValueView.TabIndex = 4;
     76      //
    9077      // DirectoryValueView
    9178      //
    9279      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    93       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     80      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     81      this.Controls.Add(this.stringConvertibleValueView);
     82      this.Controls.Add(this.openButton);
    9483      this.Name = "DirectoryValueView";
    9584      this.Size = new System.Drawing.Size(194, 24);
    96       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    97       this.splitContainer.Panel1.ResumeLayout(false);
    98       this.splitContainer.Panel1.PerformLayout();
    99       this.splitContainer.Panel2.ResumeLayout(false);
    100       this.splitContainer.Panel2.PerformLayout();
    101       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    102       this.splitContainer.ResumeLayout(false);
    10385      this.ResumeLayout(false);
    10486
     
    10991    protected System.Windows.Forms.Button openButton;
    11092    protected System.Windows.Forms.FolderBrowserDialog folderBrowserDialog;
     93    private StringConvertibleValueView stringConvertibleValueView;
    11194
    11295  }
  • stable/HeuristicLab.Data.Views/3.3/Path Views/DirectoryValueView.cs

    r9697 r9961  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.Core.Views;
    2425using HeuristicLab.MainForm;
    2526
     
    2728  [View("DirectoryValueView")]
    2829  [Content(typeof(DirectoryValue), true)]
    29   public partial class DirectoryValueView : StringConvertibleValueView {
     30  public partial class DirectoryValueView : ItemView {
    3031    public new DirectoryValue Content {
    3132      get { return (DirectoryValue)base.Content; }
    3233      set { base.Content = value; }
    33     }
    34 
    35     public override bool ReadOnly {
    36       get {
    37         if ((Content != null) && Content.ReadOnly) return true;
    38         return base.ReadOnly;
    39       }
    40       set { base.ReadOnly = value; }
    4134    }
    4235
     
    4740    protected override void SetEnabledStateOfControls() {
    4841      base.SetEnabledStateOfControls();
    49       valueTextBox.Enabled = !Locked && !ReadOnly && Content != null;
    50       valueTextBox.ReadOnly = Locked || ReadOnly || Content == null;
    5142      openButton.Enabled = !Locked && !ReadOnly && Content != null;
    5243    }
     
    5546      base.OnContentChanged();
    5647      if (Content == null) {
    57         valueTextBox.Text = string.Empty;
     48        stringConvertibleValueView.Content = null;
    5849        return;
    5950      }
    6051
    61       valueTextBox.Text = Content.Value;
    62       openButton.Enabled = !Content.ReadOnly;
     52      stringConvertibleValueView.Content = Content.StringValue;
    6353    }
    6454
  • stable/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.Designer.cs

    r9680 r9961  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FileValueView));
    4847      this.openButton = new System.Windows.Forms.Button();
    4948      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    50       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    51       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    52       this.splitContainer.Panel1.SuspendLayout();
    53       this.splitContainer.Panel2.SuspendLayout();
    54       this.splitContainer.SuspendLayout();
     49      this.stringConvertibleValueView = new HeuristicLab.Data.Views.StringConvertibleValueView();
    5550      this.SuspendLayout();
    56       //
    57       // valueTextBox
    58       //
    59       this.errorProvider.SetIconAlignment(this.valueTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    60       this.errorProvider.SetIconPadding(this.valueTextBox, 2);
    61       this.valueTextBox.Location = new System.Drawing.Point(17, 2);
    62       this.valueTextBox.Size = new System.Drawing.Size(116, 20);
    63       //
    64       // valueLabel
    65       //
    66       this.valueLabel.Location = new System.Drawing.Point(3, 5);
    67       this.valueLabel.Size = new System.Drawing.Size(26, 13);
    68       this.valueLabel.Text = "File:";
    69       //
    70       // splitContainer
    71       //
    72       //
    73       // splitContainer.Panel2
    74       //
    75       this.splitContainer.Panel2.Controls.Add(this.openButton);
    76       this.splitContainer.Size = new System.Drawing.Size(194, 24);
    77       this.splitContainer.SplitterDistance = 27;
    7851      //
    7952      // openButton
     
    8154      this.openButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    8255      this.openButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
    83       this.openButton.Location = new System.Drawing.Point(139, 0);
     56      this.openButton.Location = new System.Drawing.Point(167, 0);
    8457      this.openButton.Name = "openButton";
    8558      this.openButton.Size = new System.Drawing.Size(24, 24);
     
    8861      this.openButton.Click += new System.EventHandler(this.openButton_Click);
    8962      //
     63      // stringConvertibleValueView
     64      //
     65      this.stringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     66            | System.Windows.Forms.AnchorStyles.Right)));
     67      this.stringConvertibleValueView.Caption = "StringConvertibleValue View";
     68      this.stringConvertibleValueView.Content = null;
     69      this.stringConvertibleValueView.LabelVisible = true;
     70      this.stringConvertibleValueView.Location = new System.Drawing.Point(4, 2);
     71      this.stringConvertibleValueView.Name = "stringConvertibleValueView";
     72      this.stringConvertibleValueView.ReadOnly = false;
     73      this.stringConvertibleValueView.Size = new System.Drawing.Size(157, 21);
     74      this.stringConvertibleValueView.TabIndex = 0;
     75      //
    9076      // FileValueView
    9177      //
    92       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    93       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     78      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     79      this.Controls.Add(this.stringConvertibleValueView);
     80      this.Controls.Add(this.openButton);
    9481      this.Name = "FileValueView";
    9582      this.Size = new System.Drawing.Size(194, 24);
    96       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    97       this.splitContainer.Panel1.ResumeLayout(false);
    98       this.splitContainer.Panel1.PerformLayout();
    99       this.splitContainer.Panel2.ResumeLayout(false);
    100       this.splitContainer.Panel2.PerformLayout();
    101       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    102       this.splitContainer.ResumeLayout(false);
    10383      this.ResumeLayout(false);
    10484
     
    10989    protected System.Windows.Forms.Button openButton;
    11090    protected System.Windows.Forms.OpenFileDialog openFileDialog;
     91    protected StringConvertibleValueView stringConvertibleValueView;
    11192  }
    11293}
  • stable/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.cs

    r9697 r9961  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.Core.Views;
    2425using HeuristicLab.MainForm;
    2526
     
    2728  [View("FileValueView")]
    2829  [Content(typeof(FileValue), true)]
    29   public partial class FileValueView : StringConvertibleValueView {
     30  public partial class FileValueView : ItemView {
    3031    public new FileValue Content {
    3132      get { return (FileValue)base.Content; }
    3233      set { base.Content = value; }
    33     }
    34 
    35     public override bool ReadOnly {
    36       get {
    37         if ((Content != null) && Content.ReadOnly) return true;
    38         return base.ReadOnly;
    39       }
    40       set { base.ReadOnly = value; }
    4134    }
    4235
     
    4538    }
    4639
    47     protected override void RegisterContentEvents() {
    48       base.RegisterContentEvents();
    49       Content.FileOpenDialogFilterChanged += new EventHandler(Content_FileOpenDialogFilterChanged);
    50     }
    51     protected override void DeregisterContentEvents() {
    52       Content.FileOpenDialogFilterChanged -= new EventHandler(Content_FileOpenDialogFilterChanged);
    53       base.DeregisterContentEvents();
    54     }
    5540    protected override void SetEnabledStateOfControls() {
    5641      base.SetEnabledStateOfControls();
    57       valueTextBox.Enabled = !Locked && !ReadOnly && Content != null;
    58       valueTextBox.ReadOnly = Locked || ReadOnly || Content == null;
    5942      openButton.Enabled = !Locked && !ReadOnly && Content != null;
    6043    }
     
    6346      base.OnContentChanged();
    6447      if (Content == null) {
    65         valueTextBox.Text = string.Empty;
     48        stringConvertibleValueView.Content = null;
    6649        return;
    6750      }
    6851
    69       valueTextBox.Text = Content.Value;
    70       openButton.Enabled = !Content.ReadOnly;
    71       openFileDialog.Filter = Content.FileDialogFilter;
    72     }
    73 
    74     protected virtual void Content_FileOpenDialogFilterChanged(object sender, EventArgs e) {
     52      stringConvertibleValueView.Content = Content.StringValue;
    7553      openFileDialog.Filter = Content.FileDialogFilter;
    7654    }
    7755
    7856    protected virtual void openButton_Click(object sender, EventArgs e) {
     57      openFileDialog.Filter = Content.FileDialogFilter;
    7958      if (openFileDialog.ShowDialog(this) != DialogResult.OK) return;
    8059      Content.Value = openFileDialog.FileName;
  • stable/HeuristicLab.Data.Views/3.3/Path Views/TextFileView.cs

    r9714 r9961  
    2424using System.IO;
    2525using System.Windows.Forms;
    26 using HeuristicLab.Core.Views;
    2726using HeuristicLab.MainForm;
     27using HeuristicLab.PluginInfrastructure;
    2828
    2929namespace HeuristicLab.Data.Views {
    3030  [View("TextFileView")]
    3131  [Content(typeof(TextFileValue), true)]
    32   public sealed partial class TextFileView : ItemView {
    33     private bool changedFileContent;
    34     private bool ChangedFileContent {
    35       get { return changedFileContent; }
     32  public sealed partial class TextFileView : FileValueView {
     33    private bool fileContentChanged;
     34    private bool FileContentChanged {
     35      get { return fileContentChanged; }
    3636      set {
    37         if (changedFileContent != value) {
    38           changedFileContent = value;
    39           OnChangedFileContent();
     37        if (fileContentChanged != value) {
     38          fileContentChanged = value;
     39          OnFileContentChanged();
    4040        }
    4141      }
     
    4949    public TextFileView() {
    5050      InitializeComponent();
    51       changedFileContent = false;
     51      fileContentChanged = false;
    5252    }
    5353
    5454    protected override void RegisterContentEvents() {
    5555      base.RegisterContentEvents();
    56       Content.ValueChanged += Content_FilePathChanged;
    57       Content.FileOpenDialogFilterChanged += Content_FileDialogFilterChanged;
     56      Content.StringValue.ValueChanged += Content_FilePathChanged;
    5857    }
    5958    protected override void DeregisterContentEvents() {
    60       Content.ValueChanged -= Content_FilePathChanged;
    61       Content.FileOpenDialogFilterChanged -= Content_FileDialogFilterChanged;
     59      Content.StringValue.ValueChanged -= Content_FilePathChanged;
    6260      fileSystemWatcher.EnableRaisingEvents = false;
    6361      base.DeregisterContentEvents();
     
    6664      base.SetEnabledStateOfControls();
    6765      textBox.ReadOnly = Locked || ReadOnly || Content == null;
    68       saveButton.Enabled = !Locked && !ReadOnly && Content != null && ChangedFileContent;
     66      saveButton.Enabled = !Locked && !ReadOnly && Content != null && FileContentChanged;
    6967
    7068      if (Content != null && Content.Exists()) {
     
    8381    protected override void OnContentChanged() {
    8482      base.OnContentChanged();
    85       ChangedFileContent = false;
     83      FileContentChanged = false;
    8684      if (Content == null) {
    87         fileValueView.Content = null;
    8885        textBox.Text = string.Empty;
    8986        //mkommend: other properties of the file system watcher cannot be cleared (e.g., path) as this leads to an ArgumentException
     
    9188        return;
    9289      }
    93 
    94       fileValueView.Content = Content;
    9590      saveFileDialog.Filter = Content.FileDialogFilter;
    9691      UpdateTextBox();
     
    10196      SetEnabledStateOfControls();
    10297    }
    103     private void Content_FileDialogFilterChanged(object sender, EventArgs e) {
    104       saveFileDialog.Filter = Content.FileDialogFilter;
    105     }
    10698
    10799    private void textBox_TextChanged(object sender, EventArgs e) {
    108       ChangedFileContent = fileText != textBox.Text;
    109     }
    110 
    111     private void OnChangedFileContent() {
     100      FileContentChanged = fileText != textBox.Text;
     101    }
     102
     103    private void OnFileContentChanged() {
    112104      SetEnabledStateOfControls();
    113       if (ChangedFileContent) {
    114         textBox.ForeColor = Color.Red;
    115       } else {
    116         textBox.ForeColor = Color.Black;
    117       }
     105      textBox.ForeColor = FileContentChanged ? Color.Red : Color.Black;
    118106    }
    119107
     
    146134        } else {
    147135          fileText = newContent;
    148           ChangedFileContent = true;
     136          FileContentChanged = true;
    149137        }
    150138      }
     
    185173      WriteFile(path, textBox.Text);
    186174      Content.Value = path;
    187       ChangedFileContent = false;
     175      FileContentChanged = false;
    188176      fileSystemWatcher.EnableRaisingEvents = true;
    189177    }
     
    212200    }
    213201    private void textBox_Validated(object sender, EventArgs e) {
    214       if (!ChangedFileContent) return;
     202      if (!FileContentChanged) return;
    215203      string msg = string.Format("You have not saved the changes in the file \"{0}\" yet. Do you want to save the changes?", Content.Value);
    216204      var result = MessageBox.Show(this, msg, "Save changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
     
    229217      if (!File.Exists(path)) return null;
    230218      string fileContent = string.Empty;
    231       using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
    232         using (StreamReader streamReader = new StreamReader(fileStream)) {
    233           fileContent = streamReader.ReadToEnd();
    234         }
     219      try {
     220        using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
     221          using (StreamReader streamReader = new StreamReader(fileStream)) {
     222            fileContent = streamReader.ReadToEnd();
     223          }
     224        }
     225      }
     226      catch (Exception e) {
     227        ErrorHandling.ShowErrorDialog(e);
    235228      }
    236229      return fileContent;
     
    238231
    239232    private static void WriteFile(string path, string fileContent) {
    240       using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write)) {
    241         using (StreamWriter streamWriter = new StreamWriter(fileStream)) {
    242           streamWriter.Write(fileContent);
    243         }
     233      try {
     234        using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) {
     235          using (StreamWriter streamWriter = new StreamWriter(fileStream)) {
     236            streamWriter.Write(fileContent);
     237          }
     238        }
     239      }
     240      catch (Exception e) {
     241        ErrorHandling.ShowErrorDialog(e);
    244242      }
    245243    }
Note: See TracChangeset for help on using the changeset viewer.