IDEMPIERE-369 Master Detail layout improvements. Fixed click on row indicator not working in header grid view. Single click instead of double click to maximize selected detail tab. Not to auto switch to form view for the detail record icon and the click to maximize selected tab action.

This commit is contained in:
Heng Sin Low 2013-01-02 20:54:49 +08:00
parent 147b55cd26
commit d112a9c316
6 changed files with 69 additions and 49 deletions

View File

@ -246,25 +246,30 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
ctrl = ExecutionsCtrl.getCurrentCtrl();
((DesktopCtrl)Executions.getCurrent().getDesktop()).setVisualizer(vi);
//detach root component from old page
//detach root component from old page
Page page = appDesktop.getComponent().getPage();
Collection<?> collection = page.getRoots();
Object[] objects = new Object[0];
objects = collection.toArray(objects);
for(Object obj : objects) {
try {
if (obj instanceof Component) {
((Component)obj).detach();
rootComponents.add((Component) obj);
if (page.getDesktop() != null) {
Collection<?> collection = page.getRoots();
Object[] objects = new Object[0];
objects = collection.toArray(objects);
for(Object obj : objects) {
try {
if (obj instanceof Component) {
((Component)obj).detach();
rootComponents.add((Component) obj);
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
// e.printStackTrace();
}
appDesktop.getComponent().detach();
DesktopCache desktopCache = ((SessionCtrl)currSess).getDesktopCache();
if (desktopCache != null)
desktopCache.removeDesktop(Executions.getCurrent().getDesktop());
} else {
appDesktop = null;
}
appDesktop.getComponent().detach();
DesktopCache desktopCache = ((SessionCtrl)currSess).getDesktopCache();
if (desktopCache != null)
desktopCache.removeDesktop(Executions.getCurrent().getDesktop());
} catch (Exception e) {
e.printStackTrace();
appDesktop = null;

View File

@ -69,6 +69,7 @@ import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.au.out.AuFocus;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.IdSpace;
@ -106,6 +107,8 @@ import org.zkoss.zul.impl.XulElement;
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
DataStatusListener, IADTabpanel, IdSpace
{
public static final String ON_POST_INIT_EVENT = "onPostInit";
public static final String ON_SWITCH_VIEW_EVENT = "onSwitchView";
public static final String ON_DYNAMIC_DISPLAY_EVENT = "onDynamicDisplay";
@ -190,7 +193,7 @@ DataStatusListener, IADTabpanel, IdSpace
removeAttribute(ATTR_ON_ACTIVATE_POSTED);
}
});
addEventListener("onPostInit", this);
addEventListener(ON_POST_INIT_EVENT, this);
}
private void initComponents()
@ -498,7 +501,10 @@ DataStatusListener, IADTabpanel, IdSpace
//stretch component to fill grid cell
editor.fillHorizontal();
editor.getComponent().setId(field.getColumnName());
Component fellow = editor.getComponent().getFellowIfAny(field.getColumnName());
if (fellow == null) {
editor.getComponent().setId(field.getColumnName());
}
//setup editor context menu
WEditorPopupMenu popupMenu = editor.getPopupMenu();
@ -932,9 +938,14 @@ DataStatusListener, IADTabpanel, IdSpace
else if (WPaymentEditor.ON_SAVE_PAYMENT.equals(event.getName())) {
windowPanel.onSavePayment();
}
else if ("onPostInit".equals(event.getName())) {
else if (ON_POST_INIT_EVENT.equals(event.getName())) {
if (detailPane != null) {
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, detailPane));
Desktop desktop = Executions.getCurrent().getDesktop();
//for unknown reason, this is needed once per desktop to fixed the layout of the detailpane.
if (desktop.getAttribute("adtabpanel.detailpane.postinit.redraw") == null) {
desktop.setAttribute("adtabpanel.detailpane.postinit.redraw", Boolean.TRUE);
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, detailPane));
}
}
}
}

View File

@ -586,7 +586,7 @@ 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.getSelectedTabpanel()));
Events.echoEvent(new Event(ADTabpanel.ON_POST_INIT_EVENT, adTabbox.getSelectedTabpanel()));
}
/**

View File

@ -87,11 +87,12 @@ public class CompositeADTabbox extends AbstractADTabbox
final int row = detailPane.getSelectedADTabpanel() != null
? detailPane.getSelectedADTabpanel().getGridTab().getCurrentRow()
: 0;
final boolean formView = event.getData() != null ? (Boolean)event.getData() : true;
adWindowPanel.saveAndNavigate(new Callback<Boolean>() {
@Override
public void onCallback(Boolean result) {
if (result)
onEditDetail(row);
onEditDetail(row, formView);
}
});
}
@ -105,7 +106,7 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override
public void onCallback(Boolean result) {
if (result) {
onEditDetail(row);
onEditDetail(row, true);
if (!adWindowPanel.getActiveGridTab().isNew())
adWindowPanel.onNew();
}
@ -136,7 +137,7 @@ public class CompositeADTabbox extends AbstractADTabbox
});
}
protected void onEditDetail(int row) {
protected void onEditDetail(int row, boolean formView) {
int oldIndex = selectedIndex;
IADTabpanel selectedPanel = detailPane.getSelectedADTabpanel();
if (selectedPanel == null) return;
@ -150,7 +151,7 @@ public class CompositeADTabbox extends AbstractADTabbox
}
headerTab.setDetailPaneMode(false);
if (headerTab.isGridView()) {
if (formView && headerTab.isGridView()) {
headerTab.switchRowPresentation();
}
headerTab.getGridTab().setCurrentRow(row, true);
@ -213,9 +214,6 @@ public class CompositeADTabbox extends AbstractADTabbox
if (b != null && b.booleanValue()) {
activateDetailADTabpanel();
}
if (selectedIndex > 0 && tabPanel.isGridView()) {
tabPanel.switchRowPresentation();
}
} else {
onActivateDetail(tabPanel);
}
@ -274,7 +272,7 @@ public class CompositeADTabbox extends AbstractADTabbox
if (tabPanel == headerTab) {
adWindowPanel.onToggle();
} else {
detailPane.onEdit();
detailPane.onEdit(true);
}
}
@ -285,7 +283,7 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override
public void onEvent(Event event) throws Exception {
GridView gridView = (GridView) event.getTarget();
if (gridView.getParent() == headerTab) {
if (!gridView.isDetailPaneMode()) {
adWindowPanel.onToggle();
}
}
@ -549,7 +547,7 @@ public class CompositeADTabbox extends AbstractADTabbox
public void onDetailRecord() {
if (detailPane != null && detailPane.getSelectedADTabpanel() != null) {
try {
detailPane.onEdit();
detailPane.onEdit(false);
} catch (Exception e) {}
}
}

View File

@ -46,6 +46,8 @@ import org.zkoss.zul.Toolbar;
*/
public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
private static final String TABBOX_ONSELECT_ATTRIBUTE = "detailpane.tabbox.onselect";
public static final String ON_POST_SELECT_TAB_EVENT = "onPostSelectTab";
private static final String STATUS_TEXT_ATTRIBUTE = "status.text";
@ -95,7 +97,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
@Override
public void onEvent(Event event) throws Exception {
fireActivateDetailEvent();
Events.postEvent(new Event(ON_POST_SELECT_TAB_EVENT, DetailPane.this));
Events.postEvent(new Event(ON_POST_SELECT_TAB_EVENT, DetailPane.this));
Executions.getCurrent().setAttribute(TABBOX_ONSELECT_ATTRIBUTE, Boolean.TRUE);
}
});
tabbox.setSclass("adwindow-detailpane-tabbox");
@ -104,10 +107,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
this.setSclass("adwindow-detailpane");
addEventListener(LayoutUtils.ON_REDRAW_EVENT, this);
addEventListener("onPostInit", this);
addEventListener(LayoutUtils.ON_REDRAW_EVENT, this);
setId("detailPane");
}
@ -154,12 +155,16 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
tab.setSclass("adwindow-detailpane-sub-tab");
}
tab.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener<Event>() {
tab.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Tab tab = (Tab) event.getTarget();
if (!tab.isSelected())
return;
if (Executions.getCurrent().getAttribute(TABBOX_ONSELECT_ATTRIBUTE) != null)
return;
org.zkoss.zul.Tabpanel zkTabpanel = tab.getLinkedPanel();
IADTabpanel adtab = null;
for(Component c : zkTabpanel.getChildren()) {
@ -169,7 +174,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
}
}
if (adtab != null && adtab.isDetailPaneMode()) {
onEdit();
onEdit(false);
}
}
});
@ -207,7 +212,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
button.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
onEdit();
onEdit(true);
}
});
button.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord")));
@ -259,7 +264,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
public void onEvent(Event event) throws Exception {
GridView gridView = (GridView) event.getTarget();
if (gridView.isDetailPaneMode())
onEdit();
onEdit(true);
}
});
}
@ -407,14 +412,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
return;
}
LayoutUtils.redraw(this);
} else if (event.getName().equals("onPostInit")) {
IADTabpanel adtabpanel = getSelectedADTabpanel();
if (adtabpanel != null) {
GridView gridView = adtabpanel.getGridView();
if (gridView != null && gridView.getListbox() != null)
Clients.resize(gridView.getListbox());
}
}
}
}
protected void createPopupContent(String status) {
@ -518,8 +516,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
}
}
public void onEdit() throws Exception {
Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this);
public void onEdit(boolean formView) throws Exception {
Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this, Boolean.valueOf(formView));
eventListener.onEvent(openEvent);
}

View File

@ -522,6 +522,14 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
overflow-y: visible;
}
.adwindow-detailpane-tabbox .z-tab-seld span.z-tab-text {
cursor: pointer;
}
.adwindow-detailpane-tabbox .z-tab-seld span.z-tab-text:hover {
text-decoration: underline;
}
.adwindow-detailpane-tabpanel {
background-color: #fff
}