use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class NavBar2Desktop method doCreatePart.
protected Component doCreatePart(Component parent) {
SidePanel pnlSide = new SidePanel();
HeaderPanel pnlHead = new HeaderPanel();
pnlSide.getMenuPanel().addMenuListener(this);
layout = new Borderlayout();
if (parent != null) {
layout.setParent(parent);
layout.setWidth("100%");
layout.setHeight("100%");
layout.setStyle("position: absolute");
} else
layout.setPage(page);
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
North n = new North();
n.setSplittable(true);
n.setCollapsible(false);
layout.appendChild(n);
pnlHead.setParent(n);
West w = new West();
layout.appendChild(w);
w.setWidth("300px");
w.setCollapsible(true);
w.setSplittable(true);
w.setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Menu")));
//w.setHflex("true");
w.setVflex("true");
w.addEventListener(Events.ON_OPEN, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
OpenEvent oe = (OpenEvent) event;
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
pref.setProperty(UserPreference.P_MENU_COLLAPSED, !oe.isOpen());
pref.savePreference();
}
});
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
boolean menuCollapsed = pref.isPropertyBool(UserPreference.P_MENU_COLLAPSED);
w.setOpen(!menuCollapsed);
pnlSide.setParent(w);
Center center = new Center();
center.setParent(layout);
center.setHflex("true");
center.setVflex("true");
Borderlayout innerLayout = new Borderlayout();
innerLayout.setHeight("100%");
innerLayout.setWidth("100%");
innerLayout.setParent(center);
West innerW = new West();
innerW.setWidth("200px");
innerW.setCollapsible(true);
innerW.setTitle("Navigation");
innerW.setSplittable(true);
innerW.setCollapsible(true);
innerW.setParent(innerLayout);
shortcutPanel = new Accordion();
shortcutPanel.setWidth("100%");
shortcutPanel.setHeight("100%");
innerW.appendChild(shortcutPanel);
Div div = new Div();
Executions.createComponents(FAVOURITES_PATH, div, null);
shortcutPanel.add(div, "Favourites");
div = new Div();
Component component = Executions.createComponents(ACTIVITIES_PATH, div, null);
if (component instanceof DashboardPanel) {
DashboardPanel dashboardPanel = (DashboardPanel) component;
dashboardRunnable.add(dashboardPanel);
}
shortcutPanel.add(div, "Activities");
shortcutPanel.setSelectedIndex(0);
windowArea = new Center();
windowArea.setParent(innerLayout);
windowArea.setHflex("true");
windowArea.setVflex("true");
windowContainer.createPart(windowArea);
createHomeTab();
return layout;
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class TabbedDesktop method closeWindow.
/**
*
* @param windowNo
* @return boolean
*/
public boolean closeWindow(int windowNo) {
Tabbox tabbox = windowContainer.getComponent();
Tabpanels panels = tabbox.getTabpanels();
List<?> childrens = panels.getChildren();
for (Object child : childrens) {
Tabpanel panel = (Tabpanel) child;
Component component = panel.getFirstChild();
Object att = component.getAttribute(WINDOWNO_ATTRIBUTE);
if (att != null && (att instanceof Integer)) {
if (windowNo == (Integer) att) {
Tab tab = panel.getLinkedTab();
panel.getLinkedTab().onClose();
if (tab.getParent() == null) {
unregisterWindow(windowNo);
return true;
} else {
return false;
}
}
}
}
return false;
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class DPActivities method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof Button) {
Button btn = (Button) comp;
int menuId = 0;
try {
menuId = Integer.valueOf(btn.getName());
} catch (Exception e) {
}
if (menuId > 0)
SessionManager.getAppDesktop().onMenuSelected(menuId);
}
}
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class WindowContainer method insertBefore.
/**
*
* @param refTab
* @param comp
* @param title
* @param closeable
* @param enable
*/
public void insertBefore(Tab refTab, Component comp, String title, boolean closeable, boolean enable) {
Tab tab = new Tab();
title = title.replaceAll("[&]", "");
if (title.length() <= MAX_TITLE_LENGTH) {
tab.setLabel(title);
} else {
tab.setTooltiptext(title);
title = title.substring(0, 27) + "...";
tab.setLabel(title);
}
tab.setClosable(closeable);
// fix scroll position lost coming back into a grid view tab
tab.addEventListener(Events.ON_SELECT, new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
Tab tab = (Tab) event.getTarget();
org.zkoss.zul.Tabpanel panel = tab.getLinkedPanel();
Component component = panel.getFirstChild();
if (component != null && component.getAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY) instanceof ITabOnSelectHandler) {
ITabOnSelectHandler handler = (ITabOnSelectHandler) component.getAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY);
handler.onSelect();
}
}
});
Tabpanel tabpanel = null;
if (comp instanceof Tabpanel) {
tabpanel = (Tabpanel) comp;
} else {
tabpanel = new Tabpanel();
tabpanel.appendChild(comp);
}
tabpanel.setZclass("desktop-tabpanel");
tabpanel.setHeight("100%");
tabpanel.setWidth("100%");
tabpanel.setStyle("position: relative;");
if (refTab == null) {
tabbox.getTabs().appendChild(tab);
tabbox.getTabpanels().appendChild(tabpanel);
} else {
org.zkoss.zul.Tabpanel refpanel = refTab.getLinkedPanel();
tabbox.getTabs().insertBefore(tab, refTab);
tabbox.getTabpanels().insertBefore(tabpanel, refpanel);
}
if (enable)
setSelectedTab(tab);
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class MenuPanel method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof Treerow) {
Treeitem selectedItem = (Treeitem) comp.getParent();
if (selectedItem.getValue() != null) {
fireMenuSelectedEvent(selectedItem);
} else {
selectedItem.setOpen(!selectedItem.isOpen());
}
}
} else // Elaine 2009/02/27 - expand tree
if (eventName.equals(Events.ON_CHECK) && event.getTarget() == chkExpand) {
expandOnCheck();
}
//
}
Aggregations