Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/11 15:20:23 (14 years ago)
Author:
cneumuel
Message:

#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
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/MenuItems/ExperimentManagerMenuItem.cs

    r6373 r6479  
    2727  public class ExperimentManagerMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
    2828    public override string Name {
    29       get { return "&Experiment Manager (dev)"; }
     29      get { return "&Experiment Manager"; }
    3030    }
    3131    public override IEnumerable<string> Structure {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/HiveExperimentPermissionView.Designer.cs

    r6463 r6479  
    6161      this.usernameTextBox.TabIndex = 3;
    6262      this.usernameTextBox.Validated += new System.EventHandler(this.usernameTextBox_Validated);
     63      this.usernameTextBox.Validating += new System.ComponentModel.CancelEventHandler(usernameTextBox_Validating);
    6364      //
    6465      // permissionComboBox
     
    7374      this.permissionComboBox.TabIndex = 4;
    7475      this.permissionComboBox.Validated += new System.EventHandler(this.permissionComboBox_Validated);
     76      this.permissionComboBox.Validating += new System.ComponentModel.CancelEventHandler(permissionComboBox_Validating);
    7577      //
    7678      // HiveExperimentPermissionView
     
    9294
    9395    }
    94 
    9596    #endregion
    9697
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/HiveExperimentPermissionView.cs

    r6465 r6479  
    2020#endregion
    2121
     22using System.ComponentModel;
    2223using HeuristicLab.Clients.Hive.Views;
    2324using HeuristicLab.MainForm;
     
    6263
    6364    #region Child Control Events
    64     private void usernameTextBox_Validated(object sender, System.EventArgs e) {
     65
     66    private void usernameTextBox_Validating(object sender, CancelEventArgs e) {
    6567      Content.GrantedUserName = usernameTextBox.Text;
    6668    }
     69    private void usernameTextBox_Validated(object sender, System.EventArgs e) {
     70     
     71    }
    6772
     73    private void permissionComboBox_Validating(object sender, CancelEventArgs e) {
     74      Content.Permission = (Permission)permissionComboBox.SelectedItem;
     75    }
    6876    private void permissionComboBox_Validated(object sender, System.EventArgs e) {
    69       Content.Permission = (Permission)permissionComboBox.SelectedItem;
     77     
    7078    }
    7179    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentListView.cs

    r6465 r6479  
    3939      this.itemsListView.HeaderStyle = ColumnHeaderStyle.Clickable;
    4040      this.itemsListView.FullRowSelect = true;
     41      this.itemsListView.Sorting = SortOrder.Ascending;
     42      this.itemsListView.Sort();
    4143    }
    4244
    4345    protected override RefreshableHiveExperiment CreateItem() {
    44       return new RefreshableHiveExperiment();
     46      return new RefreshableHiveExperiment() { IsAllowedPrivileged = HiveClient.Instance.IsAllowedPrivileged };
    4547    }
    4648
     
    5254    }
    5355
     56    protected override void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<RefreshableHiveExperiment> e) {
     57      base.Content_ItemsAdded(sender, e);
     58
     59    }
     60
    5461    protected override ListViewItem CreateListViewItem(RefreshableHiveExperiment item) {
    5562      ListViewItem listViewItem = base.CreateListViewItem(item);
     
    5966      listViewItem.Group = GetListViewGroup(item.HiveExperiment.OwnerUsername);
    6067      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;
    6177    }
    6278
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.Designer.cs

    r6463 r6479  
    5555      this.stateLogViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5656      this.sharingTabPage = new System.Windows.Forms.TabPage();
     57      this.refreshPermissionsButton = new System.Windows.Forms.Button();
    5758      this.hiveExperimentPermissionListView = new HeuristicLab.Clients.Hive.ExperimentManager.Views.HiveExperimentPermissionListView();
    5859      this.logTabPage = new System.Windows.Forms.TabPage();
     
    7980      this.calculatingLabel = new System.Windows.Forms.Label();
    8081      this.jobsLabel = new System.Windows.Forms.Label();
    81       this.refreshPermissionsButton = new System.Windows.Forms.Button();
    8282      this.tabControl.SuspendLayout();
    8383      this.jobsTabPage.SuspendLayout();
     
    102102      this.tabControl.Size = new System.Drawing.Size(717, 452);
    103103      this.tabControl.TabIndex = 4;
     104      this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged);
    104105      //
    105106      // jobsTabPage
     
    165166      this.sharingTabPage.UseVisualStyleBackColor = true;
    166167      //
     168      // refreshPermissionsButton
     169      //
     170      this.refreshPermissionsButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshPermissionsButton.Image")));
     171      this.refreshPermissionsButton.Location = new System.Drawing.Point(3, 3);
     172      this.refreshPermissionsButton.Name = "refreshPermissionsButton";
     173      this.refreshPermissionsButton.Size = new System.Drawing.Size(24, 24);
     174      this.refreshPermissionsButton.TabIndex = 23;
     175      this.toolTip.SetToolTip(this.refreshPermissionsButton, "Refresh Data");
     176      this.refreshPermissionsButton.UseVisualStyleBackColor = true;
     177      this.refreshPermissionsButton.Click += new System.EventHandler(this.refreshPermissionsButton_Click);
     178      //
    167179      // hiveExperimentPermissionListView
    168180      //
     
    172184      this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View";
    173185      this.hiveExperimentPermissionListView.Content = null;
     186      this.hiveExperimentPermissionListView.HiveExperimentId = new System.Guid("00000000-0000-0000-0000-000000000000");
    174187      this.hiveExperimentPermissionListView.Location = new System.Drawing.Point(3, 33);
    175188      this.hiveExperimentPermissionListView.Name = "hiveExperimentPermissionListView";
     
    410423      this.jobsLabel.TabIndex = 0;
    411424      this.jobsLabel.Text = "Jobs:";
    412       //
    413       // refreshPermissionsButton
    414       //
    415       this.refreshPermissionsButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshPermissionsButton.Image")));
    416       this.refreshPermissionsButton.Location = new System.Drawing.Point(3, 3);
    417       this.refreshPermissionsButton.Name = "refreshPermissionsButton";
    418       this.refreshPermissionsButton.Size = new System.Drawing.Size(24, 24);
    419       this.refreshPermissionsButton.TabIndex = 23;
    420       this.toolTip.SetToolTip(this.refreshPermissionsButton, "Refresh Data");
    421       this.refreshPermissionsButton.UseVisualStyleBackColor = true;
    422       this.refreshPermissionsButton.Click += new System.EventHandler(this.refreshPermissionsButton_Click);
    423425      //
    424426      // RefreshableHiveExperimentView
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.cs

    r6463 r6479  
    6363      Content.ExceptionOccured += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
    6464      Content.StateLogListChanged += new EventHandler(Content_StateLogListChanged);
     65      Content.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);
     66      Content.HiveJobsChanged += new EventHandler(Content_HiveJobChanged);
     67      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
     68      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
     69      Content.IsAllowedPrivilegedChanged += new EventHandler(Content_IsAllowedPrivilegedChanged);
    6570    }
    6671
     
    7277      Content.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
    7378      Content.StateLogListChanged -= new EventHandler(Content_StateLogListChanged);
     79      Content.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);
     80      Content.HiveJobsChanged -= new EventHandler(Content_HiveJobChanged);
     81      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
     82      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
    7483      base.DeregisterContentEvents();
    7584    }
    7685
    7786    private void RegisterHiveExperimentEvents() {
    78       Content.HiveExperiment.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
    79       Content.HiveExperiment.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
    80       Content.HiveExperiment.HiveJobsChanged += new EventHandler(Content_HiveJobChanged);
    81       Content.HiveExperiment.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);
    8287      Content.HiveExperiment.PropertyChanged += new PropertyChangedEventHandler(HiveExperiment_PropertyChanged);
    8388    }
    8489   
    8590    private void DeregisterHiveExperimentEvents() {
    86       Content.HiveExperiment.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
    87       Content.HiveExperiment.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
    88       Content.HiveExperiment.HiveJobsChanged -= new EventHandler(Content_HiveJobChanged);
    89       Content.HiveExperiment.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);
    9091      Content.HiveExperiment.PropertyChanged -= new PropertyChangedEventHandler(HiveExperiment_PropertyChanged);
    9192    }
    9293
    9394    private void RegisterHiveJobEvents() {
    94       Content.HiveExperiment.HiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    95       Content.HiveExperiment.HiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    96       Content.HiveExperiment.HiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     95      Content.HiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     96      Content.HiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     97      Content.HiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    9798    }
    9899    private void DeregisterHiveJobEvents() {
    99       Content.HiveExperiment.HiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    100       Content.HiveExperiment.HiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    101       Content.HiveExperiment.HiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     100      Content.HiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     101      Content.HiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     102      Content.HiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    102103    }
    103104
     
    114115      } else {
    115116        nameTextBox.Text = Content.HiveExperiment.Name;
    116         executionTimeTextBox.Text = Content.HiveExperiment.ExecutionTime.ToString();
     117        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    117118        resourceNamesTextBox.Text = Content.HiveExperiment.ResourceNames;
    118119        isPrivilegedCheckBox.Checked = Content.HiveExperiment.IsPrivileged;
     
    139140      if (Content != null) {
    140141        bool alreadyUploaded = Content.Id != Guid.Empty;
    141         bool jobsLoaded = Content.HiveExperiment.HiveJobs != null && Content.HiveExperiment.HiveJobs.All(x => x.Job.Id != Guid.Empty);
    142 
    143         this.nameTextBox.ReadOnly = !Content.IsControllable || Content.HiveExperiment.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
    144         this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.HiveExperiment.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
    145         this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.HiveExperiment.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
    146 
    147         this.isPrivilegedCheckBox.Enabled = Content.IsControllable && !(Content.HiveExperiment.ExecutionState != ExecutionState.Prepared || alreadyUploaded); // TODO: check if user has the rights to do this       
    148         this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.HiveExperiment.ExecutionState == ExecutionState.Started;
    149         this.refreshButton.Enabled = Content.IsControllable && alreadyUploaded;
    150         this.Locked = !Content.IsControllable || Content.HiveExperiment.ExecutionState == ExecutionState.Started;
    151 
     142        bool jobsLoaded = Content.HiveJobs != null && Content.HiveJobs.All(x => x.Job.Id != Guid.Empty);
     143
     144        this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
     145        this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
     146        this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
     147
     148        this.isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded); // TODO: check if user has the rights to do this       
     149        this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started;
     150        this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded;
     151        this.Locked = !Content.IsControllable || Content.ExecutionState == ExecutionState.Started;
    152152      }
    153153      SetEnabledStateOfExecutableButtons();
     154      tabControl_SelectedIndexChanged(this, EventArgs.Empty); // ensure sharing tabpage is disabled
    154155    }
    155156
     
    214215        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
    215216      else
    216         executionTimeTextBox.Text = Content.HiveExperiment.ExecutionTime.ToString();
     217        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    217218    }
    218219    private void Content_RefreshAutomaticallyChanged(object sender, EventArgs e) {
     
    228229        Invoke(new EventHandler(Content_HiveJobChanged), sender, e);
    229230      else {
    230         if (Content != null && Content.HiveExperiment.HiveJobs != null) {
    231           jobsTreeView.Content = Content.HiveExperiment.HiveJobs;
     231        if (Content != null && Content.HiveJobs != null) {
     232          jobsTreeView.Content = Content.HiveJobs;
    232233          RegisterHiveJobEvents();
    233234        } else {
     
    263264    }
    264265    private void Content_ExceptionOccured(object sender, EventArgs<Exception> e) {
    265       if (Content.IsControllable) {
    266         // show error dialog only if Controllable (otherwise it should continue trying without an error dialog (e.g. HiveEngine))
    267         ErrorHandling.ShowErrorDialog(this, e.Value);
    268       }
     266      // don't show exception, it is logged anyway
    269267    }
    270268    private void Content_StateLogListChanged(object sender, EventArgs e) {
     
    275273      }
    276274    }
     275    private void Content_IsAllowedPrivilegedChanged(object sender, EventArgs e) {
     276      if (InvokeRequired)
     277        Invoke(new EventHandler(Content_IsAllowedPrivilegedChanged), sender, e);
     278      else {
     279        SetEnabledStateOfControls();
     280      }
     281    }
     282
    277283
    278284    private void UpdateStateLogList() {
    279285      if (Content != null && this.Content.HiveExperiment != null) {
    280         stateLogViewHost.Content = this.Content.HiveExperiment.StateLogList;
     286        stateLogViewHost.Content = this.Content.StateLogList;
    281287      } else {
    282288        stateLogViewHost.Content = null;
     
    294300    }
    295301    private void pauseButton_Click(object sender, EventArgs e) {
    296       HiveClient.PauseExperiment(Content.HiveExperiment);
     302      HiveClient.PauseExperiment(Content);
    297303    }
    298304    private void stopButton_Click(object sender, EventArgs e) {
    299       HiveClient.StopExperiment(Content.HiveExperiment);
     305      HiveClient.StopExperiment(Content);
    300306    }
    301307    private void resetButton_Click(object sender, EventArgs e) { }
     
    320326
    321327    private void refreshButton_Click(object sender, EventArgs e) {
    322       var invoker = new Action<HiveExperiment>(HiveClient.LoadExperiment);
    323       invoker.BeginInvoke(Content.HiveExperiment, (ar) => {
     328      var invoker = new Action<RefreshableHiveExperiment>(HiveClient.LoadExperiment);
     329      invoker.BeginInvoke(Content, (ar) => {
    324330        try {
    325331          invoker.EndInvoke(ar);
     
    343349        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    344350      } else {
    345         startButton.Enabled = Content.IsControllable && Content.HiveExperiment.HiveJobs != null && Content.HiveExperiment.HiveJobs.Count > 0 && Content.HiveExperiment.ExecutionState == ExecutionState.Prepared;
    346         pauseButton.Enabled = Content.IsControllable && Content.HiveExperiment.ExecutionState == ExecutionState.Started;
    347         stopButton.Enabled = Content.IsControllable && Content.HiveExperiment.ExecutionState == ExecutionState.Started;
     351        startButton.Enabled = Content.IsControllable && Content.HiveJobs != null && Content.HiveJobs.Count > 0 && Content.ExecutionState == ExecutionState.Prepared;
     352        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
     353        stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
    348354        resetButton.Enabled = false;
    349355      }
     
    356362        Invoke(new EventHandler(Content_IsProgressingChanged), sender, e);
    357363      } else {
    358         if (Content != null && Content.HiveExperiment.IsProgressing) {
     364        if (Content != null && Content.IsProgressing) {
    359365          SetProgressView();
    360366        } else {
     
    366372    private void SetProgressView() {
    367373      if (progressView == null) {
    368         progressView = new ProgressView(this, Content.HiveExperiment.Progress);
    369       }
    370       progressView.Progress = Content.HiveExperiment.Progress;
     374        progressView = new ProgressView(this, Content.Progress);
     375      }
     376      progressView.Progress = Content.Progress;
    371377    }
    372378
     
    389395      var obj = e.Data.GetData(Constants.DragDropDataFormat);
    390396      if (obj is IOptimizer) {
    391         e.Effect = DragDropEffects.Copy;
     397        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     398        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
    392399      }
    393400    }
     
    399406        var optimizer = obj as IOptimizer;
    400407        if (optimizer != null) {
    401           Content.HiveExperiment.HiveJobs.Add(new OptimizerHiveJob(optimizer));
     408          Content.HiveJobs.Add(new OptimizerHiveJob(e.Effect.HasFlag(DragDropEffects.Copy) ? (IOptimizer)optimizer.Clone() : optimizer));
    402409        }
    403410      }
    404411    }
    405412    #endregion
     413
     414    private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
     415      if (tabControl.SelectedTab == sharingTabPage) {
     416        if (!Content.IsSharable) {
     417          MessageBox.Show("Unable to load tab. You have insufficient access privileges.");
     418          tabControl.SelectedTab = jobsTabPage;
     419        }
     420      }
     421    }
    406422  }
    407423}
Note: See TracChangeset for help on using the changeset viewer.