IDEMPIERE-357 Move the Menu to be a Portlet. Remove unnecessary appendChild. Always hide the popup container first before the opening of window.

This commit is contained in:
Heng Sin Low 2012-08-22 17:41:31 +08:00
parent 98d4cd4a89
commit 0050af3c3a
2 changed files with 58 additions and 25 deletions

View File

@ -40,6 +40,7 @@ import org.zkoss.zk.ui.event.EventQueues;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.A;
import org.zkoss.zul.Panel;
import org.zkoss.zul.Popup;
import org.zkoss.zul.Toolbarbutton;
import org.zkoss.zul.Tree;
import org.zkoss.zul.Treecell;
@ -277,26 +278,7 @@ public abstract class AbstractMenuPanel extends Panel implements EventListener<E
{
if (newRecord)
{
try
{
int menuId = Integer.parseInt((String)selectedItem.getValue());
MMenu menu = new MMenu(Env.getCtx(), menuId, null);
MQuery query = new MQuery("");
query.addRestriction("1=2");
query.setRecordCount(0);
ADWindow frame = SessionManager.getAppDesktop().openWindow(menu.getAD_Window_ID(), query);
if(frame == null)
return;
GridTab tab = frame.getADWindowPanel().getActiveGridTab();
tab.dataNew(false);
}
catch (Exception e)
{
throw new ApplicationException(e.getMessage(), e);
}
onNewRecord(selectedItem);
}
else
{
@ -310,11 +292,42 @@ public abstract class AbstractMenuPanel extends Panel implements EventListener<E
}
}
private void onNewRecord(Treeitem selectedItem) {
try
{
int menuId = Integer.parseInt((String)selectedItem.getValue());
MMenu menu = new MMenu(Env.getCtx(), menuId, null);
MQuery query = new MQuery("");
query.addRestriction("1=2");
query.setRecordCount(0);
if (getParent() instanceof Popup) {
((Popup)getParent()).close();
}
ADWindow frame = SessionManager.getAppDesktop().openWindow(menu.getAD_Window_ID(), query);
if(frame == null)
return;
GridTab tab = frame.getADWindowPanel().getActiveGridTab();
tab.dataNew(false);
}
catch (Exception e)
{
throw new ApplicationException(e.getMessage(), e);
}
}
protected void fireMenuSelectedEvent(Treeitem selectedItem) {
int nodeId = Integer.parseInt((String)selectedItem.getValue());
try
{
if (getParent() instanceof Popup) {
((Popup)getParent()).close();
}
SessionManager.getAppDesktop().onMenuSelected(nodeId);
}
catch (Exception e)

View File

@ -25,6 +25,7 @@ import org.adempiere.webui.window.AboutWindow;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -87,16 +88,14 @@ public class HeaderPanel extends Panel implements EventListener<Event>
popMenu = new Popup();
popMenu.setId("menuTreePopup");
popMenu.appendChild(new MenuTreePanel(popMenu));
new MenuTreePanel(popMenu);
popMenu.setWidth("600px");
popMenu.setHeight("90%");
popMenu.setParent(hbox);
btnMenu = new ToolBarButton();
btnMenu.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(),"Menu")));
LayoutUtils.addSclass("desktop-header-font", btnMenu);
btnMenu.setParent(hbox);
btnMenu.setPopup("menuTreePopup");
btnMenu.addEventListener(Events.ON_CLICK, this);
LayoutUtils.addSclass("desktop-header-left", west);
@ -130,4 +129,25 @@ public class HeaderPanel extends Panel implements EventListener<Event>
}
}
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.AbstractComponent#onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)
*/
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
if (newpage != null)
popMenu.setPage(newpage);
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.AbstractComponent#onPageDetached(org.zkoss.zk.ui.Page)
*/
@Override
public void onPageDetached(Page page) {
super.onPageDetached(page);
popMenu.setPage(null);
}
}