IDEMPIERE-2007 Detail Pane: Reduce vertical space use by paging control.

This commit is contained in:
Heng Sin Low 2014-06-19 22:34:42 +08:00
parent c6e660ca50
commit ec78079e40
4 changed files with 116 additions and 13 deletions

View File

@ -1395,6 +1395,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
if (listPanel.isVisible()) { if (listPanel.isVisible()) {
listPanel.refresh(gridTab); listPanel.refresh(gridTab);
listPanel.scrollToCurrentRow(); listPanel.scrollToCurrentRow();
Clients.resize(listPanel);
} else { } else {
listPanel.deactivate(); listPanel.deactivate();
} }
@ -1649,5 +1650,13 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
} }
@Override
public void setParent(Component parent) {
super.setParent(parent);
if (parent != null) {
listPanel.onADTabPanelParentChanged();
}
}
} }

View File

@ -1372,8 +1372,15 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
StringBuilder adMessage = new StringBuilder(); StringBuilder adMessage = new StringBuilder();
String origmsg = null; String origmsg = null;
if (msg != null && msg.length() > 0) if (msg != null && msg.length() > 0)
{
if (detailTab && GridTable.DATA_REFRESH_MESSAGE.equals(e.getAD_Message()))
{
origmsg = e.getTotalRows() + " " + Msg.getMsg(Env.getCtx(), "Records");
}
else
{ {
origmsg = Msg.getMsg(Env.getCtx(), e.getAD_Message()); origmsg = Msg.getMsg(Env.getCtx(), e.getAD_Message());
}
adMessage.append(origmsg); adMessage.append(origmsg);
} }
String info = e.getInfo(); String info = e.getInfo();

View File

@ -58,6 +58,7 @@ import org.zkoss.zul.Div;
import org.zkoss.zul.Frozen; import org.zkoss.zul.Frozen;
import org.zkoss.zul.Paging; import org.zkoss.zul.Paging;
import org.zkoss.zul.Row; import org.zkoss.zul.Row;
import org.zkoss.zul.Tabpanel;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
import org.zkoss.zul.event.ZulEvents; import org.zkoss.zul.event.ZulEvents;
@ -143,7 +144,6 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
this.setHflex("1"); this.setHflex("1");
gridFooter = new Div(); gridFooter = new Div();
gridFooter.setHflex("1");
gridFooter.setVflex("0"); gridFooter.setVflex("0");
//default paging size //default paging size
@ -195,6 +195,11 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
if (paging != null && paging.getPageSize() != pageSize) { if (paging != null && paging.getPageSize() != pageSize) {
paging.setPageSize(pageSize); paging.setPageSize(pageSize);
updateModel(); updateModel();
if (paging.getPageSize() > 1) {
showPagingControl();
} else {
hidePagingControl();
}
} }
} }
@ -217,6 +222,21 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
updateListIndex(); updateListIndex();
this.init = true; this.init = true;
showRecordsCount();
}
private void showRecordsCount() {
Component parent = this.getParent();
while (parent != null) {
if (parent instanceof DetailPane) {
DetailPane p = (DetailPane) parent;
if (p.getSelectedADTabpanel() != null && p.getSelectedADTabpanel().getGridTab() == this.gridTab)
p.setStatusMessage(tableModel.getRowCount() + " " + Msg.getMsg(Env.getCtx(), "Records"), false);
break;
}
parent = parent.getParent();
}
} }
private void setupFields(GridTab gridTab) { private void setupFields(GridTab gridTab) {
@ -290,6 +310,8 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
public void activate(GridTab gridTab) { public void activate(GridTab gridTab) {
if (!isInit()) { if (!isInit()) {
init(gridTab); init(gridTab);
} else {
showRecordsCount();
} }
} }
@ -329,7 +351,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
if (paging.getTotalSize() != gridTab.getRowCount()) if (paging.getTotalSize() != gridTab.getRowCount())
paging.setTotalSize(gridTab.getRowCount()); paging.setTotalSize(gridTab.getRowCount());
if (paging.getPageCount() > 1 && !gridFooter.isVisible()) { if (paging.getPageCount() > 1 && !gridFooter.isVisible()) {
gridFooter.setVisible(true); showPagingControl();
} }
int pgIndex = rowIndex >= 0 ? rowIndex % pageSize : 0; int pgIndex = rowIndex >= 0 ? rowIndex % pageSize : 0;
int pgNo = rowIndex >= 0 ? (rowIndex - pgIndex) / pageSize : 0; int pgNo = rowIndex >= 0 ? (rowIndex - pgIndex) / pageSize : 0;
@ -359,9 +381,9 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
paging.setActivePage(pgNo); paging.setActivePage(pgNo);
} }
if (paging.getPageCount() == 1) { if (paging.getPageCount() == 1) {
gridFooter.setVisible(false); hidePagingControl();
} else { } else {
gridFooter.setVisible(true); showPagingControl();
} }
if (rowIndex >= 0 && pgIndex >= 0) { if (rowIndex >= 0 && pgIndex >= 0) {
echoOnPostSelectedRowChanged(); echoOnPostSelectedRowChanged();
@ -373,6 +395,16 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
} }
} }
private void hidePagingControl() {
if (gridFooter.isVisible())
gridFooter.setVisible(false);
}
private void showPagingControl() {
if (!gridFooter.isVisible())
gridFooter.setVisible(true);
}
/** /**
* *
*/ */
@ -530,20 +562,20 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
paging.setPageSize(pageSize); paging.setPageSize(pageSize);
paging.setTotalSize(tableModel.getRowCount()); paging.setTotalSize(tableModel.getRowCount());
paging.setDetailed(true); paging.setDetailed(true);
paging.setId("paging");
gridFooter.appendChild(paging); gridFooter.appendChild(paging);
gridFooter.setSclass("adtab-grid-south");
paging.addEventListener(ZulEvents.ON_PAGING, this); paging.addEventListener(ZulEvents.ON_PAGING, this);
renderer.setPaging(paging); renderer.setPaging(paging);
if (paging.getPageCount() == 1) { if (paging.getPageCount() == 1) {
gridFooter.setVisible(false); hidePagingControl();
} else { } else {
gridFooter.setVisible(true); showPagingControl();
} }
paging.setId("paging"); positionPagingControl();
} }
else else
{ {
gridFooter.setVisible(false); hidePagingControl();
} }
} }
@ -1055,4 +1087,38 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
break; break;
} }
} }
protected void onADTabPanelParentChanged() {
positionPagingControl();
}
private void positionPagingControl() {
if (isDetailPane()) {
Component parent = this.getParent();
while (parent != null) {
if (parent instanceof Tabpanel) {
Component firstChild = parent.getFirstChild();
if ( gridFooter.getParent() != firstChild ) {
firstChild.appendChild(gridFooter);
gridFooter.setHflex("0");
gridFooter.setSclass("adwindow-detailpane-adtab-grid-south");
}
break;
}
parent = parent.getParent();
}
if (paging != null)
paging.setDetailed(false);
}
else
{
if (gridFooter.getParent() != this) {
gridFooter.setHflex("1");
gridFooter.setSclass("adtab-grid-south");
appendChild(gridFooter);
}
if (paging != null)
paging.setDetailed(true);
}
}
} }

View File

@ -856,6 +856,23 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
background-color: #D3D3D3; background-color: #D3D3D3;
} }
.adwindow-detailpane-adtab-grid-south {
background-color: transparent;
position: absolute;
right: 0px;
top: 0px;
height: 24px;
}
.adwindow-detailpane-adtab-grid-south .z-paging {
padding: 0px !important;
}
.adwindow-detailpane-adtab-grid-south .z-paging .z-paging-inp {
height: 16px;
line-height: 16px;
}
.adwindow-gridview-detail { .adwindow-gridview-detail {
height: 200px; height: 200px;
} }
@ -956,6 +973,10 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
background-image: none !important; background-image: none !important;
} }
div.z-column-cnt, div.z-grid-header div.z-auxheader-cnt {
padding: 4px 2px 3px;
}
.form-label .form-label
{ {
text-align: right; text-align: right;