IDEMPIERE-286 Zk: When you first open the menu window, current menu record is not visible in the tree.
This commit is contained in:
parent
4ad18e38e4
commit
e93dee5efc
|
@ -98,6 +98,8 @@ import org.zkoss.zul.impl.XulElement;
|
||||||
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
|
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
|
||||||
DataStatusListener, IADTabpanel, VetoableChangeListener
|
DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
{
|
{
|
||||||
|
private static final String ON_DEFER_SET_SELECTED_NODE = "onDeferSetSelectedNode";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generated serial version ID
|
* generated serial version ID
|
||||||
*/
|
*/
|
||||||
|
@ -160,6 +162,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
initComponents();
|
initComponents();
|
||||||
|
addEventListener(ON_DEFER_SET_SELECTED_NODE, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents()
|
private void initComponents()
|
||||||
|
@ -548,7 +551,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gridTab.isSingleRow() && !isGridView())
|
if (!gridTab.isSingleRow() && !isGridView())
|
||||||
switchRowPresentation();
|
switchRowPresentation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createSpacer() {
|
private Component createSpacer() {
|
||||||
|
@ -785,6 +788,10 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
{
|
{
|
||||||
activateChild(activate, ep);
|
activateChild(activate, ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gridTab.getRecord_ID() > 0 && gridTab.isTreeTab() && treePanel != null) {
|
||||||
|
setSelectedNode(gridTab.getRecord_ID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activateChild(boolean activate, EmbeddedPanel panel) {
|
private void activateChild(boolean activate, EmbeddedPanel panel) {
|
||||||
|
@ -840,6 +847,11 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
Treeitem item = treePanel.getTree().getSelectedItem();
|
Treeitem item = treePanel.getTree().getSelectedItem();
|
||||||
navigateTo((DefaultTreeNode)item.getValue());
|
navigateTo((DefaultTreeNode)item.getValue());
|
||||||
}
|
}
|
||||||
|
else if (ON_DEFER_SET_SELECTED_NODE.equals(event.getName())) {
|
||||||
|
if (gridTab.getRecord_ID() > 0 && gridTab.isTreeTab() && treePanel != null) {
|
||||||
|
setSelectedNode(gridTab.getRecord_ID());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateTo(DefaultTreeNode value) {
|
private void navigateTo(DefaultTreeNode value) {
|
||||||
|
@ -991,11 +1003,11 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
MTreeNode root = (MTreeNode) treeNode.getData();
|
MTreeNode root = (MTreeNode) treeNode.getData();
|
||||||
MTreeNode node = new MTreeNode (gridTab.getRecord_ID(), 0, name, description,
|
MTreeNode node = new MTreeNode (gridTab.getRecord_ID(), 0, name, description,
|
||||||
root.getNode_ID(), summary, imageIndicator, false, null);
|
root.getNode_ID(), summary, imageIndicator, false, null);
|
||||||
DefaultTreeNode newNode = new DefaultTreeNode(node, new ArrayList<Object>());
|
DefaultTreeNode newNode = new DefaultTreeNode(node);
|
||||||
model.addNode(newNode);
|
model.addNode(newNode);
|
||||||
int[] path = model.getPath(newNode);
|
int[] path = model.getPath(newNode);
|
||||||
Treeitem ti = treePanel.getTree().renderItemByPath(path);
|
Treeitem ti = treePanel.getTree().renderItemByPath(path);
|
||||||
treePanel.getTree().setSelectedItem(ti);
|
treePanel.getTree().setSelectedItem(ti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,17 +1015,24 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
if (recordId <= 0) return;
|
if (recordId <= 0) return;
|
||||||
|
|
||||||
//force on init render
|
//force on init render
|
||||||
if (TreeUtils.isOnInitRenderPosted(treePanel.getTree())) {
|
if (TreeUtils.isOnInitRenderPosted(treePanel.getTree()) || treePanel.getTree().getTreechildren() == null) {
|
||||||
treePanel.getTree().onInitRender();
|
treePanel.getTree().onInitRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SimpleTreeModel model = (SimpleTreeModel) treePanel.getTree().getModel();
|
||||||
if (treePanel.getTree().getSelectedItem() != null) {
|
if (treePanel.getTree().getSelectedItem() != null) {
|
||||||
DefaultTreeNode treeNode = (DefaultTreeNode) treePanel.getTree().getSelectedItem().getValue();
|
DefaultTreeNode treeNode = (DefaultTreeNode) treePanel.getTree().getSelectedItem().getValue();
|
||||||
MTreeNode data = (MTreeNode) treeNode.getData();
|
MTreeNode data = (MTreeNode) treeNode.getData();
|
||||||
if (data.getNode_ID() == recordId) return;
|
if (data.getNode_ID() == recordId) {
|
||||||
|
int[] path = model.getPath(treeNode);
|
||||||
|
Treeitem ti = treePanel.getTree().renderItemByPath(path);
|
||||||
|
if (ti.getPage() == null) {
|
||||||
|
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleTreeModel model = (SimpleTreeModel) treePanel.getTree().getModel();
|
|
||||||
DefaultTreeNode treeNode = model.find(null, recordId);
|
DefaultTreeNode treeNode = model.find(null, recordId);
|
||||||
if (treeNode != null) {
|
if (treeNode != null) {
|
||||||
int[] path = model.getPath(treeNode);
|
int[] path = model.getPath(treeNode);
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
package org.adempiere.webui.panel;
|
package org.adempiere.webui.panel;
|
||||||
|
|
||||||
|
|
||||||
import org.adempiere.webui.component.Checkbox;
|
|
||||||
import org.adempiere.webui.component.SimpleTreeModel;
|
import org.adempiere.webui.component.SimpleTreeModel;
|
||||||
import org.adempiere.webui.component.ToolBarButton;
|
import org.adempiere.webui.component.ToolBarButton;
|
||||||
import org.adempiere.webui.util.TreeUtils;
|
import org.adempiere.webui.util.TreeUtils;
|
||||||
|
@ -35,7 +34,7 @@ import org.zkoss.zul.Tree;
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ADTreePanel extends Panel implements EventListener
|
public class ADTreePanel extends Panel implements EventListener<Event>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue