[ 2674923 ] Performance enhancement

zk.xml
- turn of js compression
ServerContextCallback
- avoid expensive reflection call for the 2 most common use case
CompositeADTab
- replace Window with ligher weight Div
Window
- turn off drop shadow to improve performance and resize behaviour
windowContainer
- remove delay resize to improve responsiveness of UI
This commit is contained in:
Heng Sin Low 2009-03-10 02:14:07 +00:00
parent bd452d6b5b
commit 3d373500ff
5 changed files with 26 additions and 38 deletions

View File

@ -15,10 +15,10 @@ package org.adempiere.webui;
import java.io.Serializable;
import java.lang.reflect.Method;
import net.sf.cglib.proxy.InvocationHandler;
import org.adempiere.webui.session.ServerContext;
import net.sf.cglib.proxy.InvocationHandler;
/**
* Intercaptor for Server context properties that delegate to the threadlocal instance
* @author Low Heng Sin
@ -31,6 +31,18 @@ public class ServerContextCallback implements InvocationHandler, Serializable {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
ServerContext context = ServerContext.getCurrentInstance();
//optimize for the 2 most common access
if (method.getName().equals("getProperty")) {
Class<?>[] types = method.getParameterTypes();
if (types != null && types.length == 1 && types[0] == String.class &&
args != null && args.length == 1 && args[0] instanceof String) {
return context.getProperty((String)args[0]);
}
else if (types != null && types.length == 2 && types[0] == String.class &&
types[1] == String.class && args != null && args[0] instanceof String &&
args[1] instanceof String)
return context.getProperty((String)args[0], (String)args[1]);
}
Method m = context.getClass().getMethod(method.getName(), method.getParameterTypes());
return m.invoke(context, args);
}

View File

@ -27,6 +27,7 @@ import org.compiere.model.GridTab;
import org.compiere.util.CLogger;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Div;
/**
*
@ -44,7 +45,7 @@ public class CompositeADTab extends AbstractADTab
private List<ADTabListModel.ADTabLabel> tabLabelList = new ArrayList<ADTabListModel.ADTabLabel>();
private Window window;
private Div div;
protected ADButtonTabList tabList;
@ -56,20 +57,19 @@ public class CompositeADTab extends AbstractADTab
protected Component doCreatePart(Component parent)
{
window = new Window();
div= new Div();
if (parent != null) {
window.setParent(parent);
LayoutUtils.addSclass("adtab-body", window);
window.setContentSclass("adtab-body");
div.setParent(parent);
LayoutUtils.addSclass("adtab-body", div);
} else {
window.setPage(page);
div.setPage(page);
}
return window;
return div;
}
@Override
protected void doAddTab(GridTab gTab, IADTabpanel tabPanel) {
tabPanel.setParent(window);
tabPanel.setParent(div);
tabPanel.setVisible(false);
ADTabListModel.ADTabLabel tabLabel = new ADTabListModel.ADTabLabel(gTab.getName(), gTab.getTabLevel());
@ -140,6 +140,6 @@ public class CompositeADTab extends AbstractADTab
}
public Component getComponent() {
return window;
return div;
}
}

View File

@ -50,6 +50,7 @@ public class Window extends org.zkoss.zul.Window
public Window()
{
super();
setShadow(false);
}
/**

View File

@ -13,24 +13,19 @@
package org.adempiere.webui.part;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Tab;
import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabpanels;
import org.adempiere.webui.component.Tabs;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
/**
*
* @author Low Heng Sin
*
*/
public class WindowContainer extends AbstractUIPart implements EventListener
public class WindowContainer extends AbstractUIPart
{
private static final long serialVersionUID = 1L;
@ -67,8 +62,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener
tabbox.setWidth("100%");
tabbox.setHeight("100%");
tabbox.addEventListener(Events.ON_SELECT, this);
if (parent != null)
tabbox.setParent(parent);
else
@ -151,7 +144,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener
if (enable)
setSelectedTab(tab);
deferLayout();
}
/**
@ -216,23 +208,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener
}
//
/**
* @param event
*/
public void onEvent(Event event) throws Exception {
if (Events.ON_SELECT.equals(event.getName()))
deferLayout();
}
private void deferLayout() {
Tabpanel panel = (Tabpanel) tabbox.getSelectedPanel();
if (panel.getFirstChild() instanceof Borderlayout) {
LayoutUtils.sendDeferLayoutEvent((Borderlayout) panel.getChildren().get(0), 50);
} else if (panel.getFirstChild() != null){
panel.getFirstChild().invalidate();
}
}
/**
* @return Tabbox
*/

View File

@ -12,7 +12,7 @@ Copyright (C) 2006 Potix Corporation. All Rights Reserved.
<!-- change to false to use compress js which is much smaller -->
<client-config>
<debug-js>true</debug-js>
<debug-js>false</debug-js>
</client-config>
<!--