Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2665


Ignore:
Timestamp:
01/21/10 05:10:12 (15 years ago)
Author:
swagner
Message:

Continued work on adapting and refactoring HeuristicLab.Data according to the changes in HeuristicLab.Core (#95)

Location:
trunk/sources
Files:
8 added
16 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj

    r2664 r2665  
    5959    </Compile>
    6060    <Compile Include="Auxiliary.cs" />
    61     <Compile Include="DefaultItemView.cs">
    62       <SubType>UserControl</SubType>
    63     </Compile>
    64     <Compile Include="DefaultItemView.Designer.cs">
    65       <DependentUpon>DefaultItemView.cs</DependentUpon>
    66     </Compile>
    6761    <Compile Include="EngineView.cs">
    6862      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Core.Views/3.3/ParameterView.cs

    r2664 r2665  
    3333  /// The visual representation of a <see cref="Parameter"/>.
    3434  /// </summary>
    35   [Content(typeof(IParameter), true)]
     35  [Content(typeof(Parameter), true)]
    3636  public partial class ParameterView : NamedItemView {
    3737    /// <summary>
     
    4040    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    4141    /// No own data storage present.</remarks>
    42     public IParameter Parameter {
    43       get { return (IParameter)Item; }
     42    public Parameter Parameter {
     43      get { return (Parameter)Item; }
    4444      set { base.Item = value; }
    4545    }
     
    5757    /// <remarks>Calls <see cref="VariableView()"/>.</remarks>
    5858    /// <param name="variable">The variable to represent visually.</param>
    59     public ParameterView(IParameter parameter)
     59    public ParameterView(Parameter parameter)
    6060      : this() {
    6161      Parameter = parameter;
  • trunk/sources/HeuristicLab.Core.Views/3.3/ViewHost.Designer.cs

    r2655 r2665  
    4646    private void InitializeComponent() {
    4747      this.viewPanel = new System.Windows.Forms.Panel();
     48      this.messageLabel = new System.Windows.Forms.Label();
    4849      this.viewLabel = new System.Windows.Forms.Label();
    4950      this.viewComboBox = new System.Windows.Forms.ComboBox();
     
    5960      this.viewPanel.Size = new System.Drawing.Size(227, 157);
    6061      this.viewPanel.TabIndex = 2;
     62      //
     63      // messageLabel
     64      //
     65      this.messageLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     66                  | System.Windows.Forms.AnchorStyles.Right)));
     67      this.messageLabel.Location = new System.Drawing.Point(3, 24);
     68      this.messageLabel.Name = "messageLabel";
     69      this.messageLabel.Size = new System.Drawing.Size(221, 20);
     70      this.messageLabel.TabIndex = 0;
     71      this.messageLabel.Text = "No view available.";
     72      this.messageLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
    6173      //
    6274      // viewLabel
     
    8597      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    8698      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     99      this.Controls.Add(this.messageLabel);
    87100      this.Controls.Add(this.viewComboBox);
    88101      this.Controls.Add(this.viewLabel);
     
    100113    private System.Windows.Forms.Label viewLabel;
    101114    private System.Windows.Forms.ComboBox viewComboBox;
     115    private System.Windows.Forms.Label messageLabel;
    102116
    103117  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ViewHost.cs

    r2655 r2665  
    5353      viewComboBox.Enabled = false;
    5454      viewComboBox.Visible = false;
     55      messageLabel.Visible = false;
    5556      if (viewPanel.Controls.Count > 0) viewPanel.Controls[0].Dispose();
    5657      viewPanel.Controls.Clear();
     
    6364        foreach (Type viewType in viewTypes)
    6465          viewComboBox.Items.Add(viewType);
    65         if (viewComboBox.Items.Count > 0) {
     66        if (viewComboBox.Items.Count == 0) {
     67          messageLabel.Visible = true;
     68        } else {
    6669          viewLabel.Visible = true;
    6770          viewComboBox.Enabled = true;
    6871          viewComboBox.Visible = true;
     72          messageLabel.Visible = false;
    6973        }
    7074
  • trunk/sources/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj

    r2663 r2665  
    5151  </ItemGroup>
    5252  <ItemGroup>
    53     <Compile Include="HeuristicLabDataViewsPlugin.cs" />
    54     <Compile Include="IntDataView.cs">
     53    <Compile Include="BoolDataView.cs">
    5554      <SubType>UserControl</SubType>
    5655    </Compile>
    57     <Compile Include="IntDataView.Designer.cs">
    58       <DependentUpon>IntDataView.cs</DependentUpon>
     56    <Compile Include="BoolDataView.Designer.cs">
     57      <DependentUpon>BoolDataView.cs</DependentUpon>
    5958    </Compile>
     59    <Compile Include="StringConvertibleDataView.cs">
     60      <SubType>UserControl</SubType>
     61    </Compile>
     62    <Compile Include="StringConvertibleDataView.Designer.cs">
     63      <DependentUpon>StringConvertibleDataView.cs</DependentUpon>
     64    </Compile>
     65    <Compile Include="HeuristicLabDataViewsPlugin.cs" />
    6066    <Compile Include="Properties\AssemblyInfo.cs" />
    6167  </ItemGroup>
  • trunk/sources/HeuristicLab.Data/3.3/BoolData.cs

    r2526 r2665  
    2828
    2929namespace HeuristicLab.Data {
    30   /// <summary>
    31   /// Class to represent boolean values.
    32   /// </summary>
    3330  [EmptyStorableClass]
    34   public class BoolData : ObjectData {
    35     /// <summary>
    36     /// Gets or sets the boolean value.
    37     /// </summary>
    38     /// <remarks>Uses property <see cref="ObjectData.Data"/>
    39     /// of base class <see cref="ObjectData"/>. No own data storage present.</remarks>
    40     public new bool Data {
    41       get { return (bool)base.Data; }
    42       set { base.Data = value; }
     31  [Item("Boolean", "Represents a boolean value.")]
     32  [Creatable("Test")]
     33  public sealed class BoolData : ValueTypeData<bool>, IStringConvertibleData {
     34    public BoolData() : base() { }
     35    public BoolData(bool value)
     36      : base() {
     37      Value = value;
    4338    }
    4439
    45     /// <summary>
    46     /// Initializes a new instance of <see cref="BoolData"/> with default value <c>false</c>.
    47     /// </summary>
    48     public BoolData() {
    49       Data = false;
    50     }
    51     /// <summary>
    52     /// Initializes a new instance of <see cref="BoolData"/> with the boolean value <paramref name="data"/>.
    53     /// </summary>
    54     /// <param name="data">The boolean value to assign.</param>
    55     public BoolData(bool data) {
    56       Data = data;
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      BoolData clone = new BoolData(Value);
     42      cloner.RegisterClonedObject(this, clone);
     43      return clone;
    5744    }
    5845
    59     /// <summary>
    60     /// Clones the current instance.
    61     /// </summary>
    62     /// <remarks>The cloned instance is added to the <paramref name="dictionary"/>.</remarks>
    63     /// <param name="clonedObjects">Dictionary of all already cloned objects.</param>
    64     /// <returns>The cloned instance as <see cref="BoolData"/>.</returns>
    65     public override IItem Clone(ICloner cloner) {
    66       BoolData clone = new BoolData();
    67       cloner.RegisterClonedObject(this, clone);
    68       clone.Data = Data;
    69       return clone;
     46    string IStringConvertibleData.GetValue() {
     47      return Value.ToString();
     48    }
     49    bool IStringConvertibleData.SetValue(string value) {
     50      bool b;
     51      if (bool.TryParse(value, out b)) {
     52        Value = b;
     53        return true;
     54      } else {
     55        return false;
     56      }
    7057    }
    7158  }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs

    r2526 r2665  
    2525using System.Xml;
    2626using HeuristicLab.Core;
    27 using System.Globalization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
    3029namespace HeuristicLab.Data {
    31   /// <summary>
    32   /// Class to represent double values.
    33   /// </summary>
    3430  [EmptyStorableClass]
    35   public class DoubleData : ObjectData {
    36     /// <summary>
    37     /// Gets or sets the double value.
    38     /// </summary>
    39     /// <remarks>Uses property <see cref="ObjectData.Data"/> of base class <see cref="ObjectData"></see>.
    40     /// No own data storage present.</remarks>
    41     public new double Data {
    42       get { return (double)base.Data; }
    43       set { base.Data = value; }
     31  [Item("Double", "Represents a double value.")]
     32  [Creatable("Test")]
     33  public sealed class DoubleData : ValueTypeData<double>, IStringConvertibleData {
     34    public DoubleData() : base() { }
     35    public DoubleData(double value)
     36      : base() {
     37      Value = value;
    4438    }
    4539
    46     /// <summary>
    47     /// Initializes a new instance of <see cref="DoubleData"/> with default value <c>0.0</c>.
    48     /// </summary>
    49     public DoubleData() {
    50       Data = 0.0;
    51     }
    52     /// <summary>
    53     /// Initializes a new instance of <see cref="DoubleData"/>.
    54     /// <note type="caution"> No CopyConstructor! <paramref name="data"/> is not copied!</note>
    55     /// </summary>
    56     /// <param name="data">The double value the instance should represent.</param>
    57     public DoubleData(double data) {
    58       Data = data;
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      DoubleData clone = new DoubleData(Value);
     42      cloner.RegisterClonedObject(this, clone);
     43      return clone;
    5944    }
    6045
    61     /// <summary>
    62     /// Clones the current instance and adds it to the dictionary <paramref name="clonedObjects"/>.
    63     /// </summary>
    64     /// <param name="clonedObjects">Dictionary of all already cloned objects.</param>
    65     /// <returns>The cloned instance as <see cref="DoubleData"/>.</returns>
    66     public override IItem Clone(ICloner cloner) {
    67       DoubleData clone = new DoubleData();
    68       cloner.RegisterClonedObject(this, clone);
    69       clone.Data = Data;
    70       return clone;
     46    string IStringConvertibleData.GetValue() {
     47      return Value.ToString();
     48    }
     49    bool IStringConvertibleData.SetValue(string value) {
     50      double d;
     51      if (double.TryParse(value, out d)) {
     52        Value = d;
     53        return true;
     54      } else {
     55        return false;
     56      }
    7157    }
    7258  }
  • trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj

    r2663 r2665  
    100100  </ItemGroup>
    101101  <ItemGroup>
     102    <Compile Include="BoolData.cs">
     103      <SubType>Code</SubType>
     104    </Compile>
     105    <Compile Include="ReferenceTypeData.cs" />
     106    <Compile Include="StringData.cs">
     107      <SubType>Code</SubType>
     108    </Compile>
     109    <Compile Include="TimeSpanData.cs" />
     110    <Compile Include="DateTimeData.cs" />
     111    <Compile Include="DoubleData.cs">
     112      <SubType>Code</SubType>
     113    </Compile>
     114    <Compile Include="IStringConvertibleData.cs" />
    102115    <Compile Include="ValueTypeData.cs">
    103116      <SubType>Code</SubType>
  • trunk/sources/HeuristicLab.Data/3.3/IntData.cs

    r2663 r2665  
    2929namespace HeuristicLab.Data {
    3030  [EmptyStorableClass]
    31   [Item("Int Data", "Represents an integer value.")]
     31  [Item("Integer", "Represents an integer value.")]
    3232  [Creatable("Test")]
    33   public sealed class IntData : ValueTypeData<int> {
     33  public sealed class IntData : ValueTypeData<int>, IStringConvertibleData {
    3434    public IntData() : base() { }
    3535    public IntData(int value)
     
    4343      return clone;
    4444    }
     45
     46    string IStringConvertibleData.GetValue() {
     47      return Value.ToString();
     48    }
     49    bool IStringConvertibleData.SetValue(string value) {
     50      int i;
     51      if (int.TryParse(value, out i)) {
     52        Value = i;
     53        return true;
     54      } else {
     55        return false;
     56      }
     57    }
    4558  }
    4659}
  • trunk/sources/HeuristicLab.Data/3.3/StringData.cs

    r2526 r2665  
    2828
    2929namespace HeuristicLab.Data {
    30   /// <summary>
    31   /// The representation of a string.
    32   /// </summary>
    3330  [EmptyStorableClass]
    34   public class StringData : ObjectData {
    35     /// <summary>
    36     /// Gets or sets the string value.
    37     /// </summary>
    38     /// <remarks>Uses property <see cref="ObjectData.Data"/> of base class <see cref="ObjectData"/>.
    39     /// No own data storage present.</remarks>
    40     public new string Data {
    41       get { return (string)base.Data; }
    42       set { base.Data = value; }
     31  [Item("String", "Represents a string.")]
     32  [Creatable("Test")]
     33  public sealed class StringData : ReferenceTypeData<string>, IStringConvertibleData {
     34    public StringData() : base() {
     35      Value = string.Empty;
     36    }
     37    public StringData(string value)
     38      : base() {
     39      Value = value;
    4340    }
    4441
    45     /// <summary>
    46     /// Initializes a new instance of <see cref="StringData"/>
    47     /// with the name of the type of the current instance as default value.
    48     /// </summary>
    49     public StringData() {
    50       Data = this.GetType().Name;
    51     }
    52     /// <summary>
    53     /// Initializes a new instance of <see cref="StringData"/> with the specified <paramref name="data"/>.
    54     /// </summary>
    55     /// <param name="data">The string value the current instance should represent.</param>
    56     public StringData(string data) {
    57       Data = data;
    58     }
    59 
    60     /// <summary>
    61     /// Clones the current instance.
    62     /// </summary>
    63     /// <remarks>The current instance is added to the dictionary <paramref name="clonedObjects"/>.</remarks>
    64     /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    65     /// <returns>The coned instance as <see cref="StringData"/>.</returns>
    66     public override IItem Clone(ICloner cloner) {
    67       StringData clone = new StringData();
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      StringData clone = new StringData(Value);
    6844      cloner.RegisterClonedObject(this, clone);
    69       clone.Data = Data;
    7045      return clone;
    7146    }
    7247
    73     /// <summary>
    74     /// The string representation of the current instance.
    75     /// </summary>
    76     /// <returns>The string value.</returns>
    77     public override string ToString() {
    78       return Data;
     48    string IStringConvertibleData.GetValue() {
     49      return Value;
     50    }
     51    bool IStringConvertibleData.SetValue(string value) {
     52      Value = value != null ? value : string.Empty;
     53      return true;
    7954    }
    8055  }
  • trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs

    r2656 r2665  
    5353      if (newItemDialog.ShowDialog() == DialogResult.OK) {
    5454        IView view = MainFormManager.CreateDefaultView(newItemDialog.Item);
    55         if (view is IObjectView) {
    56           view.Caption = "Item" + newDocumentsCounter.ToString() + ".hl";
    57           newDocumentsCounter++;
     55        if (view == null) {
     56          MessageBox.Show("There is no view for the new item. It cannot be displayed. ", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error);
     57        } else {
     58          if (view is IObjectView) {
     59            view.Caption = "Item" + newDocumentsCounter.ToString() + ".hl";
     60            newDocumentsCounter++;
     61          }
     62          MainFormManager.MainForm.ShowView(view);
    5863        }
    59         MainFormManager.MainForm.ShowView(view);
    6064      }
    6165    }
     
    188192              Invoke(delegate() {
    189193                IObjectView view = MainFormManager.CreateDefaultView(item) as IObjectView;
    190                 if (view != null) {
     194                if (view == null) {
     195                  MessageBox.Show("There is no view for the loaded item. It cannot be displayed. ", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error);
     196                } else {
    191197                  view.Caption = Path.GetFileName(filename);
    192198                  files.Add(view, new FileInfo(filename));
Note: See TracChangeset for help on using the changeset viewer.