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();
}
//
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class GridTabListItemRenderer method render.
/**
* @param listitem
* @param data
* @see ListitemRenderer#render(Listitem, Object)
*/
public void render(Listitem listitem, Object data, int arg2) throws Exception {
//don't render if not visible
for (Component c = listitem.getParent(); c != null; c = c.getParent()) {
if (!c.isVisible())
return;
}
Object[] values = (Object[]) data;
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
for (int i = 0; i < columnCount; i++) {
if (!(gridField[i].isDisplayed() && gridField[i].isDisplayedGrid())) {
continue;
}
if (editors.get(gridField[i]) == null)
editors.put(gridField[i], WebEditorFactory.getEditor(gridField[i], true));
int rowIndex = listitem.getIndex();
if (paging != null && paging.getPageSize() > 0) {
rowIndex = (paging.getActivePage() * paging.getPageSize()) + rowIndex;
}
Listcell cell = null;
if (rowIndex == gridTab.getCurrentRow() && gridField[i].isEditable(true)) {
cell = getEditorCell(gridField[i], values[i], i);
cell.setParent(listitem);
} else {
if (gridField[i].getDisplayType() == DisplayType.YesNo) {
cell = new Listcell("", null);
cell.setParent(listitem);
cell.setStyle("text-align:center");
createReadonlyCheckbox(values[i], cell);
} else {
String text = getDisplayText(values[i], i);
String display = text;
if (text != null && text.length() > MAX_TEXT_LENGTH)
display = text.substring(0, MAX_TEXT_LENGTH - 3) + "...";
cell = new Listcell(display, null);
cell.setParent(listitem);
if (text != null && text.length() > MAX_TEXT_LENGTH)
cell.setTooltiptext(text);
if (DisplayType.isNumeric(gridField[i].getDisplayType())) {
cell.setStyle("text-align:right");
} else if (gridField[i].getDisplayType() == DisplayType.Image) {
cell.setStyle("text-align:center");
}
}
}
CellListener listener = new CellListener((Listbox) listitem.getParent());
cell.addEventListener(Events.ON_DOUBLE_CLICK, listener);
}
}
Aggregations