Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/06/15 12:44:09 (9 years ago)
Author:
jkarder
Message:

#2077: merged r11807:11811, r11816, r11819, r11822, r11825, r11834, r11835, r11836, r11933 and r11936 into stable

Location:
stable
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.cs

    r11907 r11937  
    2121
    2222using System;
     23using System.Drawing;
     24using System.Threading;
    2325using System.Windows.Forms;
    2426using HeuristicLab.Common;
     
    3133  [Content(typeof(CSharpScript), true)]
    3234  public partial class CSharpScriptView : ScriptView {
     35    private const string ScriptExecutionStartedMessage = "Script execution started";
     36    private const string ScriptExecutionCanceledMessage = "Script execution canceled";
     37    private const string ScriptExecutionSuccessfulMessage = "Script execution successful";
     38    private const string ScriptExecutionFailedMessage = "Script execution failed";
     39
    3340    protected bool Running { get; set; }
    3441
     
    6572        startStopButton.Image = VSImageLibrary.Stop;
    6673        toolTip.SetToolTip(startStopButton, "Stop (Shift+F5)");
     74        UpdateInfoTextLabel(ScriptExecutionStartedMessage, SystemColors.ControlText);
    6775        infoTabControl.SelectedTab = outputTabPage;
    6876      }
     
    7684        startStopButton.Image = VSImageLibrary.Play;
    7785        toolTip.SetToolTip(startStopButton, "Run (F5)");
     86
     87        var ex = e.Value;
     88        if (ex == null) {
     89          UpdateInfoTextLabel(ScriptExecutionSuccessfulMessage, Color.DarkGreen);
     90        } else if (ex is ThreadAbortException) {
     91          // the execution was canceled by the user
     92          UpdateInfoTextLabel(ScriptExecutionCanceledMessage, Color.DarkOrange);
     93        } else {
     94          UpdateInfoTextLabel(ScriptExecutionFailedMessage, Color.DarkRed);
     95          PluginInfrastructure.ErrorHandling.ShowErrorDialog(this, ex);
     96        }
     97
    7898        Running = false;
    79         var ex = e.Value;
    80         if (ex != null)
    81           PluginInfrastructure.ErrorHandling.ShowErrorDialog(this, ex);
    8299      }
    83100    }
     
    111128        if (Compile()) {
    112129          outputTextBox.Clear();
     130          Running = true;
    113131          Content.ExecuteAsync();
    114           Running = true;
    115132        }
    116133    }
  • stable/HeuristicLab.Scripting.Views/3.3/HeuristicLab.Scripting.Views-3.3.csproj

    r11920 r11937  
    118118  </ItemGroup>
    119119  <ItemGroup>
    120     <ProjectReference Include="..\..\HeuristicLab.CodeEditor\3.3\HeuristicLab.CodeEditor-3.3.csproj">
    121       <Project>{489cfe09-fdf7-4c89-bab5-bd09cadd61ad}</Project>
    122       <Name>HeuristicLab.CodeEditor-3.3</Name>
    123       <Private>False</Private>
     120    <ProjectReference Include="..\..\HeuristicLab.CodeEditor\3.4\HeuristicLab.CodeEditor-3.4.csproj">
     121      <Project>{c38691ae-ecb4-489a-a05d-b035554e0168}</Project>
     122      <Name>HeuristicLab.CodeEditor-3.4</Name>
    124123    </ProjectReference>
    125124    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
  • stable/HeuristicLab.Scripting.Views/3.3/Plugin.cs.frame

    r11173 r11937  
    2525  [Plugin("HeuristicLab.Scripting.Views", "3.3.10.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Scripting.Views-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.CodeEditor", "3.3")]
     27  [PluginDependency("HeuristicLab.CodeEditor", "3.4")]
    2828  [PluginDependency("HeuristicLab.Collections", "3.3")]
    2929  [PluginDependency("HeuristicLab.Common", "3.3")]
  • stable/HeuristicLab.Scripting.Views/3.3/ScriptView.Designer.cs

    r11907 r11937  
    1919 */
    2020#endregion
     21
     22using System.Collections.Generic;
     23using System.Reflection;
     24using HeuristicLab.Common;
    2125
    2226namespace HeuristicLab.Scripting.Views {
     
    4650    private void InitializeComponent() {
    4751      this.components = new System.ComponentModel.Container();
    48       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScriptView));
    49       this.compilationLabel = new System.Windows.Forms.Label();
     52      this.infoTextLabel = new System.Windows.Forms.Label();
    5053      this.imageList = new System.Windows.Forms.ImageList(this.components);
    5154      this.compileButton = new System.Windows.Forms.Button();
     
    8487      this.infoLabel.Location = new System.Drawing.Point(816, 4);
    8588      //
    86       // compilationLabel
    87       //
    88       this.compilationLabel.AutoSize = true;
    89       this.compilationLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
    90       this.compilationLabel.Location = new System.Drawing.Point(66, 32);
    91       this.compilationLabel.Name = "compilationLabel";
    92       this.compilationLabel.Size = new System.Drawing.Size(69, 13);
    93       this.compilationLabel.TabIndex = 3;
    94       this.compilationLabel.Text = "Not compiled";
     89      // infoTextLabel
     90      //
     91      this.infoTextLabel.AutoSize = true;
     92      this.infoTextLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
     93      this.infoTextLabel.Location = new System.Drawing.Point(66, 32);
     94      this.infoTextLabel.Name = "infoTextLabel";
     95      this.infoTextLabel.Size = new System.Drawing.Size(69, 13);
     96      this.infoTextLabel.TabIndex = 3;
     97      this.infoTextLabel.Text = "Not compiled";
    9598      //
    9699      // imageList
     
    215218      this.codeEditor.UserCode = "";
    216219      this.codeEditor.TextEditorTextChanged += new System.EventHandler(this.codeEditor_TextEditorTextChanged);
     220      this.codeEditor.AssembliesLoading += new System.EventHandler<HeuristicLab.Common.EventArgs<System.Collections.Generic.IEnumerable<System.Reflection.Assembly>>>(this.codeEditor_AssembliesLoading);
     221      this.codeEditor.AssembliesLoaded += new System.EventHandler<HeuristicLab.Common.EventArgs<System.Collections.Generic.IEnumerable<System.Reflection.Assembly>>>(this.codeEditor_AssembliesLoaded);
     222      this.codeEditor.AssembliesUnloading += new System.EventHandler<HeuristicLab.Common.EventArgs<System.Collections.Generic.IEnumerable<System.Reflection.Assembly>>>(this.codeEditor_AssembliesUnloading);
     223      this.codeEditor.AssembliesUnloaded += new System.EventHandler<HeuristicLab.Common.EventArgs<System.Collections.Generic.IEnumerable<System.Reflection.Assembly>>>(this.codeEditor_AssembliesUnloaded);
    217224      //
    218225      // splitContainer1
     
    241248      this.Controls.Add(this.splitContainer1);
    242249      this.Controls.Add(this.compileButton);
    243       this.Controls.Add(this.compilationLabel);
     250      this.Controls.Add(this.infoTextLabel);
    244251      this.Name = "ScriptView";
    245252      this.Size = new System.Drawing.Size(835, 602);
    246       this.Controls.SetChildIndex(this.compilationLabel, 0);
     253      this.Controls.SetChildIndex(this.infoTextLabel, 0);
    247254      this.Controls.SetChildIndex(this.compileButton, 0);
    248255      this.Controls.SetChildIndex(this.splitContainer1, 0);
     
    266273    #endregion
    267274
    268     protected System.Windows.Forms.Label compilationLabel;
     275    protected System.Windows.Forms.Label infoTextLabel;
    269276    protected System.Windows.Forms.Button compileButton;
    270277    protected System.Windows.Forms.ImageList imageList;
  • stable/HeuristicLab.Scripting.Views/3.3/ScriptView.cs

    r11908 r11937  
    2222using System;
    2323using System.CodeDom.Compiler;
     24using System.Collections.Generic;
    2425using System.Drawing;
    2526using System.Globalization;
    2627using System.Linq;
     28using System.Reflection;
    2729using System.Windows.Forms;
     30using HeuristicLab.Common;
    2831using HeuristicLab.Common.Resources;
    2932using HeuristicLab.Core.Views;
     
    3538  [Content(typeof(Script), true)]
    3639  public partial class ScriptView : NamedItemView {
     40    private const string NotCompiledMessage = "Not compiled";
     41    private const string CompilationSucceededMessage = "Compilation succeeded";
     42    private const string CompilationFailedMessage = "Compilation failed";
     43    private const string AssembliesLoadingMessage = "Loading Assemblies";
     44    private const string AssembliesUnloadingMessage = "Unloading Assemblies";
     45    private const int SilentAssemblyLoadingOperationLimit = 10;
     46
    3747    #region Properties
    3848    public new Script Content {
     
    7383        codeEditor.UserCode = string.Empty;
    7484      } else {
    75         if (codeEditor.UserCode != Content.Code)
    76           codeEditor.UserCode = Content.Code;
    77         foreach (var asm in Content.GetAssemblies())
    78           codeEditor.AddAssembly(asm);
     85        codeEditor.UserCode = Content.Code;
     86        codeEditor.AddAssembliesAsync(Content.GetAssemblies());
    7987        if (Content.CompileErrors == null) {
    80           compilationLabel.ForeColor = SystemColors.ControlDarkDark;
    81           compilationLabel.Text = "Not compiled";
    82         } else if (Content.CompileErrors.HasErrors) {
    83           compilationLabel.ForeColor = Color.DarkRed;
    84           compilationLabel.Text = "Compilation failed";
    85         } else {
    86           compilationLabel.ForeColor = Color.DarkGreen;
    87           compilationLabel.Text = "Compilation successful";
     88          UpdateInfoTextLabel(NotCompiledMessage, SystemColors.ControlText);
    8889        }
    8990      }
     
    114115      try {
    115116        Content.Compile();
    116         outputTextBox.AppendText("Compilation succeeded.");
     117        outputTextBox.AppendText(CompilationSucceededMessage);
     118        UpdateInfoTextLabel(CompilationSucceededMessage, Color.DarkGreen);
    117119        return true;
    118120      } catch (CompilationException) {
    119121        if (Content.CompileErrors.HasErrors) {
    120           outputTextBox.AppendText("Compilation failed.");
     122          outputTextBox.AppendText(CompilationFailedMessage);
     123          UpdateInfoTextLabel(CompilationFailedMessage, Color.DarkRed);
    121124          return false;
    122125        } else {
    123           outputTextBox.AppendText("Compilation succeeded.");
     126          outputTextBox.AppendText(CompilationSucceededMessage);
     127          UpdateInfoTextLabel(CompilationSucceededMessage, Color.DarkGreen);
    124128          return true;
    125129        }
     
    131135        Locked = false;
    132136        codeEditor.Focus();
    133         OnContentChanged();
    134137      }
    135138    }
     
    137140    #region Helpers
    138141    protected virtual void ShowCompilationResults() {
    139       if (Content.CompileErrors.Count == 0) return;
    140 
    141142      var messages = Content.CompileErrors.OfType<CompilerError>()
    142143                                      .OrderBy(x => x.IsWarning)
     
    157158      }
    158159
    159       codeEditor.ShowCompileErrors(Content.CompileErrors, ".cs");
     160      codeEditor.ShowCompileErrors(Content.CompileErrors);
    160161
    161162      AdjustErrorListViewColumnSizes();
     163    }
     164
     165    protected virtual void UpdateInfoTextLabel(string message, Color color) {
     166      infoTextLabel.Text = message;
     167      infoTextLabel.ForeColor = color;
    162168    }
    163169
     
    167173        ch.Width = -2;
    168174    }
     175
     176    #region ProgressView
     177    private bool progressViewCreated;
     178
     179    private void AddProgressView(string progressMessage) {
     180      var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     181      mainForm.AddOperationProgressToView(this, progressMessage);
     182      progressViewCreated = true;
     183    }
     184
     185    private void RemoveProgressView() {
     186      if (!progressViewCreated) return;
     187      var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     188      mainForm.RemoveOperationProgressFromView(this);
     189      progressViewCreated = false;
     190    }
     191    #endregion
    169192    #endregion
    170193
    171194    #region Event Handlers
    172195    private void Content_CodeChanged(object sender, EventArgs e) {
    173       if (InvokeRequired)
    174         Invoke(new EventHandler(Content_CodeChanged), sender, e);
     196      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_CodeChanged, sender, e);
    175197      else {
    176198        codeEditor.UserCode = Content.Code;
     
    196218    }
    197219    #endregion
     220
     221    private void codeEditor_AssembliesLoading(object sender, EventArgs<IEnumerable<Assembly>> e) {
     222      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesLoading, sender, e);
     223      else {
     224        int nrOfAssemblies = e.Value.Count();
     225        if (nrOfAssemblies > SilentAssemblyLoadingOperationLimit)
     226          AddProgressView(AssembliesLoadingMessage);
     227      }
     228    }
     229
     230    private void codeEditor_AssembliesLoaded(object sender, EventArgs<IEnumerable<Assembly>> e) {
     231      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesLoaded, sender, e);
     232      else {
     233        RemoveProgressView();
     234      }
     235    }
     236
     237    private void codeEditor_AssembliesUnloading(object sender, EventArgs<IEnumerable<Assembly>> e) {
     238      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesUnloading, sender, e);
     239      else {
     240        int nrOfAssemblies = e.Value.Count();
     241        if (nrOfAssemblies > SilentAssemblyLoadingOperationLimit)
     242          AddProgressView(AssembliesUnloadingMessage);
     243      }
     244    }
     245
     246    private void codeEditor_AssembliesUnloaded(object sender, EventArgs<IEnumerable<Assembly>> e) {
     247      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesUnloaded, sender, e);
     248      else {
     249        RemoveProgressView();
     250      }
     251    }
    198252  }
    199253}
Note: See TracChangeset for help on using the changeset viewer.