Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/20/14 17:33:22 (10 years ago)
Author:
jkarder
Message:

#2136:

  • refactored HLScriptGeneration to separate outputs from different running HL scripts.
  • added persistence support for HLScripts and fixed cloning
  • added code completion for all types in the currently loaded assemblies
  • merged trunk changes
Location:
branches/HLScript
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HLScript

  • branches/HLScript/HeuristicLab.HLScript.Views/3.3/HLScriptView.Designer.cs

    r10332 r10358  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.components = new System.ComponentModel.Container();
    4847      this.compilationLabel = new System.Windows.Forms.Label();
    4948      this.showCodeButton = new System.Windows.Forms.Button();
    5049      this.startStopButton = new System.Windows.Forms.Button();
    51       this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    5250      this.errorListView = new System.Windows.Forms.ListView();
    5351      this.categoryColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     
    6361      this.outputTabPage = new System.Windows.Forms.TabPage();
    6462      this.outputTextBox = new System.Windows.Forms.TextBox();
     63      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    6564      this.variableStoreView = new HeuristicLab.HLScript.Views.VariableStoreView();
    66       this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     65      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6766      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
    6867      this.splitContainer1.Panel1.SuspendLayout();
     
    7877      this.SuspendLayout();
    7978      //
     79      // nameTextBox
     80      //
     81      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     82      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
     83      this.nameTextBox.Location = new System.Drawing.Point(60, 0);
     84      this.nameTextBox.Size = new System.Drawing.Size(750, 20);
     85      //
     86      // infoLabel
     87      //
     88      this.infoLabel.Location = new System.Drawing.Point(816, 4);
     89      //
    8090      // compilationLabel
    8191      //
    8292      this.compilationLabel.AutoSize = true;
    8393      this.compilationLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
    84       this.compilationLabel.Location = new System.Drawing.Point(63, 9);
     94      this.compilationLabel.Location = new System.Drawing.Point(63, 32);
    8595      this.compilationLabel.Name = "compilationLabel";
    8696      this.compilationLabel.Size = new System.Drawing.Size(69, 13);
     
    91101      //
    92102      this.showCodeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PrintPreview;
    93       this.showCodeButton.Location = new System.Drawing.Point(33, 3);
     103      this.showCodeButton.Location = new System.Drawing.Point(33, 26);
    94104      this.showCodeButton.Name = "showCodeButton";
    95105      this.showCodeButton.Size = new System.Drawing.Size(24, 24);
     
    103113      //
    104114      this.startStopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
    105       this.startStopButton.Location = new System.Drawing.Point(3, 3);
     115      this.startStopButton.Location = new System.Drawing.Point(3, 26);
    106116      this.startStopButton.Name = "startStopButton";
    107117      this.startStopButton.Size = new System.Drawing.Size(24, 24);
     
    126136      this.errorListView.Location = new System.Drawing.Point(3, 3);
    127137      this.errorListView.Name = "errorListView";
    128       this.errorListView.Size = new System.Drawing.Size(623, 83);
     138      this.errorListView.Size = new System.Drawing.Size(623, 79);
    129139      this.errorListView.TabIndex = 0;
    130140      this.errorListView.UseCompatibleStateImageBehavior = false;
     
    161171      this.codeEditor.Name = "codeEditor";
    162172      this.codeEditor.Prefix = "";
    163       this.codeEditor.Size = new System.Drawing.Size(637, 447);
     173      this.codeEditor.Size = new System.Drawing.Size(637, 428);
    164174      this.codeEditor.Suffix = "";
    165175      this.codeEditor.TabIndex = 0;
     
    169179      // splitContainer1
    170180      //
    171       this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    172             | System.Windows.Forms.AnchorStyles.Left)
     181      this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     182            | System.Windows.Forms.AnchorStyles.Left) 
    173183            | System.Windows.Forms.AnchorStyles.Right)));
    174       this.splitContainer1.Location = new System.Drawing.Point(3, 33);
     184      this.splitContainer1.Location = new System.Drawing.Point(3, 56);
    175185      this.splitContainer1.Name = "splitContainer1";
    176186      //
     
    183193      this.splitContainer1.Panel2.Controls.Add(this.variableStoreView);
    184194      this.splitContainer1.Panel2.Controls.Add(this.viewHost);
    185       this.splitContainer1.Size = new System.Drawing.Size(829, 566);
     195      this.splitContainer1.Size = new System.Drawing.Size(829, 543);
    186196      this.splitContainer1.SplitterDistance = 637;
    187197      this.splitContainer1.TabIndex = 7;
     
    201211      //
    202212      this.splitContainer2.Panel2.Controls.Add(this.tabControl1);
    203       this.splitContainer2.Size = new System.Drawing.Size(637, 566);
    204       this.splitContainer2.SplitterDistance = 447;
     213      this.splitContainer2.Size = new System.Drawing.Size(637, 543);
     214      this.splitContainer2.SplitterDistance = 428;
    205215      this.splitContainer2.TabIndex = 5;
    206216      //
     
    213223      this.tabControl1.Name = "tabControl1";
    214224      this.tabControl1.SelectedIndex = 0;
    215       this.tabControl1.Size = new System.Drawing.Size(637, 115);
     225      this.tabControl1.Size = new System.Drawing.Size(637, 111);
    216226      this.tabControl1.TabIndex = 1;
    217227      //
     
    222232      this.errorListTabPage.Name = "errorListTabPage";
    223233      this.errorListTabPage.Padding = new System.Windows.Forms.Padding(3);
    224       this.errorListTabPage.Size = new System.Drawing.Size(629, 89);
     234      this.errorListTabPage.Size = new System.Drawing.Size(629, 85);
    225235      this.errorListTabPage.TabIndex = 0;
    226236      this.errorListTabPage.Text = "Error List";
     
    233243      this.outputTabPage.Name = "outputTabPage";
    234244      this.outputTabPage.Padding = new System.Windows.Forms.Padding(3);
    235       this.outputTabPage.Size = new System.Drawing.Size(629, 89);
     245      this.outputTabPage.Size = new System.Drawing.Size(629, 85);
    236246      this.outputTabPage.TabIndex = 1;
    237247      this.outputTabPage.Text = "Output";
     
    247257      this.outputTextBox.ReadOnly = true;
    248258      this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
    249       this.outputTextBox.Size = new System.Drawing.Size(623, 83);
     259      this.outputTextBox.Size = new System.Drawing.Size(623, 79);
    250260      this.outputTextBox.TabIndex = 0;
    251261      this.outputTextBox.WordWrap = false;
    252       //
    253       // variableStoreView
    254       //
    255       this.variableStoreView.Caption = "ItemCollection View";
    256       this.variableStoreView.Content = null;
    257       this.variableStoreView.Dock = System.Windows.Forms.DockStyle.Fill;
    258       this.variableStoreView.Location = new System.Drawing.Point(0, 0);
    259       this.variableStoreView.Name = "variableStoreView";
    260       this.variableStoreView.ReadOnly = false;
    261       this.variableStoreView.Size = new System.Drawing.Size(188, 566);
    262       this.variableStoreView.TabIndex = 0;
    263262      //
    264263      // viewHost
     
    271270      this.viewHost.Name = "viewHost";
    272271      this.viewHost.ReadOnly = false;
    273       this.viewHost.Size = new System.Drawing.Size(188, 566);
     272      this.viewHost.Size = new System.Drawing.Size(188, 543);
    274273      this.viewHost.TabIndex = 0;
    275274      this.viewHost.ViewsLabelVisible = true;
    276275      this.viewHost.ViewType = null;
     276      //
     277      // variableStoreView
     278      //
     279      this.variableStoreView.Caption = "ItemCollection View";
     280      this.variableStoreView.Content = null;
     281      this.variableStoreView.Dock = System.Windows.Forms.DockStyle.Fill;
     282      this.variableStoreView.Location = new System.Drawing.Point(0, 0);
     283      this.variableStoreView.Name = "variableStoreView";
     284      this.variableStoreView.ReadOnly = false;
     285      this.variableStoreView.Size = new System.Drawing.Size(188, 543);
     286      this.variableStoreView.TabIndex = 0;
    277287      //
    278288      // HLScriptView
     
    285295      this.Name = "HLScriptView";
    286296      this.Size = new System.Drawing.Size(835, 602);
     297      this.Controls.SetChildIndex(this.showCodeButton, 0);
     298      this.Controls.SetChildIndex(this.compilationLabel, 0);
     299      this.Controls.SetChildIndex(this.startStopButton, 0);
     300      this.Controls.SetChildIndex(this.splitContainer1, 0);
     301      this.Controls.SetChildIndex(this.nameLabel, 0);
     302      this.Controls.SetChildIndex(this.nameTextBox, 0);
     303      this.Controls.SetChildIndex(this.infoLabel, 0);
     304      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    287305      this.splitContainer1.Panel1.ResumeLayout(false);
    288306      this.splitContainer1.Panel2.ResumeLayout(false);
     
    307325    private System.Windows.Forms.Label compilationLabel;
    308326    private System.Windows.Forms.Button startStopButton;
    309     private System.Windows.Forms.ToolTip toolTip;
    310327    private System.Windows.Forms.ListView errorListView;
    311328    private System.Windows.Forms.ColumnHeader descriptionColumnHeader;
  • branches/HLScript/HeuristicLab.HLScript.Views/3.3/HLScriptView.cs

    r10332 r10358  
    3636  [View("HLScript View")]
    3737  [Content(typeof(HLScript), true)]
    38   public partial class HLScriptView : ItemView {
     38  public partial class HLScriptView : NamedItemView {
    3939    private bool running;
    4040
     
    6969    }
    7070    private void Content_ScriptExecutionStarted(object sender, EventArgs e) {
    71       ReadOnly = true;
     71      Locked = true;
    7272      startStopButton.Image = VSImageLibrary.Stop;
    7373    }
    7474    private void Content_ScriptExecutionFinished(object sender, EventArgs e) {
    75       ReadOnly = false;
     75      Locked = false;
    7676      startStopButton.Image = VSImageLibrary.Play;
    7777      running = false;
     
    9292      } else {
    9393        codeEditor.UserCode = Content.Code;
     94        foreach (var asm in Content.GetAssemblies())
     95          codeEditor.AddAssembly(asm);
    9496        variableStoreView.Content = Content.VariableStore;
    9597        if (Content.CompileErrors == null) {
     
    108110    protected override void SetEnabledStateOfControls() {
    109111      base.SetEnabledStateOfControls();
    110       startStopButton.Enabled = Content != null;
     112      startStopButton.Enabled = Content != null && !Locked;
    111113      showCodeButton.Enabled = Content != null && !string.IsNullOrEmpty(Content.CompilationUnitCode);
    112       codeEditor.Enabled = Content != null && !ReadOnly;
     114      codeEditor.Enabled = Content != null && !Locked && !ReadOnly;
    113115    }
    114116
     
    137139    protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
    138140      if (keyData == Keys.F5) {
    139         if (Content == null || ReadOnly)
     141        if (Content == null || Locked)
    140142          return base.ProcessCmdKey(ref msg, keyData);
    141143        outputTextBox.Clear();
     
    144146          outputTextBox.Clear();
    145147          Content.Execute();
     148          running = true;
    146149        }
    147150        return true;
     
    156159    private bool Compile() {
    157160      ReadOnly = true;
     161      Locked = true;
    158162      errorListView.Items.Clear();
    159163      outputTextBox.Clear();
     
    170174        OnContentChanged();
    171175        ReadOnly = false;
     176        Locked = false;
    172177      }
    173178    }
  • branches/HLScript/HeuristicLab.HLScript.Views/3.3/HeuristicLab.HLScript.Views-3.3.csproj

    r10332 r10358  
    115115      <Private>False</Private>
    116116    </ProjectReference>
     117    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
     118      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
     119      <Name>HeuristicLab.Persistence-3.3</Name>
     120      <Private>False</Private>
     121    </ProjectReference>
    117122    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    118123      <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project>
  • branches/HLScript/HeuristicLab.HLScript.Views/3.3/Plugin.cs.frame

    r10332 r10358  
    3434  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3535  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
     36  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3637  public class HeuristicLabHLScriptViewsPlugin : PluginBase {
    3738  }
  • branches/HLScript/HeuristicLab.HLScript.Views/3.3/VariableStoreView.Designer.cs

    r10332 r10358  
    6161            this.valueColumnHeader,
    6262            this.typeColumnHeader});
     63      this.variableListView.FullRowSelect = true;
    6364      this.variableListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
    6465      this.variableListView.HideSelection = false;
  • branches/HLScript/HeuristicLab.HLScript.Views/3.3/VariableStoreView.cs

    r10332 r10358  
    2323using System.Collections;
    2424using System.Collections.Generic;
     25using System.Drawing;
    2526using System.Linq;
    2627using System.Windows.Forms;
     
    3132using HeuristicLab.MainForm;
    3233using HeuristicLab.MainForm.WindowsForms;
     34using HeuristicLab.Persistence.Core;
     35using HeuristicLab.Persistence.Default.Xml;
    3336using HeuristicLab.PluginInfrastructure;
    3437
     
    5356      InitializeComponent();
    5457      itemListViewItemMapping = new Dictionary<string, ListViewItem>();
     58      variableListView.SmallImageList.Images.AddRange(new Image[] {
     59        HeuristicLab.Common.Resources.VSImageLibrary.Error,
     60        HeuristicLab.Common.Resources.VSImageLibrary.Object,
     61        HeuristicLab.Common.Resources.VSImageLibrary.Nothing
     62      });
    5563    }
    5664
     
    101109        variableListView.Enabled = false;
    102110      } else {
    103         addButton.Enabled = /*!Content.IsReadOnly &&*/ !ReadOnly;
     111        addButton.Enabled = !Locked && !ReadOnly;
    104112        sortAscendingButton.Enabled = variableListView.Items.Count > 1;
    105113        sortDescendingButton.Enabled = variableListView.Items.Count > 1;
    106         removeButton.Enabled = /*!Content.IsReadOnly &&*/ !ReadOnly && variableListView.SelectedItems.Count > 0;
     114        removeButton.Enabled = !Locked && !ReadOnly && variableListView.SelectedItems.Count > 0;
    107115        variableListView.Enabled = true;
    108116      }
     
    130138      string value = (variable.Value ?? "null").ToString();
    131139      string type = variable.Value == null ? "null" : variable.Value.GetType().ToString();
    132       var listViewItem = new ListViewItem(new[] { variable.Key, value, type }) { ToolTipText = GetToolTipText(variable), Tag = variable };
    133       variableListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Object);
    134       listViewItem.ImageIndex = variableListView.SmallImageList.Images.Count - 1;
     140      bool serializable = IsSerializable(variable);
     141      var listViewItem = new ListViewItem(new[] { variable.Key, value, type }) { ToolTipText = GetToolTipText(variable, serializable), Tag = variable };
     142      if (serializable) {
     143        listViewItem.ImageIndex = variable.Value == null ? 2 : 1;
     144      } else listViewItem.ImageIndex = 0;
    135145      variableListView.Items.Add(listViewItem);
    136146      itemListViewItemMapping[variable.Key] = listViewItem;
     
    160170        string value = (variable.Value ?? "null").ToString();
    161171        string type = variable.Value == null ? "null" : variable.Value.GetType().ToString();
     172        bool serializable = IsSerializable(variable);
     173        if (serializable) {
     174          listViewItem.ImageIndex = variable.Value == null ? 2 : 1;
     175        } else listViewItem.ImageIndex = 0;
    162176        listViewItem.SubItems[1].Text = value;
    163177        listViewItem.SubItems[2].Text = type;
    164         listViewItem.ToolTipText = GetToolTipText(variable);
     178        listViewItem.ToolTipText = GetToolTipText(variable, serializable);
    165179        listViewItem.Tag = variable;
    166180      } else throw new ArgumentException("A variable with the specified name does not exist.", "variable");
     
    169183    #region ListView Events
    170184    protected virtual void variableListView_SelectedIndexChanged(object sender, EventArgs e) {
    171       removeButton.Enabled = (Content != null) /*&& !Content.IsReadOnly*/ && !ReadOnly && variableListView.SelectedItems.Count > 0;
     185      removeButton.Enabled = (Content != null) && !Locked && !ReadOnly && variableListView.SelectedItems.Count > 0;
    172186      AdjustListViewColumnSizes();
    173187    }
    174188    protected virtual void variableListView_KeyDown(object sender, KeyEventArgs e) {
    175189      if (e.KeyCode == Keys.Delete) {
    176         if ((variableListView.SelectedItems.Count > 0) /*&& !Content.IsReadOnly*/ && !ReadOnly) {
     190        if ((variableListView.SelectedItems.Count > 0) && !Locked && !ReadOnly) {
    177191          foreach (ListViewItem item in variableListView.SelectedItems)
    178192            Content.Remove(item.Text);
     
    207221          if (items.Count == 1) data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items[0]);
    208222          else data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items);
    209           if (/*Content.IsReadOnly ||*/ ReadOnly) {
     223          if (ReadOnly) {
    210224            DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);
    211225          } else {
     
    220234    protected virtual void variableListView_DragEnter(object sender, DragEventArgs e) {
    221235      validDragOperation = false;
    222       if (/*!Content.IsReadOnly &&*/ !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is object)) {
     236      if (!Locked && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is object)) {
    223237        validDragOperation = true;
    224       } else if (/*!Content.IsReadOnly &&*/ !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) {
     238      } else if (!Locked && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) {
    225239        validDragOperation = true;
    226240        IEnumerable items = (IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     
    361375          item.SubItems[1].Text = value;
    362376          item.SubItems[2].Text = variable.Value.Value.GetType().ToString();
    363           item.ToolTipText = GetToolTipText(variable.Value);
     377          item.ToolTipText = GetToolTipText(variable.Value, item.ImageIndex == 0);
    364378          return;
    365379        }
     
    382396    protected virtual void RebuildImageList() {
    383397      variableListView.SmallImageList.Images.Clear();
     398      variableListView.SmallImageList.Images.AddRange(new Image[] {
     399        HeuristicLab.Common.Resources.VSImageLibrary.Error,
     400        HeuristicLab.Common.Resources.VSImageLibrary.Object,
     401        HeuristicLab.Common.Resources.VSImageLibrary.Nothing
     402      });
    384403      foreach (ListViewItem listViewItem in variableListView.Items) {
    385         object item = listViewItem.Tag as object;
    386         variableListView.SmallImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : HeuristicLab.Common.Resources.VSImageLibrary.Object);//item.ItemImage);
    387         listViewItem.ImageIndex = variableListView.SmallImageList.Images.Count - 1;
    388       }
    389     }
    390 
    391     private string GetToolTipText(KeyValuePair<string, object> variable) {
     404        var variable = (KeyValuePair<string, object>)listViewItem.Tag;
     405        bool serializable = IsSerializable(variable);
     406        if (serializable) {
     407          listViewItem.ImageIndex = variable.Value == null ? 2 : 1;
     408        } else listViewItem.ImageIndex = 0;
     409      }
     410    }
     411
     412    private string GetToolTipText(KeyValuePair<string, object> variable, bool serializable) {
    392413      if (string.IsNullOrEmpty(variable.Key)) throw new ArgumentException("The variable must have a name.", "variable");
    393414      string value = (variable.Value ?? "null").ToString();
     415      string type = variable.Value == null ? "null" : variable.Value.GetType().ToString();
    394416      string[] lines = {
    395417        "Name: " + variable.Key,
    396418        "Value: " + value,
    397         "Type: " + variable.Value.GetType()
     419        "Type: " + type
    398420      };
    399       return string.Join(Environment.NewLine, lines);
     421      string toolTipText = string.Join(Environment.NewLine, lines);
     422      if (!serializable)
     423        toolTipText += Environment.NewLine + "CAUTION: Type is not serializable!";
     424      return toolTipText;
    400425    }
    401426
     
    411436      return defaultName;
    412437    }
     438
     439    private bool IsSerializable(KeyValuePair<string, object> variable) {
     440      var ser = new Serializer(variable, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()), "ROOT", true);
     441      try {
     442        return ser.Count() > 0;
     443      } catch (PersistenceException) {
     444        return false;
     445      }
     446    }
    413447    #endregion
    414448  }
Note: See TracChangeset for help on using the changeset viewer.