Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2026 worked on GPDL integration into HL.
Implemented problem provider for examples. Implemented editor for GPDL definitions.

File size: 2.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.IO;
7using System.Linq;
8using System.Text;
9using System.Windows.Forms;
10using HeuristicLab.MainForm.WindowsForms;
11using HeuristicLab.Optimization.Views;
12using HeuristicLab.Problems.Instances;
13using HeuristicLab.Problems.Instances.Views;
14
15namespace HeuristicLab.Problems.GPDL.Views {
16  public partial class GpdlEditor : AsynchronousContentView, IProblemInstanceConsumer<string> {
17    public GpdlEditor() {
18      InitializeComponent();
19
20      viewHost.Content = null; //necessary to enable the change of the ViewType
21      viewHost.ViewType = typeof(GpdlProblemInstanceConsumerView);
22      viewHost.Content = this;
23      ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)viewHost.ActiveView;
24      splitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any();
25    }
26
27    private void compileButton_Click(object sender, EventArgs e) {
28      Utils.InstallModule("Utils", new Utils.ModuleMethodDelegate(Utils.UtilsMethod));
29      Utils.InstallModule("Sets", new Utils.ModuleMethodDelegate(Sets.SetsMethod));
30      Utils.InstallModule("Errors", new Utils.ModuleMethodDelegate(Errors.ErrorsMethod));
31
32      Utils.InstallModule("GPDefLex", new Utils.ModuleMethodDelegate(GPDefLex.GPDefLexMethod));
33      Utils.InstallModule("GPDefSem", new Utils.ModuleMethodDelegate(GPDefSem.GPDefSemMethod));
34      Utils.InstallModule("GPDefSyn", new Utils.ModuleMethodDelegate(GPDefSyn.GPDefSynMethod));
35
36      // --- initialize modules ---
37      Utils.Modules(Utils.ModuleAction.initModule);
38
39      Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
40
41      using (var src = new StringReader(gpdlTextBox.Text)) {
42        GPDefLex.src = src;
43        GPDefSyn.Parse();
44      }
45
46      GPDefLex.InitLex();
47      GPDefSyn.Interpret();
48
49      MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem);
50    }
51
52    private void Abort(string abortKind, string moduleName, string methodName, string descr) {
53
54    }
55
56    void IProblemInstanceConsumer<string>.Load(string data) {
57      this.gpdlTextBox.Text = data;
58    }
59
60  }
61}
Note: See TracBrowser for help on using the repository browser.