IDEMPIERE-2005 Improvement to collapsed page header mode.

This commit is contained in:
Heng Sin Low 2014-06-19 17:29:05 +08:00
parent 330253aa89
commit c6e660ca50
4 changed files with 110 additions and 9 deletions

View File

@ -27,6 +27,7 @@ import org.adempiere.base.event.IEventManager;
import org.adempiere.base.event.IEventTopics; import org.adempiere.base.event.IEventTopics;
import org.adempiere.model.MBroadcastMessage; import org.adempiere.model.MBroadcastMessage;
import org.adempiere.util.ServerContext; import org.adempiere.util.ServerContext;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.adwindow.ADWindow;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.BusyDialog; import org.adempiere.webui.apps.BusyDialog;
@ -37,6 +38,7 @@ import org.adempiere.webui.component.Tab;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.component.ToolBar;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DrillEvent; import org.adempiere.webui.event.DrillEvent;
import org.adempiere.webui.event.MenuListener; import org.adempiere.webui.event.MenuListener;
import org.adempiere.webui.event.ZKBroadCastManager; import org.adempiere.webui.event.ZKBroadCastManager;
@ -111,6 +113,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
private static final String IMAGES_DOWNARROW_PNG = "images/expand-header.png"; private static final String IMAGES_DOWNARROW_PNG = "images/expand-header.png";
private static final String IMAGES_CONTEXT_HELP_PNG = "images/Help16.png"; private static final String IMAGES_CONTEXT_HELP_PNG = "images/Help16.png";
private static final String IMAGES_THREELINE_MENU_PNG = "images/threelines.png";
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class); private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class);
@ -138,6 +142,12 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
private ToolBarButton max; private ToolBarButton max;
private ToolBarButton contextHelp; private ToolBarButton contextHelp;
private ToolBarButton showHeader;
private Component headerContainer;
private Window headerPopup;
public DefaultDesktop() public DefaultDesktop()
{ {
@ -156,12 +166,14 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
queue.subscribe(this); queue.subscribe(this);
} }
protected Component doCreatePart(Component parent) @SuppressWarnings("serial")
protected Component doCreatePart(Component parent)
{ {
PageDefinition pagedef = Executions.getCurrent().getPageDefinition(ThemeManager.getThemeResource("zul/desktop/desktop.zul")); PageDefinition pagedef = Executions.getCurrent().getPageDefinition(ThemeManager.getThemeResource("zul/desktop/desktop.zul"));
Component page = Executions.createComponents(pagedef, parent, null); Component page = Executions.createComponents(pagedef, parent, null);
layout = (Borderlayout) page.getFellow("layout"); layout = (Borderlayout) page.getFellow("layout");
pnlHead = (HeaderPanel) page.getFellow("northBody").getFellow("header"); headerContainer = page.getFellow("northBody");
pnlHead = (HeaderPanel) headerContainer.getFellow("header");
layout.addEventListener("onZoom", this); layout.addEventListener("onZoom", this);
layout.addEventListener(DrillEvent.ON_DRILL_DOWN, this); layout.addEventListener(DrillEvent.ON_DRILL_DOWN, this);
@ -272,6 +284,23 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
ToolBar toolbar = new ToolBar(); ToolBar toolbar = new ToolBar();
windowContainer.getComponent().appendChild(toolbar); windowContainer.getComponent().appendChild(toolbar);
showHeader = new ToolBarButton() {
@Override
public void onPageDetached(Page page) {
super.onPageDetached(page);
if (DefaultDesktop.this.headerPopup != null) {
DefaultDesktop.this.headerPopup.setPage(null);
}
}
};
toolbar.appendChild(showHeader);
showHeader.setImage(ThemeManager.getThemeResource(IMAGES_THREELINE_MENU_PNG));
showHeader.addEventListener(Events.ON_CLICK, this);
showHeader.setSclass("window-container-toolbar-btn");
showHeader.setStyle("cursor: pointer; border: 1px solid transparent; padding: 2px;");
showHeader.setVisible(false);
max = new ToolBarButton(); max = new ToolBarButton();
toolbar.appendChild(max); toolbar.appendChild(max);
max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG)); max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG));
@ -288,6 +317,11 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
contextHelp.setTooltiptext(Util.cleanAmp(Msg.getElement(Env.getCtx(), "AD_CtxHelp_ID"))); contextHelp.setTooltiptext(Util.cleanAmp(Msg.getElement(Env.getCtx(), "AD_CtxHelp_ID")));
contextHelp.setVisible(!e.isVisible()); contextHelp.setVisible(!e.isVisible());
boolean headerCollapsed= pref.isPropertyBool(UserPreference.P_HEADER_COLLAPSED);
if (headerCollapsed) {
collapseHeader();
}
return layout; return layout;
} }
@ -302,6 +336,12 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
pref.setProperty(UserPreference.P_HELP_COLLAPSED, collapsed); pref.setProperty(UserPreference.P_HELP_COLLAPSED, collapsed);
pref.savePreference(); pref.savePreference();
} }
private void updateHeaderCollapsedPreference(boolean collapsed) {
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
pref.setProperty(UserPreference.P_HEADER_COLLAPSED, collapsed);
pref.savePreference();
}
public void renderHomeTab() public void renderHomeTab()
{ {
@ -330,15 +370,20 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
{ {
if (layout.getNorth().isVisible()) if (layout.getNorth().isVisible())
{ {
layout.getNorth().setVisible(false); collapseHeader();
max.setImage(ThemeManager.getThemeResource(IMAGES_DOWNARROW_PNG));
} }
else else
{ {
layout.getNorth().setVisible(true); restoreHeader();
max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG));
} }
} }
else if (comp == showHeader)
{
showHeader.setPressed(true);
if (pnlHead.getParent() != headerPopup)
headerPopup.appendChild(pnlHead);
LayoutUtils.openPopupWindow(showHeader, headerPopup, "after_start");
}
else if (comp == contextHelp) else if (comp == contextHelp)
{ {
layout.getEast().setVisible(true); layout.getEast().setVisible(true);
@ -405,6 +450,42 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
} }
} }
protected void restoreHeader() {
layout.getNorth().setVisible(true);
max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG));
showHeader.setVisible(false);
pnlHead.detach();
headerContainer.appendChild(pnlHead);
Clients.resize(pnlHead);
updateHeaderCollapsedPreference(false);
}
protected void collapseHeader() {
layout.getNorth().setVisible(false);
max.setImage(ThemeManager.getThemeResource(IMAGES_DOWNARROW_PNG));
showHeader.setVisible(true);
pnlHead.detach();
if (headerPopup == null)
{
headerPopup = new Window();
headerPopup.setWidth("100%");
headerPopup.setVflex("true");
headerPopup.setShadow(true);
headerPopup.setVisible(false);
headerPopup.addEventListener(Events.ON_OPEN, new EventListener<OpenEvent>() {
@Override
public void onEvent(OpenEvent event) throws Exception {
if (!event.isOpen()) {
if (showHeader.isPressed())
showHeader.setPressed(false);
}
}
});
}
headerPopup.appendChild(pnlHead);
updateHeaderCollapsedPreference(true);
}
/** /**
* Execute Drill to Query * Execute Drill to Query
* @param query query * @param query query
@ -654,4 +735,17 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
} }
return false; return false;
} }
@Override
public void onMenuSelected(int menuId) {
super.onMenuSelected(menuId);
if (showHeader.isVisible()) {
//ensure header popup is close
String script = "var w=zk.Widget.$('#" + layout.getUuid()+"'); " +
"zWatch.fire('onFloatUp', w);";
Clients.response(new AuScript(script));
}
}
} }

View File

@ -122,7 +122,8 @@ public class HeaderPanel extends Panel implements EventListener<Event>
@Override @Override
public void onPageDetached(Page page) { public void onPageDetached(Page page) {
super.onPageDetached(page); super.onPageDetached(page);
popMenu.setPage(null); if (popMenu != null)
popMenu.setPage(null);
} }

View File

@ -67,6 +67,10 @@ public final class UserPreference implements Serializable {
/** Help Panel Collapsed **/ /** Help Panel Collapsed **/
public static final String P_HELP_COLLAPSED = "HelpCollapsed"; public static final String P_HELP_COLLAPSED = "HelpCollapsed";
public static final String DEFAULT_HELP_COLLAPSED = "N"; public static final String DEFAULT_HELP_COLLAPSED = "N";
/** Header Collapsed **/
public static final String P_HEADER_COLLAPSED = "HeaderCollapsed";
public static final String DEFAULT_HEADER_COLLAPSED = "N";
/** Ini Properties */ /** Ini Properties */
private static final String[] PROPERTIES = new String[] { private static final String[] PROPERTIES = new String[] {
@ -78,7 +82,8 @@ public final class UserPreference implements Serializable {
P_AUTO_COMMIT, P_AUTO_COMMIT,
P_AUTO_NEW, P_AUTO_NEW,
P_MENU_COLLAPSED, P_MENU_COLLAPSED,
P_HELP_COLLAPSED}; P_HELP_COLLAPSED,
P_HEADER_COLLAPSED};
/** Ini Property Values */ /** Ini Property Values */
private static final String[] VALUES = new String[] { private static final String[] VALUES = new String[] {
DEFAULT_LANGUAGE, DEFAULT_LANGUAGE,
@ -89,7 +94,8 @@ public final class UserPreference implements Serializable {
DEFAULT_AUTO_COMMIT, DEFAULT_AUTO_COMMIT,
DEFAULT_AUTO_NEW, DEFAULT_AUTO_NEW,
DEFAULT_MENU_COLLAPSED, DEFAULT_MENU_COLLAPSED,
DEFAULT_HELP_COLLAPSED}; DEFAULT_HELP_COLLAPSED,
DEFAULT_HEADER_COLLAPSED};
/** Container for Properties */ /** Container for Properties */
private Properties props = new Properties(); private Properties props = new Properties();

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B