Search in sources :

Example 51 with Component

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;
}
Also used : Tab(org.zkoss.zul.Tab) Tabpanels(org.zkoss.zul.Tabpanels) Tabbox(org.adempiere.webui.component.Tabbox) Component(org.zkoss.zk.ui.Component) Tabpanel(org.adempiere.webui.component.Tabpanel) DesktopTabpanel(org.adempiere.webui.component.DesktopTabpanel)

Example 52 with Component

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);
        }
    }
}
Also used : Button(org.adempiere.webui.component.Button) Component(org.zkoss.zk.ui.Component)

Example 53 with Component

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);
}
Also used : Tab(org.adempiere.webui.component.Tab) Event(org.zkoss.zk.ui.event.Event) Component(org.zkoss.zk.ui.Component) Tabpanel(org.adempiere.webui.component.Tabpanel)

Example 54 with Component

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();
    }
//
}
Also used : Treeitem(org.zkoss.zul.Treeitem) Component(org.zkoss.zk.ui.Component) Treerow(org.zkoss.zul.Treerow)

Example 55 with Component

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);
    }
}
Also used : Listcell(org.zkoss.zul.Listcell) GridField(org.compiere.model.GridField) Component(org.zkoss.zk.ui.Component)

Aggregations

Component (org.zkoss.zk.ui.Component)70 IOException (java.io.IOException)8 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)8 Checkbox (org.adempiere.webui.component.Checkbox)7 ToolBarButton (org.adempiere.webui.component.ToolBarButton)7 Div (org.zkoss.zul.Div)7 Listitem (org.zkoss.zul.Listitem)7 MapLayer (au.org.emii.portal.menu.MapLayer)6 Button (org.adempiere.webui.component.Button)6 Tabpanel (org.adempiere.webui.component.Tabpanel)6 WEditor (org.adempiere.webui.editor.WEditor)6 ParseException (org.json.simple.parser.ParseException)6 Event (org.zkoss.zk.ui.event.Event)6 MapComposer (au.org.emii.portal.composer.MapComposer)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 DashboardPanel (org.adempiere.webui.dashboard.DashboardPanel)5 HeaderPanel (org.adempiere.webui.panel.HeaderPanel)5 SidePanel (org.adempiere.webui.panel.SidePanel)5 UiException (org.zkoss.zk.ui.UiException)5