Changeset 16064 for branches/2839_HiveProjectManagement
- Timestamp:
- 08/07/18 16:31:41 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15995 r16064 212 212 private void btnAddGroup_Click(object sender, EventArgs e) { 213 213 Guid? parentResourceId = null; 214 if (!IsAdmin()) {214 if (!IsAdmin()) { 215 215 MessageBox.Show( 216 216 "You have no permission to add a resource group.", … … 219 219 MessageBoxIcon.Information); 220 220 return; 221 } else if (selectedResource != null && selectedResource.Id == Guid.Empty) {221 } else if (selectedResource != null && selectedResource.Id == Guid.Empty) { 222 222 MessageBox.Show( 223 223 "You cannot add a resource group to a not yet stored group.", … … 227 227 return; 228 228 } 229 229 230 230 if (selectedResource != null && selectedResource is SlaveGroup) parentResourceId = selectedResource.Id; 231 231 var group = new SlaveGroup { … … 276 276 RemoveResource(selectedResource); 277 277 }, 278 finallyCallback: () => { 278 finallyCallback: () => { 279 279 btnRemoveGroup.Enabled = true; 280 280 }); 281 } 281 } 282 282 } 283 283 … … 304 304 if (node == null || node == ungroupedGroupNode) return; 305 305 var r = (Resource)node.Tag; 306 if (!HiveAdminClient.Instance.DisabledParentResources.Contains(r)) ChangeSelectedResourceNode(node);306 if (!HiveAdminClient.Instance.DisabledParentResources.Contains(r)) ChangeSelectedResourceNode(node); 307 307 } 308 308 … … 312 312 313 313 private void treeSlaveGroup_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 314 if (e.Node == ungroupedGroupNode) {314 if (e.Node == ungroupedGroupNode) { 315 315 e.Cancel = true; 316 316 } else { 317 317 var r = (Resource)e.Node.Tag; 318 if (HiveAdminClient.Instance.DisabledParentResources.Contains(r)) {318 if (HiveAdminClient.Instance.DisabledParentResources.Contains(r)) { 319 319 e.Cancel = true; 320 320 } … … 329 329 var resources = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IEnumerable<Resource>; 330 330 331 foreach (var r in resources) {331 foreach (var r in resources) { 332 332 r.ParentResourceId = targetResource?.Id; 333 333 } … … 343 343 var nodes = GetCheckedNodes(treeView.Nodes).ToList(); 344 344 TreeNode sourceNode = (TreeNode)e.Item; 345 if (!sourceNode.Checked) nodes.Add(sourceNode);345 if (!sourceNode.Checked) nodes.Add(sourceNode); 346 346 nodes.Remove(ungroupedGroupNode); 347 347 ungroupedGroupNode.Checked = false; 348 348 var resources = nodes.Select(x => x.Tag).OfType<Resource>().ToList(); 349 349 350 if (resources.Count > 0) {350 if (resources.Count > 0) { 351 351 DataObject data = new DataObject(); 352 352 data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, resources); 353 353 var action = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 354 if (action.HasFlag(DragDropEffects.Move)) {354 if (action.HasFlag(DragDropEffects.Move)) { 355 355 foreach (var node in nodes) node.Remove(); 356 356 StyleTreeNode(ungroupedGroupNode, (Resource)ungroupedGroupNode.Tag, resources); … … 363 363 foreach (var node in nodes.OfType<TreeNode>()) { 364 364 if (node.Checked && node != ungroupedGroupNode) yield return node; 365 366 367 365 foreach (var child in GetCheckedNodes(node.Nodes)) 366 yield return child; 367 } 368 368 } 369 369 } … … 375 375 var targetResource = targetNode?.Tag as Resource; 376 376 377 if (!IsAdmin()377 if (!IsAdmin() 378 378 || resources == null 379 379 || !resources.Any() … … 389 389 390 390 private async void TabSlaveGroup_Selected(object sender, System.Windows.Forms.TabControlEventArgs e) { 391 if (e.TabPage == tabSchedule) {391 if (e.TabPage == tabSchedule) { 392 392 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 393 393 action: () => UpdateSchedule(), … … 435 435 } 436 436 437 if (disabledParentResources.Contains(newResource)) {437 if (disabledParentResources.Contains(newResource)) { 438 438 newNode.Checked = false; 439 439 newNode.ForeColor = grayTextColor; … … 469 469 470 470 // collapse slave-only nodes 471 foreach (TreeNode n in treeView.Nodes) {471 foreach (TreeNode n in treeView.Nodes) { 472 472 CollapseSlaveOnlyNodes(n); 473 473 } 474 474 475 475 ungroupedGroupNode = new TreeNode(UNGROUPED_GROUP_NAME) { 476 476 ForeColor = SystemColors.GrayText, … … 501 501 ungroupedGroupNode.Expand(); 502 502 } 503 treeView.Nodes.Add(ungroupedGroupNode); 503 treeView.Nodes.Add(ungroupedGroupNode); 504 504 } 505 505 … … 507 507 Resource r = (Resource)tn.Tag; 508 508 var descendants = GetResourceDescendants(); 509 if (descendants.ContainsKey(r.Id)) {510 if (descendants[r.Id].OfType<SlaveGroup>().Any()) {509 if (descendants.ContainsKey(r.Id)) { 510 if (descendants[r.Id].OfType<SlaveGroup>().Any()) { 511 511 tn.Expand(); 512 512 foreach (TreeNode n in tn.Nodes) CollapseSlaveOnlyNodes(n); … … 546 546 HiveAdminClient.Instance.Refresh(); 547 547 Content = HiveAdminClient.Instance.Resources; 548 } catch (AnonymousUserException) {548 } catch (AnonymousUserException) { 549 549 ShowHiveInformationDialog(); 550 550 } … … 564 564 Content.Remove(selectedResource); 565 565 } 566 } catch (AnonymousUserException) {566 } catch (AnonymousUserException) { 567 567 ShowHiveInformationDialog(); 568 568 } … … 586 586 n.ForeColor = Color.Black; 587 587 588 if (HiveAdminClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id)) {588 if (HiveAdminClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id)) { 589 589 n.ForeColor = grayTextColor; 590 590 } else if (r.Id == Guid.Empty && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { … … 607 607 .Count(); 608 608 } 609 } else if (n == ungroupedGroupNode /*|| r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) {609 } else if (n == ungroupedGroupNode /*|| r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 610 610 childSlavesCount = resources 611 611 .OfType<Slave>() 612 .Where(x => x.ParentResourceId == null 612 .Where(x => x.ParentResourceId == null 613 613 || (x.ParentResourceId.HasValue && x.ParentResourceId.Value == Guid.Empty)) 614 614 .Count(); … … 634 634 635 635 // ungrouped 636 if (n == ungroupedGroupNode /*r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) {637 n.ForeColor = ForeColor =SystemColors.GrayText;636 if (n == ungroupedGroupNode /*r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 637 n.ForeColor = SystemColors.GrayText; 638 638 } 639 639 } … … 704 704 705 705 foreach (var r in resources) resourceDescendants.Add(r.Id, new HashSet<Resource>()); 706 foreach (var r in resources) {706 foreach (var r in resources) { 707 707 var parentResourceId = r.ParentResourceId; 708 while (parentResourceId != null) {708 while (parentResourceId != null) { 709 709 var parent = resources.SingleOrDefault(x => x.Id == parentResourceId); 710 if (parent != null) {710 if (parent != null) { 711 711 resourceDescendants[parent.Id].Add(r); 712 712 parentResourceId = parent.ParentResourceId; … … 718 718 return resourceDescendants; 719 719 } 720 720 721 721 #endregion 722 722 }
Note: See TracChangeset
for help on using the changeset viewer.