Free cookie consent management tool by TermsFeed Policy Generator

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/HeuristicLab.JsonInterface.OptimizerIntegration/Views
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.