IDEMPIERE-950 Tree from detail tab not updated when master record change
This commit is contained in:
parent
b90a6bfef1
commit
256c4f5cc4
|
@ -601,9 +601,19 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
||||||
|
|
||||||
//create tree
|
//create tree
|
||||||
if (gridTab.isTreeTab() && treePanel != null) {
|
if (gridTab.isTreeTab() && treePanel != null) {
|
||||||
int AD_Tree_ID = MTree.getDefaultAD_Tree_ID (
|
int AD_Tree_ID = Env.getContextAsInt (Env.getCtx(), getWindowNo(), "AD_Tree_ID", true);
|
||||||
Env.getAD_Client_ID(Env.getCtx()), gridTab.getKeyColumnName());
|
int AD_Tree_ID_Default = MTree.getDefaultAD_Tree_ID (Env.getAD_Client_ID(Env.getCtx()), gridTab.getKeyColumnName());
|
||||||
treePanel.initTree(AD_Tree_ID, windowNo);
|
if (gridTab.getRecord_ID() >= 0) {
|
||||||
|
if (AD_Tree_ID != 0) {
|
||||||
|
treePanel.initTree(AD_Tree_ID, windowNo);
|
||||||
|
setSelectedNode(gridTab.getRecord_ID());
|
||||||
|
} else if (AD_Tree_ID_Default != 0) {
|
||||||
|
treePanel.initTree(AD_Tree_ID_Default, windowNo);
|
||||||
|
setSelectedNode(gridTab.getRecord_ID());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
treePanel.getTree().clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gridTab.isSingleRow() && !isGridView())
|
if (!gridTab.isSingleRow() && !isGridView())
|
||||||
|
@ -1155,19 +1165,65 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
||||||
createUI();
|
createUI();
|
||||||
dynamicDisplay(col);
|
dynamicDisplay(col);
|
||||||
|
|
||||||
//sync tree
|
//sync tree
|
||||||
if (treePanel != null) {
|
if (treePanel != null)
|
||||||
|
{
|
||||||
if ("Deleted".equalsIgnoreCase(e.getAD_Message()))
|
if ("Deleted".equalsIgnoreCase(e.getAD_Message()))
|
||||||
if (e.Record_ID != null
|
{
|
||||||
&& e.Record_ID instanceof Integer
|
if (e.Record_ID != null && e.Record_ID instanceof Integer && ((Integer)e.Record_ID != gridTab.getRecord_ID()))
|
||||||
&& ((Integer)e.Record_ID != gridTab.getRecord_ID()))
|
|
||||||
deleteNode((Integer)e.Record_ID);
|
deleteNode((Integer)e.Record_ID);
|
||||||
else
|
else
|
||||||
setSelectedNode(gridTab.getRecord_ID());
|
setSelectedNode(gridTab.getRecord_ID());
|
||||||
else
|
}
|
||||||
setSelectedNode(gridTab.getRecord_ID());
|
else if (!e.isInserting())
|
||||||
|
{
|
||||||
|
boolean refresh=true;
|
||||||
|
Treeitem item = treePanel.getTree().getSelectedItem();
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
MTreeNode treeNode = ((DefaultTreeNode<MTreeNode>) item.getValue()).getData();
|
||||||
|
if (treeNode.getNode_ID() == gridTab.getRecord_ID()){
|
||||||
|
setSelectedNode(gridTab.getRecord_ID());
|
||||||
|
refresh = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
treePanel.initTree(AD_Tree_ID, windowNo);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(e.isInserting() && gridTab.getRecord_ID() < 0 && gridTab.getTabLevel() > 0 )
|
||||||
|
{
|
||||||
|
int AD_Tree_ID = Integer.parseInt(gridTab.getParentTab().getValue("AD_Tree_ID").toString());
|
||||||
|
MTreeNode root = new MTree (Env.getCtx(), AD_Tree_ID, true, true, null).getRoot();
|
||||||
|
SimpleTreeModel treeModel = SimpleTreeModel.createFrom(root);
|
||||||
|
try {
|
||||||
|
treePanel.getTree().setItemRenderer(treeModel);
|
||||||
|
treePanel.getTree().setModel(treeModel);
|
||||||
|
} catch (Exception treeExc) {
|
||||||
|
logger.log(Level.SEVERE, "Failed to setup tree");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listPanel.isVisible()) {
|
if (listPanel.isVisible()) {
|
||||||
listPanel.updateListIndex();
|
listPanel.updateListIndex();
|
||||||
listPanel.dynamicDisplay(col);
|
listPanel.dynamicDisplay(col);
|
||||||
|
|
|
@ -81,11 +81,16 @@ public class SimpleTreeModel extends org.zkoss.zul.DefaultTreeModel<Object> impl
|
||||||
SimpleTreeModel treeModel = SimpleTreeModel.createFrom(root);
|
SimpleTreeModel treeModel = SimpleTreeModel.createFrom(root);
|
||||||
treeModel.setItemDraggable(true);
|
treeModel.setItemDraggable(true);
|
||||||
treeModel.addOnDropEventListener(new ADTreeOnDropListener(tree, treeModel, vTree, windowNo));
|
treeModel.addOnDropEventListener(new ADTreeOnDropListener(tree, treeModel, vTree, windowNo));
|
||||||
|
|
||||||
Treecols treeCols = new Treecols();
|
if (tree.getTreecols() == null)
|
||||||
tree.appendChild(treeCols);
|
{
|
||||||
Treecol treeCol = new Treecol();
|
Treecols treeCols = new Treecols();
|
||||||
treeCols.appendChild(treeCol);
|
tree.getTreecols();
|
||||||
|
tree.appendChild(treeCols);
|
||||||
|
Treecol treeCol = new Treecol();
|
||||||
|
treeCols.appendChild(treeCol);
|
||||||
|
}
|
||||||
|
|
||||||
tree.setPageSize(-1);
|
tree.setPageSize(-1);
|
||||||
try {
|
try {
|
||||||
tree.setItemRenderer(treeModel);
|
tree.setItemRenderer(treeModel);
|
||||||
|
|
Loading…
Reference in New Issue