Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17444


Ignore:
Timestamp:
02/18/20 16:28:53 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • added two new methods in IJsonItem -> FixatePath and LoosenPath to fixate/loosen the path (to enable name changing without effects on path)
  • set IsInRange to virtual and made overrides for IntMatrixJsonItem and DoubleMatrixJsonItem (IsInRange is a bad name and needs to be renamed in future versions)
  • implemented basic validation feedback with ErrorProvider for some inputs (templateName, Name, Range)
  • now all items gets validated before export (validation errors are shown with ErrorHandling.ShowErrorDialog)
  • added a check in AlgorithmConverter to prevent an exception for accessing the first element of an empty IEnumerable
Location:
branches/3026_IntegrationIntoSymSpace
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.Designer.cs

    r17443 r17444  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      this.components = new System.ComponentModel.Container();
    2627      this.labelEnable = new System.Windows.Forms.Label();
    2728      this.checkBoxActive = new System.Windows.Forms.CheckBox();
     
    3233      this.labelDescription = new System.Windows.Forms.Label();
    3334      this.textBoxDescription = new System.Windows.Forms.TextBox();
     35      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     36      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3437      this.SuspendLayout();
    3538      //
     
    7780      this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    7881            | System.Windows.Forms.AnchorStyles.Right)));
     82      this.errorProvider.SetIconAlignment(this.textBoxName, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    7983      this.textBoxName.Location = new System.Drawing.Point(92, 23);
    8084      this.textBoxName.Name = "textBoxName";
    8185      this.textBoxName.Size = new System.Drawing.Size(402, 20);
    8286      this.textBoxName.TabIndex = 10;
     87      this.textBoxName.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxName_Validating);
    8388      //
    8489      // label1
     
    110115      this.textBoxDescription.TabIndex = 14;
    111116      //
     117      // errorProvider
     118      //
     119      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
     120      this.errorProvider.ContainerControl = this;
     121      //
    112122      // JsonItemBaseControl
    113123      //
     
    122132      this.Controls.Add(this.textBoxName);
    123133      this.Controls.Add(this.label1);
     134      this.errorProvider.SetIconAlignment(this, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    124135      this.Name = "JsonItemBaseControl";
    125136      this.Padding = new System.Windows.Forms.Padding(3);
    126137      this.Size = new System.Drawing.Size(500, 154);
     138      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    127139      this.ResumeLayout(false);
    128140      this.PerformLayout();
     
    140152    private System.Windows.Forms.Label labelDescription;
    141153    private System.Windows.Forms.TextBox textBoxDescription;
     154    protected System.Windows.Forms.ErrorProvider errorProvider;
    142155  }
    143156}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.cs

    r17443 r17444  
    3131      else
    3232        textBoxActualName.Text = VM.Item.ActualName;
    33        
     33
     34    }
     35
     36    private void textBoxName_Validating(object sender, CancelEventArgs e) {
     37      if(string.IsNullOrWhiteSpace(textBoxName.Text)) {
     38        errorProvider.SetError(textBoxName, "Name must not be empty.");
     39        e.Cancel = true;
     40      } else {
     41        errorProvider.SetError(textBoxName, null);
     42      }
    3443    }
    3544  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.resx

    r17404 r17444  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
    120123</root>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/NumericRangeControl.Designer.cs

    r17411 r17444  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      this.components = new System.ComponentModel.Container();
    2627      this.textBoxFrom = new System.Windows.Forms.TextBox();
    2728      this.label6 = new System.Windows.Forms.Label();
    2829      this.groupBox2 = new System.Windows.Forms.GroupBox();
    29       this.checkBoxFrom = new System.Windows.Forms.CheckBox();
    3030      this.checkBoxTo = new System.Windows.Forms.CheckBox();
    3131      this.textBoxTo = new System.Windows.Forms.TextBox();
    3232      this.label1 = new System.Windows.Forms.Label();
     33      this.checkBoxFrom = new System.Windows.Forms.CheckBox();
     34      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    3335      this.groupBox2.SuspendLayout();
     36      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3437      this.SuspendLayout();
    3538      //
     
    3841      this.textBoxFrom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    3942            | System.Windows.Forms.AnchorStyles.Right)));
    40       this.textBoxFrom.Location = new System.Drawing.Point(36, 36);
     43      this.errorProvider.SetIconAlignment(this.textBoxFrom, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     44      this.textBoxFrom.Location = new System.Drawing.Point(67, 17);
    4145      this.textBoxFrom.Name = "textBoxFrom";
    4246      this.textBoxFrom.ReadOnly = true;
    43       this.textBoxFrom.Size = new System.Drawing.Size(164, 20);
     47      this.textBoxFrom.Size = new System.Drawing.Size(253, 20);
    4448      this.textBoxFrom.TabIndex = 2;
     49      this.textBoxFrom.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxFrom_Validating);
    4550      //
    4651      // label6
     
    4954            | System.Windows.Forms.AnchorStyles.Right)));
    5055      this.label6.AutoSize = true;
    51       this.label6.Location = new System.Drawing.Point(7, 20);
     56      this.label6.Location = new System.Drawing.Point(31, 21);
    5257      this.label6.Name = "label6";
    5358      this.label6.Size = new System.Drawing.Size(30, 13);
     
    5762      // groupBox2
    5863      //
    59       this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    60             | System.Windows.Forms.AnchorStyles.Right)));
    6164      this.groupBox2.Controls.Add(this.checkBoxTo);
    6265      this.groupBox2.Controls.Add(this.textBoxTo);
     
    6568      this.groupBox2.Controls.Add(this.textBoxFrom);
    6669      this.groupBox2.Controls.Add(this.label6);
    67       this.groupBox2.Location = new System.Drawing.Point(0, 3);
     70      this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
     71      this.groupBox2.Location = new System.Drawing.Point(0, 0);
    6872      this.groupBox2.Name = "groupBox2";
    69       this.groupBox2.Size = new System.Drawing.Size(206, 109);
     73      this.groupBox2.Size = new System.Drawing.Size(326, 75);
    7074      this.groupBox2.TabIndex = 19;
    7175      this.groupBox2.TabStop = false;
    7276      this.groupBox2.Text = "Range";
    7377      //
    74       // checkBoxFrom
    75       //
    76       this.checkBoxFrom.AutoSize = true;
    77       this.checkBoxFrom.Location = new System.Drawing.Point(10, 39);
    78       this.checkBoxFrom.Name = "checkBoxFrom";
    79       this.checkBoxFrom.Size = new System.Drawing.Size(15, 14);
    80       this.checkBoxFrom.TabIndex = 4;
    81       this.checkBoxFrom.UseVisualStyleBackColor = true;
    82       //
    8378      // checkBoxTo
    8479      //
    8580      this.checkBoxTo.AutoSize = true;
    86       this.checkBoxTo.Location = new System.Drawing.Point(10, 78);
     81      this.checkBoxTo.Location = new System.Drawing.Point(10, 46);
    8782      this.checkBoxTo.Name = "checkBoxTo";
    8883      this.checkBoxTo.Size = new System.Drawing.Size(15, 14);
     
    9489      this.textBoxTo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    9590            | System.Windows.Forms.AnchorStyles.Right)));
    96       this.textBoxTo.Location = new System.Drawing.Point(36, 75);
     91      this.errorProvider.SetIconAlignment(this.textBoxTo, System.Windows.Forms.ErrorIconAlignment.TopLeft);
     92      this.textBoxTo.Location = new System.Drawing.Point(67, 43);
    9793      this.textBoxTo.Name = "textBoxTo";
    9894      this.textBoxTo.ReadOnly = true;
    99       this.textBoxTo.Size = new System.Drawing.Size(164, 20);
     95      this.textBoxTo.Size = new System.Drawing.Size(253, 20);
    10096      this.textBoxTo.TabIndex = 6;
     97      this.textBoxTo.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxTo_Validating);
    10198      //
    10299      // label1
     
    105102            | System.Windows.Forms.AnchorStyles.Right)));
    106103      this.label1.AutoSize = true;
    107       this.label1.Location = new System.Drawing.Point(7, 59);
     104      this.label1.Location = new System.Drawing.Point(31, 46);
    108105      this.label1.Name = "label1";
    109106      this.label1.Size = new System.Drawing.Size(20, 13);
    110107      this.label1.TabIndex = 5;
    111108      this.label1.Text = "To";
     109      //
     110      // checkBoxFrom
     111      //
     112      this.checkBoxFrom.AutoSize = true;
     113      this.checkBoxFrom.Location = new System.Drawing.Point(10, 20);
     114      this.checkBoxFrom.Name = "checkBoxFrom";
     115      this.checkBoxFrom.Size = new System.Drawing.Size(15, 14);
     116      this.checkBoxFrom.TabIndex = 4;
     117      this.checkBoxFrom.UseVisualStyleBackColor = true;
     118      //
     119      // errorProvider
     120      //
     121      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
     122      this.errorProvider.ContainerControl = this;
    112123      //
    113124      // NumericRangeControl
     
    117128      this.Controls.Add(this.groupBox2);
    118129      this.Name = "NumericRangeControl";
    119       this.Size = new System.Drawing.Size(206, 112);
     130      this.Size = new System.Drawing.Size(326, 75);
    120131      this.groupBox2.ResumeLayout(false);
    121132      this.groupBox2.PerformLayout();
     133      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    122134      this.ResumeLayout(false);
    123135
     
    132144    private System.Windows.Forms.Label label1;
    133145    private System.Windows.Forms.CheckBox checkBoxFrom;
     146    private System.Windows.Forms.ErrorProvider errorProvider;
    134147  }
    135148}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/NumericRangeControl.cs

    r17411 r17444  
    3333      textBoxFrom.ReadOnly = !checkBoxFrom.Checked;
    3434    }
     35
     36    private void textBoxFrom_Validating(object sender, CancelEventArgs e) {
     37      if (string.IsNullOrWhiteSpace(textBoxFrom.Text)) {
     38        errorProvider.SetError(textBoxFrom, "'From' must not be empty.");
     39        e.Cancel = true;
     40      } else {
     41        errorProvider.SetError(textBoxFrom, null);
     42      }
     43    }
     44
     45    private void textBoxTo_Validating(object sender, CancelEventArgs e) {
     46      if (string.IsNullOrWhiteSpace(textBoxTo.Text)) {
     47        errorProvider.SetError(textBoxTo, "'To' must not be empty.");
     48        e.Cancel = true;
     49      } else {
     50        errorProvider.SetError(textBoxTo, null);
     51      }
     52    }
    3553  }
    3654}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/NumericRangeControl.resx

    r17405 r17444  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
    120123</root>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs

    r17439 r17444  
    99
    1010namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    11   public class JsonItemVMBase : INotifyPropertyChanged {
     11  public class JsonItemVMBase : INotifyPropertyChanged, IDisposable {
    1212    public event PropertyChangedEventHandler PropertyChanged;
    1313    public event Action ItemChanged;
     
    1717      get => item;
    1818      set {
     19        item?.LoosenPath();
    1920        item = value;
     21        item.FixatePath();
    2022        ItemChanged?.Invoke();
    2123      }
     
    8082    }
    8183
     84    #region IDisposable Support
     85    private bool disposedValue = false; // To detect redundant calls
     86
     87    protected virtual void Dispose(bool disposing) {
     88      if (!disposedValue) {
     89        if (disposing) {
     90          item.LoosenPath();
     91          item = null;
     92        }
     93        disposedValue = true;
     94      }
     95    }
     96
     97    // This code added to correctly implement the disposable pattern.
     98    public void Dispose() {
     99      // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
     100      Dispose(true);
     101    }
     102    #endregion
    82103  }
    83104}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs

    r17443 r17444  
    3333      this.groupBox2 = new System.Windows.Forms.GroupBox();
    3434      this.groupBox3 = new System.Windows.Forms.GroupBox();
     35      this.treeViewResults = new System.Windows.Forms.TreeView();
    3536      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
    3637      this.tabControl1 = new System.Windows.Forms.TabControl();
    3738      this.tabPage1 = new System.Windows.Forms.TabPage();
    3839      this.tabPage2 = new System.Windows.Forms.TabPage();
     40      this.label1 = new System.Windows.Forms.Label();
     41      this.textBoxTemplateName = new System.Windows.Forms.TextBox();
     42      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    3943      this.jsonItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
    40       this.treeViewResults = new System.Windows.Forms.TreeView();
    4144      this.groupBoxDetails.SuspendLayout();
    4245      this.groupBox2.SuspendLayout();
     
    4952      this.tabPage1.SuspendLayout();
    5053      this.tabPage2.SuspendLayout();
     54      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5155      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit();
    5256      this.SuspendLayout();
     
    6064      // exportButton
    6165      //
    62       this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    63             | System.Windows.Forms.AnchorStyles.Right)));
    64       this.exportButton.Location = new System.Drawing.Point(591, 578);
     66      this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     67      this.exportButton.Location = new System.Drawing.Point(629, 578);
    6568      this.exportButton.Name = "exportButton";
    66       this.exportButton.Size = new System.Drawing.Size(229, 29);
     69      this.exportButton.Size = new System.Drawing.Size(191, 29);
    6770      this.exportButton.TabIndex = 1;
    6871      this.exportButton.Text = "Export";
     
    7881      this.treeView.Location = new System.Drawing.Point(6, 19);
    7982      this.treeView.Name = "treeView";
    80       this.treeView.Size = new System.Drawing.Size(352, 497);
     83      this.treeView.Size = new System.Drawing.Size(352, 471);
    8184      this.treeView.TabIndex = 3;
    8285      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
     
    9093      this.groupBoxDetails.Location = new System.Drawing.Point(3, 0);
    9194      this.groupBoxDetails.Name = "groupBoxDetails";
    92       this.groupBoxDetails.Size = new System.Drawing.Size(415, 522);
     95      this.groupBoxDetails.Size = new System.Drawing.Size(415, 496);
    9396      this.groupBoxDetails.TabIndex = 4;
    9497      this.groupBoxDetails.TabStop = false;
     
    103106      this.panel.Location = new System.Drawing.Point(7, 20);
    104107      this.panel.Name = "panel";
    105       this.panel.Size = new System.Drawing.Size(402, 496);
     108      this.panel.Size = new System.Drawing.Size(402, 470);
    106109      this.panel.TabIndex = 0;
    107110      //
     
    114117      this.resultItems.Location = new System.Drawing.Point(6, 364);
    115118      this.resultItems.Name = "resultItems";
    116       this.resultItems.Size = new System.Drawing.Size(777, 154);
     119      this.resultItems.Size = new System.Drawing.Size(777, 124);
    117120      this.resultItems.TabIndex = 5;
    118121      //
     
    125128      this.groupBox2.Location = new System.Drawing.Point(0, 0);
    126129      this.groupBox2.Name = "groupBox2";
    127       this.groupBox2.Size = new System.Drawing.Size(364, 522);
     130      this.groupBox2.Size = new System.Drawing.Size(364, 496);
    128131      this.groupBox2.TabIndex = 6;
    129132      this.groupBox2.TabStop = false;
     
    139142      this.groupBox3.Location = new System.Drawing.Point(6, 6);
    140143      this.groupBox3.Name = "groupBox3";
    141       this.groupBox3.Size = new System.Drawing.Size(789, 522);
     144      this.groupBox3.Size = new System.Drawing.Size(789, 496);
    142145      this.groupBox3.TabIndex = 7;
    143146      this.groupBox3.TabStop = false;
    144147      this.groupBox3.Text = "Result Elements";
    145       //
    146       // splitContainer2
    147       //
    148       this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    149             | System.Windows.Forms.AnchorStyles.Left)
    150             | System.Windows.Forms.AnchorStyles.Right)));
    151       this.splitContainer2.Location = new System.Drawing.Point(6, 6);
    152       this.splitContainer2.Name = "splitContainer2";
    153       //
    154       // splitContainer2.Panel1
    155       //
    156       this.splitContainer2.Panel1.Controls.Add(this.groupBox2);
    157       //
    158       // splitContainer2.Panel2
    159       //
    160       this.splitContainer2.Panel2.Controls.Add(this.groupBoxDetails);
    161       this.splitContainer2.Size = new System.Drawing.Size(789, 522);
    162       this.splitContainer2.SplitterDistance = 367;
    163       this.splitContainer2.TabIndex = 9;
    164       //
    165       // tabControl1
    166       //
    167       this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    168             | System.Windows.Forms.AnchorStyles.Left)
    169             | System.Windows.Forms.AnchorStyles.Right)));
    170       this.tabControl1.Controls.Add(this.tabPage1);
    171       this.tabControl1.Controls.Add(this.tabPage2);
    172       this.tabControl1.Location = new System.Drawing.Point(12, 12);
    173       this.tabControl1.Name = "tabControl1";
    174       this.tabControl1.SelectedIndex = 0;
    175       this.tabControl1.Size = new System.Drawing.Size(809, 560);
    176       this.tabControl1.TabIndex = 10;
    177       //
    178       // tabPage1
    179       //
    180       this.tabPage1.Controls.Add(this.splitContainer2);
    181       this.tabPage1.Location = new System.Drawing.Point(4, 22);
    182       this.tabPage1.Name = "tabPage1";
    183       this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
    184       this.tabPage1.Size = new System.Drawing.Size(801, 534);
    185       this.tabPage1.TabIndex = 0;
    186       this.tabPage1.Text = "Parameters";
    187       this.tabPage1.UseVisualStyleBackColor = true;
    188       //
    189       // tabPage2
    190       //
    191       this.tabPage2.Controls.Add(this.groupBox3);
    192       this.tabPage2.Location = new System.Drawing.Point(4, 22);
    193       this.tabPage2.Name = "tabPage2";
    194       this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
    195       this.tabPage2.Size = new System.Drawing.Size(801, 534);
    196       this.tabPage2.TabIndex = 1;
    197       this.tabPage2.Text = "Results";
    198       this.tabPage2.UseVisualStyleBackColor = true;
    199       //
    200       // jsonItemBindingSource
    201       //
    202       this.jsonItemBindingSource.DataSource = typeof(HeuristicLab.JsonInterface.IJsonItem);
    203148      //
    204149      // treeViewResults
     
    210155      this.treeViewResults.TabIndex = 6;
    211156      //
     157      // splitContainer2
     158      //
     159      this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     160            | System.Windows.Forms.AnchorStyles.Left)
     161            | System.Windows.Forms.AnchorStyles.Right)));
     162      this.splitContainer2.Location = new System.Drawing.Point(6, 6);
     163      this.splitContainer2.Name = "splitContainer2";
     164      //
     165      // splitContainer2.Panel1
     166      //
     167      this.splitContainer2.Panel1.Controls.Add(this.groupBox2);
     168      //
     169      // splitContainer2.Panel2
     170      //
     171      this.splitContainer2.Panel2.Controls.Add(this.groupBoxDetails);
     172      this.splitContainer2.Size = new System.Drawing.Size(789, 496);
     173      this.splitContainer2.SplitterDistance = 367;
     174      this.splitContainer2.TabIndex = 9;
     175      //
     176      // tabControl1
     177      //
     178      this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     179            | System.Windows.Forms.AnchorStyles.Left)
     180            | System.Windows.Forms.AnchorStyles.Right)));
     181      this.tabControl1.Controls.Add(this.tabPage1);
     182      this.tabControl1.Controls.Add(this.tabPage2);
     183      this.tabControl1.Location = new System.Drawing.Point(12, 38);
     184      this.tabControl1.Name = "tabControl1";
     185      this.tabControl1.SelectedIndex = 0;
     186      this.tabControl1.Size = new System.Drawing.Size(809, 534);
     187      this.tabControl1.TabIndex = 10;
     188      //
     189      // tabPage1
     190      //
     191      this.tabPage1.Controls.Add(this.splitContainer2);
     192      this.tabPage1.Location = new System.Drawing.Point(4, 22);
     193      this.tabPage1.Name = "tabPage1";
     194      this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
     195      this.tabPage1.Size = new System.Drawing.Size(801, 508);
     196      this.tabPage1.TabIndex = 0;
     197      this.tabPage1.Text = "Parameters";
     198      this.tabPage1.UseVisualStyleBackColor = true;
     199      //
     200      // tabPage2
     201      //
     202      this.tabPage2.Controls.Add(this.groupBox3);
     203      this.tabPage2.Location = new System.Drawing.Point(4, 22);
     204      this.tabPage2.Name = "tabPage2";
     205      this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
     206      this.tabPage2.Size = new System.Drawing.Size(801, 508);
     207      this.tabPage2.TabIndex = 1;
     208      this.tabPage2.Text = "Results";
     209      this.tabPage2.UseVisualStyleBackColor = true;
     210      //
     211      // label1
     212      //
     213      this.label1.AutoSize = true;
     214      this.label1.Location = new System.Drawing.Point(12, 15);
     215      this.label1.Name = "label1";
     216      this.label1.Size = new System.Drawing.Size(82, 13);
     217      this.label1.TabIndex = 11;
     218      this.label1.Text = "Template Name";
     219      //
     220      // textBoxTemplateName
     221      //
     222      this.textBoxTemplateName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     223            | System.Windows.Forms.AnchorStyles.Right)));
     224      this.errorProvider.SetIconAlignment(this.textBoxTemplateName, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     225      this.textBoxTemplateName.Location = new System.Drawing.Point(100, 12);
     226      this.textBoxTemplateName.Name = "textBoxTemplateName";
     227      this.textBoxTemplateName.Size = new System.Drawing.Size(720, 20);
     228      this.textBoxTemplateName.TabIndex = 12;
     229      this.textBoxTemplateName.Text = "Template";
     230      this.textBoxTemplateName.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxTemplateName_Validating);
     231      //
     232      // errorProvider
     233      //
     234      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
     235      this.errorProvider.ContainerControl = this;
     236      //
     237      // jsonItemBindingSource
     238      //
     239      this.jsonItemBindingSource.DataSource = typeof(HeuristicLab.JsonInterface.IJsonItem);
     240      //
    212241      // ExportJsonDialog
    213242      //
     
    215244      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    216245      this.ClientSize = new System.Drawing.Size(833, 619);
     246      this.Controls.Add(this.textBoxTemplateName);
     247      this.Controls.Add(this.label1);
    217248      this.Controls.Add(this.exportButton);
    218249      this.Controls.Add(this.tabControl1);
     
    231262      this.tabPage1.ResumeLayout(false);
    232263      this.tabPage2.ResumeLayout(false);
     264      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    233265      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit();
    234266      this.ResumeLayout(false);
     267      this.PerformLayout();
    235268
    236269    }
     
    253286    private System.Windows.Forms.TabPage tabPage2;
    254287    private System.Windows.Forms.TreeView treeViewResults;
     288    private System.Windows.Forms.Label label1;
     289    private System.Windows.Forms.TextBox textBoxTemplateName;
     290    private System.Windows.Forms.ErrorProvider errorProvider;
    255291  }
    256292}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r17443 r17444  
    1616namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1717  public partial class ExportJsonDialog : Form {
    18     private static SaveFileDialog SaveFileDialog { get; set; }
     18    private static FolderBrowserDialog FolderBrowserDialog { get; set; }
    1919    private IDictionary<int, UserControl> Hash2Control { get; set; } = new Dictionary<int, UserControl>();
    2020    private IDictionary<TreeNode, JsonItemVMBase> Node2VM { get; set; } = new Dictionary<TreeNode, JsonItemVMBase>();
     
    7171
    7272    private void exportButton_Click(object sender, EventArgs e) {
    73       foreach(var x in VMs) {
     73      foreach (var x in VMs) {
    7474        if (!x.Selected) {
    7575          x.Item.Parent.Children.Remove(x.Item);
     
    7777      }
    7878
    79       foreach(var x in ResultItems.Values) {
     79      foreach (var x in ResultItems.Values) {
    8080        x.Parent.Children.Remove(x);
    8181      }
    8282
    83       foreach(var x in resultItems.CheckedItems) {
    84         if(ResultItems.TryGetValue((string)x, out IJsonItem item)) {
     83      foreach (var x in resultItems.CheckedItems) {
     84        if (ResultItems.TryGetValue((string)x, out IJsonItem item)) {
    8585          Root.AddChildren(item);
    8686        }
     
    8888
    8989      IList<IJsonItem> faultyItems = new List<IJsonItem>();
    90       if(!Root.GetValidator().Validate(ref faultyItems)) {
     90     
     91      if (!Root.GetValidator().Validate(ref faultyItems)) {
     92        IList<Exception> list = new List<Exception>();
    9193        //print faultyItems
     94        foreach (var x in faultyItems) {
     95          list.Add(new Exception($"Combination of value and range is not valid for {x.Name}"));
     96        }
     97        ErrorHandling.ShowErrorDialog(this, new AggregateException(list));
     98      } else {
     99        if (FolderBrowserDialog == null) {
     100          FolderBrowserDialog = new FolderBrowserDialog();
     101          FolderBrowserDialog.Description = "Select .json-Template Dictionary";
     102        }
     103
     104        if (FolderBrowserDialog.ShowDialog() == DialogResult.OK) {
     105          Generator.GenerateTemplate(FolderBrowserDialog.SelectedPath, textBoxTemplateName.Text, Optimizer, Root);
     106        }
     107
     108        Close();
    92109      }
    93 
    94       if (SaveFileDialog == null) {
    95         SaveFileDialog = new SaveFileDialog();
    96         SaveFileDialog.Title = "Export .json-Template";
    97         SaveFileDialog.DefaultExt = "json";
    98         SaveFileDialog.Filter = ".json-Template|*.json|All Files|*.*";
    99         SaveFileDialog.FilterIndex = 1;
    100       }
    101      
    102       SaveFileDialog.FileName = "template";
    103 
    104       if (SaveFileDialog.ShowDialog() == DialogResult.OK) {
    105         Generator.GenerateTemplate(@"C:\Users\p41997\Desktop", "template", Optimizer, Root);
    106       }
    107 
    108       Close();
    109110    }
    110111
     
    162163      }
    163164    }
     165
     166    private void textBoxTemplateName_Validating(object sender, CancelEventArgs e) {
     167      if (string.IsNullOrWhiteSpace(textBoxTemplateName.Text)) {
     168        errorProvider.SetError(textBoxTemplateName, "Template name must not be empty.");
     169        e.Cancel = true;
     170      } else {
     171        errorProvider.SetError(textBoxTemplateName, null);
     172      }
     173    }
    164174  }
    165175}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.resx

    r17404 r17444  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>194, 17</value>
     122  </metadata>
    120123  <metadata name="jsonItemBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    121124    <value>17, 17</value>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValueControl.Designer.cs

    r17443 r17444  
    3737      this.textBoxValue.Size = new System.Drawing.Size(402, 20);
    3838      this.textBoxValue.TabIndex = 14;
     39      this.textBoxValue.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxValue_Validating);
    3940      //
    4041      // label2
     
    5152      this.numericRangeControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    5253            | System.Windows.Forms.AnchorStyles.Right)));
    53       this.numericRangeControl1.Location = new System.Drawing.Point(9, 127);
     54      this.numericRangeControl1.Location = new System.Drawing.Point(9, 125);
    5455      this.numericRangeControl1.Name = "numericRangeControl1";
    55       this.numericRangeControl1.Size = new System.Drawing.Size(485, 112);
     56      this.numericRangeControl1.Size = new System.Drawing.Size(485, 72);
    5657      this.numericRangeControl1.TabIndex = 16;
    5758      //
     
    6465      this.Controls.Add(this.textBoxValue);
    6566      this.Name = "JsonItemValueControl";
    66       this.Size = new System.Drawing.Size(500, 247);
     67      this.Size = new System.Drawing.Size(500, 199);
    6768      this.Controls.SetChildIndex(this.textBoxValue, 0);
    6869      this.Controls.SetChildIndex(this.label2, 0);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValueControl.cs

    r17443 r17444  
    5050    }
    5151   
    52     protected void Init() {
     52    protected void Init() { 
    5353      TBValue.DataBindings.Add("Text", base.VM, ValuePropertyId);
    5454      NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM.MinRange));
     
    6060    }
    6161
     62    private void textBoxValue_Validating(object sender, CancelEventArgs e) {
     63      if (string.IsNullOrWhiteSpace(textBoxValue.Text)) {
     64        errorProvider.SetError(textBoxValue, "Value must not be empty.");
     65        e.Cancel = true;
     66      } else {
     67        errorProvider.SetError(textBoxValue, null);
     68      }
     69    }
    6270  }
    6371}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs

    r17443 r17444  
    1616      base.Inject(item, data, root);
    1717      IAlgorithm algorithm = item as IAlgorithm;
    18       IJsonItem problemData = data.Children.Where(x => x.Name == algorithm.Problem.ItemName).First();
    19       root.Inject(algorithm.Problem, problemData, root);
    20 
     18      var collection = data.Children.Where(x => x.Name == algorithm.Problem.ItemName);
     19      if(collection.Count() > 0) {
     20        IJsonItem problemData = collection.First();
     21        root.Inject(algorithm.Problem, problemData, root);
     22      }
    2123    }
    2224   
     
    2729        item.AddChildren(new ResultItem() {
    2830          Name = res.Name,
    29           Description = res.Description,
    30           Value = true,
    31           Range = new object[] { true, false }
     31          Description = res.Description
    3232        });
    3333      }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs

    r17433 r17444  
    3333
    3434    void AddChildren(IEnumerable<IJsonItem> childs);
     35
     36    /// <summary>
     37    /// This method fixates the path.
     38    /// After calling, the path cannot be changed by changing the name or parent.
     39    /// </summary>
     40    void FixatePath();
     41
     42    /// <summary>
     43    /// This method looses the path again after a call of FixatePath.
     44    /// After calling, the path is calculated by the position in item tree again.
     45    /// </summary>
     46    void LoosenPath();
    3547  }
    3648}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs

    r17435 r17444  
    4545    public virtual string Description { get; set; }
    4646
     47    private string fixedPath = "";
    4748    public virtual string Path {
    4849      get {
     50        if (!string.IsNullOrWhiteSpace(fixedPath))
     51          return fixedPath;
     52
    4953        IJsonItem tmp = Parent;
    5054        StringBuilder builder = new StringBuilder(this.Name);
     
    5761    }
    5862
     63    public virtual object Value { get; set; }
     64
     65    public virtual IEnumerable<object> Range { get; set; }
     66   
     67    public virtual string ActualName { get; set; }
     68
    5969    [JsonIgnore]
    6070    public virtual IList<IJsonItem> Children { get; protected set; }
     
    6272    [JsonIgnore]
    6373    public virtual IJsonItem Parent { get; set; }
    64 
    65     public virtual object Value { get; set; }
    66 
    67     public virtual IEnumerable<object> Range { get; set; }
    68    
    69     public virtual string ActualName { get; set; }
    7074
    7175    #region Constructors
     
    97101
    98102    public void AddChildren(IEnumerable<IJsonItem> childs) {
     103      if (childs == null) return;
    99104      if (Children == null)
    100105        Children = new List<IJsonItem>();
     
    106111
    107112    public virtual IJsonItemValidator GetValidator() => new JsonItemValidator(this);
     113
     114    public void FixatePath() => fixedPath = Path;
     115    public void LoosenPath() => fixedPath = "";
    108116    #endregion
    109117
    110118    #region Helper
    111     protected bool IsInRange() {
     119    protected virtual bool IsInRange() {
    112120      bool b1 = true, b2 = true;
    113121      if (Value is IEnumerable && !(Value is string)) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItems.cs

    r17420 r17444  
    99  public class IntArrayJsonItem: JsonItem<int[], int> { }
    1010  public class IntRangeJsonItem : JsonItem<int[], int> { }
    11   public class IntMatrixJsonItem : JsonItem<int[][], int> { }
     11  public class IntMatrixJsonItem : JsonItem<int[][], int> {
     12    protected override bool IsInRange() {
     13      for (int c = 0; c < Value.Length; ++c) {
     14        for (int r = 0; r < Value[c].Length; ++r) {
     15          if (Value[c][r] < Range.First() && Range.Last() < Value[c][r])
     16            return false;
     17        }
     18      }
     19      return true;
     20    }
     21  }
    1222
    1323  public class DoubleJsonItem: JsonItem<double> {}
    1424  public class DoubleArrayJsonItem: JsonItem<double[], double> { }
    1525  public class DoubleRangeJsonItem : JsonItem<double[], double> { }
    16   public class DoubleMatrixJsonItem : JsonItem<double[][], double> { }
     26  public class DoubleMatrixJsonItem : JsonItem<double[][], double> {
     27    protected override bool IsInRange() {
     28      for(int c = 0; c < Value.Length; ++c) {
     29        for(int r = 0; r < Value[c].Length; ++r) {
     30          if (Value[c][r] < Range.First() && Range.Last() < Value[c][r])
     31            return false;
     32        }
     33      }
     34      return true;
     35    }
     36  }
    1737
    1838  public class BoolJsonItem: JsonItem<bool> { }
Note: See TracChangeset for help on using the changeset viewer.