Search in sources :

Example 11 with Textbox

use of org.adempiere.webui.component.Textbox in project adempiere by adempiere.

the class WPAttributeDialog method addAttributeLine.

//	initAttribute
/**
	 * 	Add Attribute Line
	 *	@param attribute attribute
	 * 	@param product product level attribute
	 * 	@param readOnly value is read only
	 */
private void addAttributeLine(Rows rows, MAttribute attribute, boolean product, boolean readOnly) {
    log.fine(attribute + ", Product=" + product + ", R/O=" + readOnly);
    m_row++;
    Label label = new Label(attribute.getName());
    if (product)
        label.setStyle("font-weight: bold");
    if (attribute.getDescription() != null)
        label.setTooltiptext(attribute.getDescription());
    Row row = rows.newRow();
    row.appendChild(label.rightAlign());
    //
    MAttributeInstance instance = attribute.getMAttributeInstance(m_M_AttributeSetInstance_ID);
    if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attribute.getAttributeValueType())) {
        //	optional = null
        MAttributeValue[] values = attribute.getMAttributeValues();
        Listbox editor = new Listbox();
        editor.setMold("select");
        for (MAttributeValue value : values) {
            ListItem item = new ListItem(value != null ? value.getName() : "", value);
            editor.appendChild(item);
        }
        boolean found = false;
        if (instance != null) {
            for (int i = 0; i < values.length; i++) {
                if (values[i] != null && values[i].getM_AttributeValue_ID() == instance.getM_AttributeValue_ID()) {
                    editor.setSelectedIndex(i);
                    found = true;
                    break;
                }
            }
            if (found)
                log.fine("Attribute=" + attribute.getName() + " #" + values.length + " - found: " + instance);
            else
                log.warning("Attribute=" + attribute.getName() + " #" + values.length + " - NOT found: " + instance);
        } else
            //	setComboBox
            log.fine("Attribute=" + attribute.getName() + " #" + values.length + " no instance");
        row.appendChild(editor);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    } else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attribute.getAttributeValueType())) {
        NumberBox editor = new NumberBox(false);
        if (instance != null)
            editor.setValue(instance.getValueNumber());
        else
            editor.setValue(Env.ZERO);
        row.appendChild(editor);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    } else //	Text Field
    {
        Textbox editor = new Textbox();
        if (instance != null)
            editor.setText(instance.getValue());
        row.appendChild(editor);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    }
}
Also used : MAttributeInstance(org.compiere.model.MAttributeInstance) MAttributeValue(org.compiere.model.MAttributeValue) Label(org.adempiere.webui.component.Label) Textbox(org.adempiere.webui.component.Textbox) Row(org.adempiere.webui.component.Row) ListItem(org.adempiere.webui.component.ListItem) NumberBox(org.adempiere.webui.component.NumberBox) Listbox(org.adempiere.webui.component.Listbox)

Example 12 with Textbox

use of org.adempiere.webui.component.Textbox in project adempiere by adempiere.

the class WContext method init.

private void init() {
    setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
    setBorder("normal");
    setClosable(true);
    int height = SessionManager.getAppDesktop().getClientInfo().desktopHeight * 85 / 100;
    int width = SessionManager.getAppDesktop().getClientInfo().desktopWidth * 50 / 100;
    this.setWidth(width + "px");
    this.setHeight(height + "px");
    this.setContentStyle("overflow: auto");
    this.setSizable(true);
    this.setMaximizable(true);
    this.setTitle(Msg.getMsg(Env.getCtx(), "Context"));
    Textbox contextText = new Textbox();
    contextText.setMultiline(true);
    contextText.setReadonly(true);
    contextText.setWidth("100%");
    contextText.setHeight("100%");
    confirmPanel = new ConfirmPanel(false, false, false, false, false, false);
    confirmPanel.addActionListener(Events.ON_CLICK, this);
    confirmPanel.setStyle("border-top: 2px groove #444; padding-top: 4px");
    Borderlayout mainPanel = new Borderlayout();
    //mainPanel.setWidth("100%");
    mainPanel.setHeight("100%");
    Center center = new Center();
    mainPanel.appendChild(center);
    center.appendChild(contextText);
    South south = new South();
    mainPanel.appendChild(south);
    south.appendChild(confirmPanel);
    this.appendChild(mainPanel);
    // Get the context
    String[] contextArray = Env.getEntireContext(Env.getCtx());
    Arrays.sort(contextArray);
    contextText.setText("");
    // 	Need a specific format to add the eol character.
    //  Otherwise, could use Arrays.toString(contextArray) 
    StringBuffer sb = new StringBuffer("");
    if (contextArray.length > 0) {
        String eol = System.getProperty("line.separator");
        for (int i = 0; i < contextArray.length; i++) {
            sb.append(contextArray[i] + eol);
        }
    }
    contextText.setText(sb.toString());
}
Also used : Center(org.zkoss.zul.Center) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) Textbox(org.adempiere.webui.component.Textbox) South(org.zkoss.zul.South) Borderlayout(org.zkoss.zul.Borderlayout)

Example 13 with Textbox

use of org.adempiere.webui.component.Textbox in project adempiere by adempiere.

the class LoginPanel method initComponents.

private void initComponents() {
    lblUserId = new Label();
    lblUserId.setId("lblUserId");
    lblUserId.setValue("User ID");
    lblPassword = new Label();
    lblPassword.setId("lblPassword");
    lblPassword.setValue("Password");
    lblLanguage = new Label();
    lblLanguage.setId("lblLanguage");
    lblLanguage.setValue("Language");
    txtUserId = new Textbox();
    txtUserId.setId("txtUserId");
    //txtUserId.setCols(25);
    txtUserId.setMaxlength(40);
    //txtUserId.setWidth("220px");
    // Elaine 2009/02/06
    txtUserId.addEventListener(Events.ON_CHANGE, this);
    txtPassword = new Textbox();
    txtPassword.setId("txtPassword");
    txtPassword.setType("password");
    //txtPassword.setCols(25);
    //txtPassword.setWidth("220px");
    lstLanguage = new Combobox();
    lstLanguage.setAutocomplete(true);
    lstLanguage.setAutodrop(true);
    lstLanguage.setId("lstLanguage");
    lstLanguage.addEventListener(Events.ON_SELECT, this);
    //lstLanguage.setWidth("220px");
    // Update Language List
    lstLanguage.getItems().clear();
    ArrayList<String> supported = Env.getSupportedLanguages();
    String[] availableLanguages = Language.getNames();
    for (String langName : availableLanguages) {
        Language language = Language.getLanguage(langName);
        if (!language.isBaseLanguage()) {
            if (!supported.contains(language.getAD_Language()))
                continue;
        }
        lstLanguage.appendItem(langName, language.getAD_Language());
    }
    chkRememberMe = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "RememberMe"));
    chkRememberMe.setId("chkRememberMe");
    // Make the default language the language of client System
    String defaultLanguage = MClient.get(ctx, 0).getAD_Language();
    for (int i = 0; i < lstLanguage.getItemCount(); i++) {
        Comboitem li = lstLanguage.getItemAtIndex(i);
        if (li.getValue().equals(defaultLanguage)) {
            lstLanguage.setSelectedIndex(i);
            languageChanged(li.getLabel());
            break;
        }
    }
}
Also used : Language(org.compiere.util.Language) Combobox(org.adempiere.webui.component.Combobox) Checkbox(org.zkoss.zul.Checkbox) Label(org.adempiere.webui.component.Label) Textbox(org.adempiere.webui.component.Textbox) Comboitem(org.zkoss.zul.Comboitem)

Example 14 with Textbox

use of org.adempiere.webui.component.Textbox in project adempiere by adempiere.

the class InfoGeneralPanel method statInit.

private void statInit() {
    txt1 = new Textbox();
    txt2 = new Textbox();
    txt3 = new Textbox();
    txt4 = new Textbox();
    lbl1 = new Label();
    lbl2 = new Label();
    lbl3 = new Label();
    lbl4 = new Label();
    initComponents();
}
Also used : Textbox(org.adempiere.webui.component.Textbox) Label(org.adempiere.webui.component.Label)

Example 15 with Textbox

use of org.adempiere.webui.component.Textbox 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)

Aggregations

Textbox (org.adempiere.webui.component.Textbox)21 Label (org.adempiere.webui.component.Label)11 Checkbox (org.adempiere.webui.component.Checkbox)8 NumberBox (org.adempiere.webui.component.NumberBox)6 Datebox (org.adempiere.webui.component.Datebox)5 DecimalFormat (java.text.DecimalFormat)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Button (org.adempiere.webui.component.Button)4 Component (org.zkoss.zk.ui.Component)4 Hbox (org.zkoss.zul.Hbox)4 Combobox (org.adempiere.webui.component.Combobox)3 ConfirmPanel (org.adempiere.webui.component.ConfirmPanel)3 ListItem (org.adempiere.webui.component.ListItem)3 Listbox (org.adempiere.webui.component.Listbox)3 Row (org.adempiere.webui.component.Row)3 WSearchEditor (org.adempiere.webui.editor.WSearchEditor)3 BigDecimal (java.math.BigDecimal)2 WPOSKeyboard (org.adempiere.pos.WPOSKeyboard)2 Rows (org.adempiere.webui.component.Rows)2 IDColumn (org.compiere.minigrid.IDColumn)2