protected void fireEditingStopped() {
if (taskListModel.getSelectedItem() == null || !(taskListModel.getSelectedItem() instanceof BOTask)) {
super.fireEditingStopped();
return;
}
BOTask newParent = (BOTask) taskListModel.getSelectedItem();
int rows[] = pta.getSelectedRows();
if (rows != null && rows.length > 0) {
List<BOTask> tasks = new ArrayList<BOTask>();
for (int row : rows) {
if (pta.getModel().getValueAt(row, -1) != null) {
if (pta.getModel().getValueAt(row, -1) instanceof BOTask) {
BOTask currentTask = (BOTask) pta.getModel().getValueAt(row, -1);
BOTask oldParentTask = currentTask.getParentTask();
if (oldParentTask == null || oldParentTask.equals(currentTask)) {
ApplicationContext.getCurrentProjet().getTasks().remove(currentTask);
removeObject(ApplicationContext.getCurrentProjet().getTasks(), currentTask);
} else {
oldParentTask.getChildTasks().remove(currentTask);
removeObject(oldParentTask.getChildTasks(), currentTask);
}
currentTask.setParentTask(newParent);
tasks.add(currentTask);
if (newParent.equals(currentTask)) {
ApplicationContext.getCurrentProjet().getTasks().add(currentTask);
} else {
newParent.getChildTasks().add(currentTask);
newParent.getPreviousTasks().clear();
}
ProjectCalculator.parentChanged(newParent, oldParentTask, currentTask, ApplicationContext.getCurrentUser());
}
}
}
} else {
if (currentRow >= 0 && (pta.getModel().getValueAt(currentRow, -1) != null)) {
if (pta.getModel().getValueAt(currentRow, -1) instanceof BOTask) {
BOTask currentTask = (BOTask) pta.getModel().getValueAt(currentRow, -1);
BOTask oldParentTask = currentTask.getParentTask();
if (oldParentTask == null || oldParentTask.equals(currentTask)) {
ApplicationContext.getCurrentProjet().getTasks().remove(currentTask);
removeObject(ApplicationContext.getCurrentProjet().getTasks(), currentTask);
} else {
oldParentTask.getChildTasks().remove(currentTask);
removeObject(oldParentTask.getChildTasks(), currentTask);
}
currentTask.setParentTask(newParent);
ProjectCalculator.parentChanged(newParent, oldParentTask, currentTask, ApplicationContext.getCurrentUser());
if (newParent.equals(currentTask)) {