}
ProjectTree projectTree = (ProjectTree) info.getComponent();
ProjectTreeModel treeModel = (ProjectTreeModel) projectTree.getModel();
MZmineProject project = MZmineCore.getCurrentProject();
JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation();
TreePath dropPath = dl.getPath();
DefaultMutableTreeNode droppedLocationNode = (DefaultMutableTreeNode) dropPath
.getLastPathComponent();
Object droppedLocationObject = droppedLocationNode.getUserObject();
int childIndex = dl.getChildIndex();
TreePath transferedPaths[] = projectTree.getSelectionPaths();
// Check if the drop target is among the project data files
if (droppedLocationObject == ProjectTreeModel.dataFilesNodeName) {
for (TreePath path : transferedPaths) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
.getLastPathComponent();
int currentIndex = node.getParent().getIndex(node);
Object transferObject = node.getUserObject();
if (transferObject instanceof RawDataFile) {
treeModel.removeNodeFromParent(node);
if (childIndex > currentIndex)
childIndex--;
treeModel.insertNodeInto(node, droppedLocationNode,
childIndex);
childIndex++;
}
}
}
// Check if the drop target is AFTER the data files (last position)
if ((droppedLocationObject == project) && (childIndex == 1)) {
int numOfFiles = project.getDataFiles().length;
DefaultMutableTreeNode filesNode = (DefaultMutableTreeNode) droppedLocationNode
.getChildAt(0);
for (TreePath path : transferedPaths) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
.getLastPathComponent();
Object transferObject = node.getUserObject();
if (transferObject instanceof RawDataFile) {
treeModel.removeNodeFromParent(node);
treeModel.insertNodeInto(node, filesNode, numOfFiles - 1);
}
}
}
// Check if the drop target is among the project peak lists
if (droppedLocationObject == ProjectTreeModel.peakListsNodeName) {
for (TreePath path : transferedPaths) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
.getLastPathComponent();
int currentIndex = node.getParent().getIndex(node);
Object transferObject = node.getUserObject();
if (childIndex > currentIndex)
childIndex--;
if (transferObject instanceof PeakList) {
treeModel.removeNodeFromParent(node);
treeModel.insertNodeInto(node, droppedLocationNode,
childIndex);
childIndex++;
}
}
}
// Check if the drop target is AFTER the peak lists (last position)
if ((droppedLocationObject == project) && (childIndex == 2)) {
DefaultMutableTreeNode peakListsNode = (DefaultMutableTreeNode) droppedLocationNode
.getChildAt(1);
int numOfPeakLists = project.getPeakLists().length;
for (TreePath path : transferedPaths) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
.getLastPathComponent();
Object transferObject = node.getUserObject();
if (transferObject instanceof PeakList) {