예제 #1
0
 public void copyArtifactsToGroup(
     DropTargetEvent event, final GroupExplorerItem dragOverExplorerItem) {
   // Items dropped on Group; simply add items to group
   final Artifact[] artsToRelate = ((ArtifactData) event.data).getArtifacts();
   for (Artifact artifact : artsToRelate) {
     if (!artifact.getBranch().equals(branch)) {
       AWorkbench.popup(
           "ERROR",
           "Cross-branch grouping not supported.\n\nGroup and Artifacts must belong to same branch.");
       return;
     }
   }
   boolean alreadyRelated = true;
   for (Artifact artifact : artsToRelate) {
     if (!dragOverExplorerItem.contains(artifact)) {
       alreadyRelated = false;
       break;
     }
   }
   if (alreadyRelated) {
     AWorkbench.popup("ERROR", "Artifact(s) already related.");
     return;
   }
   try {
     for (Artifact art : artsToRelate) {
       if (!dragOverExplorerItem.contains(art)) {
         dragOverExplorerItem
             .getArtifact()
             .addRelation(CoreRelationTypes.Universal_Grouping__Members, art);
       }
     }
     dragOverExplorerItem.getArtifact().persist("Drag and drop: copy artifacts to group");
   } catch (Exception ex) {
     OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
   }
 }