From ed5fcfd04a7d3ddac3aa7ccdd17119389593e426 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 28 Mar 2013 10:28:43 +0800 Subject: [PATCH] IDEMPIERE-787 Cannot create tree of menu. --- .../src/org/adempiere/webui/adwindow/ADTabpanel.java | 2 +- .../webui/component/ADTreeOnDropListener.java | 11 +++++++---- .../adempiere/webui/component/SimpleTreeModel.java | 4 +++- 3 files changed, 11 insertions(+), 6 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 e13156836d..d428ba6002 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 @@ -1,5 +1,5 @@ /****************************************************************************** -f * Product: Posterita Ajax UI * + * Product: Posterita Ajax UI * * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADTreeOnDropListener.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADTreeOnDropListener.java index c2bdcfb0aa..55c3dbfc7e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADTreeOnDropListener.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADTreeOnDropListener.java @@ -145,7 +145,7 @@ public class ADTreeOnDropListener implements EventListener { } // insert - treeModel.addNode(newParent, movingNode, index); + newParent = treeModel.addNode(newParent, movingNode, index); int path[] = treeModel.getPath(movingNode); if (TreeUtils.isOnInitRenderPosted(tree) || tree.getTreechildren() == null) @@ -192,7 +192,7 @@ public class ADTreeOnDropListener implements EventListener { .append(" WHERE AD_Tree_ID=").append(mTree.getAD_Tree_ID()) .append(" AND Node_ID=").append(md.getNode_ID()); if (log.isLoggable(Level.FINE)) log.fine(sql.toString()); - no = DB.executeUpdate(sql.toString(),trx.getTrxName()); + DB.executeUpdateEx(sql.toString(),trx.getTrxName()); } } // COMMIT ********************* @@ -203,8 +203,11 @@ public class ADTreeOnDropListener implements EventListener { trx.rollback(); FDialog.error(windowNo, tree, "TreeUpdateError", e.getLocalizedMessage()); } - trx.close(); - trx = null; + finally + { + trx.close(); + trx = null; + } } class MenuListener implements EventListener { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/SimpleTreeModel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/SimpleTreeModel.java index 80e3b3ab1d..134ed8ef82 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/SimpleTreeModel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/SimpleTreeModel.java @@ -249,8 +249,9 @@ public class SimpleTreeModel extends org.zkoss.zul.DefaultTreeModel impl * @param newParent * @param newNode * @param index + * @return parent node. this could be a new instance created to replace the newParent node param */ - public void addNode(DefaultTreeNode newParent, DefaultTreeNode newNode, + public DefaultTreeNode addNode(DefaultTreeNode newParent, DefaultTreeNode newNode, int index) { DefaultTreeNode parent = newParent; if (newParent.getChildren() == null) { @@ -260,6 +261,7 @@ public class SimpleTreeModel extends org.zkoss.zul.DefaultTreeModel impl } parent.getChildren().add(index, newNode); + return parent; } /**