Search in sources :

Example 61 with Component

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

the class InfoPAttributePanel method setDisplay.

/**
	 *   Set the display text
	 */
private void setDisplay() {
    StringBuffer display = new StringBuffer();
    if (serNoField != null && serNoField.getValue().toString().length() > 0)
        display.append(serNoField.getValue().toString() + "-");
    if (lotField != null && lotField.getValue().toString().length() > 0)
        display.append(lotField.getValue().toString() + "-");
    if (lotSelection != null && lotSelection.getSelectedItem().getValue().toString().length() > 0)
        display.append(lotSelection.getSelectedItem().getValue().toString() + "-");
    if (guaranteeDateField != null && guaranteeDateField.getValue() != null)
        display.append(guaranteeDateSelection.getSelectedItem().getValue().toString() + guaranteeDateField.getValue().toString() + "-");
    for (int i = 0; i < m_productEditors.size(); i++) {
        Component c = (Component) m_productEditors.get(i);
        Component cTo = (Component) m_productEditorsTo.get(i);
        if (c instanceof Listbox) {
            Listbox field = (Listbox) c;
            display.append(field.getSelectedItem().getValue().toString() + "-");
        } else if (c instanceof NumberBox) {
            NumberBox field = (NumberBox) c;
            if (field.getValue() != null)
                display.append(field.getValue().toString() + "-");
            NumberBox fieldTo = (NumberBox) cTo;
            if (fieldTo.getValue() != null)
                display.append(fieldTo.getValue().toString() + "-");
        } else {
            Textbox field = (Textbox) c;
            display.append(field.getValue() + "-");
        }
    }
    for (int i = 0; i < m_instanceEditors.size(); i++) {
        Component c = (Component) m_instanceEditors.get(i);
        Component cTo = (Component) m_instanceEditorsTo.get(i);
        if (c instanceof Listbox) {
            Listbox field = (Listbox) c;
            display.append(field.getSelectedItem().getValue().toString() + "-");
        } else if (c instanceof NumberBox) {
            NumberBox field = (NumberBox) c;
            if (field.getValue() != null)
                display.append(field.getValue().toString() + "-");
            NumberBox fieldTo = (NumberBox) cTo;
            if (fieldTo.getValue() != null)
                display.append(fieldTo.getValue().toString() + "-");
        } else {
            Textbox field = (Textbox) c;
            display.append(field.getValue() + "-");
        }
    }
    //  TODO - there is a more elegant way to do this.
    while (display.toString().contains("--") && display.length() > 1) {
        display.delete(display.indexOf("--"), display.indexOf("--") + 1);
    }
    while (display.toString().startsWith("-") && display.length() > 1) {
        display.delete(0, 1);
    }
    while (display.toString().endsWith("-") && display.length() > 1) {
        display.delete(display.length() - 1, display.length());
    }
    m_display = display.toString();
}
Also used : Textbox(org.zkoss.zul.Textbox) NumberBox(org.adempiere.webui.component.NumberBox) Component(org.zkoss.zk.ui.Component) Listbox(org.adempiere.webui.component.Listbox)

Example 62 with Component

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

the class InfoOrderPanel method onEvent.

public void onEvent(Event e) {
    if (!p_loadedOK)
        return;
    Component component = e.getTarget();
    if (component != null) {
        if (component instanceof Checkbox) {
            Checkbox cb = (Checkbox) component;
            //  ShowDetail check box
            if (cb.getName() != null && cb.getName().equals("IsSOTrx")) {
                if (cb.isChecked()) {
                    fIsDelivered.setLabel(Msg.translate(Env.getCtx(), "IsDelivered"));
                } else {
                    fIsDelivered.setLabel(Msg.translate(Env.getCtx(), "Received"));
                }
            }
        }
    }
    //
    super.onEvent(e);
}
Also used : Checkbox(org.adempiere.webui.component.Checkbox) Component(org.zkoss.zk.ui.Component)

Example 63 with Component

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

the class LoginPanel method onEvent.

public void onEvent(Event event) {
    Component eventComp = event.getTarget();
    if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) {
        validateLogin();
    }
    if (event.getName().equals(Events.ON_SELECT)) {
        if (eventComp.getId().equals(lstLanguage.getId())) {
            String langName = (String) lstLanguage.getSelectedItem().getLabel();
            languageChanged(langName);
        }
    }
    // Elaine 2009/02/06 - initial language
    if (event.getName().equals(Events.ON_CHANGE)) {
        if (eventComp.getId().equals(txtUserId.getId())) {
            onUserIdChange();
        }
    }
//
}
Also used : Component(org.zkoss.zk.ui.Component)

Example 64 with Component

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

the class WBrowserListItemRenderer method getCellComponent.

/**
	 * Generate the cell for the given <code>field</code>.
	 *
	 * @param table 	The table into which the cell will be placed.
	 * @param field		The data field for which the cell is to be created.
	 * @param rowIndex	The row in which the cell is to be placed.
	 * @param columnIndex	The column in which the cell is to be placed.
	 * @return	The list cell component.
	 */
private Listcell getCellComponent(WBrowserTable table, Object field, int rowIndex, int columnIndex) {
    ListCell listcell = new ListCell();
    if (table == null)
        return listcell;
    BrowserRow browserRows = table.getData();
    //	BR [ 257 ]
    MBrowseField browseField = browserRows.getBrowserField(browserRows.getTableIndex(columnIndex));
    if (browseField == null)
        return listcell;
    //	
    GridField gridField = table.getGridFieldAt(rowIndex, columnIndex);
    boolean isColumnVisible = true;
    if (!m_tableColumns.isEmpty())
        isColumnVisible = isColumnVisible(getColumn(columnIndex));
    // are assigned to Table Columns
    if (isColumnVisible && gridField != null) {
        //	Set Read Only
        boolean isCellEditable = table.isCellEditable(rowIndex, columnIndex);
        //	
        if (DisplayType.YesNo == browseField.getAD_Reference_ID()) {
            //	BR [ 347 ]
            boolean selected = false;
            if (field != null) {
                selected = Boolean.valueOf(field.toString());
            }
            listcell.setValue(selected);
            if (columnIndex == 0)
                table.setCheckmark(false);
            Checkbox checkbox = new Checkbox();
            checkbox.setChecked(selected);
            if (isCellEditable) {
                checkbox.setEnabled(true);
                checkbox.addEventListener(Events.ON_CHECK, this);
            } else {
                checkbox.setEnabled(false);
            }
            listcell.appendChild(checkbox);
            ZkCssHelper.appendStyle(listcell, "text-align:center");
        } else if ((DisplayType.isNumeric(browseField.getAD_Reference_ID())) && !browseField.isKey()) {
            DecimalFormat format = field instanceof BigDecimal ? DisplayType.getNumberFormat(DisplayType.Amount, AEnv.getLanguage(Env.getCtx())) : DisplayType.getNumberFormat(DisplayType.Integer, AEnv.getLanguage(Env.getCtx()));
            // set cell value to allow sorting
            listcell.setValue((field == null ? "0" : field.toString()));
            if (isCellEditable) {
                NumberBox numberbox = new NumberBox(false);
                numberbox.setFormat(format);
                numberbox.setValue(field);
                numberbox.setWidth("100px");
                numberbox.setStyle("text-align:right; " + listcell.getStyle());
                numberbox.addEventListener(Events.ON_CHANGE, this);
                listcell.appendChild(numberbox);
                numberbox.setEnabled(true);
            } else {
                listcell.setLabel(format.format(((Number) (field == null ? Env.ZERO : field)).doubleValue()));
                ZkCssHelper.appendStyle(listcell, "text-align:right");
            }
        } else if (DisplayType.Date == browseField.getAD_Reference_ID() || DisplayType.DateTime == browseField.getAD_Reference_ID()) {
            if (field != null) {
                SimpleDateFormat dateFormat = DisplayType.getDateFormat(browseField.getAD_Reference_ID(), AEnv.getLanguage(Env.getCtx()));
                //	BR [ 270 ]
                listcell.setValue(dateFormat.format(field));
                if (isCellEditable) {
                    Datebox datebox = new Datebox();
                    datebox.setFormat(dateFormat.toPattern());
                    //	
                    datebox.setValue((Date) field);
                    datebox.addEventListener(Events.ON_CHANGE, this);
                    listcell.appendChild(datebox);
                } else {
                    listcell.setLabel(dateFormat.format(field));
                }
            }
        } else //	Add support to other String
        if (browseField.getAD_Reference_ID() == DisplayType.String || browseField.getAD_Reference_ID() == DisplayType.PrinterName || browseField.getAD_Reference_ID() == DisplayType.Text || browseField.getAD_Reference_ID() == DisplayType.TextLong) {
            listcell.setValue((field == null ? "" : field.toString()));
            if (isCellEditable) {
                Textbox textbox = new Textbox();
                textbox.setValue((field == null ? "" : field.toString()));
                textbox.addEventListener(Events.ON_CHANGE, this);
                listcell.appendChild(textbox);
            } else {
                listcell.setLabel((field == null ? "" : field.toString()));
            }
        } else if (field instanceof org.adempiere.webui.component.Combobox) {
            listcell.setValue(field);
            if (isCellEditable) {
                Combobox combobox = (Combobox) field;
                combobox.addEventListener(Events.ON_CHANGE, this);
                listcell.appendChild(combobox);
            } else {
                Combobox combobox = (Combobox) field;
                if (combobox != null && combobox.getItemCount() > 0) {
                    if (combobox.getSelectedIndex() >= 0)
                        listcell.setLabel((String) combobox.getItemAtIndex(combobox.getSelectedIndex()).getLabel());
                    else
                        listcell.setLabel("");
                }
            }
        } else if (field instanceof org.adempiere.webui.component.Button) {
            listcell.setValue(field);
            if (isCellEditable) {
                Button button = (Button) field;
                button.addEventListener(Events.ON_CLICK, this);
                listcell.appendChild(button);
            } else {
                Button button = (Button) field;
                if (button != null) {
                    listcell.setLabel("");
                }
            }
        } else // if ID column make it invisible
        if (field instanceof IDColumn && browseField.isKey()) {
            IDColumn id = (IDColumn) field;
            if (id != null && id.getRecord_ID() != null) {
                listcell.setValue(id.getRecord_ID());
                if (!table.isCheckmark()) {
                    table.setCheckmark(true);
                    table.removeEventListener(Events.ON_SELECT, this);
                    table.addEventListener(Events.ON_SELECT, this);
                }
            }
        } else if ((DisplayType.isLookup(browseField.getAD_Reference_ID()) || DisplayType.ID == browseField.getAD_Reference_ID()) && !browseField.isKey()) {
            if (isCellEditable) {
                WEditor editor = WebEditorFactory.getEditor(gridField, true);
                editor.addValueChangeListener(this);
                editor.dynamicDisplay();
                editor.setReadWrite(true);
                editor.fillHorizontal();
                gridField.addPropertyChangeListener(editor);
                listcell.appendChild(editor.getComponent());
            } else {
                Component component;
                if (gridField.getDisplayType() == DisplayType.YesNo) {
                    component = createReadonlyCheckbox(field);
                } else {
                    String text = getDisplayText(field, gridField);
                    Label label = new Label();
                    setLabelText(text, label);
                    component = label;
                }
                listcell.appendChild(component);
            }
        } else {
            listcell.setLabel((field == null ? null : field.toString()));
            listcell.setValue((field == null ? null : field.toString()));
        }
    } else {
        listcell.setLabel("");
        listcell.setValue("");
    }
    listcell.setAttribute("zk_component_ID", "ListItem_Cell_" + rowIndex + "_" + columnIndex);
    return listcell;
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) Datebox(org.adempiere.webui.component.Datebox) Button(org.adempiere.webui.component.Button) Combobox(org.adempiere.webui.component.Combobox) ListCell(org.adempiere.webui.component.ListCell) DecimalFormat(java.text.DecimalFormat) Textbox(org.adempiere.webui.component.Textbox) Label(org.zkoss.zhtml.Label) GridField(org.compiere.model.GridField) NumberBox(org.adempiere.webui.component.NumberBox) WEditor(org.adempiere.webui.editor.WEditor) BigDecimal(java.math.BigDecimal) IDColumn(org.compiere.minigrid.IDColumn) Button(org.adempiere.webui.component.Button) Checkbox(org.adempiere.webui.component.Checkbox) Component(org.zkoss.zk.ui.Component) SimpleDateFormat(java.text.SimpleDateFormat)

Example 65 with Component

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

the class WPOSUserPinListener method doPerformAction.

protected void doPerformAction(Event e) {
    if (e != null && e.getTarget() == userPinTimer) {
        pos.invalidateUserPin();
        userPinTimer.stop();
        return;
    }
    if (userPinTimer.isRunning())
        return;
    Component objectSource = e.getTarget();
    POSNumberBox number = null;
    Button button = null;
    if (objectSource instanceof POSNumberBox)
        number = (POSNumberBox) objectSource;
    if (objectSource instanceof Button)
        button = (Button) objectSource;
    if (!pos.isRequiredPIN())
        return;
    if (//Number field validation
    (number != null && (Msg.translate(Env.getCtx(), "Discount").equals(number.getTooltiptext()) || Msg.translate(Env.getCtx(), "PriceActual").equals(number.getTooltiptext())) || //Button validation
    (button != null && ("Cancel".equals(button.getName())))))
        WPOSUserPinDialog.show(pos);
    return;
}
Also used : Button(org.adempiere.webui.component.Button) 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