From 9f7635ac7b1f7417d32a59016200c06f710f2056 Mon Sep 17 00:00:00 2001 From: hieplq Date: Thu, 26 Dec 2013 20:19:50 +0700 Subject: [PATCH] IDEMPIERE-1477 NPE on tree --- .../adempiere/webui/adwindow/ADTabpanel.java | 54 ++++++++----------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java index f41fbb00f8..9ecc039090 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java @@ -614,17 +614,14 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer if (gridTab.isTreeTab() && treePanel != null) { int AD_Tree_ID = Env.getContextAsInt (Env.getCtx(), getWindowNo(), "AD_Tree_ID", true); int AD_Tree_ID_Default = MTree.getDefaultAD_Tree_ID (Env.getAD_Client_ID(Env.getCtx()), gridTab.getKeyColumnName()); - if (gridTab.getRecord_ID() >= 0) { - if (AD_Tree_ID != 0) { - treePanel.initTree(AD_Tree_ID, windowNo); - Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null); - } else if (AD_Tree_ID_Default != 0) { - treePanel.initTree(AD_Tree_ID_Default, windowNo); - Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null); - } - } else { - treePanel.getTree().clear(); - } + + if (AD_Tree_ID != 0) { + treePanel.initTree(AD_Tree_ID, windowNo); + Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null); + } else if (AD_Tree_ID_Default != 0) { + treePanel.initTree(AD_Tree_ID_Default, windowNo); + Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null); + } } if (!gridTab.isSingleRow() && !isGridView()) @@ -1228,26 +1225,21 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer if (refresh) { int AD_Tree_ID = Env.getContextAsInt (Env.getCtx(), getWindowNo(), "AD_Tree_ID", true); - if (gridTab.getRecord_ID()>=0) - { - if (AD_Tree_ID != 0) - { - if (treePanel.initTree(AD_Tree_ID, windowNo)) - echoDeferSetSelectedNodeEvent(); - else - setSelectedNode(gridTab.getRecord_ID()); - - } - else - { - AD_Tree_ID = MTree.getDefaultAD_Tree_ID (Env.getAD_Client_ID(Env.getCtx()), gridTab.getKeyColumnName()); - treePanel.initTree(AD_Tree_ID, windowNo); - } - } - else - { - treePanel.getTree().clear(); - } + + if (AD_Tree_ID != 0) + { + if (treePanel.initTree(AD_Tree_ID, windowNo)) + echoDeferSetSelectedNodeEvent(); + else + setSelectedNode(gridTab.getRecord_ID()); + + } + else + { + AD_Tree_ID = MTree.getDefaultAD_Tree_ID (Env.getAD_Client_ID(Env.getCtx()), gridTab.getKeyColumnName()); + treePanel.initTree(AD_Tree_ID, windowNo); + } + } }else if(e.isInserting() && gridTab.getRecord_ID() < 0 && gridTab.getTabLevel() > 0 )