IDEMPIERE-1248 Performance Optimization: Eliminate the fire and processing of duplicate event.
This commit is contained in:
parent
a128d9b302
commit
6819bbc720
|
@ -127,6 +127,10 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
|
||||
public static final String ON_DYNAMIC_DISPLAY_EVENT = "onDynamicDisplay";
|
||||
|
||||
public static final String ON_DEFER_DYNAMIC_DISPLAY_EVENT = "onDeferDynamicDisplay";
|
||||
|
||||
public static final String ON_DEFER_DYNAMIC_DISPLAY_EVENT_ATTR = "onDeferDynamicDisplay.Event.Posted";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -134,6 +138,8 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
|
||||
private static final String ON_DEFER_SET_SELECTED_NODE = "onDeferSetSelectedNode";
|
||||
|
||||
private static final String ON_DEFER_SET_SELECTED_NODE_ATTR = "onDeferSetSelectedNode.Event.Posted";
|
||||
|
||||
private static final CLogger logger;
|
||||
|
||||
static
|
||||
|
@ -217,6 +223,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
});
|
||||
addEventListener(ON_POST_INIT_EVENT, this);
|
||||
addEventListener(ON_SAVE_OPEN_PREFERENCE_EVENT, this);
|
||||
addEventListener(ON_DEFER_DYNAMIC_DISPLAY_EVENT, this);
|
||||
}
|
||||
|
||||
private void initComponents()
|
||||
|
@ -654,8 +661,21 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
* @param col
|
||||
*/
|
||||
@Override
|
||||
public void dynamicDisplay (int col)
|
||||
public void dynamicDisplay (int col)
|
||||
{
|
||||
//0 and -1 is same
|
||||
if (col < 0)
|
||||
col = 0;
|
||||
if (getAttribute(ON_DEFER_DYNAMIC_DISPLAY_EVENT_ATTR+"_"+col) == null)
|
||||
{
|
||||
setAttribute(ON_DEFER_DYNAMIC_DISPLAY_EVENT_ATTR+"_"+col, Boolean.TRUE);
|
||||
Events.postEvent(ON_DEFER_DYNAMIC_DISPLAY_EVENT, this, col);
|
||||
}
|
||||
}
|
||||
|
||||
private void onDeferDynamicDisplay (int col)
|
||||
{
|
||||
removeAttribute(ON_DEFER_DYNAMIC_DISPLAY_EVENT_ATTR+"_"+col);
|
||||
if (!gridTab.isOpen())
|
||||
{
|
||||
return;
|
||||
|
@ -796,10 +816,17 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
}
|
||||
|
||||
Events.sendEvent(this, new Event(ON_DYNAMIC_DISPLAY_EVENT, this));
|
||||
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||
echoDeferSetSelectedNodeEvent();
|
||||
if (logger.isLoggable(Level.CONFIG)) logger.config(gridTab.toString() + " - fini - " + (col<=0 ? "complete" : "seletive"));
|
||||
} // dynamicDisplay
|
||||
|
||||
private void echoDeferSetSelectedNodeEvent() {
|
||||
if (getAttribute(ON_DEFER_SET_SELECTED_NODE_ATTR) == null) {
|
||||
setAttribute(ON_DEFER_SET_SELECTED_NODE_ATTR, Boolean.TRUE);
|
||||
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
|
@ -957,7 +984,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
}
|
||||
|
||||
if (gridTab.getRecord_ID() > 0 && gridTab.isTreeTab() && treePanel != null) {
|
||||
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||
echoDeferSetSelectedNodeEvent();
|
||||
}
|
||||
|
||||
Event event = new Event(ON_ACTIVATE_EVENT, this, activate);
|
||||
|
@ -1006,6 +1033,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
navigateTo((DefaultTreeNode<MTreeNode>)item.getValue());
|
||||
}
|
||||
else if (ON_DEFER_SET_SELECTED_NODE.equals(event.getName())) {
|
||||
removeAttribute(ON_DEFER_SET_SELECTED_NODE_ATTR);
|
||||
if (gridTab.getRecord_ID() >= 0 && gridTab.isTreeTab() && treePanel != null) {
|
||||
setSelectedNode(gridTab.getRecord_ID());
|
||||
}
|
||||
|
@ -1052,6 +1080,10 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
Env.getCtx().setProperty("P"+windowId+"|"+adTabId+"|DetailPane.IsOpen", value ? "Y" : "N");
|
||||
}
|
||||
}
|
||||
else if (event.getName().equals(ON_DEFER_DYNAMIC_DISPLAY_EVENT)) {
|
||||
Integer col = (Integer) event.getData();
|
||||
onDeferDynamicDisplay(col);
|
||||
}
|
||||
}
|
||||
|
||||
private void onSouthEvent(SouthEvent event) {
|
||||
|
@ -1197,7 +1229,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
if (AD_Tree_ID != 0)
|
||||
{
|
||||
if (treePanel.initTree(AD_Tree_ID, windowNo))
|
||||
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||
echoDeferSetSelectedNodeEvent();
|
||||
else
|
||||
setSelectedNode(gridTab.getRecord_ID());
|
||||
|
||||
|
@ -1282,7 +1314,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
int[] path = model.getPath(treeNode);
|
||||
Treeitem ti = treePanel.getTree().renderItemByPath(path);
|
||||
if (ti.getPage() == null) {
|
||||
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||
echoDeferSetSelectedNodeEvent();
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.zkoss.zk.ui.util.Clients;
|
|||
*/
|
||||
public class DPPerformance extends DashboardPanel {
|
||||
|
||||
private static final String ON_POST_RENDER_ATTR = "onPostRender.Event.Posted";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -53,22 +54,31 @@ public class DPPerformance extends DashboardPanel {
|
|||
|
||||
public void refresh(ServerPushTemplate template) {
|
||||
super.refresh(template);
|
||||
if (Executions.getCurrent() != null)
|
||||
Events.echoEvent("onPostRender", this, null);
|
||||
if (Executions.getCurrent() != null) {
|
||||
if (this.getAttribute(ON_POST_RENDER_ATTR) == null) {
|
||||
setAttribute(ON_POST_RENDER_ATTR, Boolean.TRUE);
|
||||
Events.echoEvent("onPostRender", this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageAttached(Page newpage, Page oldpage) {
|
||||
super.onPageAttached(newpage, oldpage);
|
||||
if (newpage != null) {
|
||||
if (Executions.getCurrent() != null)
|
||||
Events.echoEvent("onPostRender", this, null);
|
||||
if (Executions.getCurrent() != null) {
|
||||
if (this.getAttribute(ON_POST_RENDER_ATTR) == null) {
|
||||
setAttribute(ON_POST_RENDER_ATTR, Boolean.TRUE);
|
||||
Events.echoEvent("onPostRender", this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//adjust window height to match grid height
|
||||
public void onPostRender()
|
||||
{
|
||||
removeAttribute(ON_POST_RENDER_ATTR);
|
||||
if (this.getFirstChild() != null)
|
||||
{
|
||||
Component grid = this.getFirstChild().getFirstChild();
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
package org.adempiere.webui.util;
|
||||
|
||||
import org.zkoss.zk.ui.Execution;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.util.EventInterceptor;
|
||||
|
||||
|
@ -35,8 +37,18 @@ public class LogEventInterceptor implements EventInterceptor {
|
|||
*/
|
||||
@Override
|
||||
public Event beforeProcessEvent(Event event) {
|
||||
String locator = event.getTarget() != null ? event.getTarget().getWidgetAttribute("_zk_locator") : "";
|
||||
System.out.println("beforeProcessEvent, event="+event.getName()+",target="+event.getTarget()+",locator="+locator);
|
||||
if (event.getTarget() != null) {
|
||||
Execution execution = Executions.getCurrent();
|
||||
String uuid = event.getTarget().getUuid();
|
||||
String key = uuid + event.getName();
|
||||
if (execution.getAttribute(key) != null) {
|
||||
System.out.println("Duplicate Event., event="+event.getName()+",target="+event.getTarget());
|
||||
} else {
|
||||
execution.setAttribute(key, Boolean.TRUE);
|
||||
String locator = event.getTarget() != null ? event.getTarget().getWidgetAttribute("_zk_locator") : "";
|
||||
System.out.println("beforeProcessEvent, event="+event.getName()+",target="+event.getTarget()+",locator="+locator);
|
||||
}
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,6 +206,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
|
||||
private Properties m_findCtx;
|
||||
|
||||
private static final String ON_POST_VISIBLE_ATTR = "onPostVisible.Event.Posted";
|
||||
|
||||
/**
|
||||
* FindPanel Constructor
|
||||
|
@ -2157,6 +2158,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
}
|
||||
|
||||
public void OnPostVisible() {
|
||||
removeAttribute(ON_POST_VISIBLE_ATTR);
|
||||
if (m_sEditors.size() > 0)
|
||||
Clients.response(new AuFocus(m_sEditors.get(0).getComponent()));
|
||||
}
|
||||
|
@ -2180,7 +2182,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
public boolean setVisible(boolean visible) {
|
||||
boolean ret = super.setVisible(visible);
|
||||
if (visible) {
|
||||
Events.echoEvent("OnPostVisible", this, null);
|
||||
if (getAttribute(ON_POST_VISIBLE_ATTR) == null) {
|
||||
setAttribute(ON_POST_VISIBLE_ATTR, Boolean.TRUE);
|
||||
Events.echoEvent("OnPostVisible", this, null);
|
||||
}
|
||||
} else {
|
||||
//auto detach
|
||||
detach();
|
||||
|
|
Loading…
Reference in New Issue