Fixed NPE when deleting nodes too fast on project or template WBS trees
This was happening when clicking too fast on the node deletion column on the tree, wich caused an exception due to trying to remove an already deleted element. FEA: ItEr77S04BugFixing
This commit is contained in:
parent
05132fd5a7
commit
b3f557f58a
2 changed files with 17 additions and 5 deletions
|
|
@ -31,6 +31,8 @@ import java.util.ListIterator;
|
|||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.zkoss.zul.AbstractTreeModel;
|
||||
import org.zkoss.zul.event.TreeDataEvent;
|
||||
|
||||
|
|
@ -39,6 +41,8 @@ import org.zkoss.zul.event.TreeDataEvent;
|
|||
*/
|
||||
public class MutableTreeModel<T> extends AbstractTreeModel {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(MutableTreeModel.class);
|
||||
|
||||
public interface IChildrenExtractor<T> {
|
||||
|
||||
public List<? extends T> getChildren(T parent);
|
||||
|
|
@ -354,10 +358,14 @@ public class MutableTreeModel<T> extends AbstractTreeModel {
|
|||
|
||||
public List<T> getParents(T node) {
|
||||
ArrayList<T> result = new ArrayList<T>();
|
||||
T current = node;
|
||||
while (!isRoot(current)) {
|
||||
current = getParent(current);
|
||||
result.add(current);
|
||||
try {
|
||||
T current = node;
|
||||
while (!isRoot(current)) {
|
||||
current = getParent(current);
|
||||
result.add(current);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Trying to get the parent of a removed node", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,11 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
|||
|
||||
public void remove(T element) {
|
||||
List<T> parentNodes = getModel().getParents(element);
|
||||
getModel().removeNode(element);
|
||||
try {
|
||||
getModel().removeNode(element);
|
||||
} catch (NullPointerException e) {
|
||||
LOG.error("Trying to delete an already removed node", e);
|
||||
}
|
||||
getRenderer().refreshHoursValueForNodes(parentNodes);
|
||||
getRenderer().refreshBudgetValueForNodes(parentNodes);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue