Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11836


Ignore:
Timestamp:
01/28/15 14:32:00 (10 years ago)
Author:
jkarder
Message:

#2077:

  • changed error and warning markup handling
  • minor code changes
Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CodeEditor/3.4/CodeEditor.cs

    r11835 r11836  
    248248          if (marker.Length != (int)marker.Tag)
    249249            marker.Delete();
     250          else {
     251            int caretOffset = TextEditor.CaretOffset;
     252            var line = Doc.GetLineByOffset(marker.StartOffset);
     253            int lineEndOffset = line.EndOffset;
     254            if (caretOffset == lineEndOffset) // special case for markers beyond line length
     255              marker.Delete();
     256          }
    250257        }
    251258        OnTextEditorTextChanged();
  • trunk/sources/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.cs

    r11834 r11836  
    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    }
  • trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.Designer.cs

    r11807 r11836  
    5050    private void InitializeComponent() {
    5151      this.components = new System.ComponentModel.Container();
    52       this.compilationLabel = new System.Windows.Forms.Label();
     52      this.infoTextLabel = new System.Windows.Forms.Label();
    5353      this.imageList = new System.Windows.Forms.ImageList(this.components);
    5454      this.compileButton = new System.Windows.Forms.Button();
     
    8787      this.infoLabel.Location = new System.Drawing.Point(816, 4);
    8888      //
    89       // compilationLabel
    90       //
    91       this.compilationLabel.AutoSize = true;
    92       this.compilationLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
    93       this.compilationLabel.Location = new System.Drawing.Point(66, 32);
    94       this.compilationLabel.Name = "compilationLabel";
    95       this.compilationLabel.Size = new System.Drawing.Size(69, 13);
    96       this.compilationLabel.TabIndex = 3;
    97       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";
    9898      //
    9999      // imageList
     
    217217      this.codeEditor.TabIndex = 0;
    218218      this.codeEditor.UserCode = "";
    219       this.codeEditor.AssembliesLoaded += new System.EventHandler<EventArgs<IEnumerable<Assembly>>>(this.codeEditor_AssembliesLoaded);
    220       this.codeEditor.AssembliesLoading += new System.EventHandler<EventArgs<IEnumerable<Assembly>>>(this.codeEditor_AssembliesLoading);
    221       this.codeEditor.AssembliesUnloaded += new System.EventHandler<EventArgs<IEnumerable<Assembly>>>(this.codeEditor_AssembliesUnloaded);
    222       this.codeEditor.AssembliesUnloading += new System.EventHandler<EventArgs<IEnumerable<Assembly>>>(this.codeEditor_AssembliesUnloading);
    223219      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);
    224224      //
    225225      // splitContainer1
    226226      //
    227       this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    228             | System.Windows.Forms.AnchorStyles.Left)
     227      this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     228            | System.Windows.Forms.AnchorStyles.Left) 
    229229            | System.Windows.Forms.AnchorStyles.Right)));
    230230      this.splitContainer1.Location = new System.Drawing.Point(0, 56);
     
    248248      this.Controls.Add(this.splitContainer1);
    249249      this.Controls.Add(this.compileButton);
    250       this.Controls.Add(this.compilationLabel);
     250      this.Controls.Add(this.infoTextLabel);
    251251      this.Name = "ScriptView";
    252252      this.Size = new System.Drawing.Size(835, 602);
    253       this.Controls.SetChildIndex(this.compilationLabel, 0);
     253      this.Controls.SetChildIndex(this.infoTextLabel, 0);
    254254      this.Controls.SetChildIndex(this.compileButton, 0);
    255255      this.Controls.SetChildIndex(this.splitContainer1, 0);
     
    273273    #endregion
    274274
    275     protected System.Windows.Forms.Label compilationLabel;
     275    protected System.Windows.Forms.Label infoTextLabel;
    276276    protected System.Windows.Forms.Button compileButton;
    277277    protected System.Windows.Forms.ImageList imageList;
  • trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.cs

    r11819 r11836  
    8686        codeEditor.AddAssembliesAsync(Content.GetAssemblies());
    8787        if (Content.CompileErrors == null) {
    88           compilationLabel.ForeColor = SystemColors.ControlDarkDark;
    89           compilationLabel.Text = NotCompiledMessage;
     88          UpdateInfoTextLabel(NotCompiledMessage, SystemColors.ControlText);
    9089        }
    9190      }
     
    117116        Content.Compile();
    118117        outputTextBox.AppendText(CompilationSucceededMessage);
    119         compilationLabel.ForeColor = Color.DarkGreen;
    120         compilationLabel.Text = CompilationSucceededMessage;
     118        UpdateInfoTextLabel(CompilationSucceededMessage, Color.DarkGreen);
    121119        return true;
    122120      } catch (InvalidOperationException) {
    123121        if (Content.CompileErrors.HasErrors) {
    124122          outputTextBox.AppendText(CompilationFailedMessage);
    125           compilationLabel.ForeColor = Color.DarkRed;
    126           compilationLabel.Text = CompilationFailedMessage;
     123          UpdateInfoTextLabel(CompilationFailedMessage, Color.DarkRed);
    127124          return false;
    128125        } else {
    129126          outputTextBox.AppendText(CompilationSucceededMessage);
    130           compilationLabel.ForeColor = Color.DarkGreen;
    131           compilationLabel.Text = CompilationSucceededMessage;
     127          UpdateInfoTextLabel(CompilationSucceededMessage, Color.DarkGreen);
    132128          return true;
    133129        }
     
    144140    #region Helpers
    145141    protected virtual void ShowCompilationResults() {
    146       if (Content.CompileErrors.Count == 0) return;
    147 
    148142      var messages = Content.CompileErrors.OfType<CompilerError>()
    149143                                      .OrderBy(x => x.IsWarning)
     
    169163    }
    170164
     165    protected virtual void UpdateInfoTextLabel(string message, Color color) {
     166      infoTextLabel.Text = message;
     167      infoTextLabel.ForeColor = color;
     168    }
     169
    171170    protected virtual void AdjustErrorListViewColumnSizes() {
    172171      foreach (ColumnHeader ch in errorListView.Columns)
  • trunk/sources/HeuristicLab.Scripting/3.3/Scripts/CSharp/CSharpScript.cs

    r11834 r11836  
    102102          OnScriptExecutionStarted();
    103103          compiledScript.Execute(VariableStore);
    104         } catch (ThreadAbortException) {
    105           // the execution was cancelled by the user
    106104        } catch (Exception e) {
    107105          ex = e;
Note: See TracChangeset for help on using the changeset viewer.