Changeset 6492 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administration/3.4/Views
- Timestamp:
- 06/28/11 14:08:11 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administration/3.4/Views/ResourcesView.cs
r6464 r6492 116 116 TreeNode stn = new TreeNode(r.Name); 117 117 if (r is Slave) { 118 stn.ImageIndex = 0;118 stn.ImageIndex = slaveImageIndex; 119 119 } else if (r is SlaveGroup) { 120 120 stn.ImageIndex = slaveGroupImageIndex; … … 125 125 126 126 BuildSlaveGroupTree(r, stn); 127 tn.ExpandAll(); 127 128 } 128 129 } … … 169 170 170 171 private void btnRemoveGroup_Click(object sender, EventArgs e) { 171 //TODO: display some warning?172 172 if (treeSlaveGroup.SelectedNode != null && treeSlaveGroup.SelectedNode.Tag != null) { 173 173 Resource res = (Resource)treeSlaveGroup.SelectedNode.Tag; 174 174 175 if (res is Slave) { 176 Content.Remove(res); 177 ServiceLocator.Instance.CallHiveService(service => service.DeleteSlave(res.Id)); 178 } else if (res is SlaveGroup) { 179 //only delete empty groups 180 if (Content.Where(s => s.ParentResourceId == res.Id).Count() < 1) { 175 DialogResult diagRes = MessageBox.Show("Do you really want to delete " + res.Name + "?", "HeuristicLab Hive Administration", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 176 if (diagRes == DialogResult.Yes) { 177 if (res is Slave) { 181 178 Content.Remove(res); 182 ServiceLocator.Instance.CallHiveService(service => service.DeleteSlaveGroup(res.Id)); 183 } else { 184 MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administration", MessageBoxButtons.OK, MessageBoxIcon.Error); 179 ServiceLocator.Instance.CallHiveService(service => service.DeleteSlave(res.Id)); 180 } else if (res is SlaveGroup) { 181 //only delete empty groups 182 if (Content.Where(s => s.ParentResourceId == res.Id).Count() < 1) { 183 Content.Remove(res); 184 ServiceLocator.Instance.CallHiveService(service => service.DeleteSlaveGroup(res.Id)); 185 } else { 186 MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administration", MessageBoxButtons.OK, MessageBoxIcon.Error); 187 } 185 188 } 186 189 } … … 218 221 219 222 SlaveGroup sgrp = null; 223 TreeNode parentNode = null; 220 224 if (destNode.Tag != null && destNode.Tag is SlaveGroup) { 221 225 sgrp = (SlaveGroup)destNode.Tag; 226 parentNode = destNode; 222 227 } else if (destNode.Parent != null && destNode.Parent.Tag is SlaveGroup) { 223 228 sgrp = (SlaveGroup)destNode.Parent.Tag; 229 parentNode = destNode.Parent; 230 } 231 232 if (newNode.Tag is SlaveGroup && CheckParentsEqualsMovedNode(parentNode, newNode)) { 233 return; 224 234 } 225 235 … … 234 244 if (slave.ParentResourceId == null || (slave.ParentResourceId != null && slave.ParentResourceId != sgrp.Id)) { 235 245 slave.ParentResourceId = sgrp.Id; 246 newNode.Remove(); 247 parentNode.Nodes.Clear(); 248 BuildSlaveGroupTree(sgrp, parentNode); 236 249 } 237 250 } else if (newNode.Tag is SlaveGroup) { … … 239 252 if (slaveGroup.ParentResourceId == null || (slaveGroup.ParentResourceId != null && slaveGroup.ParentResourceId != sgrp.Id)) { 240 253 slaveGroup.ParentResourceId = sgrp.Id; 254 newNode.Remove(); 255 parentNode.Nodes.Clear(); 256 BuildSlaveGroupTree(sgrp, parentNode); 241 257 } 242 258 } 243 OnContentChanged(); 244 } 245 } 246 } 259 } 260 } 261 } 262 } 263 264 private bool CheckParentsEqualsMovedNode(TreeNode dest, TreeNode movedNode) { 265 TreeNode tmp = dest; 266 267 while (tmp != null) { 268 if (tmp == movedNode) { 269 return true; 270 } 271 tmp = tmp.Parent; 272 } 273 return false; 247 274 } 248 275
Note: See TracChangeset
for help on using the changeset viewer.