Search in sources :

Example 26 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class DPActivities method updateUI.

@Override
public void updateUI() {
    //don't update if not visible
    Component c = this.getParent();
    while (c != null) {
        if (!c.isVisible())
            return;
        c = c.getParent();
    }
    btnNotice.setLabel(Msg.translate(Env.getCtx(), "AD_Note_ID") + " : " + noOfNotice);
    btnRequest.setLabel(Msg.translate(Env.getCtx(), "R_Request_ID") + " : " + noOfRequest);
    btnWorkflow.setLabel(Msg.getMsg(Env.getCtx(), "WorkflowActivities") + " : " + noOfWorkflow);
}
Also used : Component(org.zkoss.zk.ui.Component)

Example 27 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class TabbedDesktop method closeActiveWindow.

/**
	 * Close active tab
	 * @return boolean
	 */
public boolean closeActiveWindow() {
    if (windowContainer.getSelectedTab() != null) {
        Tabpanel panel = (Tabpanel) windowContainer.getSelectedTab().getLinkedPanel();
        Component component = panel.getFirstChild();
        Object att = component.getAttribute(WINDOWNO_ATTRIBUTE);
        if (windowContainer.closeActiveWindow()) {
            if (att != null && (att instanceof Integer)) {
                unregisterWindow((Integer) att);
            }
            return true;
        } else {
            return false;
        }
    }
    return false;
}
Also used : Component(org.zkoss.zk.ui.Component) Tabpanel(org.adempiere.webui.component.Tabpanel) DesktopTabpanel(org.adempiere.webui.component.DesktopTabpanel)

Example 28 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class InfoPanel method onEvent.

//	getAD_Window_ID
public void onEvent(Event event) {
    if (!p_loadedOK)
        //  We aren't ready
        return;
    if (m_busy)
        //  We're busy.  Ignore events.
        return;
    if (event != null) {
        if (event.getName().equals("onOK")) {
            //  The enter key was pressed in a criteria field.  Ignore it.  The key click will trigger
            //  other events that will be trapped.
            event.stopPropagation();
            return;
        }
        Component component = event.getTarget();
        if (component != null) {
            //  Generic components in the criteria fields
            if (component instanceof Textbox) {
                Textbox tb = ((Textbox) component);
                if (tb.hasChanged()) {
                    p_triggerRefresh = true;
                } else {
                    // if the dialog was opened from a menu.
                    if (isModal())
                        //  Save the selection and close;
                        dispose(true);
                    else
                        return;
                }
            } else if (component instanceof Checkbox) {
                //  Check box changes generally always cause a refresh
                //  Capture changes that don't in a specific event handler
                p_triggerRefresh = true;
                Checkbox cb = (Checkbox) component;
                if (cb.getName() != null && cb.getName().equals("AutoQuery")) {
                    //  Only trigger a refresh if the check box is selected
                    if (!cb.isSelected()) {
                        return;
                    }
                }
            } else {
                //  Assume another type of component
                if (event.getName().equals("onChange")) {
                    if (component instanceof Combobox) {
                        if (//  Test for meaningful changes. Null == " ".
                        hasOutstandingChanges())
                            p_triggerRefresh = true;
                    } else
                        p_triggerRefresh = true;
                }
            }
            //  Buttons
            if (component.equals(confirmPanel.getButton(ConfirmPanel.A_OK))) {
                //  VLookup fields in the criteria
                if (hasOutstandingChanges()) {
                    return;
                } else {
                    // We might close
                    p_triggerRefresh = false;
                }
                onOk();
            } else if (component == p_table && event.getName().equals(Events.ON_DOUBLE_CLICK)) {
                onDoubleClick();
            } else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_RESET))) {
                //  Created by the reset button, if used, to reset the criteria panel.
                //  Go back to the defaults
                // Prevent other actions
                m_busy = true;
                // Should be overridden in the subordinate class
                initInfo();
                m_busy = false;
                p_triggerRefresh = true;
                // Ignore the autoQuery value and refresh now.
                p_refreshNow = true;
            } else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH))) {
                //  Refresh always causes a requery in case there are
                //  changes to the underlying tables - even if the 
                //  criteria haven't changed.
                p_resetColumns = true;
                p_triggerRefresh = true;
                p_refreshNow = true;
            } else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CANCEL))) {
                m_cancel = true;
                // close
                dispose(false);
            } else // Elaine 2008/12/16
            if (component.equals(confirmPanel.getButton(ConfirmPanel.A_HISTORY))) {
                if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
                    showHistory();
                }
                return;
            } else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CUSTOMIZE))) {
                if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
                    customize();
                }
                return;
            } else //
            if (component.equals(confirmPanel.getButton(ConfirmPanel.A_ZOOM))) {
                if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
                    zoom();
                    if (isModal())
                        this.detach();
                }
                return;
            } else if (component == paging) {
                int pgNo = paging.getActivePage();
                if (pageNo != pgNo) {
                    p_table.clearSelection();
                    pageNo = pgNo;
                    int start = pageNo * PAGE_SIZE;
                    int end = start + PAGE_SIZE;
                    List<Object> subList = readLine(start, end);
                    model = new ListModelTable(subList);
                    model.setSorter(this);
                    model.addTableModelListener(this);
                    p_table.setData(model, null);
                    p_table.setSelectedIndex(0);
                }
            }
        }
        //  All events, unless trapped above, will get here.
        //  Check if we need to reset the table.  The flag is reset when
        //  the table is reset.  The first change triggers the reset.
        p_resetColumns = p_resetColumns || columnIsDynamic(component);
        // Refresh if the autoquery feature is selected or the refresh button is clicked.
        if ((p_triggerRefresh && autoQuery()) || p_refreshNow) {
            prepareAndExecuteQuery();
            p_refreshNow = false;
        }
    }
}
Also used : Checkbox(org.adempiere.webui.component.Checkbox) Combobox(org.adempiere.webui.component.Combobox) Textbox(org.adempiere.webui.component.Textbox) ListModelTable(org.adempiere.webui.component.ListModelTable) HtmlNativeComponent(org.zkoss.zk.ui.HtmlNativeComponent) Component(org.zkoss.zk.ui.Component)

Example 29 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class InfoPaymentPanel method onEvent.

// initInfo
public void onEvent(Event e) {
    if (!p_loadedOK)
        return;
    Component component = e.getTarget();
    if (component != null) {
        if (component instanceof Checkbox) {
            Checkbox cb = (Checkbox) component;
            // Make the checkboxes exclusive
            if (cb.getName() == "OnlyReceipt") {
                if (fCheckReceipt.isSelected())
                    fCheckPayment.setSelected(false);
            }
            if (cb.getName() == "OnlyPayment") {
                if (fCheckPayment.isSelected())
                    fCheckReceipt.setSelected(false);
            }
        }
    }
    //
    super.onEvent(e);
}
Also used : Checkbox(org.adempiere.webui.component.Checkbox) Component(org.zkoss.zk.ui.Component)

Example 30 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class InfoPAttributePanel method addAttributes.

//	dynInit
/**
	 * 	Add Attributes
	 *	@return rows
	 */
private int addAttributes() {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String whereAttributeSet;
    if (p_M_AttributeSet_ID > 0)
        whereAttributeSet = "AND M_Attribute_ID IN (SELECT M_Attribute_ID FROM M_AttributeUse WHERE M_AttributeSet_ID=" + p_M_AttributeSet_ID + ")";
    else
        whereAttributeSet = "";
    String sql = MRole.getDefault().addAccessSQL("SELECT M_Attribute_ID, Name, Description, AttributeValueType, IsInstanceAttribute " + "FROM M_Attribute " + "WHERE IsActive='Y' " + whereAttributeSet + " ORDER BY IsInstanceAttribute, Name", "M_Attribute", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    boolean instanceLine = false;
    boolean productLine = false;
    try {
        pstmt = DB.prepareStatement(sql, null);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            int attribute_ID = rs.getInt(1);
            String name = rs.getString(2);
            String description = rs.getString(3);
            String attributeValueType = rs.getString(4);
            boolean isInstanceAttribute = "Y".equals(rs.getString(5));
            // Add label for product attributes if there are any
            if (!productLine && !isInstanceAttribute) {
                Row row = new Row();
                rows.appendChild(row);
                row.setSpans("2");
                Label group = new Label(Msg.translate(Env.getCtx(), "IsProductAttribute"));
                row.appendChild(group);
                rows.appendChild(row);
                row = new Row();
                rows.appendChild(row);
                row.setSpans("2");
                Separator separator = new Separator();
                separator.setBar(true);
                row.appendChild(separator);
                rows.appendChild(row);
                productLine = true;
            }
            //	Add label for Instances attributes
            if (!instanceLine && isInstanceAttribute) {
                Row row = new Row();
                rows.appendChild(row);
                row.setSpans("2");
                Label group = new Label(Msg.translate(Env.getCtx(), "IsInstanceAttribute"));
                row.appendChild(group);
                rows.appendChild(row);
                row = new Row();
                rows.appendChild(row);
                row.setSpans("2");
                Separator separator = new Separator();
                separator.setBar(true);
                row.appendChild(separator);
                rows.appendChild(row);
                instanceLine = true;
            }
            //
            Row row = new Row();
            rows.appendChild(row);
            Label label = new Label(name);
            if (description != null && description.length() > 0)
                label.setTooltiptext(description);
            Div div = new Div();
            div.setAlign("right");
            div.appendChild(label);
            row.appendChild(div);
            Component field = null;
            if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributeValueType)) {
                field = new Listbox();
                ((Listbox) field).setRows(0);
                ((Listbox) field).setMultiple(false);
                ((Listbox) field).setMold("select");
                ((Listbox) field).setWidth("150px");
                KeyNamePair[] knp = getAttributeList(attribute_ID);
                for (int i = 0; i < knp.length; i++) ((Listbox) field).appendItem(knp[i].getName(), knp[i]);
            } else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType)) {
                field = new WNumberEditor(name, false, false, true, DisplayType.Number, name).getComponent();
                ((NumberBox) field).setWidth("150px");
            } else {
                field = new WStringEditor(name, false, false, true, 10, 40, null, null).getComponent();
                ((Textbox) field).setWidth("150px");
            }
            row.appendChild(field);
            //
            field.setId(String.valueOf(attribute_ID));
            // If name is null, replace it with "_"
            if (name.equals("")) {
                name = "_";
            }
            field.setAttribute("zk_component_ID", "InfoPAttributePanel_field_" + name.replaceAll("[^a-zA-Z0-9_]", "_"));
            //
            if (isInstanceAttribute)
                m_instanceEditors.add(field);
            else
                m_productEditors.add(field);
            //	To (numbers)
            Component fieldTo = null;
            if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType)) {
                fieldTo = new WNumberEditor(name, false, false, true, DisplayType.Number, name).getComponent();
                ((NumberBox) fieldTo).setWidth("150px");
                row = new Row();
                rows.appendChild(row);
                div = new Div();
                div.setAlign("right");
                div.appendChild(new Label("-"));
                row.appendChild(div);
                row.appendChild(fieldTo);
            }
            if (fieldTo != null)
                fieldTo.setAttribute("zk_component_ID", "InfoPAttributePanel_fieldTo_" + name);
            if (isInstanceAttribute)
                m_instanceEditorsTo.add(fieldTo);
            else
                m_productEditorsTo.add(fieldTo);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    // print instance line if not printed
    if (!instanceLine) {
        boolean isGuarantee = true;
        boolean isSerial = true;
        boolean isLot = true;
        if (p_M_AttributeSet_ID > 0) {
            MAttributeSet as = new MAttributeSet(Env.getCtx(), p_M_AttributeSet_ID, null);
            isGuarantee = as.isGuaranteeDate();
            isSerial = as.isSerNo();
            isLot = as.isLot();
        }
        if (isGuarantee || isSerial || isLot) {
            Row row = new Row();
            rows.appendChild(row);
            row.setSpans("2");
            Label group = new Label(Msg.translate(Env.getCtx(), "IsInstanceAttribute"));
            row.appendChild(group);
            rows.appendChild(row);
            row = new Row();
            rows.appendChild(row);
            row.setSpans("2");
            Separator separator = new Separator();
            separator.setBar(true);
            row.appendChild(separator);
            rows.appendChild(row);
            instanceLine = true;
        }
    }
    return 0;
}
Also used : Label(org.adempiere.webui.component.Label) PreparedStatement(java.sql.PreparedStatement) NumberBox(org.adempiere.webui.component.NumberBox) WStringEditor(org.adempiere.webui.editor.WStringEditor) MAttributeSet(org.compiere.model.MAttributeSet) Div(org.zkoss.zul.Div) ResultSet(java.sql.ResultSet) Row(org.adempiere.webui.component.Row) KeyNamePair(org.compiere.util.KeyNamePair) Component(org.zkoss.zk.ui.Component) Listbox(org.adempiere.webui.component.Listbox) Separator(org.zkoss.zul.Separator) WNumberEditor(org.adempiere.webui.editor.WNumberEditor)

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