Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9674


Ignore:
Timestamp:
06/29/13 18:04:06 (11 years ago)
Author:
gkronber
Message:

#2026: Worked on integration of ICSharpCode.AvalonEdit control for GPDL syntax-highlighting and error reporting.

Location:
branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4
Files:
7 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.Designer.cs

    r9519 r9674  
    2828    private void InitializeComponent() {
    2929      this.compileButton = new System.Windows.Forms.Button();
    30       this.gpdlTextBox = new System.Windows.Forms.TextBox();
    3130      this.splitContainer = new System.Windows.Forms.SplitContainer();
    3231      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     32      this.elementHost = new System.Windows.Forms.Integration.ElementHost();
     33      this.codeEditor = new HeuristicLab.Problems.GPDL.Views.CodeEditor();
    3334      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    3435      this.splitContainer.Panel1.SuspendLayout();
     
    4849      this.compileButton.Click += new System.EventHandler(this.compileButton_Click);
    4950      //
    50       // gpdlTextBox
    51       //
    52       this.gpdlTextBox.AcceptsReturn = true;
    53       this.gpdlTextBox.AcceptsTab = true;
    54       this.gpdlTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    55             | System.Windows.Forms.AnchorStyles.Left)
    56             | System.Windows.Forms.AnchorStyles.Right)));
    57       this.gpdlTextBox.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    58       this.gpdlTextBox.Location = new System.Drawing.Point(3, 3);
    59       this.gpdlTextBox.Multiline = true;
    60       this.gpdlTextBox.Name = "gpdlTextBox";
    61       this.gpdlTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
    62       this.gpdlTextBox.Size = new System.Drawing.Size(655, 422);
    63       this.gpdlTextBox.TabIndex = 1;
    64       //
    6551      // splitContainer
    6652      //
     
    7763      // splitContainer.Panel2
    7864      //
     65      this.splitContainer.Panel2.Controls.Add(this.elementHost);
    7966      this.splitContainer.Panel2.Controls.Add(this.compileButton);
    80       this.splitContainer.Panel2.Controls.Add(this.gpdlTextBox);
    8167      this.splitContainer.Size = new System.Drawing.Size(661, 487);
    8268      this.splitContainer.SplitterDistance = 26;
     
    9783      this.viewHost.ViewType = null;
    9884      //
     85      // elementHost
     86      //
     87      this.elementHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     88            | System.Windows.Forms.AnchorStyles.Left)
     89            | System.Windows.Forms.AnchorStyles.Right)));
     90      this.elementHost.Location = new System.Drawing.Point(0, 0);
     91      this.elementHost.Name = "elementHost";
     92      this.elementHost.Size = new System.Drawing.Size(661, 425);
     93      this.elementHost.TabIndex = 2;
     94      this.elementHost.Text = "elementHost2";
     95      this.elementHost.Child = this.codeEditor;
     96      //
    9997      // GpdlEditor
    10098      //
     
    106104      this.splitContainer.Panel1.ResumeLayout(false);
    107105      this.splitContainer.Panel2.ResumeLayout(false);
    108       this.splitContainer.Panel2.PerformLayout();
    109106      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    110107      this.splitContainer.ResumeLayout(false);
     
    117114    private ViewHost viewHost;
    118115    private System.Windows.Forms.Button compileButton;
    119     private System.Windows.Forms.TextBox gpdlTextBox;
    120116    private System.Windows.Forms.SplitContainer splitContainer;
     117    private System.Windows.Forms.Integration.ElementHost elementHost;
     118    private CodeEditor codeEditor;
    121119  }
    122120}
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs

    r9528 r9674  
    1919
    2020    private void compileButton_Click(object sender, EventArgs e) {
    21       Utils.InstallModule("Utils", new Utils.ModuleMethodDelegate(Utils.UtilsMethod));
    22       Utils.InstallModule("Sets", new Utils.ModuleMethodDelegate(Sets.SetsMethod));
    23       Utils.InstallModule("Errors", new Utils.ModuleMethodDelegate(Errors.ErrorsMethod));
     21      Utils.InstallModule("Utils", Utils.UtilsMethod);
     22      Utils.InstallModule("Sets", Sets.SetsMethod);
     23      Utils.InstallModule("Errors", Errors.ErrorsMethod);
    2424
    25       Utils.InstallModule("GPDefLex", new Utils.ModuleMethodDelegate(GPDefLex.GPDefLexMethod));
    26       Utils.InstallModule("GPDefSem", new Utils.ModuleMethodDelegate(GPDefSem.GPDefSemMethod));
    27       Utils.InstallModule("GPDefSyn", new Utils.ModuleMethodDelegate(GPDefSyn.GPDefSynMethod));
     25      Utils.InstallModule("GPDefLex", GPDefLex.GPDefLexMethod);
     26      Utils.InstallModule("GPDefSem", GPDefSem.GPDefSemMethod);
     27      Utils.InstallModule("GPDefSyn", GPDefSyn.GPDefSynMethod);
    2828
    2929      // --- initialize modules ---
     
    3232      Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
    3333
    34       using (var src = new StringReader(gpdlTextBox.Text)) {
     34      using (var src = new StringReader(codeEditor.textEditor.Text)) {
    3535        GPDefLex.src = src;
    3636        GPDefSyn.Parse();
    3737      }
    3838
    39       GPDefLex.InitLex();
    40       GPDefSyn.Interpret();
     39      codeEditor.ClearErrors();
    4140
    42       MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem);
     41      if (Errors.NumOfErrors() == 0) {
     42        GPDefLex.InitLex();
     43        GPDefSyn.Interpret();
     44
     45        MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem);
     46      } else {
     47        int nLexErrors = Errors.NumOfLexErrors();
     48        for (int i = 0; i < nLexErrors; i++) {
     49          var lexErr = Errors.GetLexError(i == 0);
     50          codeEditor.SetLexError(lexErr.msg, lexErr.line, lexErr.col);
     51        }
     52        int nSynErrors = Errors.NumOfSynErrors();
     53        for (int i = 0; i < nSynErrors; i++) {
     54          var synErr = Errors.GetSynError(i == 0);
     55          codeEditor.SetLexError(synErr.msg, synErr.line, synErr.col);
     56        }
     57      }
    4358    }
    4459
     
    4863
    4964    void IProblemInstanceConsumer<string>.Load(string data) {
    50       this.gpdlTextBox.Text = data;
     65      codeEditor.textEditor.Text = data;
    5166    }
    52 
    5367  }
    5468}
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/HeuristicLab.Problems.GPDL.Views-3.4.csproj

    r9528 r9674  
    143143      <Private>False</Private>
    144144    </Reference>
     145    <Reference Include="ICSharpCode.AvalonEdit, Version=4.3.1.9430, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
     146      <SpecificVersion>False</SpecificVersion>
     147      <HintPath>.\ICSharpCode.AvalonEdit.dll</HintPath>
     148      <Private>False</Private>
     149    </Reference>
     150    <Reference Include="PresentationCore" />
     151    <Reference Include="PresentationFramework" />
    145152    <Reference Include="System" />
    146153    <Reference Include="System.Core">
     
    150157    <Reference Include="System.Windows.Forms" />
    151158    <Reference Include="System.Windows.Forms.DataVisualization" />
     159    <Reference Include="System.Xaml" />
    152160    <Reference Include="System.Xml.Linq">
    153161      <RequiredTargetFramework>3.5</RequiredTargetFramework>
     
    158166    <Reference Include="System.Data" />
    159167    <Reference Include="System.Xml" />
    160   </ItemGroup>
    161   <ItemGroup>
     168    <Reference Include="WindowsBase" />
     169    <Reference Include="WindowsFormsIntegration" />
     170  </ItemGroup>
     171  <ItemGroup>
     172    <Compile Include="CodeEditor.xaml.cs">
     173      <DependentUpon>CodeEditor.xaml</DependentUpon>
     174    </Compile>
     175    <Compile Include="ColorizeErrors.cs" />
     176    <Compile Include="GpdlCompletionData.cs" />
    162177    <Compile Include="GpdlProblemInstanceConsumerView.cs">
    163178      <SubType>UserControl</SubType>
     
    182197    <None Include="Plugin.cs.frame" />
    183198    <None Include="Properties\AssemblyInfo.cs.frame" />
     199    <None Include="SyntaxDefinition.xsd">
     200      <SubType>Designer</SubType>
     201    </None>
    184202  </ItemGroup>
    185203  <ItemGroup>
     
    219237  </ItemGroup>
    220238  <ItemGroup>
     239    <None Include="Resources\GPDL.xshd" />
    221240    <None Include="Resources\multi-output-multiplier.txt" />
    222241  </ItemGroup>
     
    233252      <Private>False</Private>
    234253    </ProjectReference>
     254  </ItemGroup>
     255  <ItemGroup>
     256    <Page Include="CodeEditor.xaml">
     257      <SubType>Designer</SubType>
     258      <Generator>MSBuild:Compile</Generator>
     259    </Page>
     260  </ItemGroup>
     261  <ItemGroup>
     262    <Content Include="ICSharpCode.AvalonEdit.dll">
     263      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     264    </Content>
    235265  </ItemGroup>
    236266  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Plugin.cs.frame

    r9430 r9674  
    2828  [Plugin("HeuristicLab.Problems.GPDL.Views","Provides views to define genetic programming problems using GPDL.", "3.4.0.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.GPDL.Views-3.4.dll", PluginFileType.Assembly)]
     30  [PluginFile("ICSharpCode.AvalonEdit.dll", PluginFileType.Assembly)]
    3031  public class Plugin : PluginBase {
    3132  }
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Properties/Resources.Designer.cs

    r9519 r9674  
    146146       
    147147        /// <summary>
     148        ///   Looks up a localized string similar to &lt;!-- Syntax definition of GPDL for Avalonedit syntax highlighting --&gt;
     149        ///&lt;SyntaxDefinition name=&quot;GPDL&quot;
     150        ///        xmlns=&quot;http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008&quot;&gt;
     151        ///  &lt;Color name=&quot;Comment&quot; foreground=&quot;Green&quot; /&gt;
     152        ///  &lt;Color name=&quot;String&quot; foreground=&quot;Blue&quot; /&gt;
     153        ///
     154        ///  &lt;!-- This is the main ruleset. --&gt;
     155        ///  &lt;RuleSet&gt;
     156        ///    &lt;Span color=&quot;Comment&quot; multiline=&quot;true&quot; nested=&quot;true&quot;
     157        ///       begin=&quot;/\*&quot; end=&quot;\*/&quot; /&gt;
     158        ///
     159        ///    &lt;Span color=&quot;SourceCode&quot; multiline=&quot;true&quot;
     160        ///       begin=&quot;&amp;lt;&amp;lt;&quot; end=&quot;&amp;gt;&amp;gt;&quot; /&gt;
     161        ///    &lt;K [rest of string was truncated]&quot;;.
     162        /// </summary>
     163        internal static string GPDL {
     164            get {
     165                return ResourceManager.GetString("GPDL", resourceCulture);
     166            }
     167        }
     168       
     169        /// <summary>
    148170        ///   Looks up a localized string similar to PROBLEM MultiOutputMultiplier
    149171        ///
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Properties/Resources.resx

    r9519 r9674  
    128128    <value>..\Resources\Fib.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
    129129  </data>
     130  <data name="GPDL" type="System.Resources.ResXFileRef, System.Windows.Forms">
     131    <value>..\Resources\GPDL.xshd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     132  </data>
    130133  <data name="multi_output_multiplier" type="System.Resources.ResXFileRef, System.Windows.Forms">
    131134    <value>..\Resources\multi-output-multiplier.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
Note: See TracChangeset for help on using the changeset viewer.