Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs @ 9844

Last change on this file since 9844 was 9843, checked in by gkronber, 11 years ago

#2026 made the problem field non-static, added a unit test to compile all examples

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.IO;
24using System.Linq;
25using System.Text;
26using HeuristicLab.MainForm.WindowsForms;
27using HeuristicLab.Problems.Instances;
28using HeuristicLab.Problems.Instances.Views;
29
30namespace HeuristicLab.Problems.GPDL.Views {
31  public partial class GpdlEditor : AsynchronousContentView, IProblemInstanceConsumer<string> {
32    public GpdlEditor() {
33      InitializeComponent();
34
35      viewHost.Content = null; //necessary to enable the change of the ViewType
36      viewHost.ViewType = typeof(GpdlProblemInstanceConsumerView);
37      viewHost.Content = this;
38      ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)viewHost.ActiveView;
39      splitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any();
40    }
41
42    private void compileButton_Click(object sender, EventArgs e) {
43
44      using (var src = new MemoryStream(Encoding.UTF8.GetBytes(codeEditor.textEditor.Text))) {
45        Scanner scanner = new Scanner(src);
46        Parser parser = new Parser(scanner);
47        parser.Parse();
48        MainForm.MainFormManager.MainForm.ShowContent(parser.problem);
49      }
50
51      codeEditor.ClearErrors();
52
53      // TODO adapt to Coco/R error handling to show errors in the GUI
54
55      //if (Errors.NumOfErrors() == 0) {
56      //  GPDefLex.InitLex();
57      //  GPDefSyn.Interpret();
58
59      //} else {
60      //  int nLexErrors = Errors.NumOfLexErrors();
61      //  for (int i = 0; i < nLexErrors; i++) {
62      //    var lexErr = Errors.GetLexError(i == 0);
63      //    codeEditor.SetLexError(lexErr.msg, lexErr.line, lexErr.col);
64      //  }
65      //  int nSynErrors = Errors.NumOfSynErrors();
66      //  for (int i = 0; i < nSynErrors; i++) {
67      //    var synErr = Errors.GetSynError(i == 0);
68      //    codeEditor.SetLexError(synErr.msg, synErr.line, synErr.col);
69      //  }
70      //}
71    }
72
73
74    void IProblemInstanceConsumer<string>.Load(string data) {
75      codeEditor.textEditor.Text = data;
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.