Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 14:28:13 (5 years ago)
Author:
mkommend
Message:

#2839: Merged 16117, 16122, 16173, 16184, 16185, 16186, 16187, 16202, 16203, 16204, 16205, 16208, 16211, 16209, 16211, 16219, 16257, 16247 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.JobManager

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManagermergedeligible
      /trunk/HeuristicLab.Clients.Hive.JobManagermergedeligible
      /branches/1721-RandomForestPersistence/HeuristicLab.Clients.Hive.JobManager10321-10322
      /branches/2916_IndexedDataTableSerialization/HeuristicLab.Clients.Hive.JobManager15918
      /branches/2947_ConfigurableIndexedDataTable/HeuristicLab.Clients.Hive.JobManager16148-16526
      /branches/2972_PDPRowSelect/HeuristicLab.Clients.Hive.JobManager16444-16518
      /branches/Algorithms.GradientDescent/HeuristicLab.Clients.Hive.JobManager5516-5520
      /branches/Async/HeuristicLab.Clients.Hive.JobManager13329-15286
      /branches/Benchmarking/sources/HeuristicLab.Clients.Hive.JobManager6917-7005
      /branches/CloningRefactoring/HeuristicLab.Clients.Hive.JobManager4656-4721
      /branches/CodeEditor/HeuristicLab.Clients.Hive.JobManager11700-11806
      /branches/DataAnalysis Refactoring/HeuristicLab.Clients.Hive.JobManager5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Clients.Hive.JobManager5815-6180
      /branches/DataAnalysis/HeuristicLab.Clients.Hive.JobManager4458-4459,​4462,​4464
      /branches/DataPreprocessing/HeuristicLab.Clients.Hive.JobManager10085-11101
      /branches/GP.Grammar.Editor/HeuristicLab.Clients.Hive.JobManager6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Clients.Hive.JobManager5060
      /branches/HLScript/HeuristicLab.Clients.Hive.JobManager10331-10358
      /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Clients.Hive.JobManager11570-12508
      /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Clients.Hive.JobManager6123-9799
      /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Clients.Hive.JobManager11130-12721
      /branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager15377-15760
      /branches/HiveStatistics/sources/HeuristicLab.Clients.Hive.JobManager12440-12877
      /branches/LogResidualEvaluator/HeuristicLab.Clients.Hive.JobManager10202-10483
      /branches/NET40/sources/HeuristicLab.Clients.Hive.JobManager5138-5162
      /branches/NSGA-II Changes/HeuristicLab.Clients.Hive.JobManager12033-12122
      /branches/ParallelEngine/HeuristicLab.Clients.Hive.JobManager5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Clients.Hive.JobManager7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Clients.Hive.JobManager6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Clients.Hive.JobManager6828
      /branches/RuntimeOptimizer/HeuristicLab.Clients.Hive.JobManager8943-9078
      /branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.JobManager7787-8333
      /branches/SlaveShutdown/HeuristicLab.Clients.Hive.JobManager8944-8956
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Clients.Hive.JobManager10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Clients.Hive.JobManager5370-5682
      /branches/Trunk/HeuristicLab.Clients.Hive.JobManager6829-6865
      /branches/UnloadJobs/HeuristicLab.Clients.Hive.JobManager9168-9215
      /branches/VNS/HeuristicLab.Clients.Hive.JobManager5594-5752
      /branches/crossvalidation-2434/HeuristicLab.Clients.Hive.JobManager12948-12950
      /branches/histogram/HeuristicLab.Clients.Hive.JobManager5959-6341
      /branches/symbreg-factors-2650/HeuristicLab.Clients.Hive.JobManager14232-14825
      /trunk/sources/HeuristicLab.Clients.Hive.JobManager9493,​9496,​9498,​9504-9506,​9515-9517,​9520-9521,​9523,​9530-9531,​9534-9537,​9540,​9542-9544,​9552-9555,​9568-9569,​9587,​9590-9592,​9600,​9607-9608,​9610-9611,​9613,​9618,​9623-9624,​9626,​9647-9649,​9652,​9657-9660,​9664-9666,​9675,​9692,​9695,​9699,​9702,​9710,​9714,​9718-9720,​9740-9741,​9751-9752,​9755,​9762,​9764-9775,​9777-9778,​9782-9786,​9792,​9794-9795,​9803-9812,​9816-9822,​9824-9825,​9828,​9830,​9833,​9837-9841,​9845,​9848-9851,​9855,​9859-9860,​9863,​9865-9868,​9871,​9893-9897,​9900-9902,​9905-9907,​9910,​9915-9916,​9919-9921,​9928,​9930,​9934-9935,​9938-9941,​9944,​9946,​9949,​9955-9956,​9958-9959,​9964-9965,​9973-9975,​9978,​9980-9982,​9988-9989,​9991-9992,​9994-9995,​9997,​10000-10005,​10009-10010,​10015,​10130,​10149-10150,​10154,​10170-10171,​10173-10176,​10195-10196,​10212-10213,​10231,​10261,​10273,​10291-10292,​10295,​10298,​10323-10324,​10346,​10348,​10355,​10359-10360,​10362-10363,​10365-10366,​10368,​10375,​10378,​10391,​10401,​10406-10407,​10414,​10417-10418,​10428,​10432-10433,​10435,​10440,​10448,​10453,​10460,​10465-10466,​10469-10470,​10472,​10474-10477,​10480,​10484,​10486,​10488-10500,​10503-10504,​10506,​10510-10512,​10519-10523,​10526,​10531,​10540-10541,​10543,​10545,​10561-10566,​10575-10578,​10596-10597,​10599,​10601-10607,​10639,​10642-10643,​10646,​10651-10653,​10727,​10731,​10745,​10747,​10761,​10767,​10774,​10787-10791,​10793-10794,​10796,​10799-10800,​10826,​10857-10862,​10865,​10885,​10889,​10894-10896,​10924,​10926-10927,​10937,​10941,​10953,​10955-10956,​10958-10961,​10963,​10975,​10983-10986,​10988-10989,​10996,​11007-11008,​11012-11014,​11019,​11024-11027,​11031,​11034-11035,​11048,​11050-11052,​11056-11058,​11060,​11065-11067,​11071,​11074-11082,​11086-11088,​11091-11093,​11095-11097,​11099-11100,​11102,​11108,​11111-11117,​11123-11128,​11131,​11135,​11153,​11156,​11161,​11214,​11241,​11243,​11248-11251,​11256,​11263,​11274,​11280,​11282-11283,​11285-11287,​11290,​11292,​11294-11296,​11298,​11300,​11302,​11306,​11308-11309,​11313,​11315,​11317,​11324,​11326,​11330-11332,​11337-11348,​11352-11353,​11361-11362,​11364-11367,​11380-11382,​11384,​11389,​11391-11392,​11394,​11403-11404,​11410-11411,​11417-11420,​11422,​11426-11430,​11432,​11434-11437,​11439-11448,​11450,​11453,​11455-11457,​11464,​11466-11467,​11469-11472,​11474,​11477-11480,​11483,​11494-11498,​11504,​11514-11515,​11523-11525,​11532-11533,​11536,​11540-11542,​11544-11545,​11547-11549,​11555,​11557,​11581,​11592,​11596-11597,​11599-11600,​11605,​11608,​11610,​11615-11616,​11618,​11623,​11631,​11634,​11650-11652,​11657,​11675,​11679-11680,​11703-11706,​11715,​11717,​11721,​11723-11725,​11734-11736,​11756-11758,​11762-11764,​11766,​11771-11772,​11781-11782,​11784,​11787-11790,​11794,​11807-11811,​11815-11816,​11818-11819,​11822,​11825-11831,​11833-11837,​11839-11840,​11853-11854,​11856,​11877-11879,​11882,​11890,​11909,​11912-11918,​11921,​11930,​11933-11934,​11936,​11938-11939,​11942,​11945,​11948,​11950-11951,​11955-11956,​11958-11961,​11963,​11967,​11970-11971,​11978,​11982-11984,​11987-11994,​11996,​11998-12004,​12015-12744,​12755,​12770,​12772,​12787,​12790-12798,​12801,​12807,​12810-12812,​12816-12819,​12835-12837,​12839,​12844-12846,​12851,​12855,​12868,​12873,​12875,​12878-12879,​12883,​12885-12886,​12889,​12894-12907,​12911-12918,​12920-12921,​12925-12927,​12932,​12934,​12936-12938,​12940,​12946-12948,​12953-12954,​12959-12961,​12971-12973,​12975-12978,​12981-12983,​12986-12987,​13000-13005,​13008,​13014,​13016,​13024-13027,​13030,​13033-13034,​13036,​13038-13040,​13051,​13054-13060,​13064-13066,​13078,​13080,​13087,​13093-13094,​13100-13104,​13109,​13116,​13118-13121,​13131,​13133,​13136-13143,​13154,​13157-13160,​13162-13165,​13167-13169,​13173,​13180-13181,​13183,​13186,​13198,​13200-13201,​13203-13205,​13209-13210,​13212,​13214,​13217-13219,​13222-13228,​13230-13239,​13241-13245,​13247-13257,​13260-13261,​13266-13271,​13288,​13300,​13307-13309,​13311,​13313-13315,​13318,​13392-13393,​13395,​13402,​13406,​13411,​13413-13415,​13419-13420,​13425,​13427-13430,​13433-13434,​13438-13442,​13445-13447,​13450,​13458,​13471,​13473-13474,​13484,​13491,​13494,​13498-13504,​13507-13514,​13516-13517,​13525-13526,​13529,​13534-13535,​13539-13540,​13549-13550,​13552,​13560,​13566-13567,​13570-13573,​13579-13582,​13584-13586,​13592-13593,​13597,​13614,​13616,​13621,​13626-13629,​13635,​13644-13646,​13648,​13650-13655,​13657-13662,​13666,​13669-13671,​13675-13684,​13690-13693,​13695,​13697-13705,​13707-13709,​13711,​13715,​13721,​13724,​13746,​13760-13761,​13764-13766,​13779,​13784-13786,​13796,​13800-13802,​13807,​13813,​13826,​13838,​13863,​13869,​13889-13891,​13895,​13898-13901,​13916-13917,​13921-13922,​13925,​13932-13935,​13938-13939,​13941-13942,​13958,​13963-13964,​13975,​13978,​13983-13987,​13992-13993,​13998,​14000-14001,​14007-14008,​14011,​14014-14017,​14024-14026,​14032,​14034,​14036-14037,​14056-14057,​14071,​14082-14083,​14095-14096,​14098-14100,​14102-14103,​14107,​14109-14110,​14118-14122,​14124-14127,​14130-14132,​14135-14136,​14140,​14142,​14144,​14150,​14152,​14155-14160,​14162-14164,​14167-14169,​14174-14175,​14177-14179,​14181,​14189,​14191,​14196,​14198,​14200,​14202-14207,​14209,​14221-14224,​14226-14230,​14234-14236,​14244-14247,​14250,​14255-14258,​14260,​14267-14268,​14270-14273,​14282,​14284-14300,​14307,​14314-14316,​14319,​14322,​14332,​14340-14350,​14352-14358,​14367-14369,​14371-14372,​14376,​14378,​14381-14382,​14384,​14388,​14390-14391,​14393-14394,​14396,​14400,​14405,​14407-14408,​14412,​14418,​14422-14423,​14425,​14432-14439,​14443,​14457-14458,​14463-14465,​14468-14469,​14475-14476,​14478-14479,​14481-14483,​14486,​14493-14494,​14504,​14506-14509,​14516-14517,​14519,​14522-14523,​14527-14529,​14531-14533,​14548,​14553,​14561,​14582,​14597,​14623,​14630,​14647,​14651-14652,​14654,​14656,​14659-14660,​14662-14663,​14672,​14685,​14687,​14692,​14697,​14706,​14708-14709,​14718,​14721-14722,​14726,​14732,​14734,​14737-14738,​14740,​14748-14750,​14769-14770,​14772-14775,​14779-14781,​14786,​14789-14791,​14793,​14805,​14809-14810,​14817,​14819-14820,​14826-14832,​14839-14843,​14845-14847,​14851-14854,​14857,​14860-14865,​14871,​14877,​14882,​14886,​14889-14890,​14899,​14901,​14904,​14911-14912,​14916,​14918,​14936-14938,​14940,​14943-14951,​14955,​14971,​14978-14979,​14982,​14984,​14987,​14992,​14995,​15002-15010,​15013,​15015-15016,​15023-15024,​15026,​15029,​15040,​15042,​15044,​15046-15054,​15058,​15067-15077,​15079-15080,​15083-15088,​15091-15096,​15098-15099,​15102-15107,​15110-15114,​15119-15126,​15129,​15135,​15139,​15156-15158,​15160,​15162-15169,​15172-15173,​15178-15181,​15184-15185,​15187,​15191-15192,​15194,​15198,​15201,​15203,​15205-15211,​15213-15214,​15221-15228,​15230,​15233-15236,​15240-15241,​15246-15248,​15264-15266,​15271,​15276,​15287-15288,​15300-15302,​15312,​15325-15327,​15329,​15335-15336,​15339,​15357-15358,​15361,​15367-15368,​15370-15372,​15376,​15383,​15388,​15390,​15393,​15395-15398,​15400,​15402,​15408-15409,​15419,​15427,​15447-15448,​15452,​15461,​15464,​15478,​15480-15481,​15483,​15486,​15498-15499,​15502,​15505,​15513,​15517-15518,​15532,​15534,​15545,​15548,​15551,​15556,​15560,​15570,​15591,​15594,​15596,​15598,​15607,​15610-15611,​15621-15623,​15626,​15637-15638,​15645,​15665,​15667,​15672-15674
      /trunk/sources/HeuristicLab.Problems.TestFunctions.MultiObjective/HeuristicLab.Clients.Hive.JobManager14175
  • stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r15584 r17059  
    2323using System.ComponentModel;
    2424using System.Linq;
    25 using System.Text;
    2625using System.Threading;
    2726using System.Threading.Tasks;
     
    3433using HeuristicLab.Optimization;
    3534using HeuristicLab.PluginInfrastructure;
     35using System.Collections.Generic;
    3636
    3737namespace HeuristicLab.Clients.Hive.JobManager.Views {
     
    4545    private bool SuppressEvents { get; set; }
    4646    private object runCollectionViewLocker = new object();
     47    private Project selectedProject;
     48    private Dictionary<Guid, Guid> originalJobProjectAssignment = new Dictionary<Guid, Guid>();
    4749
    4850    public new RefreshableJob Content {
    4951      get { return (RefreshableJob)base.Content; }
    50       set { base.Content = value; }
     52      set {
     53        base.Content = value;
     54      }
    5155    }
    5256
     
    117121        if (Content == null) {
    118122          nameTextBox.Text = string.Empty;
     123          descriptionTextBox.Text = string.Empty;
    119124          executionTimeTextBox.Text = string.Empty;
    120           resourceNamesTextBox.Text = string.Empty;
     125          projectNameTextBox.Text = string.Empty;
    121126          refreshAutomaticallyCheckBox.Checked = false;
    122127          lock (runCollectionViewLocker) {
     
    128133          stateLogViewHost.Content = null;
    129134        } else {
     135          if(Content.Job != null
     136            && Content.Job.Id != Guid.Empty
     137            && !originalJobProjectAssignment.ContainsKey(Content.Job.Id)) {
     138            originalJobProjectAssignment.Add(Content.Job.Id, Content.Job.ProjectId);
     139          }
     140
     141          // project look up
     142          if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) {
     143            projectNameTextBox.Text = string.Empty;
     144            if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) {
     145              var p = HiveClient.Instance.Projects.FirstOrDefault();
     146              if (p != null && p.Id != Guid.Empty) {
     147                hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     148                Content.Job.ProjectId = p.Id;
     149                var resources = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).ToList();
     150                Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
     151                hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     152                hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     153
     154                var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     155                  .OfType<Slave>()
     156                  .Distinct()
     157                  .Sum(x => x.Cores);
     158
     159                projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(Content.Job.ProjectId);
     160                projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     161              }               
     162            }
     163          } else if (Content.Job != null && Content.Job.ProjectId != Guid.Empty) {
     164            if (selectedProject == null || selectedProject.Id != Content.Job.ProjectId) {
     165              selectedProject = GetProject(Content.Job.ProjectId);
     166              hiveResourceSelectorDialog = null;
     167            }
     168
     169            if(hiveResourceSelectorDialog == null)
     170              hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     171
     172            if (selectedProject != null) {
     173              projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id);
     174            } else {
     175              projectNameTextBox.Text = string.Empty;
     176            }
     177
     178            List<Resource> resources = null;
     179            if (Content.Job.ResourceIds == null)
     180              resources = HiveClient.Instance.GetAssignedResourcesForJob(Content.Job.Id).ToList();
     181            else
     182              resources = HiveClient.Instance.Resources.Where(x => Content.Job.ResourceIds.Contains(x.Id)).ToList();
     183
     184            Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
     185            hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     186
     187            var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     188              .OfType<Slave>()
     189              .Distinct()
     190              .Sum(x => x.Cores);
     191
     192            projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     193
     194          } else {
     195            selectedProject = null;
     196            projectNameTextBox.Text = string.Empty;
     197            Content.Job.ResourceIds = null;
     198          }
     199
     200
    130201          nameTextBox.Text = Content.Job.Name;
     202          descriptionTextBox.Text = Content.Job.Description;
    131203          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    132           resourceNamesTextBox.Text = Content.Job.ResourceNames;
    133204          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
     205         
    134206          logView.Content = Content.Log;
    135207          lock (runCollectionViewLocker) {
     
    137209          }
    138210        }
    139       }
    140       finally {
     211      } finally {
    141212        SuppressEvents = false;
    142213      }
    143       hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button
     214      hiveExperimentPermissionListView.Content = null; // has to be filled by refresh
    144215      Content_JobStatisticsChanged(this, EventArgs.Empty);
    145216      Content_HiveExperimentChanged(this, EventArgs.Empty);
     
    158229      tabControl.Enabled = !Locked;
    159230      nameTextBox.Enabled = !Locked;
    160       resourceNamesTextBox.Enabled = !Locked;
     231      descriptionTextBox.Enabled = !Locked;
     232      projectNameTextBox.Enabled = !Locked;
    161233      searchButton.Enabled = !Locked;
    162234      jobsTreeView.Enabled = !Locked;
     
    182254          tabControl.Enabled = !Content.IsProgressing;
    183255
    184           this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    185           this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    186           this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing;
     256          this.nameTextBox.ReadOnly = Content.IsProgressing;
     257          this.descriptionTextBox.ReadOnly = Content.IsProgressing;
     258          this.searchButton.Enabled = !Content.IsProgressing && Content.ExecutionState != ExecutionState.Stopped;
    187259          this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    188260
    189261          this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    190262          this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
     263          this.updateButton.Enabled = Content.ExecutionState != ExecutionState.Prepared && Content.ExecutionState != ExecutionState.Stopped && !Content.IsProgressing;
    191264
    192265          this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing;
     
    333406    #region Control events
    334407    private void searchButton_Click(object sender, EventArgs e) {
    335       if (hiveResourceSelectorDialog == null)
    336         hiveResourceSelectorDialog = new HiveResourceSelectorDialog();
     408      if (hiveResourceSelectorDialog == null) {
     409        hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     410      } else if(hiveResourceSelectorDialog.JobId != Content.Job.Id) {
     411        hiveResourceSelectorDialog.JobId = Content.Job.Id;
     412        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     413        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     414
     415        if (originalJobProjectAssignment.ContainsKey(Content.Job.Id)) {
     416          hiveResourceSelectorDialog.ProjectId = originalJobProjectAssignment[Content.Job.Id];
     417        } else {
     418          hiveResourceSelectorDialog.ProjectId = Guid.Empty;
     419        }
     420      } else if(hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) {
     421        hiveResourceSelectorDialog.JobId = Content.Job.Id;
     422        hiveResourceSelectorDialog.ProjectId = Guid.Empty;
     423        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     424        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     425      } else {
     426        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     427        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     428      }
     429
    337430      if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    338         StringBuilder sb = new StringBuilder();
    339         foreach (Resource resource in hiveResourceSelectorDialog.GetSelectedResources()) {
    340           sb.Append(resource.Name);
    341           sb.Append(";");
    342         }
    343         resourceNamesTextBox.Text = sb.ToString();
    344         if (Content.Job.ResourceNames != resourceNamesTextBox.Text)
    345           Content.Job.ResourceNames = resourceNamesTextBox.Text;
     431        selectedProject = hiveResourceSelectorDialog.SelectedProject;
     432        if(selectedProject != null) {       
     433          Content.Job.ProjectId = selectedProject.Id;
     434          Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     435
     436          var cores = hiveResourceSelectorDialog.SelectedResources
     437            .Union(hiveResourceSelectorDialog.SelectedResources
     438              .SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     439            .OfType<Slave>()
     440            .Distinct()
     441            .Sum(x => x.Cores);
     442
     443          projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id) + "";
     444          projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     445
     446        } else {
     447          selectedProject = null;
     448          projectNameTextBox.Text = string.Empty;
     449          Content.Job.ProjectId = Guid.Empty;
     450          Content.Job.ResourceIds = null;
     451        }
     452        SetEnabledStateOfExecutableButtons();
    346453      }
    347454    }
     
    350457      if (nameTextBox.Text.Trim() == string.Empty) {
    351458        MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     459      } else if (Content.Job.ProjectId == null || Content.Job.ProjectId == Guid.Empty) {
     460        MessageBox.Show("Please select a project before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     461      } else if (Content.Job.ResourceIds == null || !Content.Job.ResourceIds.Any()) {
     462        MessageBox.Show("Please select resources before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    352463      } else if (Content.ExecutionState == ExecutionState.Paused) {
    353464        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
     
    359470      } else {
    360471        HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
     472        UpdateSelectorDialog();
    361473      }
    362474    }
     
    403515    }
    404516
     517    private void descriptionTextBox_Validated(object sender, EventArgs e) {
     518      if (!SuppressEvents && Content.Job != null && Content.Job.Description != descriptionTextBox.Text)
     519        Content.Job.Description = descriptionTextBox.Text;
     520    }
     521
    405522    private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
    406       if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
    407         Content.Job.ResourceNames = resourceNamesTextBox.Text;
     523      //if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
     524      //  Content.Job.ResourceNames = resourceNamesTextBox.Text;
    408525    }
    409526
     
    417534        try {
    418535          invoker.EndInvoke(ar);
    419         }
    420         catch (Exception ex) {
    421           ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
     536        } catch (Exception ex) {
     537          ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
    422538        }
    423539      }, null);
    424     }
    425 
    426     private void refreshPermissionsButton_Click(object sender, EventArgs e) {
    427       if (this.Content.Job.Id == Guid.Empty) {
    428         MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    429       } else {
    430         hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
    431       }
    432     }
    433     #endregion
    434 
    435     #region Helpers
    436     private void SetEnabledStateOfExecutableButtons() {
    437       if (Content == null) {
    438         startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
    439       } else {
    440         startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    441         pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
    442         stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    443       }
    444     }
    445     #endregion
    446 
    447     #region Drag & Drop
    448     private void jobsTreeView_DragOver(object sender, DragEventArgs e) {
    449       jobsTreeView_DragEnter(sender, e);
    450     }
    451 
    452     private void jobsTreeView_DragEnter(object sender, DragEventArgs e) {
    453       e.Effect = DragDropEffects.None;
    454       var obj = (IDeepCloneable)e.Data.GetData(Constants.DragDropDataFormat);
    455 
    456       Type objType = obj.GetType();
    457       if (ItemTask.IsTypeSupported(objType)) {
    458         if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
    459         else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    460         else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
    461       }
    462     }
    463 
    464     private void jobsTreeView_DragDrop(object sender, DragEventArgs e) {
    465       if (e.Effect != DragDropEffects.None) {
    466         var obj = (IItem)e.Data.GetData(Constants.DragDropDataFormat);
    467 
    468         IItem newObj = null;
    469         if (e.Effect.HasFlag(DragDropEffects.Copy)) {
    470           newObj = (IItem)obj.Clone();
    471         } else {
    472           newObj = obj;
    473         }
    474 
    475         //IOptimizer and IExecutables need some special care
    476         if (newObj is IOptimizer) {
    477           ((IOptimizer)newObj).Runs.Clear();
    478         }
    479         if (newObj is IExecutable) {
    480           IExecutable exec = (IExecutable)newObj;
    481           if (exec.ExecutionState != ExecutionState.Prepared) {
    482             exec.Prepare();
    483           }
    484         }
    485 
    486         ItemTask hiveTask = ItemTask.GetItemTaskForItem(newObj);
    487         Content.HiveTasks.Add(hiveTask.CreateHiveTask());
    488       }
    489     }
    490     #endregion
    491 
    492     private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
    493       if (tabControl.SelectedTab == permissionTabPage) {
    494         if (!Content.IsSharable) {
    495           MessageBox.Show("Unable to load permissions. You have insufficient access privileges.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    496           tabControl.SelectedTab = tasksTabPage;
    497         }
    498       }
    499     }
    500 
    501     private RunCollection GetAllRunsFromJob(RefreshableJob job) {
    502       if (job != null) {
    503         RunCollection runs = new RunCollection() { OptimizerName = job.ItemName };
    504 
    505         foreach (HiveTask subTask in job.HiveTasks) {
    506           if (subTask is OptimizerHiveTask) {
    507             OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
    508             ohTask.ExecuteReadActionOnItemTask(new Action(delegate() {
    509               runs.AddRange(ohTask.ItemTask.Item.Runs);
    510             }));
    511           }
    512         }
    513         return runs;
    514       } else {
    515         return null;
    516       }
     540      UpdateSelectorDialog();
     541    }
     542
     543    private void updateButton_Click(object sender, EventArgs e) {
     544      if (Content.ExecutionState == ExecutionState.Stopped) {
     545        MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     546        return;
     547      }
     548
     549      var invoker = new Action<RefreshableJob>(HiveClient.UpdateJob);
     550      invoker.BeginInvoke(Content, (ar) => {
     551        try {
     552          invoker.EndInvoke(ar);
     553        } catch (Exception ex) {
     554          ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
     555        }
     556      }, null);
     557      UpdateSelectorDialog();
    517558    }
    518559
     
    526567      SetEnabledStateOfControls();
    527568    }
     569
     570    private void refreshPermissionsButton_Click(object sender, EventArgs e) {
     571      if (this.Content.Job.Id == Guid.Empty) {
     572        MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     573      } else {
     574        hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
     575      }
     576    }
     577    #endregion
     578
     579    #region Helpers
     580    private void SetEnabledStateOfExecutableButtons() {
     581      if (Content == null) {
     582        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
     583      } else {
     584        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0
     585          && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null  && Content.Job.ResourceIds.Any()
     586          && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
     587        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
     588        stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
     589      }
     590    }
     591   
     592    private Project GetProject(Guid projectId) {
     593      return HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(projectId));
     594    }
     595
     596    private void UpdateSelectorDialog() {
     597      if(hiveResourceSelectorDialog != null) {
     598        hiveResourceSelectorDialog = null;
     599        //hiveResourceSelectorDialog.JobId = Content.Job.Id;
     600        //hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     601        //hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     602      }
     603    }
     604    #endregion
     605
     606    #region Drag & Drop
     607    private void jobsTreeView_DragOver(object sender, DragEventArgs e) {
     608      jobsTreeView_DragEnter(sender, e);
     609    }
     610
     611    private void jobsTreeView_DragEnter(object sender, DragEventArgs e) {
     612      e.Effect = DragDropEffects.None;
     613      var obj = (IDeepCloneable)e.Data.GetData(Constants.DragDropDataFormat);
     614
     615      Type objType = obj.GetType();
     616      if (ItemTask.IsTypeSupported(objType)) {
     617        if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
     618        else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     619        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     620      }
     621    }
     622
     623    private void jobsTreeView_DragDrop(object sender, DragEventArgs e) {
     624      if (e.Effect != DragDropEffects.None) {
     625        var obj = (IItem)e.Data.GetData(Constants.DragDropDataFormat);
     626
     627        IItem newObj = null;
     628        if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     629          newObj = (IItem)obj.Clone();
     630        } else {
     631          newObj = obj;
     632        }
     633
     634        //IOptimizer and IExecutables need some special care
     635        if (newObj is IOptimizer) {
     636          ((IOptimizer)newObj).Runs.Clear();
     637        }
     638        if (newObj is IExecutable) {
     639          IExecutable exec = (IExecutable)newObj;
     640          if (exec.ExecutionState != ExecutionState.Prepared) {
     641            exec.Prepare();
     642          }
     643        }
     644
     645        ItemTask hiveTask = ItemTask.GetItemTaskForItem(newObj);
     646        Content.HiveTasks.Add(hiveTask.CreateHiveTask());
     647      }
     648    }
     649    #endregion
     650
     651    private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
     652      if (tabControl.SelectedTab == permissionTabPage) {
     653        if (!Content.IsSharable) {
     654          MessageBox.Show("Unable to load permissions. You have insufficient access privileges.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     655          tabControl.SelectedTab = tasksTabPage;
     656        }
     657      }
     658    }
     659
     660    private RunCollection GetAllRunsFromJob(RefreshableJob job) {
     661      if (job != null) {
     662        RunCollection runs = new RunCollection() { OptimizerName = job.ItemName };
     663
     664        foreach (HiveTask subTask in job.HiveTasks) {
     665          if (subTask is OptimizerHiveTask) {
     666            OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
     667            ohTask.ExecuteReadActionOnItemTask(new Action(delegate () {
     668              runs.AddRange(ohTask.ItemTask.Item.Runs);
     669            }));
     670          }
     671        }
     672        return runs;
     673      } else {
     674        return null;
     675      }
     676    }
     677
    528678  }
    529679}
Note: See TracChangeset for help on using the changeset viewer.