IDEMPIERE-369 Master Detail layout improvements. Minor adjustment to the redraw of detailpane.

This commit is contained in:
Heng Sin Low 2012-11-26 11:12:57 +08:00
parent b0c509fa06
commit 960a984e5d
4 changed files with 48 additions and 13 deletions

View File

@ -12,8 +12,13 @@
*****************************************************************************/
package org.adempiere.webui;
import java.io.IOException;
import java.io.StringWriter;
import org.adempiere.webui.component.Label;
import org.zkoss.zk.au.out.AuOuter;
import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.AbstractComponent;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.util.Clients;
@ -124,4 +129,14 @@ public final class LayoutUtils {
window.doOverlapped();
Clients.response("_openPopupWindow_", new AuScript(window, script.toString()));
}
public static void redraw(AbstractComponent component) {
StringWriter writer = new StringWriter(1024);
try {
component.redraw(writer);
Clients.response(new AuOuter(component, writer.toString()));
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -571,7 +571,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
private void initFirstTabpanel() {
adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords());
adTabbox.getSelectedTabpanel().activate(true);
Events.echoEvent(new Event("onPostInit", adTabbox.getComponent()));
if (adTabbox.getSelectedTabpanel().isGridView()) {
Events.postEvent(new Event(CompositeADTabbox.ON_POST_INIT_EVENT, adTabbox.getComponent()));
}
}
/**

View File

@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.ADTabListModel;
import org.adempiere.webui.component.ADTabListModel.ADTabLabel;
import org.adempiere.webui.window.FDialog;
@ -54,6 +55,8 @@ import org.zkoss.zul.Vlayout;
*/
public class CompositeADTabbox extends AbstractADTabbox
{
public static final String ON_POST_INIT_EVENT = "onPostInit";
public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged";
/** Logger */
@ -133,6 +136,18 @@ public class CompositeADTabbox extends AbstractADTabbox
}
}
});
detailPane.addEventListener(DetailPane.ON_POST_SELECT_TAB_EVENT, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if ((!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView())
|| (detailPane.getSelectedADTabpanel() instanceof ADSortTab)) {
LayoutUtils.redraw(detailPane);
Clients.scrollIntoView(detailPane.getSelectedADTabpanel());
}
}
});
}
protected void onEditDetail(int row) {
@ -188,10 +203,10 @@ public class CompositeADTabbox extends AbstractADTabbox
}
});
layout.addEventListener("onPostInit", new EventListener<Event>() {
layout.addEventListener(ON_POST_INIT_EVENT, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
layout.invalidate();
LayoutUtils.redraw(layout);
}
});
@ -547,8 +562,8 @@ public class CompositeADTabbox extends AbstractADTabbox
detailTab.activate(true);
detailTab.setDetailPaneMode(true, isUseVflexForDetailPane());
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane()));
if (!ADTabpanel.isUseSplitViewForForm()) {
layout.invalidate();
if (!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) {
Events.echoEvent(new Event(DetailPane.ON_REDRAW_EVENT, detailPane));
}
}
}
@ -647,13 +662,9 @@ public class CompositeADTabbox extends AbstractADTabbox
tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane());
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane()));
if (tabPanel instanceof ADSortTab) {
detailPane.invalidate();
detailPane.updateToolbar(false, true);
} else {
tabPanel.dynamicDisplay(0);
if (!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) {
detailPane.invalidate();
}
}
}

View File

@ -44,6 +44,10 @@ import org.zkoss.zul.Toolbar;
*/
public class DetailPane extends Panel implements EventListener<Event> {
public static final String ON_POST_SELECT_TAB_EVENT = "onPostSelectTab";
public static final String ON_REDRAW_EVENT = "onRedraw";
private static final String STATUS_TEXT_ATTRIBUTE = "status.text";
private static final String STATUS_ERROR_ATTRIBUTE = "status.error";
@ -91,9 +95,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
@Override
public void onEvent(Event event) throws Exception {
fireActivateDetailEvent();
if (!ADTabpanel.isUseSplitViewForForm()) {
Clients.scrollIntoView(getSelectedADTabpanel());
}
Events.postEvent(new Event(ON_POST_SELECT_TAB_EVENT, DetailPane.this));
}
});
tabbox.setSclass("adwindow-detailpane-tabbox");
@ -107,6 +109,8 @@ public class DetailPane extends Panel implements EventListener<Event> {
if (!ADTabpanel.isUseSplitViewForForm()) {
LayoutUtils.addSclass("adwindow-detailpane-xsplit", this);
}
addEventListener(ON_REDRAW_EVENT, this);
}
public int getSelectedIndex() {
@ -391,6 +395,8 @@ public class DetailPane extends Panel implements EventListener<Event> {
showPopup(error, messageContainer);
} else if (event.getName().equals(ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT)) {
updateProcessToolbar();
} else if (event.getName().equals(ON_REDRAW_EVENT)) {
LayoutUtils.redraw(this);
}
}