Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10433


Ignore:
Timestamp:
01/31/14 17:34:11 (11 years ago)
Author:
abeham
Message:

#2127:

  • Fixed tab order in JobView and TaskView
  • Added additional events and registriations to account for changes to the jobs and tasks
Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/JobView.Designer.cs

    r9456 r10433  
    8080      this.dueDateLabel.Name = "dueDateLabel";
    8181      this.dueDateLabel.Size = new System.Drawing.Size(56, 13);
    82       this.dueDateLabel.TabIndex = 0;
     82      this.dueDateLabel.TabIndex = 2;
    8383      this.dueDateLabel.Text = "Due Date:";
    8484      //
     
    9090      this.dueDateTextBox.Name = "dueDateTextBox";
    9191      this.dueDateTextBox.Size = new System.Drawing.Size(451, 20);
    92       this.dueDateTextBox.TabIndex = 1;
     92      this.dueDateTextBox.TabIndex = 3;
    9393      this.dueDateTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.dueDateTextBox_Validating);
    9494      //
     
    101101      this.tasksGroupBox.Name = "tasksGroupBox";
    102102      this.tasksGroupBox.Size = new System.Drawing.Size(510, 214);
    103       this.tasksGroupBox.TabIndex = 2;
     103      this.tasksGroupBox.TabIndex = 4;
    104104      this.tasksGroupBox.TabStop = false;
    105105      this.tasksGroupBox.Text = "Tasks";
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/TaskView.Designer.cs

    r9456 r10433  
    8383      this.resourceNrLabel.Name = "resourceNrLabel";
    8484      this.resourceNrLabel.Size = new System.Drawing.Size(70, 13);
    85       this.resourceNrLabel.TabIndex = 0;
     85      this.resourceNrLabel.TabIndex = 2;
    8686      this.resourceNrLabel.Text = "Resource Nr:";
    8787      //
     
    9393      this.resourceNrTextBox.Name = "resourceNrTextBox";
    9494      this.resourceNrTextBox.Size = new System.Drawing.Size(437, 20);
    95       this.resourceNrTextBox.TabIndex = 1;
     95      this.resourceNrTextBox.TabIndex = 3;
    9696      this.resourceNrTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.resourceNrTextBox_Validating);
    9797      //
     
    106106      this.jobNrLabel.Name = "jobNrLabel";
    107107      this.jobNrLabel.Size = new System.Drawing.Size(41, 13);
    108       this.jobNrLabel.TabIndex = 0;
     108      this.jobNrLabel.TabIndex = 4;
    109109      this.jobNrLabel.Text = "Job Nr:";
    110110      //
     
    116116      this.jobNrTextBox.Name = "jobNrTextBox";
    117117      this.jobNrTextBox.Size = new System.Drawing.Size(437, 20);
    118       this.jobNrTextBox.TabIndex = 1;
     118      this.jobNrTextBox.TabIndex = 5;
    119119      this.jobNrTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.jobNrTextBox_Validating);
    120120      //
     
    125125      this.durationLabel.Name = "durationLabel";
    126126      this.durationLabel.Size = new System.Drawing.Size(50, 13);
    127       this.durationLabel.TabIndex = 0;
     127      this.durationLabel.TabIndex = 6;
    128128      this.durationLabel.Text = "Duration:";
    129129      //
     
    135135      this.durationTextBox.Name = "durationTextBox";
    136136      this.durationTextBox.Size = new System.Drawing.Size(437, 20);
    137       this.durationTextBox.TabIndex = 1;
     137      this.durationTextBox.TabIndex = 7;
    138138      this.durationTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.durationTextBox_Validating);
    139139      //
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs

    r9456 r10433  
    2020#endregion
    2121
     22using System;
    2223using System.ComponentModel;
    2324using System.Text;
     25using HeuristicLab.Collections;
    2426using HeuristicLab.Common;
    2527using HeuristicLab.Core;
     
    3840        bool changed = dueDate != value;
    3941        dueDate = value;
    40         if (changed) OnPropertyChanged("DueDate");
     42        if (changed) {
     43          OnPropertyChanged("DueDate");
     44          OnToStringChanged();
     45        }
    4146      }
    4247    }
     
    4954        bool changed = index != value;
    5055        index = value;
    51         if (changed) OnPropertyChanged("Index");
     56        if (changed) {
     57          OnPropertyChanged("Index");
     58          OnToStringChanged();
     59        }
    5260      }
    5361    }
     
    7179      this.Index = original.Index;
    7280      this.Tasks = cloner.Clone(original.Tasks);
     81      RegisterEventHandlers();
    7382    }
    7483    public Job() : this(-1, double.MaxValue) { }
     
    7887      Index = index;
    7988      Tasks = new ItemList<Task>();
     89      RegisterEventHandlers();
    8090    }
    8191
    8292    public override IDeepCloneable Clone(Cloner cloner) {
    8393      return new Job(this, cloner);
     94    }
     95
     96    [StorableHook(HookType.AfterDeserialization)]
     97    private void AfterDeserialization() {
     98      RegisterEventHandlers();
     99    }
     100
     101    private void RegisterEventHandlers() {
     102      Tasks.ItemsAdded += TasksOnItemsChanged;
     103      Tasks.ItemsRemoved += TasksOnItemsChanged;
     104      Tasks.ItemsReplaced += TasksOnItemsChanged;
     105      Tasks.CollectionReset += TasksOnItemsChanged;
     106      foreach (var task in Tasks) {
     107        task.PropertyChanged += TaskOnPropertyChanged;
     108        task.ToStringChanged += TaskOnToStringChanged;
     109      }
     110    }
     111
     112    private void TasksOnItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Task>> e) {
     113      foreach (var task in e.OldItems) {
     114        task.Value.PropertyChanged -= TaskOnPropertyChanged;
     115        task.Value.ToStringChanged -= TaskOnToStringChanged;
     116      }
     117      foreach (var task in e.Items) {
     118        task.Value.PropertyChanged += TaskOnPropertyChanged;
     119        task.Value.ToStringChanged += TaskOnToStringChanged;
     120      }
     121      OnTasksChanged();
     122      OnToStringChanged();
     123    }
     124
     125    private void TaskOnPropertyChanged(object sender, EventArgs e) {
     126      OnTasksChanged();
     127    }
     128
     129    private void TaskOnToStringChanged(object sender, EventArgs e) {
     130      OnToStringChanged();
    84131    }
    85132
     
    100147    }
    101148
     149    public event EventHandler TasksChanged;
     150    protected virtual void OnTasksChanged() {
     151      var handler = TasksChanged;
     152      if (handler != null) handler(this, EventArgs.Empty);
     153    }
     154
    102155    public event PropertyChangedEventHandler PropertyChanged;
    103156    protected virtual void OnPropertyChanged(string propertyName) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs

    r9456 r10433  
    3838        bool changed = taskNr != value;
    3939        taskNr = value;
    40         if (changed) OnPropertyChanged("TaskNr");
     40        if (changed) {
     41          OnPropertyChanged("TaskNr");
     42          OnToStringChanged();
     43        }
    4144      }
    4245    }
     
    4851        bool changed = resourceNr != value;
    4952        resourceNr = value;
    50         if (changed) OnPropertyChanged("ResourceNr");
     53        if (changed) {
     54          OnPropertyChanged("ResourceNr");
     55          OnToStringChanged();
     56        }
    5157      }
    5258    }
     
    115121    }
    116122
    117     public override bool Equals(object obj) {
    118       if (obj.GetType() == typeof(Task))
    119         return AreEqual(this, obj as Task);
    120       else
    121         return false;
    122     }
    123 
    124     public override int GetHashCode() {
    125       return TaskNr ^ JobNr;
    126     }
    127 
    128     public static bool AreEqual(Task task1, Task task2) {
    129       return (task1.Duration == task2.Duration &&
    130         task1.IsScheduled == task2.IsScheduled &&
    131         task1.JobNr == task2.JobNr &&
    132         task1.ResourceNr == task2.ResourceNr &&
    133         task1.TaskNr == task2.TaskNr);
    134     }
    135 
    136123    public event PropertyChangedEventHandler PropertyChanged;
    137124    protected virtual void OnPropertyChanged(string propertyName) {
  • trunk/sources/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r10213 r10433  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
     24using HeuristicLab.Collections;
     25using HeuristicLab.Encodings.ScheduleEncoding;
    2326using HeuristicLab.MainForm;
    2427using HeuristicLab.Optimization.Views;
     
    4346    protected override void OnContentChanged() {
    4447      base.OnContentChanged();
    45       if (Content == null) {
    46         ganttChart.Reset();
    47       } else {
    48         FillGanttChart(Content);
    49       }
     48      FillGanttChart();
    5049    }
    5150
    5251    protected override void DeregisterContentEvents() {
    53       Content.JobDataParameter.ValueChanged -= JobDataParameter_ValueChanged;
     52      Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged;
     53      Content.JobData.ItemsAdded -= JobsOnChanged;
     54      Content.JobData.ItemsRemoved -= JobsOnChanged;
     55      Content.JobData.ItemsReplaced -= JobsOnChanged;
     56      Content.JobData.CollectionReset -= JobsOnChanged;
     57      foreach (var job in Content.JobData) {
     58        job.TasksChanged -= JobOnTasksChanged;
     59      }
    5460      base.DeregisterContentEvents();
    5561    }
    5662    protected override void RegisterContentEvents() {
    5763      base.RegisterContentEvents();
    58       Content.JobDataParameter.ValueChanged += JobDataParameter_ValueChanged;
    59     }
    60 
    61     void JobDataParameter_ValueChanged(object sender, System.EventArgs e) {
    62       if (Content != null) {
    63         FillGanttChart(Content);
     64      Content.JobDataParameter.ValueChanged += JobDataParameterOnValueChanged;
     65      Content.JobData.ItemsAdded += JobsOnChanged;
     66      Content.JobData.ItemsRemoved += JobsOnChanged;
     67      Content.JobData.ItemsReplaced += JobsOnChanged;
     68      Content.JobData.CollectionReset += JobsOnChanged;
     69      foreach (var job in Content.JobData) {
     70        job.TasksChanged += JobOnTasksChanged;
    6471      }
    6572    }
    6673
    67     private void FillGanttChart(JobShopSchedulingProblem content) {
     74    private void JobsOnChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {
     75      foreach (var job in e.OldItems)
     76        job.Value.TasksChanged -= JobOnTasksChanged;
     77      foreach (var job in e.Items)
     78        job.Value.TasksChanged += JobOnTasksChanged;
     79      FillGanttChart();
     80    }
     81
     82    private void JobDataParameterOnValueChanged(object sender, EventArgs e) {
     83      Content.JobData.ItemsAdded += JobsOnChanged;
     84      Content.JobData.ItemsRemoved += JobsOnChanged;
     85      Content.JobData.ItemsReplaced += JobsOnChanged;
     86      Content.JobData.CollectionReset += JobsOnChanged;
     87      foreach (var job in Content.JobData) {
     88        job.TasksChanged += JobOnTasksChanged;
     89      }
     90      FillGanttChart();
     91    }
     92
     93    private void JobOnTasksChanged(object sender, EventArgs e) {
     94      FillGanttChart();
     95    }
     96
     97    private void FillGanttChart() {
    6898      ganttChart.Reset();
     99      if (Content == null) return;
    69100      int jobCount = 0;
    70       foreach (var j in content.JobData) {
     101      foreach (var j in Content.JobData) {
    71102        double lastEndTime = 0;
    72         foreach (var t in content.JobData[jobCount].Tasks) {
     103        foreach (var t in Content.JobData[jobCount].Tasks) {
    73104          int categoryNr = t.JobNr;
    74105          string categoryName = "Job" + categoryNr;
     
    78109            lastEndTime + 1,
    79110            lastEndTime + t.Duration,
    80             "Job" + t.JobNr + " - " + "Task#" + t.TaskNr.ToString());
     111            "Job" + t.JobNr + " - " + "Task#" + t.TaskNr);
    81112          lastEndTime += t.Duration;
    82113        }
Note: See TracChangeset for help on using the changeset viewer.