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:
1 deleted
14 edited
12 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.Administrator

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administratormergedeligible
      /trunk/HeuristicLab.Clients.Hive.Administratormergedeligible
      /branches/1721-RandomForestPersistence/HeuristicLab.Clients.Hive.Administrator10321-10322
      /branches/2916_IndexedDataTableSerialization/HeuristicLab.Clients.Hive.Administrator15918
      /branches/2947_ConfigurableIndexedDataTable/HeuristicLab.Clients.Hive.Administrator16148-16526
      /branches/2972_PDPRowSelect/HeuristicLab.Clients.Hive.Administrator16444-16518
      /branches/Algorithms.GradientDescent/HeuristicLab.Clients.Hive.Administrator5516-5520
      /branches/Async/HeuristicLab.Clients.Hive.Administrator13329-15286
      /branches/Benchmarking/sources/HeuristicLab.Clients.Hive.Administrator6917-7005
      /branches/CloningRefactoring/HeuristicLab.Clients.Hive.Administrator4656-4721
      /branches/CodeEditor/HeuristicLab.Clients.Hive.Administrator11700-11806
      /branches/DataAnalysis Refactoring/HeuristicLab.Clients.Hive.Administrator5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Clients.Hive.Administrator5815-6180
      /branches/DataAnalysis/HeuristicLab.Clients.Hive.Administrator4458-4459,​4462,​4464
      /branches/DataPreprocessing/HeuristicLab.Clients.Hive.Administrator10085-11101
      /branches/GP.Grammar.Editor/HeuristicLab.Clients.Hive.Administrator6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Clients.Hive.Administrator5060
      /branches/HLScript/HeuristicLab.Clients.Hive.Administrator10331-10358
      /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Clients.Hive.Administrator11570-12508
      /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Clients.Hive.Administrator6123-9799
      /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Clients.Hive.Administrator11130-12721
      /branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator15377-15760
      /branches/HiveStatistics/sources/HeuristicLab.Clients.Hive.Administrator12440-12877
      /branches/LogResidualEvaluator/HeuristicLab.Clients.Hive.Administrator10202-10483
      /branches/NET40/sources/HeuristicLab.Clients.Hive.Administrator5138-5162
      /branches/NSGA-II Changes/HeuristicLab.Clients.Hive.Administrator12033-12122
      /branches/ParallelEngine/HeuristicLab.Clients.Hive.Administrator5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Clients.Hive.Administrator7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Clients.Hive.Administrator6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Clients.Hive.Administrator6828
      /branches/RuntimeOptimizer/HeuristicLab.Clients.Hive.Administrator8943-9078
      /branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Administrator7787-8333
      /branches/SlaveShutdown/HeuristicLab.Clients.Hive.Administrator8944-8956
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Clients.Hive.Administrator10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Clients.Hive.Administrator5370-5682
      /branches/Trunk/HeuristicLab.Clients.Hive.Administrator6829-6865
      /branches/UnloadJobs/HeuristicLab.Clients.Hive.Administrator9168-9215
      /branches/VNS/HeuristicLab.Clients.Hive.Administrator5594-5752
      /branches/crossvalidation-2434/HeuristicLab.Clients.Hive.Administrator12948-12950
      /branches/histogram/HeuristicLab.Clients.Hive.Administrator5959-6341
      /branches/symbreg-factors-2650/HeuristicLab.Clients.Hive.Administrator14232-14825
      /trunk/sources/HeuristicLab.Clients.Hive.Administrator9493,​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.Administrator14175
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj

    r11920 r17059  
    110110  </ItemGroup>
    111111  <ItemGroup>
    112     <Compile Include="HiveRoles.cs" />
    113112    <Compile Include="Views\DowntimeTypeDialog.cs">
    114113      <SubType>Form</SubType>
     
    133132    </Compile>
    134133    <Compile Include="MenuItems\AdministratorMenuItem.cs" />
     134    <Compile Include="Views\ProjectJobsView.cs">
     135      <SubType>UserControl</SubType>
     136    </Compile>
     137    <Compile Include="Views\ProjectJobsView.Designer.cs">
     138      <DependentUpon>ProjectJobsView.cs</DependentUpon>
     139    </Compile>
     140    <Compile Include="Views\ProjectPermissionsView.cs">
     141      <SubType>UserControl</SubType>
     142    </Compile>
     143    <Compile Include="Views\ProjectPermissionsView.Designer.cs">
     144      <DependentUpon>ProjectPermissionsView.cs</DependentUpon>
     145    </Compile>
     146    <Compile Include="Views\ProjectResourcesView.cs">
     147      <SubType>UserControl</SubType>
     148    </Compile>
     149    <Compile Include="Views\ProjectResourcesView.Designer.cs">
     150      <DependentUpon>ProjectResourcesView.cs</DependentUpon>
     151    </Compile>
     152    <Compile Include="Views\ProjectsView.cs">
     153      <SubType>UserControl</SubType>
     154    </Compile>
     155    <Compile Include="Views\ProjectsView.Designer.cs">
     156      <DependentUpon>ProjectsView.cs</DependentUpon>
     157    </Compile>
     158    <Compile Include="Views\ProjectView.cs">
     159      <SubType>UserControl</SubType>
     160    </Compile>
     161    <Compile Include="Views\ProjectView.Designer.cs">
     162      <DependentUpon>ProjectView.cs</DependentUpon>
     163    </Compile>
    135164    <Compile Include="Views\Recurrence.cs">
    136165      <SubType>Form</SubType>
     
    151180    <Compile Include="Views\ScheduleView.Designer.cs">
    152181      <DependentUpon>ScheduleView.cs</DependentUpon>
     182    </Compile>
     183    <Compile Include="Views\ResourceView.cs">
     184      <SubType>UserControl</SubType>
     185    </Compile>
     186    <Compile Include="Views\ResourceView.Designer.cs">
     187      <DependentUpon>ResourceView.cs</DependentUpon>
    153188    </Compile>
    154189    <Compile Include="Views\SlaveView.cs">
     
    167202  </ItemGroup>
    168203  <ItemGroup>
     204    <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Administration\3.3\HeuristicLab.Clients.Access.Administration-3.3.csproj">
     205      <Project>{C9CF6AE8-4637-4A75-9141-042F479B5D50}</Project>
     206      <Name>HeuristicLab.Clients.Access.Administration-3.3</Name>
     207    </ProjectReference>
    169208    <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Views\3.3\HeuristicLab.Clients.Access.Views-3.3.csproj">
    170209      <Project>{FE856595-64CD-46DA-9CD2-FFF3E6B0D4F2}</Project>
     
    214253      <Name>HeuristicLab.Core-3.3</Name>
    215254      <Private>False</Private>
     255    </ProjectReference>
     256    <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj">
     257      <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project>
     258      <Name>HeuristicLab.Data.Views-3.3</Name>
    216259    </ProjectReference>
    217260    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/MenuItems/AdministratorMenuItem.cs

    r15584 r17059  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    23 using HeuristicLab.Clients.Hive;
     24using System.Windows.Forms;
     25using HeuristicLab.Clients.Access;
    2426using HeuristicLab.MainForm;
     27using HeuristicLab.Optimizer;
    2528
    26 namespace HeuristicLab.Optimizer.MenuItems {
    27   public class AdministratorMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
     29namespace HeuristicLab.Clients.Hive.Administrator {
     30  public class AdministratorMenuItem : MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
    2831    public override string Name {
    2932      get { return "&Administrator"; }
    3033    }
     34
    3135    public override IEnumerable<string> Structure {
    3236      get { return new string[] { "&Services", "&Hive" }; }
    3337    }
     38
    3439    public override void Execute() {
    35       MainFormManager.MainForm.ShowContent(HiveAdminClient.Instance);
     40
     41      if (HiveRoles.CheckAdminUserPermissions() || HiveAdminClient.Instance.CheckAccessToAdminAreaGranted()) {
     42        MainFormManager.MainForm.ShowContent(HiveAdminClient.Instance);
     43      } else if (!UserInformation.Instance.UserExists) {
     44        MessageBox.Show(
     45          "Couldn't fetch user information from the server." + Environment.NewLine +
     46          "Please verify that you have an existing user and that your user name and password is correct.",
     47          "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     48      } else {
     49        MessageBox.Show(
     50          "You do not seem to have the permissions to use the Hive Administrator." + Environment.NewLine +
     51          "If that's not the case or you have any questions please write an email to support@heuristiclab.com",
     52          "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     53      }
    3654    }
     55
    3756    public override int Position {
    38       get { return 10000; }
     57      get { return 8000; }
     58    }
     59
     60    public override Keys ShortCutKeys {
     61      get { return Keys.Control | Keys.Shift | Keys.H; }
    3962    }
    4063  }
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Plugin.cs.frame

    r15587 r17059  
    3232  [PluginDependency("HeuristicLab.Core", "3.3")]
    3333  [PluginDependency("HeuristicLab.Core.Views", "3.3")] 
     34  [PluginDependency("HeuristicLab.Clients.Common", "3.3")]
    3435  [PluginDependency("HeuristicLab.Clients.Hive", "3.3")]
    3536  [PluginDependency("HeuristicLab.Clients.Hive.Views", "3.3")]
     37  [PluginDependency("HeuristicLab.Data", "3.3")]
     38  [PluginDependency("HeuristicLab.Data.Views", "3.3")]
    3639  [PluginDependency("HeuristicLab.DayView", "1.0.0.0")]
    3740  [PluginDependency("HeuristicLab.Optimizer", "3.3")]
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.Designer.cs

    r15584 r17059  
    2929      this.components = new System.ComponentModel.Container();
    3030      this.tabAdmin = new System.Windows.Forms.TabControl();
    31       this.tabSlaves = new System.Windows.Forms.TabPage();
     31      this.tabResources = new System.Windows.Forms.TabPage();
     32      this.resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView();
     33      this.tabProjects = new System.Windows.Forms.TabPage();
    3234      this.imageListUsers = new System.Windows.Forms.ImageList(this.components);
    33       this.resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView();
     35      this.projectsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectsView();
    3436      this.tabAdmin.SuspendLayout();
    35       this.tabSlaves.SuspendLayout();
     37      this.tabResources.SuspendLayout();
     38      this.tabProjects.SuspendLayout();
    3639      this.SuspendLayout();
    3740      //
    3841      // tabAdmin
    3942      //
    40       this.tabAdmin.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    41                   | System.Windows.Forms.AnchorStyles.Left)
    42                   | System.Windows.Forms.AnchorStyles.Right)));
    43       this.tabAdmin.Controls.Add(this.tabSlaves);
     43      this.tabAdmin.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     44            | System.Windows.Forms.AnchorStyles.Left)
     45            | System.Windows.Forms.AnchorStyles.Right)));
     46      this.tabAdmin.Controls.Add(this.tabResources);
     47      this.tabAdmin.Controls.Add(this.tabProjects);
    4448      this.tabAdmin.Location = new System.Drawing.Point(3, 0);
    4549      this.tabAdmin.Name = "tabAdmin";
     
    4852      this.tabAdmin.TabIndex = 0;
    4953      //
    50       // tabSlaves
     54      // tabResources
    5155      //
    52       this.tabSlaves.Controls.Add(this.resourcesView);
    53       this.tabSlaves.Location = new System.Drawing.Point(4, 22);
    54       this.tabSlaves.Name = "tabSlaves";
    55       this.tabSlaves.Padding = new System.Windows.Forms.Padding(3);
    56       this.tabSlaves.Size = new System.Drawing.Size(734, 520);
    57       this.tabSlaves.TabIndex = 3;
    58       this.tabSlaves.Text = "Slaves";
    59       this.tabSlaves.UseVisualStyleBackColor = true;
    60       //
    61       // imageListUsers
    62       //
    63       this.imageListUsers.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
    64       this.imageListUsers.ImageSize = new System.Drawing.Size(16, 16);
    65       this.imageListUsers.TransparentColor = System.Drawing.Color.Transparent;
     56      this.tabResources.Controls.Add(this.resourcesView);
     57      this.tabResources.Location = new System.Drawing.Point(4, 22);
     58      this.tabResources.Name = "tabResources";
     59      this.tabResources.Padding = new System.Windows.Forms.Padding(3);
     60      this.tabResources.Size = new System.Drawing.Size(734, 520);
     61      this.tabResources.TabIndex = 3;
     62      this.tabResources.Text = "Resources";
     63      this.tabResources.UseVisualStyleBackColor = true;
    6664      //
    6765      // resourcesView
    6866      //
    69       this.resourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    70                   | System.Windows.Forms.AnchorStyles.Left)
    71                   | System.Windows.Forms.AnchorStyles.Right)));
     67      this.resourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     68            | System.Windows.Forms.AnchorStyles.Left)
     69            | System.Windows.Forms.AnchorStyles.Right)));
    7270      this.resourcesView.Caption = "ResourcesView";
    7371      this.resourcesView.Content = null;
     
    7876      this.resourcesView.TabIndex = 0;
    7977      //
    80       // HiveAdministrationView
     78      // tabProjects
    8179      //
    82       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     80      this.tabProjects.Controls.Add(this.projectsView);
     81      this.tabProjects.Location = new System.Drawing.Point(4, 22);
     82      this.tabProjects.Name = "tabProjects";
     83      this.tabProjects.Size = new System.Drawing.Size(734, 520);
     84      this.tabProjects.TabIndex = 4;
     85      this.tabProjects.Text = "Projects";
     86      this.tabProjects.UseVisualStyleBackColor = true;
     87      //
     88      // imageListUsers
     89      //
     90      this.imageListUsers.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
     91      this.imageListUsers.ImageSize = new System.Drawing.Size(16, 16);
     92      this.imageListUsers.TransparentColor = System.Drawing.Color.Transparent;
     93      //
     94      // projectsView
     95      //
     96      this.projectsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     97            | System.Windows.Forms.AnchorStyles.Left)
     98            | System.Windows.Forms.AnchorStyles.Right)));
     99      this.projectsView.Caption = "Resources View";
     100      this.projectsView.Content = null;
     101      this.projectsView.Location = new System.Drawing.Point(0, 0);
     102      this.projectsView.Name = "projectsView";
     103      this.projectsView.ReadOnly = false;
     104      this.projectsView.Size = new System.Drawing.Size(734, 520);
     105      this.projectsView.TabIndex = 0;
     106      //
     107      // HiveAdministratorView
     108      //
    83109      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    84110      this.Controls.Add(this.tabAdmin);
    85       this.Name = "HiveAdministrationView";
     111      this.Name = "HiveAdministratorView";
    86112      this.Size = new System.Drawing.Size(745, 546);
    87113      this.tabAdmin.ResumeLayout(false);
    88       this.tabSlaves.ResumeLayout(false);
     114      this.tabResources.ResumeLayout(false);
     115      this.tabProjects.ResumeLayout(false);
    89116      this.ResumeLayout(false);
    90117
     
    95122    private System.ComponentModel.IContainer components;
    96123    private System.Windows.Forms.ImageList imageListUsers;
    97     private System.Windows.Forms.TabPage tabSlaves;
    98 
     124    private System.Windows.Forms.TabPage tabResources;
     125    private System.Windows.Forms.TabPage tabProjects;
     126    private ProjectsView projectsView;
    99127  }
    100128}
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.Designer.cs

    r16117 r17059  
    2020#endregion
    2121
     22using System.Windows.Forms;
    2223using HeuristicLab.Data.Views;
    2324
     
    5051      this.refreshButton = new System.Windows.Forms.Button();
    5152      this.removeButton = new System.Windows.Forms.Button();
     53      this.startButton = new System.Windows.Forms.Button();
     54      this.stopButton = new System.Windows.Forms.Button();
     55      this.pauseButton = new System.Windows.Forms.Button();
    5256      this.matrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
    5357      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     
    7276      this.removeButton.Size = new System.Drawing.Size(24, 24);
    7377      this.removeButton.TabIndex = 2;
    74       this.toolTip.SetToolTip(this.removeButton, "Delete job(s)");
     78      this.toolTip.SetToolTip(this.removeButton, "Remove job(s)");
    7579      this.removeButton.UseVisualStyleBackColor = true;
    7680      this.removeButton.Click += new System.EventHandler(this.removeButton_Click);
     81      //
     82      // startButton
     83      //
     84      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     85      this.startButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
     86      this.startButton.Location = new System.Drawing.Point(63, 3);
     87      this.startButton.Name = "startButton";
     88      this.startButton.Size = new System.Drawing.Size(24, 24);
     89      this.startButton.TabIndex = 4;
     90      this.toolTip.SetToolTip(this.startButton, "Resume job(s)");
     91      this.startButton.UseVisualStyleBackColor = true;
     92      this.startButton.Click += new System.EventHandler(this.startButton_Click);
     93      //
     94      // pauseButton
     95      //
     96      this.pauseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     97      this.pauseButton.Enabled = false;
     98      this.pauseButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Pause;
     99      this.pauseButton.Location = new System.Drawing.Point(93, 3);
     100      this.pauseButton.Name = "pauseButton";
     101      this.pauseButton.Size = new System.Drawing.Size(24, 24);
     102      this.pauseButton.TabIndex = 5;
     103      this.toolTip.SetToolTip(this.pauseButton, "Pause job(s)");
     104      this.pauseButton.UseVisualStyleBackColor = true;
     105      this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click);
     106      //
     107      // stopButton
     108      //
     109      this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     110      this.stopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Stop;
     111      this.stopButton.Location = new System.Drawing.Point(123, 3);
     112      this.stopButton.Name = "stopButton";
     113      this.stopButton.Size = new System.Drawing.Size(24, 24);
     114      this.stopButton.TabIndex = 6;
     115      this.toolTip.SetToolTip(this.stopButton, "Stop job(s)");
     116      this.stopButton.UseVisualStyleBackColor = true;
     117      this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
    77118      //
    78119      // matrixView
     
    98139      this.Controls.Add(this.refreshButton);
    99140      this.Controls.Add(this.removeButton);
     141      this.Controls.Add(this.startButton);
     142      this.Controls.Add(this.pauseButton);
     143      this.Controls.Add(this.stopButton);
    100144      this.Name = "ProjectJobsView";
    101145      this.Size = new System.Drawing.Size(510, 385);
     
    110154    private System.Windows.Forms.Button refreshButton;
    111155    private System.Windows.Forms.Button removeButton;
     156    private System.Windows.Forms.Button startButton;
     157    private System.Windows.Forms.Button stopButton;
     158    private System.Windows.Forms.Button pauseButton;
    112159    private StringConvertibleMatrixView matrixView;
    113160  }
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs

    r16117 r17059  
    2424using System.Drawing;
    2525using System.Linq;
     26using System.Threading.Tasks;
    2627using System.Windows.Forms;
    2728using HeuristicLab.MainForm;
     
    3031using HeuristicLab.Data;
    3132using HeuristicLab.Clients.Hive.Views;
     33using HeuristicLab.Core;
    3234
    3335namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    4143    private const string JOB_DATECREATED = "Date Created";
    4244    private const string JOB_STATE = "State";
     45    private const string JOB_EXECUTIONSTATE = "Execution State";
     46    private const string JOB_EXECUTIONTIME = "Execution Time";
    4347    private const string JOB_DESCRIPTION = "Description";
    4448    private const string JOB_TASKCOUNT = "Tasks";
     49    private const string JOB_WAITINGTASKCOUNT = "Waiting";
    4550    private const string JOB_CALCULATINGTASKCOUNT = "Calculating";
    4651    private const string JOB_FINISHEDTASKCOUNT = "Finished";
    47 
    4852
    4953    private readonly Color onlineStatusColor = Color.FromArgb(255, 189, 249, 143); // #bdf98f
     
    5357    private readonly Color deletionPendingStatusColor2 = Color.FromArgb(255, 249, 149, 143); // #f9958f
    5458
     59    private IProgress progress;
     60    public IProgress Progress {
     61      get { return progress; }
     62      set {
     63        this.progress = value;
     64        OnIsProgressingChanged();
     65      }
     66    }
     67
    5568    public new Project Content {
    5669      get { return (Project)base.Content; }
     
    6073    public ProjectJobsView() {
    6174      InitializeComponent();
    62 
    63       removeButton.Enabled = false;
     75      progress = new Progress();
     76
     77      removeButton.Enabled = false;     
     78    }
     79
     80    protected override void RegisterContentEvents() {
     81      base.RegisterContentEvents();
    6482      matrixView.DataGridView.SelectionChanged += DataGridView_SelectionChanged;
     83      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, progress);
     84    }
     85
     86    protected override void DeregisterContentEvents() {
     87      matrixView.DataGridView.SelectionChanged -= DataGridView_SelectionChanged;
     88      MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false);
     89      base.DeregisterContentEvents();
    6590    }
    6691
    6792    private void DataGridView_SelectionChanged(object sender, EventArgs e) {
    68       if (matrixView.DataGridView.SelectedRows == null || matrixView.DataGridView.SelectedRows.Count == 0) return;
    69 
    70       bool anyDeletable = false;
    71       foreach (DataGridViewRow r in matrixView.DataGridView.SelectedRows) {
    72         if (((string)r.Cells[0].Value) == JobState.Online.ToString()) anyDeletable = true;
    73       }
    74 
    75       removeButton.Enabled = anyDeletable;
     93      SetEnabledStateOfControls();
    7694    }
    7795
     
    8199      removeButton.Enabled = false;
    82100      UpdateJobs();
    83     }
     101      SetEnabledStateOfControls();
     102    }
     103
    84104    protected override void SetEnabledStateOfControls() {
    85105      base.SetEnabledStateOfControls();
    86106      bool enabled = Content != null && !Locked && !ReadOnly;
    87107
    88       refreshButton.Enabled = enabled;
    89       removeButton.Enabled = false;
    90108      matrixView.Enabled = enabled;
    91     }
     109
     110      // Buttons (start/resume, pause, stop, remove)
     111      refreshButton.Enabled = startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = removeButton.Enabled = false;
     112
     113      if (enabled && progress.ProgressState != ProgressState.Started) {
     114        var jobs = GetSelectedJobs().ToList();
     115        if (jobs.Any()) {
     116                   
     117          startButton.Enabled = jobs.All(x =>
     118            !x.IsProgressing && HiveAdminClient.Instance.Tasks.ContainsKey(x.Id) && HiveAdminClient.Instance.Tasks[x.Id].Count > 0
     119            && x.Job.ProjectId != Guid.Empty //&& x.Job.ResourceIds != null && x.Job.ResourceIds.Any()
     120            && (x.ExecutionState == ExecutionState.Prepared || x.ExecutionState == ExecutionState.Paused));
     121          pauseButton.Enabled = jobs.All(x => !x.IsProgressing && x.ExecutionState == ExecutionState.Started);
     122          stopButton.Enabled = jobs.All(x => !x.IsProgressing && (x.ExecutionState == ExecutionState.Started || x.ExecutionState == ExecutionState.Paused));
     123          removeButton.Enabled = jobs.All(x => !x.IsProgressing && x.Job.State == JobState.Online);
     124        }
     125      }
     126
     127      // refresh Button
     128      if (Content != null && !Locked && progress.ProgressState != ProgressState.Started) {
     129        refreshButton.Enabled = true;
     130      }
     131    }
     132
    92133    #endregion Overrides
    93134
     
    98139
    99140    private void refreshButton_Click(object sender, EventArgs e) {
    100       RefreshJobs();
    101     }
    102 
    103     private async void removeButton_Click(object sender, EventArgs e) {
    104       if (matrixView.DataGridView.SelectedRows == null || matrixView.DataGridView.SelectedRows.Count == 0) return;
    105 
    106       var jobNamesToDelete = new List<string>();
    107       var jobIdsToDelete = new List<Guid>();
    108       foreach (DataGridViewRow r in matrixView.DataGridView.SelectedRows) {
    109         if(((string)r.Cells[0].Value) == JobState.Online.ToString()) {
    110           jobNamesToDelete.Add(" - " + ((string)r.Cells[3].Value));
    111           jobIdsToDelete.Add(Guid.Parse((string)r.Cells[8].Value));
    112         }
    113       }
    114 
    115       if(jobIdsToDelete.Any()) {
     141      progress.Start("Refreshing jobs...");
     142      SetEnabledStateOfControls();
     143      var task = System.Threading.Tasks.Task.Factory.StartNew(RefreshJobsAsync);
     144
     145      task.ContinueWith((t) => {
     146        progress.Finish();       
     147        SetEnabledStateOfControls();
     148      });
     149    }
     150
     151    private void removeButton_Click(object sender, EventArgs e) {
     152      var jobs = GetSelectedJobs();
     153
     154      if (jobs.Any()) {
    116155        var result = MessageBox.Show("Do you really want to remove following job(s):\n\n"
    117           + String.Join("\n", jobNamesToDelete),
     156                                     + String.Join("\n", jobs.Select(x => x.Job.Name)),
    118157          "HeuristicLab Hive Administrator",
    119158          MessageBoxButtons.YesNo,
     
    121160
    122161        if (result == DialogResult.Yes) {
    123           await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    124             action: () => {
    125               DeleteJobs(jobIdsToDelete);
    126             },
    127             finallyCallback: () => {
    128               matrixView.DataGridView.ClearSelection();
    129               removeButton.Enabled = false;
    130               RefreshJobs();
    131             });
    132         }
    133       }
    134     }
    135 
     162          progress.Start("Removing job(s)...");
     163          SetEnabledStateOfControls();
     164          var task = System.Threading.Tasks.Task.Factory.StartNew(RemoveJobsAsync, jobs);
     165
     166          task.ContinueWith((t) => {
     167            RefreshJobs();
     168            progress.Finish();
     169            SetEnabledStateOfControls();
     170          }, TaskContinuationOptions.NotOnFaulted);
     171
     172          task.ContinueWith((t) => {
     173            RefreshJobs();
     174            progress.Finish();
     175            SetEnabledStateOfControls();
     176            MessageBox.Show("An error occured removing the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     177          }, TaskContinuationOptions.OnlyOnFaulted);
     178        }
     179      }
     180    }
     181
     182    private void startButton_Click(object sender, EventArgs e) {
     183      var jobs = GetSelectedJobs();
     184
     185      if (jobs.Any()) {
     186        var result = MessageBox.Show("Do you really want to resume following job(s):\n\n"
     187                                     + String.Join("\n", jobs.Select(x => x.Job.Name)),
     188          "HeuristicLab Hive Administrator",
     189          MessageBoxButtons.YesNo,
     190          MessageBoxIcon.Question);
     191
     192        if (result == DialogResult.Yes) {
     193          progress.Start("Resuming job(s)...");
     194          SetEnabledStateOfControls();
     195          var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobsAsync, jobs);
     196
     197          task.ContinueWith((t) => {
     198            RefreshJobs();           
     199            progress.Finish();
     200            SetEnabledStateOfControls();
     201          }, TaskContinuationOptions.NotOnFaulted);
     202
     203          task.ContinueWith((t) => {
     204            RefreshJobs();
     205            progress.Finish();
     206            SetEnabledStateOfControls();
     207            MessageBox.Show("An error occured resuming the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     208          }, TaskContinuationOptions.OnlyOnFaulted);
     209        }
     210      }
     211    }
     212
     213    private void pauseButton_Click(object sender, EventArgs e) {
     214      var jobs = GetSelectedJobs();
     215
     216      if (jobs.Any()) {
     217        var result = MessageBox.Show("Do you really want to pause following job(s):\n\n"
     218                                     + String.Join("\n", jobs.Select(x => x.Job.Name)),
     219          "HeuristicLab Hive Administrator",
     220          MessageBoxButtons.YesNo,
     221          MessageBoxIcon.Question);
     222
     223        if (result == DialogResult.Yes) {
     224          progress.Start("Pausing job(s)...");
     225          SetEnabledStateOfControls();
     226          var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobsAsync, jobs);
     227
     228          task.ContinueWith((t) => {
     229            RefreshJobs();           
     230            progress.Finish();
     231            SetEnabledStateOfControls();
     232          }, TaskContinuationOptions.NotOnFaulted);
     233
     234          task.ContinueWith((t) => {
     235            RefreshJobs();
     236            progress.Finish();
     237            SetEnabledStateOfControls();
     238            MessageBox.Show("An error occured pausing the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     239          }, TaskContinuationOptions.OnlyOnFaulted);
     240        }
     241      }
     242    }
     243
     244    private void stopButton_Click(object sender, EventArgs e) {
     245      var jobs = GetSelectedJobs();
     246
     247      if (jobs.Any()) {
     248        var result = MessageBox.Show("Do you really want to stop following job(s):\n\n"
     249                                     + String.Join("\n", jobs.Select(x => x.Job.Name)),
     250          "HeuristicLab Hive Administrator",
     251          MessageBoxButtons.YesNo,
     252          MessageBoxIcon.Question);
     253
     254        if (result == DialogResult.Yes) {
     255          progress.Start("Stopping job(s)...");
     256          SetEnabledStateOfControls();
     257          var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobsAsync, jobs);
     258
     259          task.ContinueWith((t) => {
     260            RefreshJobs();
     261            progress.Finish();
     262            SetEnabledStateOfControls();
     263          }, TaskContinuationOptions.NotOnFaulted);
     264
     265          task.ContinueWith((t) => {
     266            RefreshJobs();
     267            progress.Finish();
     268            SetEnabledStateOfControls();
     269            MessageBox.Show("An error occured stopping the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);           
     270          }, TaskContinuationOptions.OnlyOnFaulted);
     271        }
     272      }
     273    }
     274
     275    public event EventHandler IsProgressingChanged;
     276    private void OnIsProgressingChanged() {
     277      var handler = IsProgressingChanged;
     278      if (handler != null) handler(this, EventArgs.Empty);
     279    }
    136280    #endregion Event Handlers
    137281
    138282    #region Helpers
     283
     284    private IEnumerable<RefreshableJob> GetSelectedJobs() {
     285      if (Content == null || matrixView.DataGridView.SelectedRows == null || matrixView.DataGridView.SelectedRows.Count == 0)
     286        return Enumerable.Empty<RefreshableJob>() ;
     287
     288      var jobs = new List<RefreshableJob>();
     289      foreach (DataGridViewRow r in matrixView.DataGridView.SelectedRows) {
     290        if (((string)r.Cells[0].Value) == JobState.Online.ToString()) {
     291          jobs.Add(HiveAdminClient.Instance.Jobs[Content.Id].FirstOrDefault(x => x.Id == Guid.Parse((string) r.Cells[11].Value)));
     292        }
     293      }
     294
     295      return jobs;
     296    }
     297
    139298    private void RefreshJobs() {
    140299      HiveAdminClient.Instance.RefreshJobs();
    141300      UpdateJobs();
     301      SetEnabledStateOfControls();
    142302    }
    143303
     
    148308      var jobs = HiveAdminClient.Instance.Jobs[Content.Id];
    149309      var resources = HiveAdminClient.Instance.Resources;
    150       string[,] values = new string[jobs.Count, 10];
     310      string[,] values = new string[jobs.Count, 13];
    151311
    152312      for(int i = 0; i < jobs.Count; i++) {
    153         var job = jobs.ElementAt(i);
    154        
    155         values[i, 0] = job.State.ToString();
    156         values[i, 1] = job.DateCreated.ToString();
    157         values[i, 2] = job.OwnerUsername;
    158         values[i, 3] = job.Name;
    159         values[i, 4] = job.JobCount.ToString();
    160         values[i, 5] = job.CalculatingCount.ToString();
    161         values[i, 6] = job.FinishedCount.ToString();
    162         values[i, 7] = job.Description;       
    163         values[i, 8] = job.Id.ToString();
    164         values[i, 9] = job.OwnerUserId.ToString();
     313        var job = jobs.ElementAt(i);       
     314        values[i, 0] = job.Job.State.ToString();
     315        values[i, 1] = job.ExecutionState.ToString();
     316        values[i, 2] = job.ExecutionTime.ToString();
     317        values[i, 3] = job.Job.DateCreated.ToString();
     318        values[i, 4] = job.Job.OwnerUsername;
     319        values[i, 5] = job.Job.Name;
     320        values[i, 6] = job.Job.JobCount.ToString();
     321        values[i, 7] = (job.Job.JobCount - job.Job.CalculatingCount - job.Job.FinishedCount).ToString();
     322        values[i, 8] = job.Job.CalculatingCount.ToString();
     323        values[i, 9] = job.Job.FinishedCount.ToString();
     324        values[i, 10] = job.Job.Description;       
     325        values[i, 11] = job.Job.Id.ToString();
     326        values[i, 12] = job.Job.OwnerUserId.ToString();
    165327      }
    166328     
    167329      var matrix = new StringMatrix(values);
    168       matrix.ColumnNames = new string[] { JOB_STATE, JOB_DATECREATED, JOB_OWNER, JOB_NAME, JOB_TASKCOUNT, JOB_CALCULATINGTASKCOUNT, JOB_FINISHEDTASKCOUNT, JOB_DESCRIPTION, JOB_ID, JOB_OWNERID };
     330      matrix.ColumnNames = new string[] { JOB_STATE, JOB_EXECUTIONSTATE, JOB_EXECUTIONTIME, JOB_DATECREATED, JOB_OWNER, JOB_NAME, JOB_TASKCOUNT, JOB_WAITINGTASKCOUNT, JOB_CALCULATINGTASKCOUNT, JOB_FINISHEDTASKCOUNT, JOB_DESCRIPTION, JOB_ID, JOB_OWNERID };
    169331      matrix.SortableView = true;
    170332      return matrix;
     
    193355            matrixView.DataGridView.Columns[1].MinimumWidth = 108;
    194356          }
    195         } else {
    196           refreshButton.Enabled = false;
    197           removeButton.Enabled = false;
    198           matrixView.Content = null;
    199         }
    200       }
    201     }
    202 
    203     private void DeleteJobs(List<Guid> jobIds) {
    204       try {
    205         HiveAdminClient.DeleteJobs(jobIds);
    206       } catch (AnonymousUserException) {
    207         ShowHiveInformationDialog();
    208       }
     357        }
     358      }
     359    }
     360
     361    private void RefreshJobsAsync() {
     362      HiveAdminClient.Instance.RefreshJobs();
     363      UpdateJobs();
     364    }
     365
     366    private void ResumeJobsAsync(object jobs) {
     367      var jobList = (IEnumerable<RefreshableJob>)jobs;
     368      foreach (var job in jobList) {
     369        progress.Status = "Resuming job \"" + job.Job.Name + "\"...";
     370        HiveAdminClient.ResumeJob(job);
     371      }
     372    }
     373
     374    private void PauseJobsAsync(object jobs) {
     375      var jobList = (IEnumerable<RefreshableJob>)jobs;
     376      foreach (var job in jobList) {
     377        progress.Status = "Pausing job \"" + job.Job.Name + "\"...";
     378        HiveAdminClient.PauseJob(job);
     379      }
     380    }
     381
     382    private void StopJobsAsync(object jobs) {
     383      var jobList = (IEnumerable<RefreshableJob>) jobs;
     384      foreach (var job in jobList) {       
     385        progress.Status = "Stopping job \"" + job.Job.Name + "\"...";
     386        HiveAdminClient.StopJob(job);
     387      }
     388    }
     389
     390    private void RemoveJobsAsync(object jobs) {
     391      var jobList = (IEnumerable<RefreshableJob>)jobs;
     392      progress.Start();
     393      foreach (var job in jobList) {
     394        progress.Status = "Removing job \"" + job.Job.Name + "\"...";
     395        HiveAdminClient.RemoveJob(job);
     396      }
     397      progress.Finish();
    209398    }
    210399
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs

    r16117 r17059  
    7878        detailsViewHost.Content = null;
    7979      } else {
    80         UpdatePermissionList();
    81         detailsViewHost.ActiveView.Locked = true;
    82       }
     80        UpdatePermissionList();       
     81      }
     82      SetEnabledStateOfControls();
    8383    }
    8484
     
    9090      saveButton.Enabled = enabled;
    9191      treeView.Enabled = enabled;
     92
     93      if (detailsViewHost != null) {
     94        detailsViewHost.Locked = true;
     95      }
     96
    9297    }
    9398    #endregion
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r16117 r17059  
    3030using HeuristicLab.MainForm;
    3131using System.Collections;
     32using HeuristicLab.Common;
    3233
    3334namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    7273      treeView.ImageList.Images.Add(VSImageLibrary.MonitorLarge);
    7374      treeView.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);
     75
     76      HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing;
     77      HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed;
    7478    }
    7579
    7680    #region Overrides
     81    protected override void OnClosing(FormClosingEventArgs e) {
     82      HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
     83      HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
     84      base.OnClosing(e);
     85    }
     86
    7787    protected override void OnContentChanged() {
    7888      base.OnContentChanged();
     
    8696        UpdateAssignedResources();
    8797        UpdateIncludedResources();
    88         var top = BuildResourceTree();
    89         detailsViewHost.Content = top;
    90         detailsViewHost.Locked = true;
    91       }
     98        detailsViewHost.Content = BuildResourceTree();
     99      }
     100      SetEnabledStateOfControls();
    92101    }
    93102
     
    99108      saveButton.Enabled = enabled;
    100109      treeView.Enabled = enabled;
     110
     111      if (detailsViewHost != null) {
     112        detailsViewHost.Locked = true;
     113      }
    101114    }
    102115    #endregion
    103116
    104117    #region Event Handlers
     118    private void HiveAdminClient_Instance_Refreshing(object sender, EventArgs e) {
     119      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e);
     120      else {
     121        SetEnabledStateOfControls();
     122      }
     123    }
     124
     125    private void HiveAdminClient_Instance_Refreshed(object sender, EventArgs e) {
     126      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e);
     127      else {
     128        OnContentChanged();
     129      }
     130    }
     131
    105132    private void ProjectResourcesView_Load(object sender, EventArgs e) {
    106133
     
    382409        }
    383410
    384           if (includedResources.Contains(newResource) && newIncludedResources.Contains(newResource)) {
     411        if (includedResources.Contains(newResource) && newIncludedResources.Contains(newResource)) {
    385412          newNode.Text += INCLUDED_TAG;
    386413        } else if (addedIncludes.Contains(newResource)) {
     
    421448      }
    422449
     450      ExpandResourceNodesOfInterest(treeView.Nodes);
     451
     452      bool expandUngroupedGroupNode = false;
    423453      var ungroupedSlaves = subResources.OfType<Slave>().OrderBy(x => x.Name);
    424454      if(ungroupedSlaves.Any()) {
     
    433463        foreach (var slave in ungroupedSlaves) {
    434464          var slaveNode = new TreeNode(slave.Name) { Tag = slave };
     465          if (newAssignedResources.Contains(slave)) {
     466            slaveNode.Checked = true;
     467            expandUngroupedGroupNode = true;
     468          }
     469
     470          if (!HiveRoles.CheckAdminUserPermissions()) {
     471            slaveNode.ForeColor = SystemColors.GrayText;
     472            slaveNode.Text += IMMUTABLE_TAG;
     473          } else {
     474            if (addedAssignments.Contains(slave)) {
     475              slaveNode.BackColor = addedAssignmentColor;
     476              slaveNode.ForeColor = SystemColors.ControlText;
     477              slaveNode.Text += ADDED_ASSIGNMENT_TAG;
     478            } else if (removedAssignments.Contains(slave)) {
     479              slaveNode.BackColor = removedAssignmentColor;
     480              slaveNode.ForeColor = SystemColors.ControlText;
     481              slaveNode.Text += REMOVED_ASSIGNMENT_TAG;
     482              expandUngroupedGroupNode = true;
     483            }
     484          }
    435485          ungroupedGroupNode.Nodes.Add(slaveNode);
    436486        }
     487
     488        if(expandUngroupedGroupNode) ungroupedGroupNode.Expand();
    437489        treeView.Nodes.Add(ungroupedGroupNode);
    438490      } else if (ungroupedGroupNode != null) {
     
    441493
    442494      treeView.BeforeCheck += treeView_BeforeCheck;
    443       treeView.AfterCheck += treeView_AfterCheck;
    444      
    445       ExpandResourceNodesOfInterest(treeView.Nodes);
     495      treeView.AfterCheck += treeView_AfterCheck;         
    446496
    447497      return top;
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r16117 r17059  
    118118        endDateTimePicker.Enabled = !indefiniteCheckBox.Checked;
    119119      }
     120      SetEnabledStateOfControls();
    120121      RegisterControlEvents();
    121122    }
     
    134135
    135136      if (Content != null) {
    136         var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault();
    137         if (parentProject == null || parentProject.EndDate.HasValue) {
     137        //var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault();
     138        var parentProject = HiveAdminClient.Instance.Projects.FirstOrDefault(x => x.Id == Content.ParentProjectId);
     139        if ((!IsAdmin() && (parentProject == null || parentProject.EndDate.HasValue))
     140           || (IsAdmin() && parentProject != null && parentProject.EndDate.HasValue)) {
    138141          indefiniteCheckBox.Enabled = false;
    139142        }
    140143
    141         if (!IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) {
     144        if (Content.Id != Guid.Empty && !IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) {
    142145          ownerComboBox.Enabled = false;
    143146          startDateTimePicker.Enabled = false;
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r16117 r17059  
    4343    private const string NOT_STORED_TAG = "*"; // " [not stored]";
    4444    private const string CHANGES_NOT_STORED_TAG = "*"; // " [changes not stored]";
     45    private const string INACTIVE_TAG = " [inactive]";
    4546
    4647    private readonly Color selectedBackColor = Color.DodgerBlue;
     
    106107        BuildProjectTree(Content);
    107108      }
     109      SetEnabledStateOfControls();
    108110    }
    109111
    110112    protected override void SetEnabledStateOfControls() {
    111       base.SetEnabledStateOfControls();
    112       bool selectedProjectExists = selectedProject != null && selectedProject.Id != Guid.Empty && Content.Contains(selectedProject);
    113       bool projectIsNew = selectedProject != null && selectedProject.Id == Guid.Empty;
    114       bool locked = Content == null || selectedProject == null || Locked || ReadOnly;
    115       bool parentOwner = HiveAdminClient.Instance.CheckOwnershipOfParentProject(selectedProject, UserInformation.Instance.User.Id);
    116       bool saveLocked = locked || (!IsAdmin() && selectedProject.OwnerUserId != UserInformation.Instance.User.Id && !parentOwner);
    117       bool addLocked = saveLocked || projectIsNew || selectedProject.Id == Guid.Empty;
    118       bool deleteLocked = locked || (!IsAdmin() && !parentOwner) || Content.Where(x => x.ParentProjectId == selectedProject.Id).Any();
    119 
    120       var now = DateTime.Now;
    121       if (!addLocked && (now < selectedProject.StartDate || now > selectedProject.EndDate)) addLocked = true;
     113      base.SetEnabledStateOfControls();     
     114
     115      bool locked = Content == null || Locked || ReadOnly;     
     116      bool parentOwner = selectedProject != null && HiveAdminClient.Instance.CheckOwnershipOfParentProject(selectedProject, UserInformation.Instance.User.Id);
     117      bool selectedProjectDisabled = selectedProject == null
     118                                     || selectedProject != null && selectedProject.Id == Guid.Empty;
     119
     120      bool selectedProjectHasJobs =
     121        !selectedProjectDisabled && HiveAdminClient.Instance.Jobs.ContainsKey(selectedProject.Id)
     122                                 && HiveAdminClient.Instance.Jobs[selectedProject.Id] != null
     123                                 && HiveAdminClient.Instance.Jobs[selectedProject.Id].Any();
     124
     125      bool addLocked = locked
     126                       || (selectedProject == null && !IsAdmin())
     127                       || (selectedProject != null && selectedProject.Id == Guid.Empty)
     128                       || (selectedProject != null && !IsAdmin() && !parentOwner && selectedProject.OwnerUserId != UserInformation.Instance.User.Id)
     129                       || (selectedProject != null && (DateTime.Now < selectedProject.StartDate || DateTime.Now > selectedProject.EndDate));
     130
     131      bool deleteLocked = locked
     132                          || !Content.Any()
     133                          || selectedProject == null
     134                          || Content.Any(x => x.ParentProjectId == selectedProject.Id)
     135                          || selectedProjectHasJobs
     136                          || (!IsAdmin() && !parentOwner);
     137
     138      bool saveLocked = locked
     139                        || !Content.Any()
     140                        || selectedProject == null
     141                        || (!IsAdmin() && !parentOwner && selectedProject.OwnerUserId != UserInformation.Instance.User.Id);
     142
    122143
    123144      addButton.Enabled = !addLocked;
    124145      removeButton.Enabled = !deleteLocked;
    125146      saveProjectButton.Enabled = !saveLocked;
     147
    126148      projectView.Enabled = !locked;
    127       projectPermissionsView.Enabled = !locked;
    128       projectResourcesView.Enabled = !locked;
    129       projectJobsView.Enabled = !locked;
     149      projectPermissionsView.Enabled = !locked && !selectedProjectDisabled;
     150      projectResourcesView.Enabled = !locked && !selectedProjectDisabled;
     151      projectJobsView.Enabled = !locked && !selectedProjectDisabled;
    130152
    131153      projectView.Locked = locked;
    132       projectPermissionsView.Locked = locked;
    133       projectResourcesView.Locked = locked;
    134       projectJobsView.Locked = locked;
     154      projectPermissionsView.Locked = locked || selectedProjectDisabled;
     155      projectResourcesView.Locked = locked || selectedProjectDisabled;
     156      projectJobsView.Locked = locked || selectedProjectDisabled;
    135157    }
    136158    #endregion
     
    254276      }
    255277
    256       // double check of ChangeSelectedProject(..):
    257       // if the user is no admin nor owner of a parent project
    258       if (!IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(selectedProject, UserInformation.Instance.User.Id)) {
    259         MessageBox.Show(
    260           "Only admins and owners of parent projects are allowed to delete this project.",
    261           "HeuristicLab Hive Administrator",
    262           MessageBoxButtons.OK,
    263           MessageBoxIcon.Error);
    264         return;
    265       }           
    266 
    267 
    268       if (Content.Any(x => x.ParentProjectId == selectedProject.Id)
    269           || HiveAdminClient.Instance.ProjectDescendants[selectedProject.Id].Any()) {
    270         MessageBox.Show(
    271           "Only empty projects can be deleted.",
    272           "HeuristicLab Hive Administrator",
    273           MessageBoxButtons.OK,
    274           MessageBoxIcon.Error);
    275         return;
    276       }
    277 
    278       if (HiveAdminClient.Instance.Jobs.ContainsKey(selectedProject.Id)
    279         && HiveAdminClient.Instance.Jobs[selectedProject.Id] != null
    280         && HiveAdminClient.Instance.Jobs[selectedProject.Id].Any()) {
    281         MessageBox.Show(
    282           "There are " + HiveAdminClient.Instance.Jobs[selectedProject.Id].Count + " job(s) using this project and/or child-projects. It is necessary to delete them before the project.",
    283           "HeuristicLab Hive Administrator",
    284           MessageBoxButtons.OK,
    285           MessageBoxIcon.Error);
    286         return;
    287       }
    288 
    289278      var result = MessageBox.Show(
    290279        "Do you really want to delete " + selectedProject.Name + "?",
     
    297286          action: () => {
    298287            RemoveProject(selectedProject); 
    299           },
    300           finallyCallback: () => {
    301             removeButton.Enabled = true;
    302288          });
    303       } else {
    304         removeButton.Enabled = true;
    305       }
     289      }
     290      SetEnabledStateOfControls();
    306291    }
    307292
     
    492477      if (HiveAdminClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) {
    493478        n.ForeColor = grayTextColor;
    494       } else if (p.Id == Guid.Empty) {
    495         n.Text += NOT_STORED_TAG;
    496       } else if (p.Modified) {
    497         n.Text += CHANGES_NOT_STORED_TAG;
     479      } else {
     480        if (p.Id == Guid.Empty) {
     481          n.Text += NOT_STORED_TAG;
     482        } else if (p.Modified) {
     483          n.Text += CHANGES_NOT_STORED_TAG;
     484        }
     485
     486        if (!IsActive(p)) {
     487          n.ForeColor = grayTextColor;
     488          n.Text += INACTIVE_TAG;
     489        }
    498490      }
    499491    }
     
    540532      try {
    541533        if (project.Id != Guid.Empty) {
    542           var projectsToSave = Content.Where(x => x.Id == Guid.Empty || x.Modified);
    543           foreach (var p in projectsToSave)
    544             p.Store();
    545 
    546534          SelectedProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(project.Id).LastOrDefault();
    547535          HiveAdminClient.Delete(project);         
    548536          UpdateProjects();
    549         } else {
     537        } else {         
     538          SelectedProject = Content.FirstOrDefault(x => x.Id == project.ParentProjectId);
    550539          Content.Remove(project);
    551540        }
     
    553542        ShowHiveInformationDialog();
    554543      }
     544    }
     545
     546    private bool IsActive(Project project) {
     547      return DateTime.Now >= project.StartDate
     548             && (project.EndDate == null
     549                 || DateTime.Now < project.EndDate.Value);
    555550    }
    556551
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.Designer.cs

    r15584 r17059  
    4848      this.chbade = new System.Windows.Forms.CheckBox();
    4949      this.dtpEnd = new System.Windows.Forms.DateTimePicker();
    50       this.dtpToTime = new System.Windows.Forms.DateTimePicker();
    5150      this.label5 = new System.Windows.Forms.Label();
    5251      this.dtpStart = new System.Windows.Forms.DateTimePicker();
    53       this.dtpFromTime = new System.Windows.Forms.DateTimePicker();
    5452      this.label6 = new System.Windows.Forms.Label();
    5553      this.btSaveRecurrence = new System.Windows.Forms.Button();
     
    7472      this.gbAppointment.Controls.Add(this.chbade);
    7573      this.gbAppointment.Controls.Add(this.dtpEnd);
    76       this.gbAppointment.Controls.Add(this.dtpToTime);
    7774      this.gbAppointment.Controls.Add(this.label5);
    7875      this.gbAppointment.Controls.Add(this.dtpStart);
    79       this.gbAppointment.Controls.Add(this.dtpFromTime);
    8076      this.gbAppointment.Controls.Add(this.label6);
    8177      this.gbAppointment.Location = new System.Drawing.Point(2, 2);
     
    9894      // dtpEnd
    9995      //
    100       this.dtpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Short;
     96      this.dtpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
     97      this.dtpEnd.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss";
    10198      this.dtpEnd.Location = new System.Drawing.Point(113, 56);
    10299      this.dtpEnd.Name = "dtpEnd";
    103       this.dtpEnd.Size = new System.Drawing.Size(91, 20);
     100      this.dtpEnd.Size = new System.Drawing.Size(175, 20);
    104101      this.dtpEnd.TabIndex = 29;
    105       //
    106       // dtpToTime
    107       //
    108       this.dtpToTime.CustomFormat = "HH:mm";
    109       this.dtpToTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    110       this.dtpToTime.Location = new System.Drawing.Point(226, 56);
    111       this.dtpToTime.Name = "dtpToTime";
    112       this.dtpToTime.ShowUpDown = true;
    113       this.dtpToTime.Size = new System.Drawing.Size(73, 20);
    114       this.dtpToTime.TabIndex = 38;
    115102      //
    116103      // label5
     
    126113      //
    127114      this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
     115      this.dtpStart.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss";
    128116      this.dtpStart.Location = new System.Drawing.Point(113, 19);
    129117      this.dtpStart.Name = "dtpStart";
    130       this.dtpStart.Size = new System.Drawing.Size(89, 20);
     118      this.dtpStart.Size = new System.Drawing.Size(175, 20);
    131119      this.dtpStart.TabIndex = 28;
    132       //
    133       // dtpFromTime
    134       //
    135       this.dtpFromTime.CustomFormat = "HH:mm";
    136       this.dtpFromTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    137       this.dtpFromTime.Location = new System.Drawing.Point(226, 19);
    138       this.dtpFromTime.Name = "dtpFromTime";
    139       this.dtpFromTime.ShowUpDown = true;
    140       this.dtpFromTime.Size = new System.Drawing.Size(73, 20);
    141       this.dtpFromTime.TabIndex = 30;
    142120      //
    143121      // label6
     
    307285    private System.Windows.Forms.Button btSaveRecurrence;
    308286    private System.Windows.Forms.Button btCancelRecurrence;
    309     private System.Windows.Forms.DateTimePicker dtpFromTime;
    310     private System.Windows.Forms.DateTimePicker dtpToTime;
    311287    private System.Windows.Forms.CheckBox chbade;
    312288    private System.Windows.Forms.GroupBox gbWeekly;
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.cs

    r15584 r17059  
    4646      //check if valid
    4747      if (InputIsValid()) {
    48         dateFrom = DateTime.Parse(dtpStart.Text + " " + dtpFromTime.Text);
    49         dateTo = DateTime.Parse(dtpEnd.Text + " " + dtpToTime.Text);
     48        dateFrom = DateTime.Parse(dtpStart.Text);
     49        dateTo = DateTime.Parse(dtpEnd.Text);
    5050
    5151        RecurrentEvent recurrentEvent = new RecurrentEvent() {
     
    8989      DateTime dateFrom, dateTo;
    9090
    91       dateFrom = DateTime.Parse(dtpStart.Text + " " + dtpFromTime.Text);
    92       dateTo = DateTime.Parse(dtpEnd.Text + " " + dtpToTime.Text);
     91      dateFrom = DateTime.Parse(dtpStart.Text);
     92      dateTo = DateTime.Parse(dtpEnd.Text);
    9393
    9494      if (chbade.Checked && dateFrom < dateTo) {
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r15584 r17059  
    3737        components.Dispose();
    3838      }
    39       HiveAdminClient.Instance.Refreshing -= new EventHandler(Instance_Refreshing);
    40       HiveAdminClient.Instance.Refreshed -= new EventHandler(Instance_Refreshed);
    41 
    42       Access.AccessClient.Instance.Refreshing -= new EventHandler(AccessClient_Refreshing);
    43       Access.AccessClient.Instance.Refreshed -= new EventHandler(AccessClient_Refreshed);
    4439      base.Dispose(disposing);
    4540    }
     
    5651      this.splitSlaves = new System.Windows.Forms.SplitContainer();
    5752      this.btnRefresh = new System.Windows.Forms.Button();
    58       this.progressBar = new System.Windows.Forms.ProgressBar();
    5953      this.btnSave = new System.Windows.Forms.Button();
    6054      this.btnRemoveGroup = new System.Windows.Forms.Button();
    6155      this.btnAddGroup = new System.Windows.Forms.Button();
    62       this.btnPermissionsSave = new System.Windows.Forms.Button();
    63       this.treeSlaveGroup = new System.Windows.Forms.TreeView();
     56      this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView();
    6457      this.tabSlaveGroup = new System.Windows.Forms.TabControl();
    6558      this.tabDetails = new System.Windows.Forms.TabPage();
    66       this.slaveView = new HeuristicLab.Clients.Hive.Administrator.Views.SlaveView();
     59      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    6760      this.tabSchedule = new System.Windows.Forms.TabPage();
    6861      this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView();
    6962      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    70       this.tabPermissions = new System.Windows.Forms.TabPage();
    71       this.permissionView = new HeuristicLab.Clients.Access.Views.RefreshableLightweightUserView();
    7263      ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit();
    7364      this.splitSlaves.Panel1.SuspendLayout();
     
    7768      this.tabDetails.SuspendLayout();
    7869      this.tabSchedule.SuspendLayout();
    79       this.tabPermissions.SuspendLayout();
    8070      this.SuspendLayout();
    8171      //
     
    8878      // splitSlaves
    8979      //
    90       this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    91             | System.Windows.Forms.AnchorStyles.Left)
     80      this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     81            | System.Windows.Forms.AnchorStyles.Left) 
    9282            | System.Windows.Forms.AnchorStyles.Right)));
    9383      this.splitSlaves.Location = new System.Drawing.Point(3, 3);
     
    9787      //
    9888      this.splitSlaves.Panel1.Controls.Add(this.btnRefresh);
    99       this.splitSlaves.Panel1.Controls.Add(this.progressBar);
    10089      this.splitSlaves.Panel1.Controls.Add(this.btnSave);
    10190      this.splitSlaves.Panel1.Controls.Add(this.btnRemoveGroup);
    10291      this.splitSlaves.Panel1.Controls.Add(this.btnAddGroup);
    103       this.splitSlaves.Panel1.Controls.Add(this.treeSlaveGroup);
     92      this.splitSlaves.Panel1.Controls.Add(this.treeView);
    10493      //
    10594      // splitSlaves.Panel2
     
    117106      this.btnRefresh.Size = new System.Drawing.Size(24, 24);
    118107      this.btnRefresh.TabIndex = 8;
    119       this.toolTip.SetToolTip(this.btnRefresh, "Fetch list from server");
     108      this.toolTip.SetToolTip(this.btnRefresh, "Fetch list from server.");
    120109      this.btnRefresh.UseVisualStyleBackColor = true;
    121110      this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
    122111      //
    123       // progressBar
    124       //
    125       this.progressBar.Location = new System.Drawing.Point(123, 4);
    126       this.progressBar.Name = "progressBar";
    127       this.progressBar.Size = new System.Drawing.Size(123, 23);
    128       this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
    129       this.progressBar.TabIndex = 7;
    130       //
    131112      // btnSave
    132113      //
    133       this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
     114      this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
    134115      this.btnSave.Location = new System.Drawing.Point(93, 3);
    135116      this.btnSave.Name = "btnSave";
    136117      this.btnSave.Size = new System.Drawing.Size(24, 24);
    137118      this.btnSave.TabIndex = 5;
    138       this.toolTip.SetToolTip(this.btnSave, "Store slave and group configuration on the server");
     119      this.toolTip.SetToolTip(this.btnSave, "Store slave and group configuration on the server.");
    139120      this.btnSave.UseVisualStyleBackColor = true;
    140121      this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
     
    147128      this.btnRemoveGroup.Size = new System.Drawing.Size(24, 24);
    148129      this.btnRemoveGroup.TabIndex = 2;
    149       this.toolTip.SetToolTip(this.btnRemoveGroup, "Delete a slave or a group");
     130      this.toolTip.SetToolTip(this.btnRemoveGroup, "Remove a slave or a group.");
    150131      this.btnRemoveGroup.UseVisualStyleBackColor = true;
    151132      this.btnRemoveGroup.Click += new System.EventHandler(this.btnRemoveGroup_Click);
     
    158139      this.btnAddGroup.Size = new System.Drawing.Size(24, 24);
    159140      this.btnAddGroup.TabIndex = 1;
    160       this.toolTip.SetToolTip(this.btnAddGroup, "Add a new group");
     141      this.toolTip.SetToolTip(this.btnAddGroup, "Add a new group.");
    161142      this.btnAddGroup.UseVisualStyleBackColor = true;
    162143      this.btnAddGroup.Click += new System.EventHandler(this.btnAddGroup_Click);
    163144      //
    164       // treeSlaveGroup
    165       //
    166       this.treeSlaveGroup.AllowDrop = true;
    167       this.treeSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    168             | System.Windows.Forms.AnchorStyles.Left)
    169             | System.Windows.Forms.AnchorStyles.Right)));
    170       this.treeSlaveGroup.ImageIndex = 0;
    171       this.treeSlaveGroup.ImageList = this.imageListSlaveGroups;
    172       this.treeSlaveGroup.Location = new System.Drawing.Point(3, 33);
    173       this.treeSlaveGroup.Name = "treeSlaveGroup";
    174       this.treeSlaveGroup.SelectedImageIndex = 0;
    175       this.treeSlaveGroup.Size = new System.Drawing.Size(243, 511);
    176       this.treeSlaveGroup.TabIndex = 0;
    177       this.treeSlaveGroup.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag);
    178       this.treeSlaveGroup.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect);
    179       this.treeSlaveGroup.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop);
    180       this.treeSlaveGroup.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter);
    181       this.treeSlaveGroup.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragOver);
    182       this.treeSlaveGroup.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.treeSlaveGroup_QueryContinueDrag);
     145      // treeView
     146      //
     147      this.treeView.AllowDrop = true;
     148      this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     149            | System.Windows.Forms.AnchorStyles.Left)
     150            | System.Windows.Forms.AnchorStyles.Right)));
     151      this.treeView.CheckBoxes = true;
     152      this.treeView.ImageIndex = 0;
     153      this.treeView.ImageList = this.imageListSlaveGroups;
     154      this.treeView.Location = new System.Drawing.Point(3, 33);
     155      this.treeView.Name = "treeView";
     156      this.treeView.SelectedImageIndex = 0;
     157      this.treeView.Size = new System.Drawing.Size(243, 511);
     158      this.treeView.TabIndex = 0;
     159      this.treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag);
     160      this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeSlaveGroup_MouseDown);
     161      this.treeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeSlaveGroup_BeforeSelect);
     162      this.treeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop);
     163      this.treeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnterOver);
     164      this.treeView.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnterOver);
     165      this.treeView.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeSlaveGroup_BeforeCheck);
     166      this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterCheck);
    183167      //
    184168      // tabSlaveGroup
    185169      //
    186       this.tabSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    187             | System.Windows.Forms.AnchorStyles.Left)
     170      this.tabSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     171            | System.Windows.Forms.AnchorStyles.Left) 
    188172            | System.Windows.Forms.AnchorStyles.Right)));
    189173      this.tabSlaveGroup.Controls.Add(this.tabDetails);
    190174      this.tabSlaveGroup.Controls.Add(this.tabSchedule);
    191       this.tabSlaveGroup.Controls.Add(this.tabPermissions);
    192175      this.tabSlaveGroup.Location = new System.Drawing.Point(3, 3);
    193176      this.tabSlaveGroup.Name = "tabSlaveGroup";
     
    195178      this.tabSlaveGroup.Size = new System.Drawing.Size(585, 541);
    196179      this.tabSlaveGroup.TabIndex = 1;
    197       this.tabSlaveGroup.SelectedIndexChanged += new System.EventHandler(this.tabSlaveGroup_SelectedIndexChanged);
     180      //this.tabSlaveGroup.TabIndexChanged += TabSlaveGroup_TabIndexChanged;
     181      this.tabSlaveGroup.Selected += TabSlaveGroup_Selected;
    198182      //
    199183      // tabDetails
    200184      //
    201       this.tabDetails.Controls.Add(this.slaveView);
     185      this.tabDetails.Controls.Add(this.viewHost);
    202186      this.tabDetails.Location = new System.Drawing.Point(4, 22);
    203187      this.tabDetails.Name = "tabDetails";
     
    208192      this.tabDetails.UseVisualStyleBackColor = true;
    209193      //
    210       // slaveView
    211       //
    212       this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    213             | System.Windows.Forms.AnchorStyles.Left)
    214             | System.Windows.Forms.AnchorStyles.Right)));
    215       this.slaveView.Caption = "SlaveView";
    216       this.slaveView.Content = null;
    217       this.slaveView.Location = new System.Drawing.Point(6, 6);
    218       this.slaveView.Name = "slaveView";
    219       this.slaveView.ReadOnly = false;
    220       this.slaveView.Size = new System.Drawing.Size(565, 503);
    221       this.slaveView.TabIndex = 0;
     194      // viewHost
     195      //
     196      this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     197            | System.Windows.Forms.AnchorStyles.Left)
     198            | System.Windows.Forms.AnchorStyles.Right)));
     199      this.viewHost.Caption = "View";
     200      this.viewHost.Content = null;
     201      this.viewHost.Enabled = true;
     202      this.viewHost.Location = new System.Drawing.Point(6, 6);
     203      this.viewHost.Name = "viewHost";
     204      this.viewHost.ReadOnly = false;
     205      this.viewHost.Size = new System.Drawing.Size(565, 503);
     206      this.viewHost.TabIndex = 0;
     207      this.viewHost.ViewsLabelVisible = true;
     208      this.viewHost.ViewType = null;
    222209      //
    223210      // tabSchedule
     
    234221      // scheduleView
    235222      //
    236       this.scheduleView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    237             | System.Windows.Forms.AnchorStyles.Left)
     223      this.scheduleView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     224            | System.Windows.Forms.AnchorStyles.Left) 
    238225            | System.Windows.Forms.AnchorStyles.Right)));
    239226      this.scheduleView.Caption = "ScheduleView";
     
    244231      this.scheduleView.Size = new System.Drawing.Size(565, 503);
    245232      this.scheduleView.TabIndex = 0;
    246       //
    247       // tabPermissions
    248       //
    249       this.tabPermissions.Controls.Add(this.btnPermissionsSave);
    250       this.tabPermissions.Controls.Add(this.permissionView);
    251       this.tabPermissions.Location = new System.Drawing.Point(4, 22);
    252       this.tabPermissions.Name = "tabPermissions";
    253       this.tabPermissions.Padding = new System.Windows.Forms.Padding(3);
    254       this.tabPermissions.Size = new System.Drawing.Size(577, 515);
    255       this.tabPermissions.TabIndex = 2;
    256       this.tabPermissions.Text = "Permissions";
    257       this.tabPermissions.UseVisualStyleBackColor = true;
    258       //
    259       // btnPermissionsSave
    260       //
    261       this.btnPermissionsSave.Enabled = false;
    262       this.btnPermissionsSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
    263       this.btnPermissionsSave.Location = new System.Drawing.Point(39, 9);
    264       this.btnPermissionsSave.Name = "btnPermissionsSave";
    265       this.btnPermissionsSave.Size = new System.Drawing.Size(24, 24);
    266       this.btnPermissionsSave.TabIndex = 1;
    267       this.toolTip.SetToolTip(this.btnPermissionsSave, "Store slave and group sharing permissions on the server");
    268       this.btnPermissionsSave.UseVisualStyleBackColor = true;
    269       this.btnPermissionsSave.Click += new System.EventHandler(this.btnPermissionsSave_Click);
    270       //
    271       // permissionView
    272       //
    273       this.permissionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    274             | System.Windows.Forms.AnchorStyles.Left)
    275             | System.Windows.Forms.AnchorStyles.Right)));
    276       this.permissionView.Caption = "RefreshableLightweightUser View";
    277       this.permissionView.Content = null;
    278       this.permissionView.FetchSelectedUsers = null;
    279       this.permissionView.Location = new System.Drawing.Point(6, 6);
    280       this.permissionView.Name = "permissionView";
    281       this.permissionView.ReadOnly = false;
    282       this.permissionView.Size = new System.Drawing.Size(565, 503);
    283       this.permissionView.TabIndex = 0;
    284233      //
    285234      // ResourcesView
     
    297246      this.tabDetails.ResumeLayout(false);
    298247      this.tabSchedule.ResumeLayout(false);
    299       this.tabPermissions.ResumeLayout(false);
    300248      this.ResumeLayout(false);
    301249
    302250    }
    303 
    304251    #endregion
    305252
     
    307254    private System.Windows.Forms.Button btnRemoveGroup;
    308255    private System.Windows.Forms.Button btnAddGroup;
    309     private System.Windows.Forms.TreeView treeSlaveGroup;
     256    private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView;
    310257    private System.Windows.Forms.TabControl tabSlaveGroup;
    311258    private System.Windows.Forms.TabPage tabDetails;
    312259    private System.Windows.Forms.TabPage tabSchedule;
    313     private SlaveView slaveView;
    314260    private System.Windows.Forms.ImageList imageListSlaveGroups;
    315261    private ScheduleView scheduleView;
    316262    private System.Windows.Forms.Button btnSave;
    317     private System.Windows.Forms.ProgressBar progressBar;
    318263    private System.Windows.Forms.Button btnRefresh;
    319264    private System.Windows.Forms.ToolTip toolTip;
    320     private System.Windows.Forms.TabPage tabPermissions;
    321     private Access.Views.RefreshableLightweightUserView permissionView;
    322     private System.Windows.Forms.Button btnPermissionsSave;
     265    private MainForm.WindowsForms.ViewHost viewHost;
    323266  }
    324267}
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r15584 r17059  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Drawing;
    2526using System.Linq;
    26 using System.ServiceModel.Security;
    27 using System.Threading;
    28 using System.Threading.Tasks;
    2927using System.Windows.Forms;
    3028using HeuristicLab.Clients.Access;
    3129using HeuristicLab.Clients.Hive.Views;
     30using HeuristicLab.Collections;
     31using HeuristicLab.Common.Resources;
    3232using HeuristicLab.Core;
    3333using HeuristicLab.Core.Views;
    3434using HeuristicLab.MainForm;
    35 using TS = System.Threading.Tasks;
    3635
    3736namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    3938  [Content(typeof(IItemList<Resource>), false)]
    4039  public partial class ResourcesView : ItemView, IDisposable {
     40    private const int slaveImageIndex = 0;
     41    private const int slaveGroupImageIndex = 1;
     42    public const string UNGROUPED_GROUP_NAME = "UNGROUPED";
     43    public const string UNGROUPED_GROUP_DESCRIPTION = "Contains slaves that are not assigned to any group.";
     44    private const string SELECTED_TAG = ""; // " [selected]";
     45    private const string NOT_STORED_TAG = "*"; // " [not stored]";
     46    private const string CHANGES_NOT_STORED_TAG = "*"; // " [changes not stored]";
     47
     48    private readonly Color changedColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1
     49    private readonly Color selectedBackColor = Color.DodgerBlue;
     50    private readonly Color selectedForeColor = Color.White;
     51    private readonly Color calculatingColor = Color.FromArgb(255, 58, 114, 35); // #3a7223
     52    private readonly Color offlineColor = Color.FromArgb(255, 187, 36, 36); // #bb2424
     53    private readonly Color grayTextColor = SystemColors.GrayText;
     54
     55
     56
     57    private TreeNode ungroupedGroupNode;
     58
     59    private Resource selectedResource = null;
     60    public Resource SelectedResource {
     61      get { return selectedResource; }
     62      set { if (selectedResource != value) ChangeSelectedResource(value); }
     63    }
     64
     65    private readonly object locker = new object();
     66
    4167    public new IItemList<Resource> Content {
    4268      get { return (IItemList<Resource>)base.Content; }
     
    4470    }
    4571
    46     public const string UngroupedGroupName = "UNGROUPED";
    47     private const int slaveImageIndex = 0;
    48     private const int slaveGroupImageIndex = 1;
    49     private readonly Color ownedResourceColor = Color.LightGreen;
    50     private TS.Task progressTask;
    51     private bool stopProgressTask;
    52     private bool currentlyAuthorized;
    53 
    54 
    5572    public ResourcesView() {
    5673      InitializeComponent();
    57       treeSlaveGroup.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
    58       treeSlaveGroup.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge);
    59 
    60       HiveAdminClient.Instance.Refreshing += new EventHandler(Instance_Refreshing);
    61       HiveAdminClient.Instance.Refreshed += new EventHandler(Instance_Refreshed);
    62 
    63       Access.AccessClient.Instance.Refreshing += new EventHandler(AccessClient_Refreshing);
    64       Access.AccessClient.Instance.Refreshed += new EventHandler(AccessClient_Refreshed);
    65     }
    66 
    67     private void UpdateProgress() {
    68       while (!stopProgressTask) {
    69         int diff = (progressBar.Maximum - progressBar.Minimum) / 10;
    70 
    71         if (progressBar.InvokeRequired) {
    72           progressBar.Invoke(new Action(delegate() { progressBar.Value = (progressBar.Value + diff) % progressBar.Maximum; }));
    73         } else {
    74           progressBar.Value = (progressBar.Value + diff) % progressBar.Maximum;
    75         }
    76 
    77         //ok, this is not very clever...
    78         Thread.Sleep(500);
    79       }
    80       if (progressBar.InvokeRequired) {
    81         progressBar.Invoke(new Action(delegate() { progressBar.Value = progressBar.Minimum; }));
    82       } else {
    83         progressBar.Value = progressBar.Minimum;
    84       }
    85     }
    86 
    87     void Instance_Refreshing(object sender, EventArgs e) {
    88       stopProgressTask = false;
    89       progressTask = new TS.Task(UpdateProgress);
    90       progressTask.Start();
    91       SetEnabledStateOfControls();
    92     }
    93 
    94     void Instance_Refreshed(object sender, EventArgs e) {
    95       stopProgressTask = true;
    96       SetEnabledStateOfControls();
    97     }
    98 
    99     void AccessClient_Refreshing(object sender, EventArgs e) {
    100       stopProgressTask = false;
    101       progressTask = new TS.Task(UpdateProgress);
    102       progressTask.Start();
    103       SetEnabledStateOfControls();
    104       btnPermissionsSave.Enabled = false;
    105     }
    106 
    107     void AccessClient_Refreshed(object sender, EventArgs e) {
    108       stopProgressTask = true;
    109       SetEnabledStateOfControls();
    110     }
    111 
    112     #region Register Content Events
    113     protected override void DeregisterContentEvents() {
    114       Content.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsAdded);
    115       Content.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsRemoved);
    116       base.DeregisterContentEvents();
    117     }
     74
     75      treeView.ImageList.Images.Add(VSImageLibrary.MonitorLarge);
     76      treeView.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);
     77
     78      HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing;
     79      HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed;
     80      AccessClient.Instance.Refreshing += AccessClient_Instance_Refreshing;
     81      AccessClient.Instance.Refreshed += AccessClient_Instance_Refreshed;
     82    }
     83
     84    #region Overrides
     85    protected override void OnClosing(FormClosingEventArgs e) {
     86      AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;
     87      AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;
     88      HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
     89      HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
     90      base.OnClosing(e);
     91    }
     92
    11893    protected override void RegisterContentEvents() {
    11994      base.RegisterContentEvents();
    120       Content.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsAdded);
    121       Content.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsRemoved);
    122     }
    123     #endregion
     95      Content.ItemsAdded += Content_ItemsAdded;
     96      Content.ItemsRemoved += Content_ItemsRemoved;
     97    }
     98
     99    protected override void DeregisterContentEvents() {
     100      Content.ItemsRemoved -= Content_ItemsRemoved;
     101      Content.ItemsAdded -= Content_ItemsAdded;
     102      base.DeregisterContentEvents();
     103    }
    124104
    125105    protected override void OnContentChanged() {
    126106      base.OnContentChanged();
    127107      if (Content == null) {
    128         slaveView.Content = null;
     108        treeView.Nodes.Clear();
     109        viewHost.Content = null;
    129110        scheduleView.Content = null;
    130         permissionView.Content = null;
    131         permissionView.FetchSelectedUsers = null;
    132         treeSlaveGroup.Nodes.Clear();
    133111      } else {
    134         permissionView.Content = Access.AccessClient.Instance;
    135         treeSlaveGroup.Nodes.Clear();
    136 
    137         //rebuild
    138         TreeNode ungrp = new TreeNode(UngroupedGroupName);
    139         ungrp.ImageIndex = slaveGroupImageIndex;
    140         ungrp.SelectedImageIndex = ungrp.ImageIndex;
    141         var newGroup = new SlaveGroup();
    142         newGroup.Name = UngroupedGroupName;
    143         newGroup.Id = Guid.NewGuid();
    144         newGroup.Description = "Contains slaves which are in no group";
    145         ungrp.Tag = newGroup;
    146 
    147         foreach (Resource g in Content) {
    148           if (g.GetType() == typeof(SlaveGroup)) {
    149             //root node
    150             if (g.ParentResourceId == null) {
    151               TreeNode tn = new TreeNode();
    152               tn.ImageIndex = slaveGroupImageIndex;
    153               tn.SelectedImageIndex = tn.ImageIndex;
    154 
    155               tn.Tag = g;
    156               tn.Text = g.Name;
    157               if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) tn.BackColor = ownedResourceColor;
    158 
    159               BuildSlaveGroupTree(g, tn);
    160               treeSlaveGroup.Nodes.Add(tn);
    161             }
    162           } else if (g.GetType() == typeof(Slave)) {
    163             if (g.ParentResourceId == null) {
    164               var stn = new TreeNode(g.Name);
    165               stn.ImageIndex = slaveImageIndex;
    166               stn.SelectedImageIndex = stn.ImageIndex;
    167               stn.Tag = g;
    168               if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
    169               ungrp.Nodes.Add(stn);
    170             }
    171           }
    172         }
    173         treeSlaveGroup.Nodes.Add(ungrp);
    174       }
    175     }
    176 
    177     private void BuildSlaveGroupTree(Resource g, TreeNode tn) {
    178       foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == g.Id)) {
    179         TreeNode stn = new TreeNode(r.Name);
    180         if (r is Slave) {
    181           stn.ImageIndex = slaveImageIndex;
    182         } else if (r is SlaveGroup) {
    183           stn.ImageIndex = slaveGroupImageIndex;
    184         }
    185         stn.SelectedImageIndex = stn.ImageIndex;
    186         stn.Tag = r;
    187         if (r.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
    188         tn.Nodes.Add(stn);
    189 
    190         BuildSlaveGroupTree(r, stn);
    191       }
     112        BuildResourceTree(Content);
     113      }
     114      SetEnabledStateOfControls();
    192115    }
    193116
    194117    protected override void SetEnabledStateOfControls() {
    195118      base.SetEnabledStateOfControls();
    196       if (Content == null) {
    197         btnAddGroup.Enabled = false;
     119
     120      bool locked = Content == null || Locked || ReadOnly;
     121      bool addLocked = locked
     122                    || !IsAdmin()
     123                    || (selectedResource is Slave && selectedResource.ParentResourceId != null)
     124                    || (selectedResource != null && selectedResource.Id == Guid.Empty);
     125
     126      HashSet<Guid> descendantResources = null;
     127      bool selectedRDeleteLocked = selectedResource == null
     128                              || (selectedResource.Id != Guid.Empty && (!HiveAdminClient.Instance.ResourceDescendants.TryGetValue(selectedResource.Id, out descendantResources) || descendantResources.Any()));
     129
     130      var nodes = GetCheckedNodes(treeView.Nodes).ToList();
     131      var checkedResources = nodes.Select(x => x.Tag).OfType<Resource>().ToList();
     132      bool checkedRDeleteLocked = false;
     133      for (int i = 0; !checkedRDeleteLocked && i < checkedResources.Count; i++) {
     134        if (checkedResources[i].Id != Guid.Empty &&
     135            (!HiveAdminClient.Instance.ResourceDescendants.TryGetValue(checkedResources[i].Id, out descendantResources) ||
     136             descendantResources.Any()))
     137          checkedRDeleteLocked = true;
     138      }
     139
     140      bool deleteLocked = locked
     141                          || !IsAdmin()
     142                          || !Content.Any()
     143                          || checkedResources.Any() && checkedRDeleteLocked
     144                          || !checkedResources.Any() && selectedRDeleteLocked;
     145
     146      bool saveLocked = locked
     147                       || !IsAdmin()
     148                       || !Content.Any()
     149                       || selectedResource == null;
     150
     151      btnAddGroup.Enabled = !addLocked;
     152      btnRemoveGroup.Enabled = !deleteLocked;
     153      btnSave.Enabled = !saveLocked;
     154      viewHost.Locked = locked || !IsAdmin();
     155      scheduleView.Locked = locked || !IsAdmin();
     156    }
     157    #endregion
     158
     159    #region Event Handlers
     160    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) {
     161      if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsAdded, sender, e);
     162      else {
     163        OnContentChanged();
     164      }
     165    }
     166
     167    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) {
     168      if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsRemoved, sender, e);
     169      else {
     170        OnContentChanged();
     171      }
     172    }
     173
     174    private void SlaveViewContent_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     175      if (InvokeRequired) Invoke((Action<object, PropertyChangedEventArgs>)SlaveViewContent_PropertyChanged, sender, e);
     176      else {
     177        OnContentChanged();
     178        if (e.PropertyName == "HbInterval") {
     179          UpdateChildHbIntervall((Resource)viewHost.Content);
     180        }
     181      }
     182    }
     183
     184    private void HiveAdminClient_Instance_Refreshing(object sender, EventArgs e) {
     185      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e);
     186      else {
     187        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     188        mainForm.AddOperationProgressToView(this, "Refreshing ...");
     189        SetEnabledStateOfControls();
     190      }
     191    }
     192
     193    private void HiveAdminClient_Instance_Refreshed(object sender, EventArgs e) {
     194      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e);
     195      else {
     196        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     197        mainForm.RemoveOperationProgressFromView(this);
     198        SetEnabledStateOfControls();
     199      }
     200    }
     201
     202    private void AccessClient_Instance_Refreshing(object sender, EventArgs e) {
     203      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);
     204      else {
     205        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     206        mainForm.AddOperationProgressToView(this, "Refreshing ...");
     207        SetEnabledStateOfControls();
     208      }
     209    }
     210
     211    private void AccessClient_Instance_Refreshed(object sender, EventArgs e) {
     212      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);
     213      else {
     214        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     215        mainForm.RemoveOperationProgressFromView(this);
     216        SetEnabledStateOfControls();
     217      }
     218    }
     219
     220    private async void ResourcesView_Load(object sender, EventArgs e) {
     221      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     222        action: () => UpdateResources());
     223    }
     224
     225    private async void btnRefresh_Click(object sender, EventArgs e) {
     226      lock (locker) {
     227        if (!btnRefresh.Enabled) return;
     228        btnRefresh.Enabled = false;
     229      }
     230
     231      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     232        action: () => UpdateResources(),
     233        finallyCallback: () => btnRefresh.Enabled = true);
     234    }
     235
     236    private void btnAddGroup_Click(object sender, EventArgs e) {
     237      var parentResourceId = selectedResource is SlaveGroup ? selectedResource.Id : (Guid?)null;
     238
     239      var group = new SlaveGroup {
     240        Name = "New Group",
     241        OwnerUserId = UserInformation.Instance.User.Id,
     242        ParentResourceId = parentResourceId
     243      };
     244
     245      SelectedResource = group;
     246      Content.Add(group);
     247    }
     248
     249    private async void btnRemoveGroup_Click(object sender, EventArgs e) {     
     250      var nodes = GetCheckedNodes(treeView.Nodes).ToList();
     251      var checkedResources = nodes.Select(x => x.Tag).OfType<Resource>().ToList();
     252      if (selectedResource == null && !checkedResources.Any()) return;
     253
     254      lock (locker) {
     255        if (!btnRemoveGroup.Enabled) return;
    198256        btnRemoveGroup.Enabled = false;
     257      }
     258
     259      if (checkedResources.Count > 0) {
     260        var result = MessageBox.Show(
     261          "Do you really want to delete all " + checkedResources.Count + " checked resources?",
     262          "HeuristicLab Hive Administrator",
     263          MessageBoxButtons.YesNo,
     264          MessageBoxIcon.Question);
     265        if (result == DialogResult.Yes) {
     266          await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     267            action: () => {
     268              RemoveResource(checkedResources);
     269            });
     270        }
     271      } else {
     272        var res = checkedResources.Any() ? checkedResources.First() : selectedResource;
     273        var result = MessageBox.Show(
     274          "Do you really want to delete the selected resource " + res.Name + "?",
     275          "HeuristicLab Hive Administrator",
     276          MessageBoxButtons.YesNo,
     277          MessageBoxIcon.Question);
     278        if (result == DialogResult.Yes) {
     279          await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     280            action: () => {
     281              RemoveResource(res);
     282            });
     283        }
     284      }
     285
     286      OnContentChanged();
     287      SetEnabledStateOfControls();
     288    }
     289
     290    private async void btnSave_Click(object sender, EventArgs e) {
     291      lock (locker) {
     292        if (!btnSave.Enabled) return;
    199293        btnSave.Enabled = false;
    200         btnPermissionsSave.Enabled = false;
    201         permissionView.Enabled = false;
    202         scheduleView.SetEnabledStateOfSchedule(false);
    203         btnPermissionsSave.Enabled = false;
    204         permissionView.Enabled = false;
     294      }
     295
     296      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     297        action: () => {
     298          var resourcesToSave = Content.Where(x => x.Id == Guid.Empty || x.Modified);
     299          foreach (var resource in resourcesToSave)
     300            resource.Store();
     301          UpdateResources();
     302        });
     303
     304      OnContentChanged();
     305      SetEnabledStateOfControls();
     306    }
     307
     308    private void treeSlaveGroup_MouseDown(object sender, MouseEventArgs e) {
     309      var node = treeView.GetNodeAt(e.Location);
     310      if (node == null || node == ungroupedGroupNode) return;
     311      var r = (Resource)node.Tag;
     312      if (!HiveAdminClient.Instance.DisabledParentResources.Contains(r)) ChangeSelectedResourceNode(node);
     313    }
     314
     315    private void treeSlaveGroup_BeforeSelect(object sender, TreeViewCancelEventArgs e) {
     316      e.Cancel = true;
     317    }
     318
     319    private void treeSlaveGroup_BeforeCheck(object sender, TreeViewCancelEventArgs e) {
     320      if (!IsAdmin() || e.Node == ungroupedGroupNode) {
     321        e.Cancel = true;
    205322      } else {
    206         btnAddGroup.Enabled = true;
    207         btnRemoveGroup.Enabled = true;
    208         btnSave.Enabled = true;
    209         scheduleView.SetEnabledStateOfSchedule(IsAuthorized(slaveView.Content));
    210         btnPermissionsSave.Enabled = permissionView.FetchSelectedUsers != null;
    211         permissionView.Enabled = permissionView.FetchSelectedUsers != null;
    212       }
    213     }
    214 
    215     private bool IsAuthorized(Resource resource) {
    216       return resource != null
    217           && resource.Name != UngroupedGroupName
    218           && resource.Id != Guid.Empty
    219           && UserInformation.Instance.UserExists
    220           && (resource.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions());
    221     }
    222 
    223     private void treeSlaveGroup_AfterSelect(object sender, TreeViewEventArgs e) {
    224       if (e.Action != TreeViewAction.Unknown) {
    225         Resource selectedResource = ((Resource)e.Node.Tag);
    226         currentlyAuthorized = IsAuthorized(selectedResource);
    227         if (currentlyAuthorized) {
    228           permissionView.FetchSelectedUsers = new Func<List<Guid>>(() => {
    229             return HiveServiceLocator.Instance.CallHiveService<List<ResourcePermission>>(service => {
    230               return service.GetResourcePermissions(selectedResource.Id);
    231             }).Select(x => x.GrantedUserId).ToList();
    232           });
    233           if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions);
     323        var r = (Resource)e.Node.Tag;
     324        if (HiveAdminClient.Instance.DisabledParentResources.Contains(r)) {
     325          e.Cancel = true;
     326        }
     327      }
     328    }
     329
     330    private void treeSlaveGroup_AfterCheck(object sender, TreeViewEventArgs e) {
     331      SetEnabledStateOfControls();
     332    }
     333
     334    private void treeSlaveGroup_DragDrop(object sender, DragEventArgs e) {
     335      if (e.Effect == DragDropEffects.None) return;
     336
     337      var targetNode = treeView.GetNodeAt(treeView.PointToClient(new Point(e.X, e.Y)));
     338      var targetResource = (targetNode != null) ? (Resource)targetNode.Tag : null;
     339      var resources = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IEnumerable<Resource>;
     340
     341      foreach (var r in resources) {
     342        r.ParentResourceId = targetResource != null ? targetResource.Id : (Guid?)null;
     343      }
     344
     345      // TODO
     346      //HiveAdminClient.Instance.UpdateResourceGenealogy(Content);
     347      OnContentChanged();
     348    }
     349
     350    private void treeSlaveGroup_ItemDrag(object sender, ItemDragEventArgs e) {
     351      if (!IsAdmin()) return;
     352
     353      var nodes = GetCheckedNodes(treeView.Nodes).ToList();
     354      TreeNode sourceNode = (TreeNode)e.Item;
     355      if (!sourceNode.Checked) nodes.Add(sourceNode);
     356      nodes.Remove(ungroupedGroupNode);
     357      ungroupedGroupNode.Checked = false;
     358      var resources = nodes.Select(x => x.Tag).OfType<Resource>().ToList();
     359
     360      if (resources.Count > 0) {
     361        DataObject data = new DataObject();
     362        data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, resources);
     363        var action = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);
     364        if (action.HasFlag(DragDropEffects.Move)) {
     365          foreach (var node in nodes) node.Remove();
     366          StyleTreeNode(ungroupedGroupNode, (Resource)ungroupedGroupNode.Tag, resources);
     367        }
     368      }
     369    }
     370
     371    private IEnumerable<TreeNode> GetCheckedNodes(TreeNodeCollection nodes) {
     372      if (nodes != null) {
     373        foreach (var node in nodes.OfType<TreeNode>()) {
     374          if (node.Checked && node != ungroupedGroupNode) yield return node;
     375          foreach (var child in GetCheckedNodes(node.Nodes))
     376            yield return child;
     377        }
     378      }
     379    }
     380
     381    private void treeSlaveGroup_DragEnterOver(object sender, DragEventArgs e) {
     382      e.Effect = DragDropEffects.Move;
     383      var resources = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IEnumerable<Resource>;
     384      var targetNode = treeView.GetNodeAt(treeView.PointToClient(new Point(e.X, e.Y)));
     385      var targetResource = (targetNode != null ? targetNode.Tag : null) as Resource;
     386
     387      if (!IsAdmin()
     388        || resources == null
     389        || !resources.Any()
     390        || resources.Any(x => !HiveAdminClient.Instance.CheckParentChange(x, targetResource))
     391        || (targetNode != null && (targetNode == ungroupedGroupNode || targetNode.Parent == ungroupedGroupNode))) {
     392        e.Effect = DragDropEffects.None;
     393      }
     394    }
     395
     396    private void TabSlaveGroup_TabIndexChanged(object sender, EventArgs e) {
     397      throw new NotImplementedException();
     398    }
     399
     400    private async void TabSlaveGroup_Selected(object sender, System.Windows.Forms.TabControlEventArgs e) {
     401      if (e.TabPage == tabSchedule) {
     402        await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     403          action: () => UpdateSchedule(),
     404          finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes);
     405      }
     406      SetEnabledStateOfControls();
     407    }
     408    #endregion
     409
     410    #region Helpers
     411    private void BuildResourceTree(IEnumerable<Resource> resources) {
     412      treeView.Nodes.Clear();
     413      if (!resources.Any()) return;
     414
     415      var disabledParentResources = HiveAdminClient.Instance.DisabledParentResources;
     416      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
     417        .Where(x => x.ParentResourceId == null));
     418      //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
     419      //  .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value)));
     420      //mainResources.UnionWith(parentedMainResources);
     421      var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty));
     422      mainResources.UnionWith(mainDisabledParentResources);
     423      var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name));
     424
     425      var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
     426      if (selectedResource != null) SelectedResource = resources.Where(x => x.Id == selectedResource.Id).FirstOrDefault();
     427      bool nodeSelected = false;
     428
     429      TreeNode currentNode = null;
     430      Resource currentResource = null;
     431
     432      while (stack.Any()) {
     433        var newResource = stack.Pop();
     434        var newNode = new TreeNode(newResource.Name) { Tag = newResource };
     435        StyleTreeNode(newNode, newResource, resources);
     436
     437        if (selectedResource == null && !disabledParentResources.Contains(newResource)) {
     438          SelectedResource = newResource;
     439        }
     440        if (!nodeSelected && selectedResource != null && newResource.Id == selectedResource.Id) {
     441          newNode.BackColor = selectedBackColor;
     442          newNode.ForeColor = selectedForeColor;
     443          newNode.Text += SELECTED_TAG;
     444          nodeSelected = true;
     445        }
     446
     447        if (disabledParentResources.Contains(newResource)) {
     448          newNode.Checked = false;
     449          newNode.ForeColor = grayTextColor;
     450        }
     451
     452        // search for parent node of newNode and save in currentNode
     453        // necessary since newNodes (stack top items) might be siblings
     454        // or grand..grandparents of previous node (currentNode)
     455        while (currentNode != null && newResource.ParentResourceId != currentResource.Id) {
     456          currentNode = currentNode.Parent;
     457          currentResource = currentNode == null ? null : (Resource)currentNode.Tag;
     458        }
     459
     460        if (currentNode == null) {
     461          treeView.Nodes.Add(newNode);
    234462        } else {
    235           permissionView.FetchSelectedUsers = null;
    236           btnPermissionsSave.Enabled = false;
    237           if (selectedResource.Id == Guid.Empty) {
    238             if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions);
    239           } else tabSlaveGroup.TabPages.Remove(tabPermissions);
    240         }
    241 
    242         if (slaveView.Content != null && slaveView.Content is SlaveGroup) {
    243           slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    244         }
    245 
    246         slaveView.Content = selectedResource;
    247         HiveAdminClient.Instance.DowntimeForResourceId = selectedResource.Id;
    248 
    249         if (selectedResource is SlaveGroup) {
    250           slaveView.Content.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    251         }
    252 
    253         if (tabSlaveGroup.SelectedIndex == 1) {
    254           UpdateScheduleAsync();
    255         } else if (tabSlaveGroup.SelectedIndex == 2) {
    256           UpdatePermissionsAsync();
    257         }
    258       }
    259     }
    260 
    261     void SlaveViewContent_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
    262       OnContentChanged();
    263       if (e.PropertyName == "HbInterval") {
    264         UpdateChildHbIntervall(slaveView.Content);
     463          currentNode.Nodes.Add(newNode);
     464        }
     465
     466        if (newResource is SlaveGroup) {
     467          var childResources = subResources.Where(x => x.ParentResourceId == newResource.Id);
     468          if (childResources.Any()) {
     469            foreach (var resource in childResources.OrderByDescending(x => x.Name)) {
     470              subResources.Remove(resource);
     471              stack.Push(resource);
     472            }
     473            currentNode = newNode;
     474            currentResource = newResource;
     475          }
     476        }
     477        newNode.SelectedImageIndex = newNode.ImageIndex;
     478      }
     479
     480      // collapse slave-only nodes
     481      foreach (TreeNode n in treeView.Nodes) {
     482        CollapseSlaveOnlyNodes(n);
     483      }
     484
     485      ungroupedGroupNode = new TreeNode(UNGROUPED_GROUP_NAME) {
     486        ForeColor = SystemColors.GrayText,
     487        ImageIndex = slaveGroupImageIndex,
     488        Tag = new SlaveGroup() {
     489          Name = UNGROUPED_GROUP_NAME,
     490          Description = UNGROUPED_GROUP_DESCRIPTION
     491        }
     492      };
     493
     494      foreach (var slave in subResources.OfType<Slave>().OrderBy(x => x.Name)) {
     495        var slaveNode = new TreeNode(slave.Name) { Tag = slave };
     496        StyleTreeNode(slaveNode, slave, resources);
     497        ungroupedGroupNode.Nodes.Add(slaveNode);
     498        if (selectedResource == null) {
     499          SelectedResource = slave;
     500        }
     501
     502        if (slave.Id == selectedResource.Id && !nodeSelected) {
     503          slaveNode.BackColor = selectedBackColor;
     504          slaveNode.ForeColor = selectedForeColor;
     505          slaveNode.Text += SELECTED_TAG;
     506          nodeSelected = true;
     507        }
     508      }
     509
     510      if (ungroupedGroupNode.Nodes.Count > 0) {
     511        ungroupedGroupNode.Text += " [" + ungroupedGroupNode.Nodes.Count.ToString() + "]";
     512        ungroupedGroupNode.Expand();
     513        treeView.Nodes.Add(ungroupedGroupNode);
     514      }
     515    }
     516
     517    private void CollapseSlaveOnlyNodes(TreeNode tn) {
     518      Resource r = (Resource)tn.Tag;
     519      var descendants = GetResourceDescendants();
     520      if (descendants.ContainsKey(r.Id)) {
     521        if (descendants[r.Id].OfType<SlaveGroup>().Any()) {
     522          tn.Expand();
     523          foreach (TreeNode n in tn.Nodes) CollapseSlaveOnlyNodes(n);
     524        } else {
     525          tn.Collapse();
     526        }
     527      }
     528    }
     529
     530    private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) {
     531      foreach (TreeNode n in nodes) {
     532        Resource r = (Resource)n.Tag;
     533        if (n.Nodes.Count > 0) {
     534          if (HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) {
     535            n.Expand();
     536            ExpandResourceNodesOfInterest(n.Nodes);
     537          } else {
     538            n.Collapse();
     539          }
     540        } else {
     541          n.Collapse();
     542        }
    265543      }
    266544    }
     
    275553    }
    276554
    277     private void btnAddGroup_Click(object sender, EventArgs e) {
    278       SlaveGroup newGroup = new SlaveGroup();
    279       newGroup.Name = "New Group";
    280       newGroup.OwnerUserId = UserInformation.Instance.User.Id;
    281       Content.Add(newGroup);
    282     }
    283 
    284     void Content_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) {
    285       OnContentChanged();
    286     }
    287 
    288     void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) {
    289       OnContentChanged();
    290     }
    291 
    292     private void btnRemoveGroup_Click(object sender, EventArgs e) {
    293       if (treeSlaveGroup.SelectedNode != null && treeSlaveGroup.SelectedNode.Tag != null) {
    294         Resource res = (Resource)treeSlaveGroup.SelectedNode.Tag;
    295 
    296         DialogResult diagRes = MessageBox.Show("Do you really want to delete " + res.Name + "?", "HeuristicLab Hive Administrator", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    297         if (diagRes == DialogResult.Yes) {
    298           if (res is Slave) {
    299             Content.Remove(res);
    300             HiveAdminClient.Delete(res);
    301           } else if (res is SlaveGroup) {
    302             //only delete empty groups
    303             if (Content.Where(s => s.ParentResourceId == res.Id).Count() < 1) {
    304               Content.Remove(res);
    305               HiveAdminClient.Delete(res);
    306             } else {
    307               MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    308             }
     555    private void UpdateResources() {
     556      try {
     557        HiveAdminClient.Instance.Refresh();
     558        Content = HiveAdminClient.Instance.Resources;
     559      } catch (AnonymousUserException) {
     560        ShowHiveInformationDialog();
     561      }
     562    }
     563
     564    private void RemoveResource(Resource resource) {
     565      if (resource == null) return;
     566
     567      try {
     568        if (resource.Id != Guid.Empty) {
     569          SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(resource.Id).LastOrDefault();
     570
     571          // deal with all new, but not yet saved resources
     572          var newResources = Content.Where(x => x.ParentResourceId == resource.Id).ToList();
     573          if (newResources.Any(x => x.Id != Guid.Empty)) return;
     574          foreach (var nr in newResources) Content.Remove(nr);
     575
     576          HiveAdminClient.Delete(resource);         
     577          UpdateResources();
     578        } else {
     579          SelectedResource = Content.FirstOrDefault(x => x.Id == resource.ParentResourceId);
     580          Content.Remove(resource);
     581        }
     582      } catch (AnonymousUserException) {
     583        ShowHiveInformationDialog();
     584      }
     585    }
     586
     587    private void RemoveResource(IEnumerable<Resource> resources) {
     588      if (resources == null || !resources.Any()) return;
     589
     590      var ids = resources.Select(x => x.Id).ToList();     
     591      try {
     592        bool update = false;
     593        foreach (var r in resources) {         
     594          if (r.Id != Guid.Empty)  {
     595            if(r.Id == SelectedResource.Id)
     596              SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(r.Id).LastOrDefault();
     597
     598            // deal with all new, but not yet saved resources
     599            var newResources = Content.Where(x => x.ParentResourceId == r.Id).ToList();
     600            if (newResources.Any(x => x.Id != Guid.Empty)) return;
     601            foreach (var nr in newResources) Content.Remove(nr);
     602
     603            HiveAdminClient.Delete(r);
     604            update = true;
     605          } else {
     606            if (r.Id == SelectedResource.Id)
     607              SelectedResource = Content.FirstOrDefault(x => x.Id == r.ParentResourceId);
     608            Content.Remove(r);
    309609          }
    310610        }
    311       }
    312     }
    313 
    314     private void btnSave_Click(object sender, EventArgs e) {
    315       foreach (Resource res in Content) {
    316         if (res is SlaveGroup && res.Id == Guid.Empty) {
    317           SlaveGroup slaveGroup = (SlaveGroup)res;
    318           slaveGroup.Store();
    319         } else if (res.Id != Guid.Empty && res.Modified) {
    320           res.Store();
    321         }
    322       }
    323     }
    324 
    325     private void treeSlaveGroup_DragDrop(object sender, DragEventArgs e) {
    326       if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) {
    327         Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
    328         TreeNode destNode = ((TreeView)sender).GetNodeAt(pt);
    329         TreeNode newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
    330 
    331         if (destNode.TreeView == newNode.TreeView) {
    332           if (destNode.Text == UngroupedGroupName || (destNode.Parent != null && destNode.Parent.Text == UngroupedGroupName)) {
    333             MessageBox.Show(string.Format("You can't drag items to the group \"{0}\".{1}This group only contains slaves which haven't yet been assigned to a real group.",
    334               UngroupedGroupName, Environment.NewLine), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Information);
    335             return;
    336           }
    337 
    338           SlaveGroup sgrp = null;
    339           TreeNode parentNode = null;
    340           if (destNode.Tag != null && destNode.Tag is SlaveGroup) {
    341             sgrp = (SlaveGroup)destNode.Tag;
    342             parentNode = destNode;
    343           } else if (destNode.Parent != null && destNode.Parent.Tag is SlaveGroup) {
    344             sgrp = (SlaveGroup)destNode.Parent.Tag;
    345             parentNode = destNode.Parent;
    346           }
    347 
    348           if (newNode.Tag is SlaveGroup && CheckParentsEqualsMovedNode(parentNode, newNode)) {
    349             return;
    350           }
    351 
    352           SlaveGroup parent = (SlaveGroup)parentNode.Tag;
    353 
    354           if (parent.OwnerUserId != null && !IsAuthorized(parent)) {
    355             MessageBox.Show(string.Format("You don't have the permissions to drag items to the group \"{0}\".", ((Resource)parentNode.Tag).Name),
    356               "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    357             return;
    358           }
    359 
    360           if (sgrp != null && newNode.Tag != null) {
    361             //save parent group to get an id
    362             if (sgrp.Id == Guid.Empty) {
    363               sgrp.Store();
    364             }
    365 
    366             if (newNode.Tag is Slave) {
    367               Slave slave = (Slave)newNode.Tag;
    368               if (slave.ParentResourceId == null || (slave.ParentResourceId != null && slave.ParentResourceId != sgrp.Id)) {
    369                 slave.ParentResourceId = sgrp.Id;
    370                 newNode.Remove();
    371                 parentNode.Nodes.Clear();
    372                 BuildSlaveGroupTree(sgrp, parentNode);
    373               }
    374             } else if (newNode.Tag is SlaveGroup) {
    375               SlaveGroup slaveGroup = (SlaveGroup)newNode.Tag;
    376               if (slaveGroup.ParentResourceId == null || (slaveGroup.ParentResourceId != null && slaveGroup.ParentResourceId != sgrp.Id)) {
    377                 slaveGroup.ParentResourceId = sgrp.Id;
    378                 newNode.Remove();
    379                 parentNode.Nodes.Clear();
    380                 BuildSlaveGroupTree(sgrp, parentNode);
    381               }
    382             }
    383           }
    384         }
    385       }
    386     }
    387 
    388     private bool CheckParentsEqualsMovedNode(TreeNode dest, TreeNode movedNode) {
    389       TreeNode tmp = dest;
    390 
    391       while (tmp != null) {
    392         if (tmp == movedNode) {
    393           return true;
    394         }
    395         tmp = tmp.Parent;
    396       }
    397       return false;
    398     }
    399 
    400     private void treeSlaveGroup_ItemDrag(object sender, ItemDragEventArgs e) {
    401       TreeNode sourceNode = (TreeNode)e.Item;
    402       if (IsAuthorized((Resource)sourceNode.Tag))
    403         DoDragDrop(sourceNode, DragDropEffects.All);
    404     }
    405 
    406     private void treeSlaveGroup_DragEnter(object sender, DragEventArgs e) {
    407       e.Effect = DragDropEffects.Move;
    408     }
    409 
    410     private void treeSlaveGroup_DragOver(object sender, DragEventArgs e) {
    411       e.Effect = DragDropEffects.Move;
    412     }
    413 
    414     private void treeSlaveGroup_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) {
    415       e.Action = DragAction.Continue;
    416     }
    417 
    418     void ResetView() {
    419       if (this.InvokeRequired) {
    420         Invoke(new Action(ResetView));
     611        if (update) UpdateResources();
     612      } catch (AnonymousUserException) {
     613        ShowHiveInformationDialog();
     614      }
     615    }
     616
     617    private void UpdateSchedule() {
     618      try {
     619        HiveAdminClient.Instance.RefreshCalendar();
     620      } catch (AnonymousUserException) {
     621        ShowHiveInformationDialog();
     622      }
     623    }
     624
     625    private bool IsAdmin() {
     626      return HiveRoles.CheckAdminUserPermissions();
     627    }
     628
     629    private void StyleTreeNode(TreeNode n, Resource r, IEnumerable<Resource> resources) {
     630      n.Text = r.Name;
     631      n.BackColor = Color.Transparent;
     632      n.ForeColor = Color.Black;
     633
     634      if (HiveAdminClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id)) {
     635        n.ForeColor = grayTextColor;
     636      } else if (r.Id == Guid.Empty && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) {
     637        // not stored (i.e. new)
     638        n.Text += NOT_STORED_TAG;
     639      } else if (r.Modified && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) {
     640        // changed
     641        n.Text += CHANGES_NOT_STORED_TAG;
     642      }
     643
     644      // slave count
     645      int childSlavesCount = 0;
     646      if (r.Id != Guid.Empty && r is SlaveGroup) {
     647        var descendants = GetResourceDescendants();
     648        if (descendants.ContainsKey(r.Id)) {
     649          childSlavesCount = resources
     650            .OfType<Slave>()
     651            .Where(x => descendants[r.Id].Select(y => y.Id)
     652              .Contains(x.Id))
     653            .Count();
     654        }
     655      } else if (n == ungroupedGroupNode /*|| r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) {
     656        childSlavesCount = resources
     657          .OfType<Slave>()
     658          .Where(x => x.ParentResourceId == null
     659            || (x.ParentResourceId.HasValue && x.ParentResourceId.Value == Guid.Empty))
     660          .Count();
     661      }
     662      if (childSlavesCount > 0)
     663        n.Text += " [" + childSlavesCount.ToString() + "]";
     664
     665      // slave image index, state, utilization
     666      if (r is Slave) {
     667        n.ImageIndex = slaveImageIndex;
     668        var s = r as Slave;
     669        if (s.SlaveState == SlaveState.Calculating) {
     670          n.ForeColor = calculatingColor;
     671          n.Text += " [" + s.CpuUtilization.ToString("N2") + "%]";
     672        } else if (s.SlaveState == SlaveState.Offline) {
     673          n.ForeColor = offlineColor;
     674          if (s.LastHeartbeat.HasValue)
     675            n.Text += " [" + (s.LastHeartbeat != null ? s.LastHeartbeat.Value.ToString("g") : null) + "]";
     676        }
    421677      } else {
    422         treeSlaveGroup.Nodes.Clear();
    423 
    424         if (slaveView.Content != null && slaveView.Content is SlaveGroup) {
    425           slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged);
    426         }
    427         slaveView.Content = null;
     678        n.ImageIndex = slaveGroupImageIndex;
     679      }
     680
     681      // ungrouped
     682      if (n == ungroupedGroupNode /*r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) {
     683        n.ForeColor = SystemColors.GrayText;
     684      }
     685    }
     686
     687    private void ResetTreeNodes(TreeNodeCollection nodes, IEnumerable<Resource> resources) {
     688      foreach (TreeNode n in nodes) {
     689        StyleTreeNode(n, (Resource)n.Tag, resources);
     690        if (n.Nodes.Count > 0) {
     691          ResetTreeNodes(n.Nodes, resources);
     692        }
     693      }
     694    }
     695
     696    private async void ChangeSelectedResource(Resource resource) {
     697      selectedResource = resource;
     698      viewHost.Content = selectedResource;
     699
     700      HiveAdminClient.Instance.DowntimeForResourceId = selectedResource != null ? selectedResource.Id : Guid.Empty;
     701      if (tabSlaveGroup.SelectedTab == tabSchedule) {
     702        await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     703          action: () => UpdateSchedule(),
     704          finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes);
     705      }
     706
     707      SetEnabledStateOfControls();
     708    }
     709
     710    private void ChangeSelectedResourceNode(TreeNode resourceNode) {
     711      if (resourceNode == null) return;
     712      SelectedResource = (Resource)resourceNode.Tag;
     713      ResetTreeNodes(treeView.Nodes, Content);
     714      resourceNode.BackColor = selectedBackColor;
     715      resourceNode.ForeColor = selectedForeColor;
     716      resourceNode.Text += SELECTED_TAG;
     717    }
     718
     719    private void ShowHiveInformationDialog() {
     720      if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog);
     721      else {
     722        using (HiveInformationDialog dialog = new HiveInformationDialog()) {
     723          dialog.ShowDialog(this);
     724        }
     725      }
     726    }
     727
     728    private void ResetView() {
     729      if (InvokeRequired) Invoke((Action)ResetView);
     730      else {
     731        treeView.Nodes.Clear();
     732
     733        if (viewHost.Content != null && viewHost.Content is SlaveGroup) {
     734          ((SlaveGroup)viewHost.Content).PropertyChanged -= SlaveViewContent_PropertyChanged;
     735        }
     736
     737        viewHost.Content = null;
    428738        if (scheduleView.Content != null) {
    429739          scheduleView.Content.Clear();
    430740        }
     741
    431742        HiveAdminClient.Instance.ResetDowntime();
    432743      }
    433744    }
    434745
    435     private void UpdateResources() {
    436       ResetView();
    437 
    438       try {
    439         if (!Access.UserInformation.Instance.UserExists) {
    440           //do a refresh just in case that the user has changed his usr and pwd in between
    441           Access.UserInformation.Instance.Refresh();
    442         }
    443         HiveAdminClient.Instance.Refresh();
    444         Content = HiveAdminClient.Instance.Resources;
    445       }
    446       catch (MessageSecurityException) {
    447         ShowMessageSecurityException();
    448       }
    449       catch (AnonymousUserException) {
    450         ShowHiveInformationDialog();
    451       }
    452     }
    453 
    454     private void ShowMessageSecurityException() {
    455       if (this.InvokeRequired) {
    456         Invoke(new Action(ShowMessageSecurityException));
    457       } else {
    458         MessageBox.Show("A Message Security error has occured. This normally means that your user name or password is wrong.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    459       }
    460     }
    461 
    462     private void ShowHiveInformationDialog() {
    463       if (this.InvokeRequired) {
    464         Invoke(new Action(ShowHiveInformationDialog));
    465       } else {
    466         using (HiveInformationDialog dialog = new HiveInformationDialog()) {
    467           dialog.ShowDialog(this);
    468         }
    469       }
    470     }
    471 
    472     private void UpdateResourcesAsync() {
    473       TS.Task.Factory.StartNew(UpdateResources).ContinueWith((t) => {
    474         DisplayError(t.Exception);
    475       }, TaskContinuationOptions.OnlyOnFaulted);
    476     }
    477 
    478     private void UpdateSchedule() {
    479       HiveAdminClient.Instance.RefreshCalendar();
    480       scheduleView.Invoke(new Action(() => {
    481         scheduleView.Content = HiveAdminClient.Instance.Downtimes;
    482         SetEnabledStateOfControls();
    483       }));
    484     }
    485 
    486     private void UpdateScheduleAsync() {
    487       TS.Task.Factory.StartNew(UpdateSchedule).ContinueWith((t) => {
    488         DisplayError(t.Exception);
    489       }, TaskContinuationOptions.OnlyOnFaulted);
    490     }
    491 
    492     private void UpdatePermissions() {
    493       if (permissionView.Content != null && permissionView.FetchSelectedUsers != null)
    494         permissionView.Invoke(new Action(() => permissionView.ManualRefresh()));
    495     }
    496 
    497     private void UpdatePermissionsAsync() {
    498       TS.Task.Factory.StartNew(UpdatePermissions).ContinueWith((t) => {
    499         DisplayError(t.Exception);
    500       }, TaskContinuationOptions.OnlyOnFaulted);
    501     }
    502 
    503 
    504     private void DisplayError(Exception ex) {
    505       MessageBox.Show(string.Format("An error occured while updating: {0} {1}", Environment.NewLine, ex.Message), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    506     }
    507 
    508     private void tabSlaveGroup_SelectedIndexChanged(object sender, EventArgs e) {
    509       if (tabSlaveGroup.SelectedIndex == 1) {
    510         UpdateScheduleAsync();
    511       } else if (tabSlaveGroup.SelectedIndex == 2) {
    512         UpdatePermissionsAsync();
    513       }
    514     }
    515 
    516     private void btnRefresh_Click(object sender, EventArgs e) {
    517       UpdateResourcesAsync();
    518     }
    519 
    520     private void ResourcesView_Load(object sender, EventArgs e) {
    521       UpdateResourcesAsync();
    522     }
    523 
    524     private void btnPermissionsSave_Click(object sender, EventArgs e) {
    525       SetEnabledStateOfControls();
    526       HiveServiceLocator.Instance.CallHiveService(service => {
    527         service.GrantResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetAddedUsers().Select(x => x.Id).ToList());
    528         service.RevokeResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetDeletedUsers().Select(x => x.Id).ToList());
    529       });
    530       SetEnabledStateOfControls();
    531     }
     746
     747    private Dictionary<Guid, HashSet<Resource>> GetResourceDescendants() {
     748      var resourceDescendants = new Dictionary<Guid, HashSet<Resource>>();
     749      //var resources = Content.Where(x => x.Id != Guid.Empty).Union(HiveAdminClient.Instance.DisabledParentResources).ToList();     
     750      var resources = Content.Union(HiveAdminClient.Instance.DisabledParentResources).ToList();
     751
     752      foreach (var r in resources) {
     753        if(!resourceDescendants.ContainsKey(r.Id))
     754          resourceDescendants.Add(r.Id, new HashSet<Resource>());
     755      }
     756      foreach (var r in resources) {
     757        var parentResourceId = r.ParentResourceId;
     758        while (parentResourceId != null) {
     759          var parent = resources.SingleOrDefault(x => x.Id == parentResourceId);
     760          if (parent != null) {
     761            resourceDescendants[parent.Id].Add(r);
     762            parentResourceId = parent.ParentResourceId;
     763          } else {
     764            parentResourceId = null;
     765          }
     766        }
     767      }
     768      return resourceDescendants;
     769    }
     770
     771    #endregion
    532772  }
    533773}
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.Designer.cs

    r15584 r17059  
    4848      Calendar.DrawTool drawTool1 = new Calendar.DrawTool();
    4949      this.dvOnline = new Calendar.DayView();
    50       this.txttimeTo = new System.Windows.Forms.DateTimePicker();
    51       this.txttimeFrom = new System.Windows.Forms.DateTimePicker();
    5250      this.dtpTo = new System.Windows.Forms.DateTimePicker();
    5351      this.groupBox1 = new System.Windows.Forms.GroupBox();
     
    9492      this.dvOnline.OnSelectionChanged += new System.EventHandler<System.EventArgs>(this.dvOnline_OnSelectionChanged);
    9593      //
    96       // txttimeTo
    97       //
    98       this.txttimeTo.CustomFormat = "HH:mm";
    99       this.txttimeTo.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    100       this.txttimeTo.Location = new System.Drawing.Point(164, 45);
    101       this.txttimeTo.Name = "txttimeTo";
    102       this.txttimeTo.ShowUpDown = true;
    103       this.txttimeTo.Size = new System.Drawing.Size(73, 20);
    104       this.txttimeTo.TabIndex = 40;
    105       //
    106       // txttimeFrom
    107       //
    108       this.txttimeFrom.CustomFormat = "HH:mm";
    109       this.txttimeFrom.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    110       this.txttimeFrom.Location = new System.Drawing.Point(164, 12);
    111       this.txttimeFrom.Name = "txttimeFrom";
    112       this.txttimeFrom.ShowUpDown = true;
    113       this.txttimeFrom.Size = new System.Drawing.Size(73, 20);
    114       this.txttimeFrom.TabIndex = 39;
    115       //
    11694      // dtpTo
    11795      //
    11896      this.dtpTo.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
     97      this.dtpTo.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss";
    11998      this.dtpTo.Location = new System.Drawing.Point(72, 45);
    12099      this.dtpTo.Name = "dtpTo";
    121       this.dtpTo.Size = new System.Drawing.Size(89, 20);
     100      this.dtpTo.Size = new System.Drawing.Size(175, 20);
    122101      this.dtpTo.TabIndex = 33;
    123102      //
     
    125104      //
    126105      this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    127       this.groupBox1.Controls.Add(this.txttimeTo);
    128       this.groupBox1.Controls.Add(this.txttimeFrom);
    129106      this.groupBox1.Controls.Add(this.dtpTo);
    130107      this.groupBox1.Controls.Add(this.dtpFrom);
     
    144121      //
    145122      this.dtpFrom.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
     123      this.dtpFrom.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss";
    146124      this.dtpFrom.Location = new System.Drawing.Point(72, 12);
    147125      this.dtpFrom.Name = "dtpFrom";
    148       this.dtpFrom.Size = new System.Drawing.Size(89, 20);
     126      this.dtpFrom.Size = new System.Drawing.Size(175, 20);
    149127      this.dtpFrom.TabIndex = 32;
    150128      //
     
    157135      this.chbade.TabIndex = 31;
    158136      this.chbade.Text = "All Day Event";
     137      this.chbade.CheckedChanged += new System.EventHandler(this.chbade_CheckedChanged);
    159138      this.chbade.UseVisualStyleBackColor = true;
    160       this.chbade.CheckedChanged += new System.EventHandler(this.chbade_CheckedChanged);
    161139      //
    162140      // btnRecurrence
     
    220198      //
    221199      this.btnSaveCal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    222       this.btnSaveCal.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
     200      this.btnSaveCal.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
    223201      this.btnSaveCal.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
    224202      this.btnSaveCal.Location = new System.Drawing.Point(640, 41);
     
    273251    #endregion
    274252
    275     private System.Windows.Forms.DateTimePicker txttimeTo;
    276253    private Calendar.DayView dvOnline;
    277     private System.Windows.Forms.DateTimePicker txttimeFrom;
    278254    private System.Windows.Forms.DateTimePicker dtpTo;
    279255    private System.Windows.Forms.GroupBox groupBox1;
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs

    r15584 r17059  
    9292
    9393      if (!string.IsNullOrEmpty(dtpFrom.Text) && !string.IsNullOrEmpty(dtpTo.Text)) {
    94         if (chbade.Checked) {
     94        if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) {
    9595          //whole day appointment, only dates are visible
    96           if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to)
    97             offlineTimes.Add(CreateDowntime(from, to.AddDays(1), true, dtType));
    98           else
    99             MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    100         } else if (!string.IsNullOrEmpty(txttimeFrom.Text) && !string.IsNullOrEmpty(txttimeTo.Text)) {
    101           //Timeframe appointment
    102           if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) {
     96          if (chbade.Checked) {
     97            offlineTimes.Add(CreateDowntime(new DateTime(from.Year, from.Month, from.Day), (new DateTime(to.Year, to.Month, to.Day)).AddDays(1), true, dtType));
     98          } else {
     99            //Timeframe appointment
    103100            if (from.Date == to.Date)
    104101              offlineTimes.Add(CreateDowntime(from, to, false, dtType));
     
    111108              offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType));
    112109            }
    113           } else
    114             MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    115         }
     110          }
     111
     112        } else {
     113          MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     114        }
     115
     116
    116117        dvOnline.Invalidate();
    117118        return true;
     
    156157
    157158    private void ChangeRecurrenceDowntime(Guid recurringId) {
    158       int hourfrom = int.Parse(txttimeFrom.Text.Substring(0, txttimeFrom.Text.IndexOf(':')));
    159       int hourTo = int.Parse(txttimeTo.Text.Substring(0, txttimeTo.Text.IndexOf(':')));
    160       List<HiveDowntime> recurringDowntimes = offlineTimes.Where(appointment => ((HiveDowntime)appointment).RecurringId == recurringId).ToList();
    161       recurringDowntimes.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, hourfrom, 0, 0));
    162       recurringDowntimes.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, hourTo, 0, 0));
     159      DateTime from, to;
     160      if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) {
     161        List<HiveDowntime> recurringDowntimes = offlineTimes.Where(appointment => ((HiveDowntime)appointment).RecurringId == recurringId).ToList();
     162        recurringDowntimes.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, from.Hour, 0, 0));
     163        recurringDowntimes.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, to.Hour, 0, 0));
     164      } else {
     165        MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     166      }
    163167    }
    164168
     
    222226    protected override void SetEnabledStateOfControls() {
    223227      base.SetEnabledStateOfControls();
    224     }
    225 
    226     public virtual void SetEnabledStateOfSchedule(bool state) {
    227       if (InvokeRequired) {
    228         Invoke(new Action(() => SetEnabledStateOfSchedule(state)));
    229       } else {
    230         if (Content == null) state = false;
    231         groupBox1.Enabled = state;
    232         btnClearCal.Enabled = state;
    233         btnSaveCal.Enabled = state;
    234       }
    235     }
     228      bool enabled = Content != null && !Locked;
     229      dtpFrom.Enabled = enabled;
     230      dtpTo.Enabled = enabled;
     231      chbade.Enabled = enabled;
     232      btCreate.Enabled = enabled;
     233      btbDelete.Enabled = enabled;     
     234      btnRecurrence.Enabled = enabled;
     235      btnClearCal.Enabled = enabled;
     236      btnSaveCal.Enabled = enabled;
     237    }
     238
     239    //public virtual void SetEnabledStateOfSchedule(bool state) {
     240    //  if (InvokeRequired) {
     241    //    Invoke(new Action(() => SetEnabledStateOfSchedule(state)));
     242    //  } else {
     243    //    if (Content == null || Locked || ReadOnly) state = false;
     244    //    //groupBox1.Enabled = state;
     245    //    btnClearCal.Enabled = state;
     246    //    btnSaveCal.Enabled = state;
     247    //  }
     248    //}
    236249
    237250    private void btnClearCal_Click(object sender, System.EventArgs e) {
     
    243256
    244257    private void chbade_CheckedChanged(object sender, EventArgs e) {
    245       txttimeFrom.Visible = !chbade.Checked;
    246       txttimeTo.Visible = !chbade.Checked;
     258      if(chbade.Checked) {
     259        dtpFrom.Value = new DateTime(dtpFrom.Value.Year, dtpFrom.Value.Month, dtpFrom.Value.Day);
     260        dtpTo.Value = new DateTime(dtpTo.Value.Year, dtpTo.Value.Month, dtpTo.Value.Day);
     261      }
    247262    }
    248263
    249264    private void dvOnline_OnSelectionChanged(object sender, EventArgs e) {
    250265      if (dvOnline.Selection == SelectionType.DateRange) {
    251         dtpFrom.Text = dvOnline.SelectionStart.ToShortDateString();
    252         dtpTo.Text = dvOnline.SelectionEnd.Date.ToShortDateString();
    253         txttimeFrom.Text = dvOnline.SelectionStart.ToShortTimeString();
    254         txttimeTo.Text = dvOnline.SelectionEnd.ToShortTimeString();
     266        dtpFrom.Value = dvOnline.SelectionStart;
     267        dtpTo.Value = dvOnline.SelectionEnd.Date;
    255268        btCreate.Text = "Create Downtime";
    256269      }
    257270
    258271      if (dvOnline.Selection == SelectionType.Appointment) {
    259         dtpFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortDateString();
    260         dtpTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortDateString();
    261         txttimeFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortTimeString();
    262         txttimeTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortTimeString();
     272        dtpFrom.Value = dvOnline.SelectedAppointment.StartDate;
     273        dtpTo.Value = dvOnline.SelectedAppointment.EndDate;
    263274
    264275        if (dvOnline.SelectedAppointment.Recurring)
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.Designer.cs

    r15584 r17059  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.txtSlaveState = new System.Windows.Forms.TextBox();
    48       this.txtOS = new System.Windows.Forms.TextBox();
    49       this.label15 = new System.Windows.Forms.Label();
    50       this.label14 = new System.Windows.Forms.Label();
    51       this.txtDetailsDescription = new System.Windows.Forms.TextBox();
    52       this.label13 = new System.Windows.Forms.Label();
    53       this.txtName = new System.Windows.Forms.TextBox();
    54       this.txtCPU = new System.Windows.Forms.TextBox();
    55       this.txtMemory = new System.Windows.Forms.TextBox();
    56       this.txtLastHeartbeat = new System.Windows.Forms.TextBox();
    57       this.label12 = new System.Windows.Forms.Label();
    58       this.label11 = new System.Windows.Forms.Label();
    59       this.label10 = new System.Windows.Forms.Label();
    60       this.label9 = new System.Windows.Forms.Label();
    61       this.label1 = new System.Windows.Forms.Label();
    62       this.txtFreeMemory = new System.Windows.Forms.TextBox();
    63       this.txtId = new System.Windows.Forms.TextBox();
    64       this.label2 = new System.Windows.Forms.Label();
    65       this.label3 = new System.Windows.Forms.Label();
    66       this.txtHbIntervall = new System.Windows.Forms.TextBox();
    67       this.cbxDisposable = new System.Windows.Forms.CheckBox();
    68       this.label4 = new System.Windows.Forms.Label();
    69       this.cbxPublic = new System.Windows.Forms.CheckBox();
    70       this.label5 = new System.Windows.Forms.Label();
     47      this.cpuLabel = new System.Windows.Forms.Label();
     48      this.cpuTextBox = new System.Windows.Forms.TextBox();
     49      this.memoryLabel = new System.Windows.Forms.Label();
     50      this.memoryTextBox = new System.Windows.Forms.TextBox();
     51      this.operatingSystemLabel = new System.Windows.Forms.Label();
     52      this.operatingSystemTextBox = new System.Windows.Forms.TextBox();
     53      this.stateLabel = new System.Windows.Forms.Label();
     54      this.stateTextBox = new System.Windows.Forms.TextBox();
     55      this.lastHeartbeatLabel = new System.Windows.Forms.Label();
     56      this.lastHeartbeatTextBox = new System.Windows.Forms.TextBox();
     57      this.disposableLabel = new System.Windows.Forms.Label();
     58      this.disposableCheckBox = new System.Windows.Forms.CheckBox();
     59      ((System.ComponentModel.ISupportInitialize)(this.heartbeatIntervalNumericUpDown)).BeginInit();
    7160      this.SuspendLayout();
    7261      //
    73       // txtSlaveState
    74       //
    75       this.txtSlaveState.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    76             | System.Windows.Forms.AnchorStyles.Right)));
    77       this.txtSlaveState.Enabled = false;
    78       this.txtSlaveState.Location = new System.Drawing.Point(146, 242);
    79       this.txtSlaveState.Name = "txtSlaveState";
    80       this.txtSlaveState.Size = new System.Drawing.Size(390, 20);
    81       this.txtSlaveState.TabIndex = 27;
    82       //
    83       // txtOS
    84       //
    85       this.txtOS.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    86             | System.Windows.Forms.AnchorStyles.Right)));
    87       this.txtOS.Enabled = false;
    88       this.txtOS.Location = new System.Drawing.Point(146, 216);
    89       this.txtOS.Name = "txtOS";
    90       this.txtOS.Size = new System.Drawing.Size(390, 20);
    91       this.txtOS.TabIndex = 26;
    92       //
    93       // label15
    94       //
    95       this.label15.AutoSize = true;
    96       this.label15.Location = new System.Drawing.Point(3, 245);
    97       this.label15.Name = "label15";
    98       this.label15.Size = new System.Drawing.Size(35, 13);
    99       this.label15.TabIndex = 25;
    100       this.label15.Text = "State:";
    101       //
    102       // label14
    103       //
    104       this.label14.AutoSize = true;
    105       this.label14.Location = new System.Drawing.Point(3, 219);
    106       this.label14.Name = "label14";
    107       this.label14.Size = new System.Drawing.Size(93, 13);
    108       this.label14.TabIndex = 24;
    109       this.label14.Text = "Operating System:";
    110       //
    111       // txtDetailsDescription
    112       //
    113       this.txtDetailsDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    114             | System.Windows.Forms.AnchorStyles.Right)));
    115       this.txtDetailsDescription.Enabled = false;
    116       this.txtDetailsDescription.Location = new System.Drawing.Point(146, 112);
    117       this.txtDetailsDescription.Name = "txtDetailsDescription";
    118       this.txtDetailsDescription.Size = new System.Drawing.Size(390, 20);
    119       this.txtDetailsDescription.TabIndex = 23;
    120       //
    121       // label13
    122       //
    123       this.label13.AutoSize = true;
    124       this.label13.Location = new System.Drawing.Point(3, 115);
    125       this.label13.Name = "label13";
    126       this.label13.Size = new System.Drawing.Size(63, 13);
    127       this.label13.TabIndex = 22;
    128       this.label13.Text = "Description:";
    129       //
    130       // txtName
    131       //
    132       this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    133             | System.Windows.Forms.AnchorStyles.Right)));
    134       this.txtName.Location = new System.Drawing.Point(146, 8);
    135       this.txtName.Name = "txtName";
    136       this.txtName.Size = new System.Drawing.Size(390, 20);
    137       this.txtName.TabIndex = 21;
    138       this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
    139       //
    140       // txtCPU
    141       //
    142       this.txtCPU.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    143             | System.Windows.Forms.AnchorStyles.Right)));
    144       this.txtCPU.Enabled = false;
    145       this.txtCPU.Location = new System.Drawing.Point(146, 138);
    146       this.txtCPU.Name = "txtCPU";
    147       this.txtCPU.Size = new System.Drawing.Size(390, 20);
    148       this.txtCPU.TabIndex = 20;
    149       //
    150       // txtMemory
    151       //
    152       this.txtMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    153             | System.Windows.Forms.AnchorStyles.Right)));
    154       this.txtMemory.Enabled = false;
    155       this.txtMemory.Location = new System.Drawing.Point(146, 164);
    156       this.txtMemory.Name = "txtMemory";
    157       this.txtMemory.Size = new System.Drawing.Size(390, 20);
    158       this.txtMemory.TabIndex = 19;
    159       //
    160       // txtLastHeartbeat
    161       //
    162       this.txtLastHeartbeat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    163             | System.Windows.Forms.AnchorStyles.Right)));
    164       this.txtLastHeartbeat.Enabled = false;
    165       this.txtLastHeartbeat.Location = new System.Drawing.Point(146, 268);
    166       this.txtLastHeartbeat.Name = "txtLastHeartbeat";
    167       this.txtLastHeartbeat.Size = new System.Drawing.Size(390, 20);
    168       this.txtLastHeartbeat.TabIndex = 18;
    169       //
    170       // label12
    171       //
    172       this.label12.AutoSize = true;
    173       this.label12.Location = new System.Drawing.Point(3, 271);
    174       this.label12.Name = "label12";
    175       this.label12.Size = new System.Drawing.Size(80, 13);
    176       this.label12.TabIndex = 17;
    177       this.label12.Text = "Last Heartbeat:";
    178       //
    179       // label11
    180       //
    181       this.label11.AutoSize = true;
    182       this.label11.Location = new System.Drawing.Point(3, 167);
    183       this.label11.Name = "label11";
    184       this.label11.Size = new System.Drawing.Size(47, 13);
    185       this.label11.TabIndex = 16;
    186       this.label11.Text = "Memory:";
    187       //
    188       // label10
    189       //
    190       this.label10.AutoSize = true;
    191       this.label10.Location = new System.Drawing.Point(3, 141);
    192       this.label10.Name = "label10";
    193       this.label10.Size = new System.Drawing.Size(32, 13);
    194       this.label10.TabIndex = 15;
    195       this.label10.Text = "CPU:";
    196       //
    197       // label9
    198       //
    199       this.label9.AutoSize = true;
    200       this.label9.Location = new System.Drawing.Point(3, 11);
    201       this.label9.Name = "label9";
    202       this.label9.Size = new System.Drawing.Size(38, 13);
    203       this.label9.TabIndex = 14;
    204       this.label9.Text = "Name:";
    205       //
    206       // label1
    207       //
    208       this.label1.AutoSize = true;
    209       this.label1.Location = new System.Drawing.Point(3, 193);
    210       this.label1.Name = "label1";
    211       this.label1.Size = new System.Drawing.Size(70, 13);
    212       this.label1.TabIndex = 28;
    213       this.label1.Text = "Free memory:";
    214       //
    215       // txtFreeMemory
    216       //
    217       this.txtFreeMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    218             | System.Windows.Forms.AnchorStyles.Right)));
    219       this.txtFreeMemory.Enabled = false;
    220       this.txtFreeMemory.Location = new System.Drawing.Point(146, 190);
    221       this.txtFreeMemory.Name = "txtFreeMemory";
    222       this.txtFreeMemory.Size = new System.Drawing.Size(390, 20);
    223       this.txtFreeMemory.TabIndex = 29;
    224       //
    225       // txtId
    226       //
    227       this.txtId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    228             | System.Windows.Forms.AnchorStyles.Right)));
    229       this.txtId.Enabled = false;
    230       this.txtId.Location = new System.Drawing.Point(146, 86);
    231       this.txtId.Name = "txtId";
    232       this.txtId.Size = new System.Drawing.Size(390, 20);
    233       this.txtId.TabIndex = 30;
    234       //
    235       // label2
    236       //
    237       this.label2.AutoSize = true;
    238       this.label2.Location = new System.Drawing.Point(3, 89);
    239       this.label2.Name = "label2";
    240       this.label2.Size = new System.Drawing.Size(19, 13);
    241       this.label2.TabIndex = 31;
    242       this.label2.Text = "Id:";
    243       //
    244       // label3
    245       //
    246       this.label3.AutoSize = true;
    247       this.label3.Location = new System.Drawing.Point(3, 37);
    248       this.label3.Name = "label3";
    249       this.label3.Size = new System.Drawing.Size(137, 13);
    250       this.label3.TabIndex = 32;
    251       this.label3.Text = "Heartbeat Intervall (in sec) :";
    252       //
    253       // txtHbIntervall
    254       //
    255       this.txtHbIntervall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    256             | System.Windows.Forms.AnchorStyles.Right)));
    257       this.txtHbIntervall.Location = new System.Drawing.Point(146, 34);
    258       this.txtHbIntervall.Name = "txtHbIntervall";
    259       this.txtHbIntervall.Size = new System.Drawing.Size(390, 20);
    260       this.txtHbIntervall.TabIndex = 33;
    261       this.txtHbIntervall.TextChanged += new System.EventHandler(this.txtHbIntervall_TextChanged);
    262       //
    263       // cbxDisposable
    264       //
    265       this.cbxDisposable.AutoSize = true;
    266       this.cbxDisposable.Enabled = false;
    267       this.cbxDisposable.Location = new System.Drawing.Point(146, 297);
    268       this.cbxDisposable.Name = "cbxDisposable";
    269       this.cbxDisposable.Size = new System.Drawing.Size(15, 14);
    270       this.cbxDisposable.TabIndex = 34;
    271       this.cbxDisposable.UseVisualStyleBackColor = true;
    272       this.cbxDisposable.CheckedChanged += new System.EventHandler(this.cbxDisposable_CheckedChanged);
    273       //
    274       // label4
    275       //
    276       this.label4.AutoSize = true;
    277       this.label4.Location = new System.Drawing.Point(3, 297);
    278       this.label4.Name = "label4";
    279       this.label4.Size = new System.Drawing.Size(62, 13);
    280       this.label4.TabIndex = 35;
    281       this.label4.Text = "Disposable:";
    282       //
    283       // cbxPublic
    284       //
    285       this.cbxPublic.AutoSize = true;
    286       this.cbxPublic.Enabled = false;
    287       this.cbxPublic.Location = new System.Drawing.Point(146, 63);
    288       this.cbxPublic.Name = "cbxPublic";
    289       this.cbxPublic.Size = new System.Drawing.Size(15, 14);
    290       this.cbxPublic.TabIndex = 36;
    291       this.cbxPublic.UseVisualStyleBackColor = true;
    292       this.cbxPublic.CheckedChanged += new System.EventHandler(this.cbxPublic_CheckedChanged);
    293       //
    294       // label5
    295       //
    296       this.label5.AutoSize = true;
    297       this.label5.Location = new System.Drawing.Point(3, 63);
    298       this.label5.Name = "label5";
    299       this.label5.Size = new System.Drawing.Size(39, 13);
    300       this.label5.TabIndex = 37;
    301       this.label5.Text = "Public:";
     62      // nameTextBox
     63      //
     64      this.nameTextBox.ReadOnly = true;
     65      //
     66      // cpuLabel
     67      //
     68      this.cpuLabel.AutoSize = true;
     69      this.cpuLabel.Location = new System.Drawing.Point(3, 141);
     70      this.cpuLabel.Name = "cpuLabel";
     71      this.cpuLabel.Size = new System.Drawing.Size(32, 13);
     72      this.cpuLabel.TabIndex = 16;
     73      this.cpuLabel.Text = "CPU:";
     74      //
     75      // cpuTextBox
     76      //
     77      this.cpuTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     78            | System.Windows.Forms.AnchorStyles.Right)));
     79      this.cpuTextBox.Location = new System.Drawing.Point(130, 138);
     80      this.cpuTextBox.Name = "cpuTextBox";
     81      this.cpuTextBox.ReadOnly = true;
     82      this.cpuTextBox.Size = new System.Drawing.Size(397, 20);
     83      this.cpuTextBox.TabIndex = 17;
     84      //
     85      // memoryLabel
     86      //
     87      this.memoryLabel.AutoSize = true;
     88      this.memoryLabel.Location = new System.Drawing.Point(3, 167);
     89      this.memoryLabel.Name = "memoryLabel";
     90      this.memoryLabel.Size = new System.Drawing.Size(47, 13);
     91      this.memoryLabel.TabIndex = 18;
     92      this.memoryLabel.Text = "Memory:";
     93      //
     94      // memoryTextBox
     95      //
     96      this.memoryTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     97            | System.Windows.Forms.AnchorStyles.Right)));
     98      this.memoryTextBox.Location = new System.Drawing.Point(130, 164);
     99      this.memoryTextBox.Name = "memoryTextBox";
     100      this.memoryTextBox.ReadOnly = true;
     101      this.memoryTextBox.Size = new System.Drawing.Size(397, 20);
     102      this.memoryTextBox.TabIndex = 19;
     103      //
     104      // operatingSystemLabel
     105      //
     106      this.operatingSystemLabel.AutoSize = true;
     107      this.operatingSystemLabel.Location = new System.Drawing.Point(3, 193);
     108      this.operatingSystemLabel.Name = "operatingSystemLabel";
     109      this.operatingSystemLabel.Size = new System.Drawing.Size(93, 13);
     110      this.operatingSystemLabel.TabIndex = 20;
     111      this.operatingSystemLabel.Text = "Operating System:";
     112      //
     113      // operatingSystemTextBox
     114      //
     115      this.operatingSystemTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     116            | System.Windows.Forms.AnchorStyles.Right)));
     117      this.operatingSystemTextBox.Location = new System.Drawing.Point(130, 190);
     118      this.operatingSystemTextBox.Name = "operatingSystemTextBox";
     119      this.operatingSystemTextBox.ReadOnly = true;
     120      this.operatingSystemTextBox.Size = new System.Drawing.Size(397, 20);
     121      this.operatingSystemTextBox.TabIndex = 21;
     122      //
     123      // stateLabel
     124      //
     125      this.stateLabel.AutoSize = true;
     126      this.stateLabel.Location = new System.Drawing.Point(3, 219);
     127      this.stateLabel.Name = "stateLabel";
     128      this.stateLabel.Size = new System.Drawing.Size(35, 13);
     129      this.stateLabel.TabIndex = 22;
     130      this.stateLabel.Text = "State:";
     131      //
     132      // stateTextBox
     133      //
     134      this.stateTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     135            | System.Windows.Forms.AnchorStyles.Right)));
     136      this.stateTextBox.Location = new System.Drawing.Point(130, 216);
     137      this.stateTextBox.Name = "stateTextBox";
     138      this.stateTextBox.ReadOnly = true;
     139      this.stateTextBox.Size = new System.Drawing.Size(397, 20);
     140      this.stateTextBox.TabIndex = 23;
     141      //
     142      // lastHeartbeatLabel
     143      //
     144      this.lastHeartbeatLabel.AutoSize = true;
     145      this.lastHeartbeatLabel.Location = new System.Drawing.Point(3, 245);
     146      this.lastHeartbeatLabel.Name = "lastHeartbeatLabel";
     147      this.lastHeartbeatLabel.Size = new System.Drawing.Size(80, 13);
     148      this.lastHeartbeatLabel.TabIndex = 24;
     149      this.lastHeartbeatLabel.Text = "Last Heartbeat:";
     150      //
     151      // lastHeartbeatTextBox
     152      //
     153      this.lastHeartbeatTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     154            | System.Windows.Forms.AnchorStyles.Right)));
     155      this.lastHeartbeatTextBox.Location = new System.Drawing.Point(130, 242);
     156      this.lastHeartbeatTextBox.Name = "lastHeartbeatTextBox";
     157      this.lastHeartbeatTextBox.ReadOnly = true;
     158      this.lastHeartbeatTextBox.Size = new System.Drawing.Size(397, 20);
     159      this.lastHeartbeatTextBox.TabIndex = 25;
     160      //
     161      // disposableLabel
     162      //
     163      this.disposableLabel.AutoSize = true;
     164      this.disposableLabel.Location = new System.Drawing.Point(3, 271);
     165      this.disposableLabel.Name = "disposableLabel";
     166      this.disposableLabel.Size = new System.Drawing.Size(62, 13);
     167      this.disposableLabel.TabIndex = 28;
     168      this.disposableLabel.Text = "Disposable:";
     169      //
     170      // disposableCheckBox
     171      //
     172      this.disposableCheckBox.AutoSize = true;
     173      this.disposableCheckBox.Location = new System.Drawing.Point(130, 270);
     174      this.disposableCheckBox.Name = "disposableCheckBox";
     175      this.disposableCheckBox.Size = new System.Drawing.Size(15, 14);
     176      this.disposableCheckBox.TabIndex = 29;
     177      this.disposableCheckBox.UseVisualStyleBackColor = true;
     178      this.disposableCheckBox.CheckedChanged += new System.EventHandler(this.disposableCheckBox_CheckedChanged);
    302179      //
    303180      // SlaveView
    304181      //
    305       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    306182      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    307       this.Controls.Add(this.label5);
    308       this.Controls.Add(this.cbxPublic);
    309       this.Controls.Add(this.label4);
    310       this.Controls.Add(this.cbxDisposable);
    311       this.Controls.Add(this.txtHbIntervall);
    312       this.Controls.Add(this.label3);
    313       this.Controls.Add(this.label2);
    314       this.Controls.Add(this.txtId);
    315       this.Controls.Add(this.txtFreeMemory);
    316       this.Controls.Add(this.label1);
    317       this.Controls.Add(this.txtSlaveState);
    318       this.Controls.Add(this.txtOS);
    319       this.Controls.Add(this.label15);
    320       this.Controls.Add(this.label14);
    321       this.Controls.Add(this.txtDetailsDescription);
    322       this.Controls.Add(this.label13);
    323       this.Controls.Add(this.txtName);
    324       this.Controls.Add(this.txtCPU);
    325       this.Controls.Add(this.txtMemory);
    326       this.Controls.Add(this.txtLastHeartbeat);
    327       this.Controls.Add(this.label12);
    328       this.Controls.Add(this.label11);
    329       this.Controls.Add(this.label10);
    330       this.Controls.Add(this.label9);
     183      this.Controls.Add(this.disposableCheckBox);
     184      this.Controls.Add(this.disposableLabel);
     185      this.Controls.Add(this.lastHeartbeatTextBox);
     186      this.Controls.Add(this.lastHeartbeatLabel);
     187      this.Controls.Add(this.stateTextBox);
     188      this.Controls.Add(this.stateLabel);
     189      this.Controls.Add(this.operatingSystemTextBox);
     190      this.Controls.Add(this.operatingSystemLabel);
     191      this.Controls.Add(this.memoryTextBox);
     192      this.Controls.Add(this.memoryLabel);
     193      this.Controls.Add(this.cpuTextBox);
     194      this.Controls.Add(this.cpuLabel);
    331195      this.Name = "SlaveView";
    332       this.Size = new System.Drawing.Size(539, 407);
     196      this.Controls.SetChildIndex(this.idTextBox, 0);
     197      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
     198      this.Controls.SetChildIndex(this.heartbeatIntervalNumericUpDown, 0);
     199      this.Controls.SetChildIndex(this.publicCheckBox, 0);
     200      this.Controls.SetChildIndex(this.nameTextBox, 0);
     201      this.Controls.SetChildIndex(this.cpuLabel, 0);
     202      this.Controls.SetChildIndex(this.cpuTextBox, 0);
     203      this.Controls.SetChildIndex(this.memoryLabel, 0);
     204      this.Controls.SetChildIndex(this.memoryTextBox, 0);
     205      this.Controls.SetChildIndex(this.operatingSystemLabel, 0);
     206      this.Controls.SetChildIndex(this.operatingSystemTextBox, 0);
     207      this.Controls.SetChildIndex(this.stateLabel, 0);
     208      this.Controls.SetChildIndex(this.stateTextBox, 0);
     209      this.Controls.SetChildIndex(this.lastHeartbeatLabel, 0);
     210      this.Controls.SetChildIndex(this.lastHeartbeatTextBox, 0);
     211      this.Controls.SetChildIndex(this.disposableLabel, 0);
     212      this.Controls.SetChildIndex(this.disposableCheckBox, 0);
     213      ((System.ComponentModel.ISupportInitialize)(this.heartbeatIntervalNumericUpDown)).EndInit();
    333214      this.ResumeLayout(false);
    334215      this.PerformLayout();
     
    338219    #endregion
    339220
    340     private System.Windows.Forms.TextBox txtSlaveState;
    341     private System.Windows.Forms.TextBox txtOS;
    342     private System.Windows.Forms.Label label15;
    343     private System.Windows.Forms.Label label14;
    344     private System.Windows.Forms.TextBox txtDetailsDescription;
    345     private System.Windows.Forms.Label label13;
    346     private System.Windows.Forms.TextBox txtName;
    347     private System.Windows.Forms.TextBox txtCPU;
    348     private System.Windows.Forms.TextBox txtMemory;
    349     private System.Windows.Forms.TextBox txtLastHeartbeat;
    350     private System.Windows.Forms.Label label12;
    351     private System.Windows.Forms.Label label11;
    352     private System.Windows.Forms.Label label10;
    353     private System.Windows.Forms.Label label9;
    354     private System.Windows.Forms.Label label1;
    355     private System.Windows.Forms.TextBox txtFreeMemory;
    356     private System.Windows.Forms.TextBox txtId;
    357     private System.Windows.Forms.Label label2;
    358     private System.Windows.Forms.Label label3;
    359     private System.Windows.Forms.TextBox txtHbIntervall;
    360     private System.Windows.Forms.CheckBox cbxDisposable;
    361     private System.Windows.Forms.Label label4;
    362     private System.Windows.Forms.CheckBox cbxPublic;
    363     private System.Windows.Forms.Label label5;
     221    private System.Windows.Forms.Label cpuLabel;
     222    private System.Windows.Forms.TextBox cpuTextBox;
     223    private System.Windows.Forms.Label memoryLabel;
     224    private System.Windows.Forms.TextBox memoryTextBox;
     225    private System.Windows.Forms.Label operatingSystemLabel;
     226    private System.Windows.Forms.TextBox operatingSystemTextBox;
     227    private System.Windows.Forms.Label stateLabel;
     228    private System.Windows.Forms.TextBox stateTextBox;
     229    private System.Windows.Forms.Label lastHeartbeatLabel;
     230    private System.Windows.Forms.TextBox lastHeartbeatTextBox;
     231    private System.Windows.Forms.Label disposableLabel;
     232    private System.Windows.Forms.CheckBox disposableCheckBox;
    364233  }
    365234}
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs

    r15584 r17059  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Clients.Access;
    25 using HeuristicLab.Core.Views;
    2624using HeuristicLab.MainForm;
    2725using HeuristicLab.MainForm.WindowsForms;
    2826
    2927namespace HeuristicLab.Clients.Hive.Administrator.Views {
    30   [View("SlaveView")]
    31   [Content(typeof(Resource), IsDefaultView = true)]
    32   public partial class SlaveView : ItemView {
    33     public new Resource Content {
    34       get { return (Resource)base.Content; }
     28  [View("Slave View")]
     29  [Content(typeof(Slave), IsDefaultView = true)]
     30  public sealed partial class SlaveView : ResourceView {
     31    public new Slave Content {
     32      get { return (Slave)base.Content; }
    3533      set { base.Content = value; }
    3634    }
     
    4038    }
    4139
    42     #region Register Content Events
    43     protected override void DeregisterContentEvents() {
    44       base.DeregisterContentEvents();
    45     }
    46     protected override void RegisterContentEvents() {
    47       base.RegisterContentEvents();
    48     }
    49     #endregion
    50 
     40    #region Overrides
    5141    protected override void OnContentChanged() {
    5242      base.OnContentChanged();
    5343      if (Content == null) {
    54         ShowSlaveUI(true);
    55         txtName.Clear();
    56         txtCPU.Clear();
    57         txtDetailsDescription.Clear();
    58         txtMemory.Clear();
    59         txtOS.Clear();
    60         txtSlaveState.Clear();
    61         txtLastHeartbeat.Clear();
    62         txtFreeMemory.Clear();
    63         txtId.Clear();
    64         txtHbIntervall.Clear();
    65         cbxDisposable.Checked = false;
    66         cbxPublic.Checked = false;
     44        cpuTextBox.Clear();
     45        memoryTextBox.Clear();
     46        operatingSystemTextBox.Clear();
     47        stateTextBox.Clear();
     48        lastHeartbeatTextBox.Clear();
     49        disposableCheckBox.Checked = false;
    6750      } else {
    68         if (Content.GetType() == typeof(Slave)) {
    69           ShowSlaveUI(true);
    70           Slave ct = (Slave)Content;
    71           bool authorized = UserInformation.Instance.UserExists && (ct.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions());
    72           txtName.Text = ct.Name;
    73           txtHbIntervall.Text = ct.HbInterval.ToString();
    74           cbxPublic.Enabled = authorized;
    75           cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged);
    76           cbxPublic.Checked = ct.OwnerUserId == null;
    77           cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged);
    78           txtCPU.Text = string.Format("{0} Cores @ {1} Mhz, Arch.: {2}", ct.Cores.ToString(), ct.CpuSpeed.ToString(), ct.CpuArchitecture.ToString());
    79           txtDetailsDescription.Text = ct.Description;
    80           txtMemory.Text = ct.Memory.ToString();
    81           txtOS.Text = ct.OperatingSystem;
    82           txtSlaveState.Text = ct.SlaveState.ToString();
    83           txtLastHeartbeat.Text = ct.LastHeartbeat.ToString();
    84           txtFreeMemory.Text = ct.FreeMemory.ToString();
    85           txtId.Text = ct.Id.ToString();
    86           cbxDisposable.Enabled = authorized;
    87           cbxDisposable.Checked = ct.IsDisposable.GetValueOrDefault();
    88         } else if (Content.GetType() == typeof(SlaveGroup)) {
    89           SlaveGroup ct = (SlaveGroup)Content;
    90           txtName.Text = ct.Name;
    91           txtHbIntervall.Text = ct.HbInterval.ToString();
    92           cbxPublic.Enabled = ct.Name != "UNGROUPED" && HiveRoles.CheckAdminUserPermissions();
    93           cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged);
    94           cbxPublic.Checked = ct.OwnerUserId == null;
    95           cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged);
    96           ShowSlaveUI(false);
    97         } else {
    98           throw new Exception("Unknown Resource in SlaveView");
    99         }
     51        cpuTextBox.Text = string.Format("{0} Cores @ {1} MHz, Arch.: {2}", Content.Cores, Content.CpuSpeed, Content.CpuArchitecture);
     52        memoryTextBox.Text = string.Format("{0} ({1} Free)", Content.Memory, Content.FreeMemory);
     53        operatingSystemTextBox.Text = Content.OperatingSystem;
     54        stateTextBox.Text = Content.SlaveState.ToString();
     55        lastHeartbeatTextBox.Text = Content.LastHeartbeat.ToString();
     56        disposableCheckBox.Checked = Content.IsDisposable.GetValueOrDefault();
    10057      }
    101     }
    102 
    103     private void ShowSlaveUI(bool show) {
    104       label1.Visible = show;
    105       label2.Visible = show;
    106       label4.Visible = show;
    107       label10.Visible = show;
    108       label11.Visible = show;
    109       label12.Visible = show;
    110       label13.Visible = show;
    111       label14.Visible = show;
    112       label15.Visible = show;
    113       txtCPU.Visible = show;
    114       txtDetailsDescription.Visible = show;
    115       txtMemory.Visible = show;
    116       txtOS.Visible = show;
    117       txtSlaveState.Visible = show;
    118       txtLastHeartbeat.Visible = show;
    119       txtFreeMemory.Visible = show;
    120       txtId.Visible = show;
    121       txtName.Enabled = !show;
    122       cbxDisposable.Visible = show;
    12358    }
    12459
    12560    protected override void SetEnabledStateOfControls() {
    12661      base.SetEnabledStateOfControls();
     62      bool enabled = Content != null && !Locked;
     63      disposableCheckBox.Enabled = enabled;
    12764    }
     65    #endregion
    12866
    129     private void txtName_TextChanged(object sender, EventArgs e) {
    130       if (Content != null && Content is SlaveGroup) {
    131         Content.Name = txtName.Text;
    132       }
     67    #region Event Handlers
     68    private void disposableCheckBox_CheckedChanged(object sender, EventArgs e) {
     69      if (Content != null)
     70        Content.IsDisposable = disposableCheckBox.Checked;
    13371    }
    134 
    135     private void txtHbIntervall_TextChanged(object sender, EventArgs e) {
    136       if (Content != null) {
    137         if (txtHbIntervall.Text.Length > 0) {
    138           try {
    139             int interval = int.Parse(txtHbIntervall.Text);
    140             Content.HbInterval = interval;
    141           }
    142           catch (Exception) {
    143             MessageBox.Show("Please enter a numeric value for the Heartbeat Interval.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    144             txtHbIntervall.Text = "10";
    145           }
    146         }
    147       }
    148     }
    149 
    150     private void cbxDisposable_CheckedChanged(object sender, EventArgs e) {
    151       if (Content != null) {
    152         ((Slave)Content).IsDisposable = cbxDisposable.Checked;
    153       }
    154     }
    155 
    156     private void cbxPublic_CheckedChanged(object sender, EventArgs e) {
    157       if (Content != null) {
    158         Content.OwnerUserId = cbxPublic.Checked ? null : new Guid?(UserInformation.Instance.User.Id);
    159       }
    160     }
     72    #endregion
    16173  }
    16274}
Note: See TracChangeset for help on using the changeset viewer.