Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentListView.cs @ 6479

Last change on this file since 6479 was 6479, checked in by cneumuel, 13 years ago

#1233

  • finished experiment sharing
  • added role for executing privileged jobs
  • refreshing experiments in experimentManager does not delete already downloaded jobs
  • moved some properties from HiveExperiment into RefreshableHiveExperiment
File size: 4.1 KB
Line 
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
22using System;
23using System.Windows.Forms;
24using HeuristicLab.Core;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27
28namespace HeuristicLab.Clients.Hive.ExperimentManager.Views {
29  [View("HiveExperimentList View")]
30  [Content(typeof(ItemCollection<RefreshableHiveExperiment>), false)]
31  public partial class RefreshableHiveExperimentListView : ItemCollectionView<RefreshableHiveExperiment> {
32
33    public RefreshableHiveExperimentListView() {
34      InitializeComponent();
35      this.itemsListView.View = View.Details;
36      this.itemsListView.Columns.Clear();
37      this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" });
38      this.itemsListView.Columns.Add(new ColumnHeader("Name") { Text = "Name" });
39      this.itemsListView.HeaderStyle = ColumnHeaderStyle.Clickable;
40      this.itemsListView.FullRowSelect = true;
41      this.itemsListView.Sorting = SortOrder.Ascending;
42      this.itemsListView.Sort();
43    }
44
45    protected override RefreshableHiveExperiment CreateItem() {
46      return new RefreshableHiveExperiment() { IsAllowedPrivileged = HiveClient.Instance.IsAllowedPrivileged };
47    }
48
49    protected override void removeButton_Click(object sender, EventArgs e) {
50      DialogResult result = MessageBox.Show("This action will permanently delete this experiment (also on the hive server). Continue?", "Delete Experiment", MessageBoxButtons.OKCancel);
51      if (result == DialogResult.OK) {
52        base.removeButton_Click(sender, e);
53      }
54    }
55
56    protected override void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<RefreshableHiveExperiment> e) {
57      base.Content_ItemsAdded(sender, e);
58
59    }
60
61    protected override ListViewItem CreateListViewItem(RefreshableHiveExperiment item) {
62      ListViewItem listViewItem = base.CreateListViewItem(item);
63      listViewItem.SubItems.Clear();
64      listViewItem.SubItems.Insert(0, new ListViewItem.ListViewSubItem(listViewItem, item.HiveExperiment.DateCreated.ToString("dd.MM.yyyy HH:mm")));
65      listViewItem.SubItems.Insert(1, new ListViewItem.ListViewSubItem(listViewItem, item.HiveExperiment.Name));
66      listViewItem.Group = GetListViewGroup(item.HiveExperiment.OwnerUsername);
67      return listViewItem;
68    }
69
70    protected override void UpdateListViewItemText(ListViewItem listViewItem) {
71      if (listViewItem == null) throw new ArgumentNullException();
72      var item = listViewItem.Tag as RefreshableHiveExperiment;
73      listViewItem.SubItems[0].Text = item == null ? "null" : item.HiveExperiment.DateCreated.ToString("dd.MM.yyyy HH:mm");
74      listViewItem.SubItems[1].Text = item == null ? "null" : item.HiveExperiment.Name;
75      listViewItem.Group = GetListViewGroup(item.HiveExperiment.OwnerUsername);
76      listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription;
77    }
78
79    private ListViewGroup GetListViewGroup(string groupName) {
80      foreach (ListViewGroup group in itemsListView.Groups) {
81        if (group.Name == groupName)
82          return group;
83      }
84      var newGroup = new ListViewGroup(string.Format("Owner ({0})", groupName), HorizontalAlignment.Left) { Name = groupName };
85      itemsListView.Groups.Add(newGroup);
86      return newGroup;
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.