Program: 119785
Project: 119785
Buggy source:
public void drop(DropTargetEvent event){
  DropTarget dropTarget=(DropTarget)event.getSource();
  Item targetItem=(Item)event.item;
  if (targetItem == null) {
    return;
  }
  Control control=dropTarget.getControl();
  String row=(String)control.getData("String_Node_Str");
  if (getManager().getHl7Component().isHL7Output()) {
    if (getManager() instanceof HL7OutputManager) {
      row=((HL7OutputManager)getManager()).getCurrentSchema(true);
    }
  }
  LocalDraggedData draggedData=LocalDataTransfer.getInstance().getDraggedData();
  List<Object> dragdedData=draggedData.getTransferableEntryList();
  IMetadataTable table=null;
  if (draggedData.getTable() instanceof IMetadataTable) {
    table=(IMetadataTable)draggedData.getTable();
  }
  HL7TreeNode targetNode=(HL7TreeNode)(targetItem.getData());
  if (dragdedData.size() == 1 && isDropRelatedColumn(event)) {
    if (!targetNode.hasChildren()) {
      IMetadataColumn metaColumn=(IMetadataColumn)dragdedData.get(0);
      targetNode.setDefaultValue(null);
      targetNode.setColumn(metaColumn);
      targetNode.setTable(table);
      targetNode.setRow(row);
      linker.getXMLViewer().refresh(targetNode);
      linker.getXMLViewer().expandAll();
      Display display=linker.getSource().getDisplay();
      Cursor cursor=new Cursor(display,SWT.CURSOR_WAIT);
      linker.getSource().getShell().setCursor(cursor);
      linker.valuedChanged(targetItem);
      linker.getSource().getShell().setCursor(null);
    }
  }
 else   if (dragdedData.size() > 0) {
    boolean hide=!canAddAttribute(targetNode);
    HL7DragAndDrogDialog dialog=new HL7DragAndDrogDialog(null,hide);
    dialog.open();
    if (dialog.getReturnCode() == IDialogConstants.CANCEL_ID) {
      return;
    }
    if (dialog.getSelectValue().equals(HL7DragAndDrogDialog.CREATE_AS_TEXT)) {
      if (targetNode.hasChildren()) {
        List<HL7TreeNode> children=targetNode.getChildren();
        for (        HL7TreeNode hl7TreeNode : children) {
          if (!(hl7TreeNode instanceof Attribute)) {
            MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
            return;
          }
        }
      }
 else       if (targetNode.getParent() == null) {
        MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
        return;
      }
      IMetadataColumn metaColumn=(IMetadataColumn)dragdedData.get(0);
      targetNode.setColumn(metaColumn);
      setDefaultFixValue(targetNode);
    }
 else     if (dialog.getSelectValue().equals(HL7DragAndDrogDialog.CREATE_AS_SUBELEMENT)) {
      if (!(targetNode instanceof Element)) {
        MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
        return;
      }
      if (targetNode.getColumn() != null) {
        if (!MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str")) {
          return;
        }
        targetNode.setColumn(null);
      }
      for (      Object obj : dragdedData) {
        IMetadataColumn metaColumn=(IMetadataColumn)obj;
        boolean isContain=false;
        for (        HL7TreeNode node : ((Element)targetNode).getElementChildren()) {
          if (node.getLabel().equals(metaColumn.getLabel())) {
            node.setColumn(metaColumn);
            node.setRow(row);
            node.setTable(table);
            setDefaultFixValue(node);
            isContain=true;
          }
        }
        if (!isContain) {
          HL7TreeNode child=new Element(metaColumn.getLabel());
          child.setColumn(metaColumn);
          child.setTable(table);
          child.setRow(row);
          targetNode.addChild(child);
        }
      }
      setDefaultFixValue(targetNode);
    }
 else     if (dialog.getSelectValue().equals(HL7DragAndDrogDialog.CREATE_AS_ATTRIBUTE)) {
      if (!(targetNode instanceof Element)) {
        MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
        return;
      }
      for (      Object obj : dragdedData) {
        IMetadataColumn metaColumn=(IMetadataColumn)obj;
        boolean isContain=false;
        for (        HL7TreeNode node : ((Element)targetNode).getAttributeChildren()) {
          if (node.getLabel().equals(metaColumn.getLabel())) {
            node.setColumn(metaColumn);
            node.setTable(table);
            node.setRow(row);
            setDefaultFixValue(node);
            isContain=true;
          }
        }
        if (!isContain) {
          HL7TreeNode child=new Attribute(metaColumn.getLabel());
          child.setColumn(metaColumn);
          child.setTable(table);
          child.setRow(row);
          targetNode.addChild(child);
        }
      }
      setDefaultFixValue(targetNode);
    }
    if (row != null) {
      targetNode.setRow(row);
      if (!getManager().getHl7Component().isHL7Output()) {
        HL7TreeNode root=(HL7TreeNode)linker.getXMLViewer().getTree().getItem(0).getData();
        setTreeNodeRow(root,row);
      }
    }
    linker.getXMLViewer().refresh();
    linker.getXMLViewer().expandAll();
    Display display=linker.getSource().getDisplay();
    Cursor cursor=new Cursor(display,SWT.CURSOR_WAIT);
    linker.getSource().getShell().setCursor(cursor);
    linker.valuedChanged(targetItem);
    linker.getSource().getShell().setCursor(null);
  }
  if (row != null) {
    targetNode.setRow(row);
    if (!getManager().getHl7Component().isHL7Output()) {
      HL7TreeNode root=(HL7TreeNode)linker.getXMLViewer().getTree().getItem(0).getData();
      setTreeNodeRow(root,row);
    }
  }
  linker.getXMLViewer().refresh();
  linker.getXMLViewer().expandAll();
  linker.updateLinksStyleAndControlsSelection(control,true);
}

Fixed version (ground truth):
public void drop(DropTargetEvent event){
  DropTarget dropTarget=(DropTarget)event.getSource();
  Item targetItem=(Item)event.item;
  if (targetItem == null || !isEnabled(event)) {
    return;
  }
  Control control=dropTarget.getControl();
  String row=(String)control.getData("String_Node_Str");
  if (getManager().getHl7Component().isHL7Output()) {
    if (getManager() instanceof HL7OutputManager) {
      row=((HL7OutputManager)getManager()).getCurrentSchema(true);
    }
  }
  LocalDraggedData draggedData=LocalDataTransfer.getInstance().getDraggedData();
  List<Object> dragdedData=draggedData.getTransferableEntryList();
  IMetadataTable table=null;
  if (draggedData.getTable() instanceof IMetadataTable) {
    table=(IMetadataTable)draggedData.getTable();
  }
  HL7TreeNode targetNode=(HL7TreeNode)(targetItem.getData());
  if (dragdedData.size() == 1 && isDropRelatedColumn(event)) {
    if (!targetNode.hasChildren()) {
      IMetadataColumn metaColumn=(IMetadataColumn)dragdedData.get(0);
      targetNode.setDefaultValue(null);
      targetNode.setColumn(metaColumn);
      targetNode.setTable(table);
      targetNode.setRow(row);
      linker.getXMLViewer().refresh(targetNode);
      linker.getXMLViewer().expandAll();
      Display display=linker.getSource().getDisplay();
      Cursor cursor=new Cursor(display,SWT.CURSOR_WAIT);
      linker.getSource().getShell().setCursor(cursor);
      linker.valuedChanged(targetItem);
      linker.getSource().getShell().setCursor(null);
    }
  }
 else   if (dragdedData.size() > 0) {
    boolean hide=!canAddAttribute(targetNode);
    HL7DragAndDrogDialog dialog=new HL7DragAndDrogDialog(null,hide);
    dialog.open();
    if (dialog.getReturnCode() == IDialogConstants.CANCEL_ID) {
      return;
    }
    if (dialog.getSelectValue().equals(HL7DragAndDrogDialog.CREATE_AS_TEXT)) {
      if (targetNode.hasChildren()) {
        List<HL7TreeNode> children=targetNode.getChildren();
        for (        HL7TreeNode hl7TreeNode : children) {
          if (!(hl7TreeNode instanceof Attribute)) {
            MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
            return;
          }
        }
      }
 else       if (targetNode.getParent() == null) {
        MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
        return;
      }
      IMetadataColumn metaColumn=(IMetadataColumn)dragdedData.get(0);
      targetNode.setColumn(metaColumn);
      setDefaultFixValue(targetNode);
    }
 else     if (dialog.getSelectValue().equals(HL7DragAndDrogDialog.CREATE_AS_SUBELEMENT)) {
      if (!(targetNode instanceof Element)) {
        MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
        return;
      }
      if (targetNode.getColumn() != null) {
        if (!MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str")) {
          return;
        }
        targetNode.setColumn(null);
      }
      for (      Object obj : dragdedData) {
        IMetadataColumn metaColumn=(IMetadataColumn)obj;
        boolean isContain=false;
        for (        HL7TreeNode node : ((Element)targetNode).getElementChildren()) {
          if (node.getLabel().equals(metaColumn.getLabel())) {
            node.setColumn(metaColumn);
            node.setRow(row);
            node.setTable(table);
            setDefaultFixValue(node);
            isContain=true;
          }
        }
        if (!isContain) {
          HL7TreeNode child=new Element(metaColumn.getLabel());
          child.setColumn(metaColumn);
          child.setTable(table);
          child.setRow(row);
          targetNode.addChild(child);
        }
      }
      setDefaultFixValue(targetNode);
    }
 else     if (dialog.getSelectValue().equals(HL7DragAndDrogDialog.CREATE_AS_ATTRIBUTE)) {
      if (!(targetNode instanceof Element)) {
        MessageDialog.openConfirm(control.getShell(),"String_Node_Str","String_Node_Str" + targetNode.getLabel() + "String_Node_Str"+ "String_Node_Str");
        return;
      }
      for (      Object obj : dragdedData) {
        IMetadataColumn metaColumn=(IMetadataColumn)obj;
        boolean isContain=false;
        for (        HL7TreeNode node : ((Element)targetNode).getAttributeChildren()) {
          if (node.getLabel().equals(metaColumn.getLabel())) {
            node.setColumn(metaColumn);
            node.setTable(table);
            node.setRow(row);
            setDefaultFixValue(node);
            isContain=true;
          }
        }
        if (!isContain) {
          HL7TreeNode child=new Attribute(metaColumn.getLabel());
          child.setColumn(metaColumn);
          child.setTable(table);
          child.setRow(row);
          targetNode.addChild(child);
        }
      }
      setDefaultFixValue(targetNode);
    }
    if (row != null) {
      targetNode.setRow(row);
      if (!getManager().getHl7Component().isHL7Output()) {
        HL7TreeNode root=(HL7TreeNode)linker.getXMLViewer().getTree().getItem(0).getData();
        setTreeNodeRow(root,row);
      }
    }
    linker.getXMLViewer().refresh();
    linker.getXMLViewer().expandAll();
    Display display=linker.getSource().getDisplay();
    Cursor cursor=new Cursor(display,SWT.CURSOR_WAIT);
    linker.getSource().getShell().setCursor(cursor);
    linker.valuedChanged(targetItem);
    linker.getSource().getShell().setCursor(null);
  }
  if (row != null) {
    targetNode.setRow(row);
    if (!getManager().getHl7Component().isHL7Output()) {
      HL7TreeNode root=(HL7TreeNode)linker.getXMLViewer().getTree().getItem(0).getData();
      setTreeNodeRow(root,row);
    }
  }
  linker.getXMLViewer().refresh();
  linker.getXMLViewer().expandAll();
  linker.updateLinksStyleAndControlsSelection(control,true);
}