1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2011 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 |
|
---|
22 | using System;
|
---|
23 | using System.Windows.Forms;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Core.Views;
|
---|
26 | using HeuristicLab.MainForm;
|
---|
27 | using HeuristicLab.PluginInfrastructure;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.Scheduling.Views {
|
---|
30 | [View("JobShop Scheduling Problem View")]
|
---|
31 | [Content(typeof(JobShopSchedulingProblem), true)]
|
---|
32 | public partial class JobShopSchedulingProblemView : NamedItemView {
|
---|
33 | public JobShopSchedulingProblemView() {
|
---|
34 | InitializeComponent();
|
---|
35 | }
|
---|
36 | private SchedulingProblemImportDialog spImportDialog;
|
---|
37 |
|
---|
38 | public new JobShopSchedulingProblem Content {
|
---|
39 | get { return (JobShopSchedulingProblem)base.Content; }
|
---|
40 | set { base.Content = value; }
|
---|
41 | }
|
---|
42 |
|
---|
43 | protected override void OnContentChanged() {
|
---|
44 | base.OnContentChanged();
|
---|
45 | if (Content == null) {
|
---|
46 | parameterCollectionView.Content = null;
|
---|
47 | ganttChart.Reset();
|
---|
48 | } else {
|
---|
49 | parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
|
---|
50 | FillGanttChart(Content);
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | private void FillGanttChart(JobShopSchedulingProblem content) {
|
---|
55 | //Add Jobs as Categories
|
---|
56 | ganttChart.Reset();
|
---|
57 | int jobCount = 0;
|
---|
58 | Random random = new Random(1);
|
---|
59 | foreach (Job j in content.JobData) {
|
---|
60 | double lastEndTime = 0;
|
---|
61 | foreach (Task t in content.JobData[jobCount].Tasks) {
|
---|
62 | int categoryNr = t.JobNr;
|
---|
63 | string categoryName = "Job" + categoryNr;
|
---|
64 | ganttChart.AddJobColor(categoryNr);
|
---|
65 | ganttChart.AddData(categoryName,
|
---|
66 | categoryNr,
|
---|
67 | lastEndTime + 1,
|
---|
68 | lastEndTime + t.Duration,
|
---|
69 | "Job" + t.JobNr + " - " + "Task#" + t.TaskNr.ToString());
|
---|
70 | lastEndTime += t.Duration;
|
---|
71 | }
|
---|
72 | jobCount++;
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | protected override void SetEnabledStateOfControls() {
|
---|
77 | base.SetEnabledStateOfControls();
|
---|
78 | parameterCollectionView.Enabled = Content != null;
|
---|
79 | importButton.Enabled = Content != null && !ReadOnly;
|
---|
80 | }
|
---|
81 |
|
---|
82 | private void importButton_Click(object sender, EventArgs e) {
|
---|
83 | if (spImportDialog == null) spImportDialog = new SchedulingProblemImportDialog();
|
---|
84 |
|
---|
85 | if (spImportDialog.ShowDialog(this) == DialogResult.OK) {
|
---|
86 | try {
|
---|
87 | switch (spImportDialog.Format) {
|
---|
88 | case SPFormat.ORLib:
|
---|
89 | Content.ImportFromORLibrary(spImportDialog.SPFileName);
|
---|
90 | break;
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | if (!string.IsNullOrEmpty(spImportDialog.OptimalScheduleFileName))
|
---|
95 | Content.ImportJSMSolution(spImportDialog.OptimalScheduleFileName);
|
---|
96 | OnContentChanged();
|
---|
97 | }
|
---|
98 | catch (Exception ex) {
|
---|
99 | ErrorHandling.ShowErrorDialog(this, ex);
|
---|
100 | }
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|
104 | }
|
---|