- Timestamp:
- 03/10/20 17:17:37 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 12 added
- 1 deleted
- 52 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Interfaces/IJsonItemVM.cs
r17471 r17473 8 8 9 9 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 public interface IJsonItemVM : INotifyPropertyChanged, IDisposable { 10 public interface IJsonItemVM : INotifyPropertyChanged, IDisposable 11 { 11 12 event Action ItemChanged; 12 13 13 Type JsonItemType { get; }14 Type TargetedJsonItemType { get; } 14 15 15 16 UserControl Control { get; } 16 17 IJsonItem Item { get; set; }18 19 17 bool Selected { get; set; } 20 18 … … 26 24 27 25 TreeView TreeView { get; set; } 26 IJsonItem Item { get; set; } 27 28 } 29 30 public interface IJsonItemVM<JsonItemType> : IJsonItemVM 31 where JsonItemType : IJsonItem 32 { 33 new JsonItemType Item { get; set; } 28 34 } 29 35 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.Designer.cs
r17471 r17473 28 28 this.textBoxName = new System.Windows.Forms.TextBox(); 29 29 this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 30 this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); 31 this.textBoxDescription = new System.Windows.Forms.TextBox(); 32 this.checkBoxActive = new System.Windows.Forms.CheckBox(); 33 this.label1 = new System.Windows.Forms.Label(); 30 34 this.labelDescription = new System.Windows.Forms.Label(); 31 this.textBoxDescription = new System.Windows.Forms.TextBox();32 this.label1 = new System.Windows.Forms.Label();33 35 this.labelEnable = new System.Windows.Forms.Label(); 34 this.checkBoxActive = new System.Windows.Forms.CheckBox();35 this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel();36 36 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 37 37 this.tableLayoutPanel1.SuspendLayout(); … … 48 48 this.textBoxName.Dock = System.Windows.Forms.DockStyle.Fill; 49 49 this.errorProvider.SetIconAlignment(this.textBoxName, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 50 this.textBoxName.Location = new System.Drawing.Point(100, 2 4);50 this.textBoxName.Location = new System.Drawing.Point(100, 25); 51 51 this.textBoxName.Margin = new System.Windows.Forms.Padding(0); 52 52 this.textBoxName.Name = "textBoxName"; … … 72 72 this.tableLayoutPanel1.TabIndex = 16; 73 73 // 74 // labelDescription75 //76 this.labelDescription.AutoSize = true;77 this.labelDescription.Dock = System.Windows.Forms.DockStyle.Fill;78 this.labelDescription.Location = new System.Drawing.Point(0, 48);79 this.labelDescription.Margin = new System.Windows.Forms.Padding(0);80 this.labelDescription.Name = "labelDescription";81 this.labelDescription.Size = new System.Drawing.Size(100, 27);82 this.labelDescription.TabIndex = 13;83 this.labelDescription.Text = "Description";84 this.labelDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;85 //86 // textBoxDescription87 //88 this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill;89 this.textBoxDescription.Location = new System.Drawing.Point(100, 50);90 this.textBoxDescription.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0);91 this.textBoxDescription.Name = "textBoxDescription";92 this.textBoxDescription.Size = new System.Drawing.Size(394, 20);93 this.textBoxDescription.TabIndex = 14;94 //95 // label196 //97 this.label1.AutoSize = true;98 this.label1.Dock = System.Windows.Forms.DockStyle.Fill;99 this.label1.Location = new System.Drawing.Point(0, 24);100 this.label1.Margin = new System.Windows.Forms.Padding(0);101 this.label1.Name = "label1";102 this.label1.Size = new System.Drawing.Size(100, 24);103 this.label1.TabIndex = 9;104 this.label1.Text = "Name";105 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;106 //107 // labelEnable108 //109 this.labelEnable.AutoSize = true;110 this.labelEnable.Dock = System.Windows.Forms.DockStyle.Fill;111 this.labelEnable.Location = new System.Drawing.Point(0, 0);112 this.labelEnable.Margin = new System.Windows.Forms.Padding(0);113 this.labelEnable.Name = "labelEnable";114 this.labelEnable.Size = new System.Drawing.Size(100, 24);115 this.labelEnable.TabIndex = 3;116 this.labelEnable.Text = "Enable";117 this.labelEnable.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;118 //119 // checkBoxActive120 //121 this.checkBoxActive.AutoSize = true;122 this.checkBoxActive.Dock = System.Windows.Forms.DockStyle.Fill;123 this.checkBoxActive.Location = new System.Drawing.Point(100, 0);124 this.checkBoxActive.Margin = new System.Windows.Forms.Padding(0);125 this.checkBoxActive.Name = "checkBoxActive";126 this.checkBoxActive.Size = new System.Drawing.Size(394, 24);127 this.checkBoxActive.TabIndex = 2;128 this.checkBoxActive.UseVisualStyleBackColor = true;129 //130 74 // tableLayoutPanel5 131 75 // … … 150 94 this.tableLayoutPanel5.Size = new System.Drawing.Size(494, 75); 151 95 this.tableLayoutPanel5.TabIndex = 17; 96 // 97 // textBoxDescription 98 // 99 this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; 100 this.textBoxDescription.Location = new System.Drawing.Point(100, 52); 101 this.textBoxDescription.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0); 102 this.textBoxDescription.Name = "textBoxDescription"; 103 this.textBoxDescription.Size = new System.Drawing.Size(394, 20); 104 this.textBoxDescription.TabIndex = 14; 105 // 106 // checkBoxActive 107 // 108 this.checkBoxActive.AutoSize = true; 109 this.checkBoxActive.Dock = System.Windows.Forms.DockStyle.Fill; 110 this.checkBoxActive.Location = new System.Drawing.Point(100, 0); 111 this.checkBoxActive.Margin = new System.Windows.Forms.Padding(0); 112 this.checkBoxActive.Name = "checkBoxActive"; 113 this.checkBoxActive.Size = new System.Drawing.Size(394, 25); 114 this.checkBoxActive.TabIndex = 2; 115 this.checkBoxActive.UseVisualStyleBackColor = true; 116 // 117 // label1 118 // 119 this.label1.AutoSize = true; 120 this.label1.Dock = System.Windows.Forms.DockStyle.Fill; 121 this.label1.Location = new System.Drawing.Point(0, 25); 122 this.label1.Margin = new System.Windows.Forms.Padding(0); 123 this.label1.Name = "label1"; 124 this.label1.Size = new System.Drawing.Size(100, 25); 125 this.label1.TabIndex = 9; 126 this.label1.Text = "Name"; 127 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 128 // 129 // labelDescription 130 // 131 this.labelDescription.AutoSize = true; 132 this.labelDescription.Dock = System.Windows.Forms.DockStyle.Fill; 133 this.labelDescription.Location = new System.Drawing.Point(0, 50); 134 this.labelDescription.Margin = new System.Windows.Forms.Padding(0); 135 this.labelDescription.Name = "labelDescription"; 136 this.labelDescription.Size = new System.Drawing.Size(100, 25); 137 this.labelDescription.TabIndex = 13; 138 this.labelDescription.Text = "Description"; 139 this.labelDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 140 // 141 // labelEnable 142 // 143 this.labelEnable.AutoSize = true; 144 this.labelEnable.Dock = System.Windows.Forms.DockStyle.Fill; 145 this.labelEnable.Location = new System.Drawing.Point(0, 0); 146 this.labelEnable.Margin = new System.Windows.Forms.Padding(0); 147 this.labelEnable.Name = "labelEnable"; 148 this.labelEnable.Size = new System.Drawing.Size(100, 25); 149 this.labelEnable.TabIndex = 3; 150 this.labelEnable.Text = "Enable"; 151 this.labelEnable.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 152 152 // 153 153 // JsonItemBaseControl -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs
r17471 r17473 10 10 11 11 public class DoubleArrayValueVM : ArrayValueVM<double, DoubleArrayJsonItem> { 12 public override Type JsonItemType => typeof(DoubleArrayJsonItem);12 public override Type TargetedJsonItemType => typeof(DoubleArrayJsonItem); 13 13 14 14 protected override double MinTypeValue => double.MinValue; … … 29 29 30 30 public class IntArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> { 31 public override Type JsonItemType => typeof(IntArrayJsonItem);31 public override Type TargetedJsonItemType => typeof(IntArrayJsonItem); 32 32 33 33 protected override int MinTypeValue => int.MinValue; … … 47 47 } 48 48 49 public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T>, IArrayJsonItemVM 50 where JsonItemType : IArrayJsonItem { 49 public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IArrayJsonItemVM 50 where T : IComparable 51 where JsonItemType : class, IArrayJsonItem, IIntervalRestrictedJsonItem<T> { 51 52 52 53 public ArrayValueVM() { } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs
r17471 r17473 9 9 10 10 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 11 public abstract class JsonItemVMBase : IJsonItemVM { 12 private IJsonItem item; 13 public IJsonItem Item { 11 public abstract class JsonItemVMBase<JsonItemType> : IJsonItemVM<JsonItemType> 12 where JsonItemType : class, IJsonItem 13 { 14 IJsonItem IJsonItemVM.Item { 15 get => item; 16 set => item = (JsonItemType)value; 17 } 18 19 private JsonItemType item; 20 public JsonItemType Item { 14 21 get => item; 15 22 set { … … 27 34 Item.Active = value; 28 35 if(TreeNode != null) { 29 TreeNode.ForeColor = (Selected ? Color. Black : Color.Red);36 TreeNode.ForeColor = (Selected ? Color.Green : Color.Black); 30 37 TreeNode.Checked = value; 31 38 } … … 50 57 } 51 58 52 public abstract Type JsonItemType { get; }59 public abstract Type TargetedJsonItemType { get; } 53 60 public abstract UserControl Control { get; } 54 61 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/LookupJsonItemVM.cs
r17471 r17473 7 7 8 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 public class LookupJsonItemVM : JsonItemVMBase , ILookupJsonItemVM {10 public override Type JsonItemType => typeof(LookupJsonItem);9 public class LookupJsonItemVM : JsonItemVMBase<LookupJsonItem>, ILookupJsonItemVM { 10 public override Type TargetedJsonItemType => typeof(LookupJsonItem); 11 11 12 12 public override UserControl Control => new LookupJsonItemControl(this); 13 13 14 14 public string ActualName { 15 get => ((ILookupJsonItem)Item).ActualName;15 get => Item.ActualName; 16 16 set { 17 ((ILookupJsonItem)Item).ActualName = value;17 Item.ActualName = value; 18 18 OnPropertyChange(this, nameof(ActualName)); 19 19 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs
r17471 r17473 10 10 11 11 public class DoubleMatrixValueVM : MatrixValueVM<double, DoubleMatrixJsonItem> { 12 public override Type JsonItemType => typeof(DoubleMatrixJsonItem);12 public override Type TargetedJsonItemType => typeof(DoubleMatrixJsonItem); 13 13 public override UserControl Control => 14 14 new JsonItemDoubleMatrixValueControl(this); … … 27 27 } 28 28 29 public abstract class MatrixValueVM<T, JsonItemType> : RangedValueBaseVM<T>, IMatrixJsonItemVM 30 where JsonItemType : IMatrixJsonItem { 29 public abstract class MatrixValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IMatrixJsonItemVM 30 where T : IComparable 31 where JsonItemType : class, IMatrixJsonItem, IIntervalRestrictedJsonItem<T> { 31 32 public abstract T[][] Value { get; set; } 32 33 public bool RowsResizable { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs
r17471 r17473 9 9 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 10 11 public class IntRangeVM : RangeVM<int > {12 public override Type JsonItemType => typeof(IntRangeJsonItem);11 public class IntRangeVM : RangeVM<int, IntRangeJsonItem> { 12 public override Type TargetedJsonItemType => typeof(IntRangeJsonItem); 13 13 14 14 protected override int MinTypeValue => int.MinValue; … … 20 20 } 21 21 22 public class DoubleRangeVM : RangeVM<double > {23 public override Type JsonItemType => typeof(DoubleRangeJsonItem);22 public class DoubleRangeVM : RangeVM<double, DoubleRangeJsonItem> { 23 public override Type TargetedJsonItemType => typeof(DoubleRangeJsonItem); 24 24 25 25 protected override double MinTypeValue => double.MinValue; … … 31 31 } 32 32 33 public abstract class RangeVM<T> : RangedValueBaseVM<T> { 33 public abstract class RangeVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType> 34 where T : IComparable 35 where JsonItemType : class, IRangedJsonItem<T> 36 { 34 37 35 38 public T MinValue { 36 get => Cast(((Array)Item.Value).GetValue(0));39 get => Item.MinValue; 37 40 set { 38 SetValue(value, (T)((Array)Item.Value).GetValue(1));41 Item.MinValue = value; 39 42 OnPropertyChange(this, nameof(MinValue)); 40 43 } … … 42 45 43 46 public T MaxValue { 44 get => Cast(((Array)Item.Value).GetValue(1));47 get => Item.MaxValue; 45 48 set { 46 SetValue((T)((Array)Item.Value).GetValue(0), value);49 Item.MaxValue = value; 47 50 OnPropertyChange(this, nameof(MaxValue)); 48 51 } 49 52 } 50 51 private void SetValue(T min, T max) =>52 Item.Value = new T[] { min, max };53 53 } 54 54 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangedValueBaseVM.cs
r17420 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 8 public abstract class RangedValueBaseVM : RangedValueBaseVM<object> { }9 8 10 public abstract class RangedValueBaseVM<T> : JsonItemVMBase { 9 public abstract class RangedValueBaseVM<T, JsonItemType> : JsonItemVMBase<JsonItemType> 10 where T : IComparable 11 where JsonItemType : class, IIntervalRestrictedJsonItem<T> 12 { 11 13 public T MinRange { 12 get => Cast(Item.Range?.First());14 get => Item.Minimum; 13 15 set { 14 SetRange(value, Item.Range?.Last());16 Item.Minimum = value; 15 17 OnPropertyChange(this, nameof(MinRange)); 16 18 } … … 18 20 19 21 public T MaxRange { 20 get => Cast(Item.Range?.Last());22 get => Item.Maximum; 21 23 set { 22 SetRange(Item.Range?.First(), value);24 Item.Maximum = value; 23 25 OnPropertyChange(this, nameof(MaxRange)); 24 26 } … … 46 48 } 47 49 } 48 49 protected T Cast(object obj) => (obj==null) ? default(T) : (T)Convert.ChangeType(obj, typeof(T)); 50 51 private void SetRange(object min, object max) { 52 object[] range = new object[] { min, max }; 53 Item.Range = range; 54 } 55 50 56 51 protected abstract T MinTypeValue { get; } 57 52 protected abstract T MaxTypeValue { get; } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs
r17471 r17473 7 7 8 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 public class ResultItemVM : JsonItemVMBase {10 public override Type JsonItemType => typeof(ResultJsonItem);9 public class ResultItemVM : JsonItemVMBase<ResultJsonItem> { 10 public override Type TargetedJsonItemType => typeof(ResultJsonItem); 11 11 public override UserControl Control => 12 12 new JsonItemBaseControl(this); 13 14 13 } 15 14 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs
r17471 r17473 8 8 9 9 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 public class IntValueVM : SingleValueVM<int > {11 public override Type JsonItemType => typeof(IntJsonItem);10 public class IntValueVM : SingleValueVM<int, IntJsonItem> { 11 public override Type TargetedJsonItemType => typeof(IntJsonItem); 12 12 13 13 protected override int MinTypeValue => int.MinValue; … … 18 18 } 19 19 20 public class DoubleValueVM : SingleValueVM<double > {21 public override Type JsonItemType => typeof(DoubleJsonItem);20 public class DoubleValueVM : SingleValueVM<double, DoubleJsonItem> { 21 public override Type TargetedJsonItemType => typeof(DoubleJsonItem); 22 22 23 23 protected override double MinTypeValue => double.MinValue; … … 28 28 } 29 29 30 public class BoolValueVM : SingleValueVM<bool> {31 public override Type JsonItemType => typeof(BoolJsonItem);30 public class BoolValueVM : JsonItemVMBase<BoolJsonItem> { 31 public override Type TargetedJsonItemType => typeof(BoolJsonItem); 32 32 33 protected override bool MinTypeValue => false; 34 protected override bool MaxTypeValue => true; 35 33 public bool Value { 34 get => Item.Value; 35 set { 36 Item.Value = value; 37 OnPropertyChange(this, nameof(Value)); 38 } 39 } 40 36 41 public override UserControl Control => 37 42 new JsonItemBoolControl(this); 38 43 } 39 44 40 public abstract class SingleValueVM<T> : RangedValueBaseVM<T> { 41 45 public abstract class SingleValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType> 46 where T : IComparable 47 where JsonItemType : class, IIntervalRestrictedJsonItem<T>, IValueJsonItem<T> 48 { 49 42 50 public T Value { 43 get => Cast(Item.Value);51 get => Item.Value; 44 52 set { 45 53 Item.Value = value; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs
r17471 r17473 8 8 9 9 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 public class StringValueVM : JsonItemVMBase {11 public override Type JsonItemType => typeof(StringJsonItem);10 public class StringValueVM : JsonItemVMBase<StringJsonItem> { 11 public override Type TargetedJsonItemType => typeof(StringJsonItem); 12 12 public override UserControl Control => 13 13 new JsonItemValidValuesControl(this); … … 22 22 23 23 public IEnumerable<string> Range { 24 get => Item. Range?.Cast<string>();24 get => Item.ConcreteRestrictedItems; 25 25 set { 26 Item. Range= value;26 Item.ConcreteRestrictedItems = value; 27 27 //check if value is still in range 28 28 if (!Range.Any(x => x == Value)) { … … 37 37 } 38 38 } 39 39 40 } 40 41 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ValueLookupJsonItemVM.cs
r17471 r17473 4 4 using System.Text; 5 5 using System.Threading.Tasks; 6 using System.Windows.Forms; 6 7 7 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 8 9 public class ValueLookupJsonItemVM : LookupJsonItemVM, IValueLookupJsonItemVM { 10 public override Type TargetedJsonItemType => typeof(ValueLookupJsonItem); 11 public override UserControl Control => new ValueLookupJsonItemControl(this); 9 12 public IJsonItem JsonItemReference => ((IValueLookupJsonItem)Item).JsonItemReference; 10 13 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
r17471 r17473 53 53 foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) { 54 54 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); 55 JI2VM.Add(vm. JsonItemType, vmType);55 JI2VM.Add(vm.TargetedJsonItemType, vmType); 56 56 } 57 57 } … … 102 102 if(Node2VM.TryGetValue(childNode, out IJsonItemVM vm)) 103 103 vm.Selected = true; 104 104 105 } else { 105 106 TreeNode childNode = new TreeNode(c.Name); … … 126 127 Node2Control.Add(node, control); 127 128 } else { 128 //node. 129 node.ForeColor = Color.LightGray; 130 node.NodeFont = new Font(SystemFonts.DialogFont, FontStyle.Italic); 129 131 } 130 132 } … … 138 140 } 139 141 140 return b || (item.Value != null || item.Range != null || item is ILookupJsonItem || item is IResultJsonItem);142 return b || !(item is EmptyJsonItem); 141 143 } 142 144 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.resx
r17444 r17473 121 121 <value>194, 17</value> 122 122 </metadata> 123 <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 124 <value>37</value> 125 </metadata> 123 126 <metadata name="jsonItemBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 124 127 <value>17, 17</value> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs
r17471 r17473 167 167 private void InitRangeBinding() { 168 168 NumericRangeControl = numericRangeControl1; 169 NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM .MinRange));170 NumericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM .MaxRange));171 NumericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM .EnableMinRange),169 NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange)); 170 NumericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange)); 171 NumericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange), 172 172 false, DataSourceUpdateMode.OnPropertyChanged); 173 NumericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM .EnableMaxRange),173 NumericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange), 174 174 false, DataSourceUpdateMode.OnPropertyChanged); 175 175 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemRangeControl.Designer.cs
r17471 r17473 26 26 this.components = new System.ComponentModel.Container(); 27 27 this.groupBox1 = new System.Windows.Forms.GroupBox(); 28 this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 29 this.label2 = new System.Windows.Forms.Label(); 28 30 this.textBoxValueTo = new System.Windows.Forms.TextBox(); 31 this.textBoxValueFrom = new System.Windows.Forms.TextBox(); 29 32 this.label4 = new System.Windows.Forms.Label(); 30 this.label2 = new System.Windows.Forms.Label();31 33 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 32 this.textBoxValueFrom = new System.Windows.Forms.TextBox();33 this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();34 34 this.numericRangeControl = new HeuristicLab.JsonInterface.OptimizerIntegration.NumericRangeControl(); 35 35 this.groupBox1.SuspendLayout(); 36 this.tableLayoutPanel1.SuspendLayout(); 36 37 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 37 this.tableLayoutPanel1.SuspendLayout();38 38 this.SuspendLayout(); 39 39 // … … 50 50 this.groupBox1.TabStop = false; 51 51 this.groupBox1.Text = "Value"; 52 //53 // textBoxValueTo54 //55 this.textBoxValueTo.Dock = System.Windows.Forms.DockStyle.Fill;56 this.textBoxValueTo.Location = new System.Drawing.Point(100, 24);57 this.textBoxValueTo.Margin = new System.Windows.Forms.Padding(0);58 this.textBoxValueTo.Name = "textBoxValueTo";59 this.textBoxValueTo.Size = new System.Drawing.Size(394, 20);60 this.textBoxValueTo.TabIndex = 3;61 //62 // label463 //64 this.label4.AutoSize = true;65 this.label4.Dock = System.Windows.Forms.DockStyle.Fill;66 this.label4.Location = new System.Drawing.Point(0, 24);67 this.label4.Margin = new System.Windows.Forms.Padding(0);68 this.label4.Name = "label4";69 this.label4.Size = new System.Drawing.Size(100, 25);70 this.label4.TabIndex = 1;71 this.label4.Text = "To:";72 this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;73 //74 // label275 //76 this.label2.AutoSize = true;77 this.label2.Dock = System.Windows.Forms.DockStyle.Fill;78 this.label2.Location = new System.Drawing.Point(0, 0);79 this.label2.Margin = new System.Windows.Forms.Padding(0);80 this.label2.Name = "label2";81 this.label2.Size = new System.Drawing.Size(100, 24);82 this.label2.TabIndex = 0;83 this.label2.Text = "From:";84 this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;85 //86 // errorProvider87 //88 this.errorProvider.ContainerControl = this;89 //90 // textBoxValueFrom91 //92 this.textBoxValueFrom.Dock = System.Windows.Forms.DockStyle.Fill;93 this.textBoxValueFrom.Location = new System.Drawing.Point(100, 0);94 this.textBoxValueFrom.Margin = new System.Windows.Forms.Padding(0);95 this.textBoxValueFrom.Name = "textBoxValueFrom";96 this.textBoxValueFrom.Size = new System.Drawing.Size(394, 20);97 this.textBoxValueFrom.TabIndex = 2;98 52 // 99 53 // tableLayoutPanel1 … … 115 69 this.tableLayoutPanel1.Size = new System.Drawing.Size(494, 49); 116 70 this.tableLayoutPanel1.TabIndex = 19; 71 // 72 // label2 73 // 74 this.label2.AutoSize = true; 75 this.label2.Dock = System.Windows.Forms.DockStyle.Fill; 76 this.label2.Location = new System.Drawing.Point(0, 0); 77 this.label2.Margin = new System.Windows.Forms.Padding(0); 78 this.label2.Name = "label2"; 79 this.label2.Size = new System.Drawing.Size(100, 24); 80 this.label2.TabIndex = 0; 81 this.label2.Text = "From:"; 82 this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 83 // 84 // textBoxValueTo 85 // 86 this.textBoxValueTo.Dock = System.Windows.Forms.DockStyle.Fill; 87 this.textBoxValueTo.Location = new System.Drawing.Point(100, 24); 88 this.textBoxValueTo.Margin = new System.Windows.Forms.Padding(0); 89 this.textBoxValueTo.Name = "textBoxValueTo"; 90 this.textBoxValueTo.Size = new System.Drawing.Size(394, 20); 91 this.textBoxValueTo.TabIndex = 3; 92 // 93 // textBoxValueFrom 94 // 95 this.textBoxValueFrom.Dock = System.Windows.Forms.DockStyle.Fill; 96 this.textBoxValueFrom.Location = new System.Drawing.Point(100, 0); 97 this.textBoxValueFrom.Margin = new System.Windows.Forms.Padding(0); 98 this.textBoxValueFrom.Name = "textBoxValueFrom"; 99 this.textBoxValueFrom.Size = new System.Drawing.Size(394, 20); 100 this.textBoxValueFrom.TabIndex = 2; 101 // 102 // label4 103 // 104 this.label4.AutoSize = true; 105 this.label4.Dock = System.Windows.Forms.DockStyle.Fill; 106 this.label4.Location = new System.Drawing.Point(0, 24); 107 this.label4.Margin = new System.Windows.Forms.Padding(0); 108 this.label4.Name = "label4"; 109 this.label4.Size = new System.Drawing.Size(100, 25); 110 this.label4.TabIndex = 1; 111 this.label4.Text = "To:"; 112 this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 113 // 114 // errorProvider 115 // 116 this.errorProvider.ContainerControl = this; 117 117 // 118 118 // numericRangeControl … … 137 137 this.Size = new System.Drawing.Size(500, 147); 138 138 this.groupBox1.ResumeLayout(false); 139 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();140 139 this.tableLayoutPanel1.ResumeLayout(false); 141 140 this.tableLayoutPanel1.PerformLayout(); 141 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 142 142 this.ResumeLayout(false); 143 143 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemRangeControl.cs
r17464 r17473 32 32 33 33 private void InitNumbericRangeControl() { 34 numericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM .MinRange));35 numericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM .MaxRange));36 numericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM .EnableMinRange),34 numericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange)); 35 numericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange)); 36 numericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange), 37 37 false, DataSourceUpdateMode.OnPropertyChanged); 38 numericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM .EnableMaxRange),38 numericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange), 39 39 false, DataSourceUpdateMode.OnPropertyChanged); 40 40 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.cs
r17464 r17473 12 12 public partial class JsonItemValidValuesControl : UserControl { 13 13 14 IJsonItemVM VM { get; set; }14 StringValueVM VM { get; set; } 15 15 16 16 public JsonItemValidValuesControl(StringValueVM vm) { 17 17 InitializeComponent(); 18 18 VM = vm; 19 if (VM.Item. Range!= null) {20 foreach (var i in VM.Item. Range)21 SetupOption( (string)i);19 if (VM.Item.ConcreteRestrictedItems != null) { 20 foreach (var i in VM.Item.ConcreteRestrictedItems) 21 SetupOption(i); 22 22 comboBoxValues.DataBindings.Add("SelectedItem", VM, nameof(StringValueVM.Value)); 23 23 } else { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValueControl.cs
r17471 r17473 58 58 protected void Init() { 59 59 TBValue.DataBindings.Add("Text", VM, ValuePropertyId); 60 NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM .MinRange));61 NumericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM .MaxRange));62 NumericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM .EnableMinRange),60 NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange)); 61 NumericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange)); 62 NumericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange), 63 63 false, DataSourceUpdateMode.OnPropertyChanged); 64 NumericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM .EnableMaxRange),64 NumericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange), 65 65 false, DataSourceUpdateMode.OnPropertyChanged); 66 66 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ValueLookupJsonItemControl.Designer.cs
r17471 r17473 1 namespace HeuristicLab.JsonInterface.OptimizerIntegration .Views{1 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 2 2 partial class ValueLookupJsonItemControl { 3 3 /// <summary> … … 29 29 // content 30 30 // 31 this.content.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 32 | System.Windows.Forms.AnchorStyles.Left) 33 | System.Windows.Forms.AnchorStyles.Right))); 34 this.content.Location = new System.Drawing.Point(0, 20); 31 this.content.Dock = System.Windows.Forms.DockStyle.Fill; 32 this.content.Location = new System.Drawing.Point(0, 22); 35 33 this.content.Margin = new System.Windows.Forms.Padding(0); 36 34 this.content.Name = "content"; 37 this.content.Size = new System.Drawing.Size(651, 350); 35 this.content.Padding = new System.Windows.Forms.Padding(0, 3, 0, 0); 36 this.content.Size = new System.Drawing.Size(500, 523); 38 37 this.content.TabIndex = 14; 39 38 // … … 44 43 this.Controls.Add(this.content); 45 44 this.Name = "ValueLookupJsonItemControl"; 46 this.Size = new System.Drawing.Size( 651, 370);45 this.Size = new System.Drawing.Size(500, 545); 47 46 this.Controls.SetChildIndex(this.content, 0); 48 47 this.ResumeLayout(false); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ValueLookupJsonItemControl.cs
r17471 r17473 10 10 using HeuristicLab.PluginInfrastructure; 11 11 12 namespace HeuristicLab.JsonInterface.OptimizerIntegration .Views{12 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 13 13 public partial class ValueLookupJsonItemControl : LookupJsonItemControl { 14 private IDictionary<Type, Type> JI2VM { get; set; }14 private static IDictionary<Type, Type> JI2VM { get; set; } 15 15 16 public ValueLookupJsonItemControl() {17 InitializeComponent();18 }19 16 public ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) : base(vm) { 20 17 InitializeComponent(); 21 18 InitCache(); 22 if ( JI2VM.TryGetValue(vm.JsonItemReference.GetType(), out Type vmType)) {19 if (vm.JsonItemReference != null && JI2VM.TryGetValue(vm.JsonItemReference.GetType(), out Type vmType)) { 23 20 IJsonItemVM tmp = (IJsonItemVM)Activator.CreateInstance(vmType); 24 content.Controls.Add(tmp.Control); 25 } else { 26 //node. 21 tmp.Item = vm.JsonItemReference; 22 content.Controls.Clear(); 23 UserControl control = tmp.Control; 24 content.Controls.Add(control); 25 control.Dock = DockStyle.Fill; 26 27 27 } 28 28 } 29 29 30 30 private void InitCache() { 31 JI2VM = new Dictionary<Type, Type>(); 32 foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) { 33 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); 34 JI2VM.Add(vm.JsonItemType, vmType); 31 if(JI2VM == null) { 32 JI2VM = new Dictionary<Type, Type>(); 33 foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) { 34 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); 35 JI2VM.Add(vm.TargetedJsonItemType, vmType); 36 } 35 37 } 36 38 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs
r17433 r17473 19 19 parameter.ActualValue = x; 20 20 21 if (parameter.ActualValue is IParameterizedItem &&cdata.Children != null) {21 if (parameter.ActualValue != null && /*parameter.ActualValue is IParameterizedItem &&*/ cdata.Children != null) { 22 22 foreach(var param in cdata.Children) { 23 23 if(param.Name == parameter.ActualValue.ItemName) … … 34 34 Description = value.ItemDescription, 35 35 Value = parameter.ActualValue?.ToString(), 36 Range= GetValidValues(parameter).Select(x => x.ToString())36 ConcreteRestrictedItems = GetValidValues(parameter).Select(x => x.ToString()) 37 37 }; 38 38 item.AddChildren(GetParameterizedChilds(parameter)); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/EnumTypeConverter.cs
r17433 r17473 24 24 Description = value.ItemDescription, 25 25 Value = Enum.GetName(enumType, val), 26 Range= Enum.GetNames(enumType)26 ConcreteRestrictedItems = Enum.GetNames(enumType) 27 27 }; 28 28 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/MultiCheckedOperatorConverter.cs
r17439 r17473 19 19 IJsonItem childItem = GetChildItem(op.Name, data); 20 20 if(childItem != null) { 21 if(childItem .Value is bool b) {22 val.Operators.SetItemCheckedState(op, b );21 if(childItem is BoolJsonItem boolJsonItem) { 22 val.Operators.SetItemCheckedState(op, boolJsonItem.Value); 23 23 } 24 24 root.Inject((IItem)op, childItem, root); … … 34 34 Name = op.Name, 35 35 Description = op.Description, 36 Value = val.Operators.ItemChecked(op), 37 Range = new bool[] { false, true } 36 Value = val.Operators.ItemChecked(op) 38 37 }; 39 38 IJsonItem c = root.Extract((IItem)op, root); … … 49 48 private bool GetOperatorState(string name, IJsonItem data) { 50 49 foreach(var op in data.Children) { 51 if (op.Name == name && op .Value is bool) return (bool)op.Value;50 if (op.Name == name && op is BoolJsonItem b) return b.Value; 52 51 } 53 52 return false; … … 55 54 56 55 private IJsonItem GetChildItem(string name, IJsonItem parent) { 56 if (parent.Children == null) return null; 57 57 foreach(var c in parent.Children) { 58 58 if (c.Name == name) return c; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs
r17433 r17473 24 24 var parameterizedItem = value as IParameterizedItem; 25 25 26 IJsonItem item = new JsonItem() {26 IJsonItem item = new EmptyJsonItem() { 27 27 Name = value.ItemName, 28 28 Description = value.ItemDescription -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17471 r17473 31 31 var dataInfo = dataset.GetType().GetField("variableValues", flags); 32 32 dataInfo.SetValue(dataset, dictTmp); 33 val.TargetVariable = ( string)data.Children[3].Value;34 val.TrainingPartition.Start = ((IntRangeJsonItem)data.Children[2]). Value.First();35 val.TrainingPartition.End = ((IntRangeJsonItem)data.Children[2]). Value.Last();36 val.TestPartition.Start = ((IntRangeJsonItem)data.Children[1]). Value.First();37 val.TestPartition.End = ((IntRangeJsonItem)data.Children[1]). Value.Last();33 val.TargetVariable = ((StringJsonItem)data.Children[3]).Value; 34 val.TrainingPartition.Start = ((IntRangeJsonItem)data.Children[2]).MinValue; 35 val.TrainingPartition.End = ((IntRangeJsonItem)data.Children[2]).MaxValue; 36 val.TestPartition.Start = ((IntRangeJsonItem)data.Children[1]).MinValue; 37 val.TestPartition.End = ((IntRangeJsonItem)data.Children[1]).MaxValue; 38 38 } 39 39 40 40 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { 41 IJsonItem item = new JsonItem() {41 IJsonItem item = new EmptyJsonItem() { 42 42 Name = value.ItemName, 43 43 Description = value.ItemDescription … … 71 71 Name = "Dataset", 72 72 Value = mat, 73 RowNames = rowNames 73 RowNames = rowNames, 74 Minimum = double.MinValue, 75 Maximum = double.MaxValue 74 76 }); 75 77 } … … 80 82 item.AddChildren(new IntRangeJsonItem() { 81 83 Name = "TestPartition", 82 Value = new int[] { testPartition.Start, testPartition.End }, 83 Range = new int[] { 0, Math.Max(testPartition.End, trainingPartition.End) } 84 MinValue = testPartition.Start, 85 MaxValue = testPartition.End, 86 Minimum = 0, 87 Maximum = Math.Max(testPartition.End, trainingPartition.End) 84 88 }); 85 89 … … 87 91 item.AddChildren(new IntRangeJsonItem() { 88 92 Name = "TrainingPartition", 89 Value = new int[] { trainingPartition.Start, trainingPartition.End }, 90 Range = new int[] { 0, Math.Max(testPartition.End, trainingPartition.End)} 93 MinValue = trainingPartition.Start, 94 MaxValue = trainingPartition.End, 95 Minimum = 0, 96 Maximum = Math.Max(testPartition.End, trainingPartition.End) 91 97 }); 92 98 93 99 IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables; 94 item.AddChildren(new JsonItem() {100 item.AddChildren(new StringJsonItem() { 95 101 Name = "TargetVariable", 96 Value = ( object)targetVariable,97 Range= variables.Select(x => x.Value)102 Value = (string)targetVariable, 103 ConcreteRestrictedItems = variables.Select(x => x.Value) 98 104 }); 99 105 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs
r17471 r17473 17 17 return new ResultJsonItem() { 18 18 Name = res.ActualName, 19 Value = res.ActualName,20 19 Description = res.Description 21 20 }; … … 24 23 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 25 24 IResultParameter res = item as IResultParameter; 26 res.ActualName = (string)data.Value;25 res.ActualName = data.Name; 27 26 } 28 27 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/StringValueConverter.cs
r17443 r17473 17 17 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 18 18 new StringJsonItem() { 19 Name = "[OverridableParamName]", 19 //Name = "[OverridableParamName]", 20 Name = value.ItemName, 20 21 Description = value.ItemDescription, 21 22 Value = ((StringValue)value).Value -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs
r17471 r17473 13 13 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 14 14 IValueLookupParameter param = item as IValueLookupParameter; 15 param.ActualName = CastValue<string>(((IValueLookupJsonItem)data).ActualName); 15 IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem; 16 param.ActualName = lookupItem.ActualName; 16 17 if (param.Value != null) 17 root.Inject(param.Value, data, root);18 root.Inject(param.Value, lookupItem.JsonItemReference, root); 18 19 } 19 20 … … 25 26 if (param.Value != null) { 26 27 IJsonItem tmp = root.Extract(param.Value, root); 27 item.Value = tmp.Value;28 item.Range = tmp.Range;29 item.Name = tmp.Name;30 item.Description = tmp.Description;31 28 item.AddChildren(tmp.Children); 32 item.Active = tmp.Active;33 29 item.JsonItemReference = tmp; 34 } else {35 var min = GetMinValue(param.DataType);36 var max = GetMaxValue(param.DataType);37 if (min != null && max != null)38 item.Range = new object[] { min, max };39 else40 item.Range = null;41 30 } 42 31 item.Name = param.Name; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs
r17439 r17473 14 14 IParameter parameter = value as IParameter; 15 15 16 if (parameter.ActualValue == null && data.Value != null)16 if (parameter.ActualValue == null) 17 17 parameter.ActualValue = Instantiate(parameter.DataType); 18 18 … … 21 21 root.Inject(parameter.ActualValue, data, root); 22 22 else 23 root.Inject(parameter.ActualValue, data.Children?.First(), root);23 root.Inject(parameter.ActualValue, /*data.Children?.First()*/ data, root); 24 24 25 25 } … … 29 29 IParameter parameter = value as IParameter; 30 30 31 IJsonItem item = new JsonItem() {31 IJsonItem item = new EmptyJsonItem() { 32 32 Name = parameter.Name, 33 33 Description = parameter.Description … … 37 37 IJsonItem tmp = root.Extract(parameter.ActualValue, root); 38 38 if (!(tmp is UnsupportedJsonItem)) { 39 tmp.Name = parameter.Name; 40 tmp.Description = parameter.Description; 41 item = tmp; 42 /* 39 43 if (tmp.Name == "[OverridableParamName]") { 40 44 tmp.Name = parameter.Name; … … 44 48 } else 45 49 item.AddChildren(tmp); 50 */ 46 51 } 47 52 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs
r17451 r17473 18 18 IntRange range = item as IntRange; 19 19 IntRangeJsonItem cdata = data as IntRangeJsonItem; 20 range.Start = cdata. Value[0];21 range.End = cdata. Value[1];20 range.Start = cdata.MinValue; 21 range.End = cdata.MaxValue; 22 22 } 23 23 … … 25 25 IntRange range = value as IntRange; 26 26 return new IntRangeJsonItem() { 27 Name = "[OverridableParamName]", 27 //Name = "[OverridableParamName]", 28 Name = value.ItemName, 28 29 Description = value.ItemDescription, 29 Value = new int[] { range.Start, range.End }, 30 Range = new int[] { int.MinValue, int.MaxValue } 30 MinValue = range.Start, 31 MaxValue = range.End, 32 Minimum = int.MinValue, 33 Maximum = int.MaxValue 31 34 }; 32 35 } … … 40 43 DoubleRange range = item as DoubleRange; 41 44 DoubleRangeJsonItem cdata = data as DoubleRangeJsonItem; 42 range.Start = cdata. Value[0];43 range.End = cdata. Value[1];45 range.Start = cdata.MinValue; 46 range.End = cdata.MaxValue; 44 47 } 45 48 … … 47 50 DoubleRange range = value as DoubleRange; 48 51 return new DoubleRangeJsonItem() { 49 Name = "[OverridableParamName]", 52 //Name = "[OverridableParamName]", 53 Name = value.ItemName, 50 54 Description = value.ItemDescription, 51 Value = new double[] { range.Start, range.End }, 52 Range = new double[] { double.MinValue, double.MaxValue } 55 MinValue = range.Start, 56 MaxValue = range.End, 57 Minimum = double.MinValue, 58 Maximum = double.MaxValue 53 59 }; 54 60 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs
r17451 r17473 30 30 Description = value.ItemDescription, 31 31 Value = ((IntArray)value).CloneAsArray(), 32 Range = new int[] { int.MinValue, int.MaxValue } 32 Minimum = int.MinValue, 33 Maximum = int.MaxValue 33 34 }; 34 35 } … … 56 57 Description = value.ItemDescription, 57 58 Value = ((DoubleArray)value).CloneAsArray(), 58 Range = new double[] { double.MinValue, double.MaxValue } 59 Minimum = double.MinValue, 60 Maximum = double.MaxValue 59 61 }; 60 62 } … … 80 82 Description = value.ItemDescription, 81 83 Value = ((PercentArray)value).CloneAsArray(), 82 Range = new double[] { 0.0d, 1.0d } 84 Minimum = 0.0d, 85 Maximum = 1.0d 83 86 }; 84 87 } … … 101 104 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 102 105 new BoolArrayJsonItem() { 103 Name = "[OverridableParamName]", 106 //Name = "[OverridableParamName]", 107 Name = value.ItemName, 104 108 Description = value.ItemDescription, 105 Value = ((BoolArray)value).CloneAsArray(), 106 Range = new bool[] { false, true } 109 Value = ((BoolArray)value).CloneAsArray() 107 110 }; 108 111 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs
r17471 r17473 23 23 Description = value.ItemDescription, 24 24 Value = Transform((IntMatrix)value), 25 Range = new int[] { int.MinValue, int.MaxValue } 25 Minimum = int.MinValue, 26 Maximum = int.MaxValue 26 27 }; 27 28 } … … 42 43 Description = value.ItemDescription, 43 44 Value = Transform((DoubleMatrix)value), 44 Range = new double[] { double.MinValue, double.MaxValue }, 45 Minimum = double.MinValue, 46 Maximum = double.MaxValue, 45 47 RowNames = ((DoubleMatrix)value).RowNames, 46 48 ColumnNames = ((DoubleMatrix)value).ColumnNames … … 63 65 Description = value.ItemDescription, 64 66 Value = Transform((PercentMatrix)value), 65 Range = new double[] { 0.0d, 1.0d } 67 Minimum = 0.0d, 68 Maximum = 1.0d 66 69 }; 67 70 } … … 79 82 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 80 83 new BoolMatrixJsonItem() { 81 Name = "[OverridableParamName]", 84 //Name = "[OverridableParamName]", 85 Name = value.ItemName, 82 86 Description = value.ItemDescription, 83 Value = Transform((BoolMatrix)value), 84 Range = new bool[] { false, true } 87 Value = Transform((BoolMatrix)value) 85 88 }; 86 89 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeValueConverter.cs
r17433 r17473 18 18 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 19 19 new IntJsonItem() { 20 Name = "[OverridableParamName]", 20 //Name = "[OverridableParamName]", 21 Name = value.ItemName, 21 22 Description = value.ItemDescription, 22 23 Value = ((IntValue)value).Value, 23 Range = new int[] { int.MinValue, int.MaxValue } 24 Minimum = int.MinValue, 25 Maximum = int.MaxValue 24 26 }; 25 27 } … … 34 36 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 35 37 new DoubleJsonItem() { 36 Name = "[OverridableParamName]", 38 //Name = "[OverridableParamName]", 39 Name = value.ItemName, 37 40 Description = value.ItemDescription, 38 41 Value = ((DoubleValue)value).Value, 39 Range = new double[] { double.MinValue, double.MaxValue } 42 Minimum = double.MinValue, 43 Maximum = double.MaxValue 40 44 }; 41 45 } … … 50 54 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 51 55 new DoubleJsonItem() { 52 Name = "[OverridableParamName]", 56 //Name = "[OverridableParamName]", 57 Name = value.ItemName, 53 58 Description = value.ItemDescription, 54 59 Value = ((PercentValue)value).Value, 55 Range = new double[] { double.MinValue, double.MaxValue } 60 Minimum = double.MinValue, 61 Maximum = double.MaxValue 56 62 }; 57 63 } … … 66 72 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 67 73 new BoolJsonItem() { 68 Name = "[OverridableParamName]", 74 //Name = "[OverridableParamName]", 75 Name = value.ItemName, 69 76 Description = value.ItemDescription, 70 Value = ((BoolValue)value).Value, 71 Range = new bool[] { false, true } 77 Value = ((BoolValue)value).Value 72 78 }; 73 79 } … … 82 88 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 83 89 new DateTimeJsonItem() { 84 Name = "[OverridableParamName]", 90 //Name = "[OverridableParamName]", 91 Name = value.ItemName, 85 92 Description = value.ItemDescription, 86 93 Value = ((DateTimeValue)value).Value, 87 Range = new DateTime[] { DateTime.MinValue, DateTime.MaxValue } 94 Minimum = DateTime.MinValue, 95 Maximum = DateTime.MaxValue 88 96 }; 89 97 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
r17471 r17473 68 68 <Compile Include="Converters\ValueRangeConverter.cs" /> 69 69 <Compile Include="Interfaces\IArrayJsonItem.cs" /> 70 <Compile Include="Interfaces\IConcreteRestrictedJsonItem.cs" /> 71 <Compile Include="Interfaces\IIntervalRestrictedJsonItem.cs" /> 70 72 <Compile Include="Interfaces\IJsonItem.cs" /> 71 73 <Compile Include="Interfaces\IJsonItemValidator.cs" /> 72 74 <Compile Include="Interfaces\ILookupJsonItem.cs" /> 73 75 <Compile Include="Interfaces\IMatrixJsonItem.cs" /> 76 <Compile Include="Interfaces\IRangedJsonItem.cs" /> 74 77 <Compile Include="Interfaces\IResultJsonItem.cs" /> 78 <Compile Include="Interfaces\IValueJsonItem.cs" /> 75 79 <Compile Include="Interfaces\IValueLookupJsonItem.cs" /> 76 <Compile Include="Models\ArrayJsonItem Base.cs" />80 <Compile Include="Models\ArrayJsonItem.cs" /> 77 81 <Compile Include="Models\BoolJsonItems.cs" /> 82 <Compile Include="Models\ConcreteRestrictedArrayJsonItem.cs" /> 83 <Compile Include="Models\ConcreteRestrictedValueJsonItem.cs" /> 78 84 <Compile Include="Models\DateTimeJsonItem.cs" /> 79 85 <Compile Include="Models\DoubleJsonItems.cs" /> 80 <Compile Include="Models\GenericJsonItem.cs" /> 86 <Compile Include="Models\EmptyJsonItem.cs" /> 87 <Compile Include="Models\IntervalRestrictedArrayJsonItem.cs" /> 88 <Compile Include="Models\IntervalRestrictedMatrixJsonItem.cs" /> 89 <Compile Include="Models\IntervalRestrictedValueJsonItem.cs" /> 81 90 <Compile Include="Models\IntJsonItems.cs" /> 82 91 <Compile Include="Models\JsonItem.cs" /> 83 92 <Compile Include="Models\LookupJsonItem.cs" /> 84 <Compile Include="Models\MatrixJsonItemBase.cs" /> 93 <Compile Include="Models\MatrixJsonItem.cs" /> 94 <Compile Include="Models\RangedJsonItem.cs" /> 85 95 <Compile Include="Models\ResultJsonItem.cs" /> 86 96 <Compile Include="Models\StringJsonItem.cs" /> 87 97 <Compile Include="Models\UnsupportedJsonItem.cs" /> 98 <Compile Include="Models\ValueJsonItem.cs" /> 88 99 <Compile Include="Models\ValueLookupJsonItem.cs" /> 89 100 <Compile Include="SingleLineArrayJsonWriter.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IArrayJsonItem.cs
r17446 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public interface IArrayJsonItem : I JsonItem {8 public interface IArrayJsonItem : IValueJsonItem { 9 9 bool Resizable { get; set; } 10 10 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs
r17471 r17473 24 24 IJsonItem Parent { get; set; } 25 25 26 object Value { get; set; }26 //object Value { get; set; } 27 27 28 IEnumerable<object> Range { get; set; }28 //IEnumerable<object> Range { get; set; } 29 29 30 30 IJsonItemValidator GetValidator(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IMatrixJsonItem.cs
r17471 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public interface IMatrixJsonItem : I JsonItem {8 public interface IMatrixJsonItem : IValueJsonItem { 9 9 bool RowsResizable { get; set; } 10 10 bool ColumnsResizable { get; set; } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs
r17471 r17473 62 62 IEnumerable<IJsonItem> children = item.Children; 63 63 64 if (item.Active && (item.Value != null || item.Range != null || item is IResultJsonItem || item is ILookupJsonItem)) {64 if (item.Active && !(item is EmptyJsonItem)) { 65 65 jsonItems.Add(item); 66 66 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
r17446 r17473 105 105 instData.Objects.Add(tmp.Path, tmp); 106 106 } 107 //IList<IJsonItem> faultyItems = new List<IJsonItem>(); 108 //root.GetValidator().Validate(ref faultyItems); 107 109 } 108 110 … … 113 115 // override default value 114 116 if (instData.Objects.TryGetValue(path, out IJsonItem param)) { 115 // save range from template 116 IEnumerable<object> tmpRange = param.Range; 117 // remove fixed template parameter => dont allow to copy them from concrete config 118 obj.Property(nameof(IIntervalRestrictedJsonItem<int>.Minimum))?.Remove(); 119 obj.Property(nameof(IIntervalRestrictedJsonItem<int>.Maximum))?.Remove(); 120 obj.Property(nameof(IConcreteRestrictedJsonItem<string>.ConcreteRestrictedItems))?.Remove(); 121 // merge 117 122 param.SetFromJObject(obj); 118 // set range from template119 param.Range = tmpRange;120 123 } else throw new InvalidDataException($"No parameter with path='{path}' defined!"); 121 124 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ArrayJsonItem.cs
r17472 r17473 7 7 8 8 namespace HeuristicLab.JsonInterface { 9 public class ArrayJsonItemBase<T> : JsonItem<T[], T>, IArrayJsonItem {9 public abstract class ArrayJsonItem<T> : ValueJsonItem<T[]>, IArrayJsonItem { 10 10 public virtual bool Resizable { get; set; } 11 11 public override void SetFromJObject(JObject jObject) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/BoolJsonItems.cs
r17446 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class BoolJsonItem : JsonItem<bool> { } 8 public class BoolJsonItem : ValueJsonItem<bool> { 9 protected override bool Validate() => true; 10 } 9 11 10 public class BoolArrayJsonItem : ArrayJsonItemBase<bool> { } 12 public class BoolArrayJsonItem : ArrayJsonItem<bool> { 13 protected override bool Validate() => true; 14 } 11 15 12 public class BoolMatrixJsonItem : MatrixJsonItemBase<bool> { } 16 public class BoolMatrixJsonItem : MatrixJsonItem<bool> { 17 protected override bool Validate() => true; 18 } 13 19 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DateTimeJsonItem.cs
r17446 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class DateTimeJsonItem : JsonItem<DateTime> { } 8 public class DateTimeJsonItem : IntervalRestrictedValueJsonItem<DateTime> { 9 protected override bool Validate() => Minimum.CompareTo(Value) >= 0 && Maximum.CompareTo(Value) <= 0; 10 } 9 11 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DoubleJsonItems.cs
r17471 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class DoubleJsonItem : JsonItem<double> { } 9 public class DoubleArrayJsonItem : ArrayJsonItemBase<double> { } 10 public class DoubleRangeJsonItem : ArrayJsonItemBase<double> { 11 public override bool Resizable { get => false; set { } } 12 } 8 public class DoubleJsonItem : IntervalRestrictedValueJsonItem<double> { } 9 public class DoubleArrayJsonItem : IntervalRestrictedArrayJsonItem<double> { } 10 public class DoubleRangeJsonItem : RangedJsonItem<double> { } 13 11 14 public class DoubleMatrixJsonItem : MatrixJsonItemBase<double> { 12 public class DoubleMatrixJsonItem : IntervalRestrictedMatrixJsonItem<double> { 13 /* 15 14 protected override bool IsInRange() { 16 15 for (int c = 0; c < Value.Length; ++c) { … … 22 21 return true; 23 22 } 23 */ 24 24 } 25 25 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntJsonItems.cs
r17471 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class IntJsonItem : JsonItem<int> { 9 //public new IEnumerable<int> Range { get; } 8 public class IntJsonItem : IntervalRestrictedValueJsonItem<int> { } 9 public class IntArrayJsonItem : IntervalRestrictedArrayJsonItem<int> { } 10 public class IntRangeJsonItem : RangedJsonItem<int> { } 11 public class IntMatrixJsonItem : IntervalRestrictedMatrixJsonItem<int> { 10 12 /* 11 public int MinValue { get; set; }12 public int MaxValue { get; set; }13 */14 }15 public class IntArrayJsonItem : ArrayJsonItemBase<int> { }16 public class IntRangeJsonItem : ArrayJsonItemBase<int> {17 public override bool Resizable { get => false; set { } }18 }19 public class IntMatrixJsonItem : MatrixJsonItemBase<int> {20 21 13 protected override bool IsInRange() { 22 14 for (int c = 0; c < Value.Length; ++c) { … … 28 20 return true; 29 21 } 22 */ 30 23 } 31 24 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs
r17471 r17473 11 11 /// Main data class for json interface. 12 12 /// </summary> 13 public class JsonItem : IJsonItem {13 public abstract class JsonItem : IJsonItem { 14 14 15 15 public class JsonItemValidator : IJsonItemValidator { … … 25 25 } 26 26 27 // TODO: return ValidationResult ? 27 28 private bool ValidateHelper(JsonItem item, ref IList<IJsonItem> faultyItems) { 28 29 int hash = item.GetHashCode(); … … 30 31 return r; 31 32 32 bool res = true; 33 if (item.Value != null && item.Range != null) 34 res = item.IsInRange(); 33 bool res = item.Validate(); 35 34 if (!res) faultyItems.Add(item); 36 35 Cache.Add(hash, res); 37 if(item.Children != null) 36 if(item.Children != null) { 38 37 foreach (var child in item.Children) 39 res = res && ValidateHelper(child as JsonItem, ref faultyItems); 38 if (!ValidateHelper(child as JsonItem, ref faultyItems)) 39 res = false && res; 40 } 40 41 return res; 41 42 } … … 62 63 } 63 64 64 public virtual object Value { get; set; }65 //public virtual object Value { get; set; } 65 66 66 public virtual IEnumerable<object> Range { get; set; }67 //public virtual IEnumerable<object> Range { get; set; } 67 68 68 69 // TODO jsonIgnore dataType? … … 105 106 106 107 public virtual void SetFromJObject(JObject jObject) { 107 Value = jObject[nameof(IJsonItem.Value)]?.ToObject<object>();108 Range = jObject[nameof(IJsonItem.Range)]?.ToObject<object[]>();108 //Value = jObject[nameof(IJsonItem.Value)]?.ToObject<object>(); 109 //Range = jObject[nameof(IJsonItem.Range)]?.ToObject<object[]>(); 109 110 } 110 111 #endregion … … 114 115 * TODO protected abstract bool Validate(); 115 116 */ 116 117 protected abstract bool Validate(); 118 /* 117 119 protected virtual bool IsInRange() { 118 120 bool b1 = true, b2 = true; … … 156 158 (((T)max).CompareTo(value) == 1 || ((T)max).CompareTo(value) == 0); 157 159 } 160 */ 158 161 #endregion 159 162 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/LookupJsonItem.cs
r17471 r17473 14 14 ActualName = jObject[nameof(ILookupJsonItem.ActualName)]?.ToString(); 15 15 } 16 17 protected override bool Validate() => true; 16 18 } 17 19 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/MatrixJsonItem.cs
r17472 r17473 7 7 8 8 namespace HeuristicLab.JsonInterface { 9 public class MatrixJsonItemBase<T> : JsonItem<T[][], T>, IMatrixJsonItem {9 public abstract class MatrixJsonItem<T> : ValueJsonItem<T[][]>, IMatrixJsonItem { 10 10 public virtual bool RowsResizable { get; set; } 11 11 public virtual bool ColumnsResizable { get; set; } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ResultJsonItem.cs
r17471 r17473 7 7 namespace HeuristicLab.JsonInterface { 8 8 public class ResultJsonItem : JsonItem, IResultJsonItem { 9 9 protected override bool Validate() => true; 10 10 } 11 11 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/StringJsonItem.cs
r17451 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class StringJsonItem : JsonItem<string> { }9 public class StringArrayJsonItem : JsonItem<string[],string> { }8 public class StringJsonItem : ConcreteRestrictedValueJsonItem<string> { } 9 public class StringArrayJsonItem : ConcreteRestrictedArrayJsonItem<string> { } 10 10 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/UnsupportedJsonItem.cs
r17471 r17473 34 34 } 35 35 36 public override object Value { 37 get => throw new NotSupportedException(); 38 set => throw new NotSupportedException(); 39 } 40 41 public override IEnumerable<object> Range { 42 get => throw new NotSupportedException(); 43 set => throw new NotSupportedException(); 44 } 36 protected override bool Validate() => true; 45 37 } 46 38 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ValueLookupJsonItem.cs
r17471 r17473 10 10 [JsonIgnore] 11 11 public IJsonItem JsonItemReference { get; set; } 12 13 protected override bool Validate() { 14 if (JsonItemReference == null) return true; 15 IList<IJsonItem> faultyItems = new List<IJsonItem>(); 16 return JsonItemReference.GetValidator().Validate(ref faultyItems); 17 } 12 18 } 13 19 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/SingleLineArrayJsonWriter.cs
r17442 r17473 19 19 base.Formatting = Formatting.Indented; 20 20 base.WritePropertyName(name); 21 isRangeArray = name == nameof(IJsonItem.Range) || name == nameof(IJsonItem.Value); 21 isRangeArray = 22 name == nameof(IConcreteRestrictedJsonItem<int>.ConcreteRestrictedItems) || 23 name == nameof(IValueJsonItem.Value) || 24 name == nameof(IMatrixJsonItem.RowNames) || 25 name == nameof(IMatrixJsonItem.ColumnNames); 22 26 } 23 27 -
branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs
r17451 r17473 46 46 47 47 IJsonItem root = JsonItemConverter.Extract(alg); 48 var x = root.Children[0]; 49 root.Children.Remove(x); 50 x.Parent = null; 48 ActivateJsonItems(root); 49 //var x = root.Children[0]; 50 //root.Children.Remove(x); 51 //x.Parent = null; 51 52 52 53 … … 64 65 65 66 } 67 68 private static void ActivateJsonItems(IJsonItem item) { 69 item.Active = true; 70 if(item.Children != null) { 71 foreach (var x in item.Children) 72 ActivateJsonItems(x); 73 } 74 } 66 75 } 67 76 }
Note: See TracChangeset
for help on using the changeset viewer.