Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15767


Ignore:
Timestamp:
02/13/18 15:32:00 (7 years ago)
Author:
jzenisek
Message:

#2839: fixed cyclic-relation bug in projects- and resources-view by preventing parents from being dragged onto descendants

Location:
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.Designer.cs

    r15422 r15767  
    128128      this.projectsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.projectsTreeView_AfterSelect);
    129129      this.projectsTreeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.projectsTreeView_DragDrop);
    130       this.projectsTreeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.projectsTreeView_DragEnter);
    131       this.projectsTreeView.DragOver += new System.Windows.Forms.DragEventHandler(this.projectsTreeView_DragOver);
     130      this.projectsTreeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.projectsTreeView_DragEnterOver);
     131      this.projectsTreeView.DragOver += new System.Windows.Forms.DragEventHandler(this.projectsTreeView_DragEnterOver);
    132132      this.projectsTreeView.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.projectsTreeView_QueryContinueDrag);
    133133      //
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r15760 r15767  
    293293
    294294    private void projectsTreeView_DragDrop(object sender, DragEventArgs e) {
     295      if (e.Effect == DragDropEffects.None) return;
     296
    295297      var sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
    296298      if (sourceNode == null) return;
    297       var sourceResource = ((Project)sourceNode.Tag);
    298       if (sourceResource == null) return;
     299      var sourceProject = ((Project)sourceNode.Tag);
     300      if (sourceProject == null) return;
    299301
    300302      var treeView = (TreeView)sender;
     
    313315          MessageBoxButtons.OK,
    314316          MessageBoxIcon.Information);
    315             return;
     317        return;
     318      }
     319      if(!HiveAdminClient.Instance.CheckParentChange(sourceProject, targetProject)) {
     320        MessageBox.Show(
     321          "You cannot drag to this project.",
     322          "HeuristicLab Hive Administrator",
     323          MessageBoxButtons.OK,
     324          MessageBoxIcon.Information);
     325      return;
    316326      }
    317327
     
    320330      } else {
    321331        sourceNode.Parent.Nodes.Remove(sourceNode);
    322         sourceResource.ParentProjectId = null;
     332        sourceProject.ParentProjectId = null;
    323333      }
    324334
     
    327337      } else if(targetProject.Id != Guid.Empty) {
    328338        targetNode.Nodes.Add(sourceNode);
    329         sourceResource.ParentProjectId = targetProject.Id;
    330       }
    331 
    332       selectedProject = sourceResource;
     339        sourceProject.ParentProjectId = targetProject.Id;
     340      }
     341
     342      selectedProject = sourceProject;
    333343      OnContentChanged();
    334344    }
     
    340350    }
    341351
    342     private void projectsTreeView_DragEnter(object sender, DragEventArgs e) {
     352    private void projectsTreeView_DragEnterOver(object sender, DragEventArgs e) {
    343353      e.Effect = DragDropEffects.Move;
    344     }
    345 
    346     private void projectsTreeView_DragOver(object sender, DragEventArgs e) {
    347       e.Effect = DragDropEffects.Move;
     354
     355      var sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
     356      var sourceProject = ((Project)sourceNode.Tag);
     357
     358      var targetPoint = projectsTreeView.PointToClient(new Point(e.X, e.Y));
     359      var targetNode = projectsTreeView.GetNodeAt(targetPoint);
     360      var targetProject = (targetNode != null) ? (Project)targetNode.Tag : null;
     361
     362      if ((!IsAdmin() && (targetNode == null || targetProject == null))
     363      || sourceNode == null
     364      || sourceProject == null
     365      || sourceNode == targetNode
     366      || (targetProject != null && targetProject.Id == Guid.Empty)
     367      || (targetProject != null && targetProject.Id == sourceProject.ParentProjectId)
     368      || !HiveAdminClient.Instance.CheckParentChange(sourceProject, targetProject)) {
     369        e.Effect = DragDropEffects.None;
     370      }
    348371    }
    349372
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r15742 r15767  
    160160      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect);
    161161      this.treeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop);
    162       this.treeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter);
    163       this.treeView.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragOver);
     162      this.treeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnterOver);
     163      this.treeView.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnterOver);
    164164      this.treeView.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.treeSlaveGroup_QueryContinueDrag);
    165165      //
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r15760 r15767  
    308308
    309309    private void treeSlaveGroup_DragDrop(object sender, DragEventArgs e) {
     310      if (e.Effect == DragDropEffects.None) return;
     311
    310312      var sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
    311313      if (sourceNode == null) return;
     
    336338          MessageBoxIcon.Information);
    337339        return;
    338       } else if(targetResource != null && targetResource.Id == Guid.Empty) {
     340      } else if (targetResource != null && targetResource.Id == Guid.Empty) {
    339341        MessageBox.Show(
    340342          "You cannot drag resources to a not yet stored resource group.",
     
    342344          MessageBoxButtons.OK,
    343345          MessageBoxIcon.Information);
    344             return;
     346        return;
     347      } else if(!HiveAdminClient.Instance.CheckParentChange(sourceResource, targetResource)) {
     348        MessageBox.Show(
     349          "You cannot drag resources to this group.",
     350          "HeuristicLab Hive Administrator",
     351          MessageBoxButtons.OK,
     352          MessageBoxIcon.Information);
     353        return;
    345354      } else if (targetNode != null && (targetNode.Text == ungroupedGroupName || targetNode.Parent != null && targetNode.Parent.Text == ungroupedGroupName)) {
    346355        MessageBox.Show(
     
    376385    }
    377386
    378     private void treeSlaveGroup_DragEnter(object sender, DragEventArgs e) {
     387    private void treeSlaveGroup_DragEnterOver(object sender, DragEventArgs e) {
    379388      e.Effect = DragDropEffects.Move;
    380     }
    381 
    382     private void treeSlaveGroup_DragOver(object sender, DragEventArgs e) {
    383       e.Effect = DragDropEffects.Move;
     389
     390      var sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
     391      var sourceResource = ((Resource)sourceNode.Tag);
     392
     393      var targetPoint = treeView.PointToClient(new Point(e.X, e.Y));
     394      var targetNode = treeView.GetNodeAt(targetPoint);
     395      var targetResource = (targetNode != null) ? (Resource)targetNode.Tag : null;
     396
     397      if(!IsAdmin()
     398        || sourceNode == null
     399        || sourceResource == null
     400        || sourceNode == targetNode
     401        || (targetResource != null && targetResource is Slave)
     402        || (targetResource != null && targetResource.Id == Guid.Empty)
     403        || (targetResource != null && targetResource.Id == sourceResource.ParentResourceId)
     404        || !HiveAdminClient.Instance.CheckParentChange(sourceResource, targetResource)
     405        || (targetNode != null && (targetNode.Text == ungroupedGroupName || targetNode.Parent != null && targetNode.Parent.Text == ungroupedGroupName))) {
     406        e.Effect = DragDropEffects.None;
     407      }
    384408    }
    385409
Note: See TracChangeset for help on using the changeset viewer.