Search in sources :

Example 6 with Combobox

use of org.adempiere.webui.component.Combobox 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 7 with Combobox

use of org.adempiere.webui.component.Combobox 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 8 with Combobox

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

the class WStringEditor method dynamicDisplay.

@Override
public void dynamicDisplay() {
    //referesh auto complete list
    if (gridField.isAutocomplete()) {
        Combobox combo = (Combobox) getComponent();
        List<String> items = gridField.getEntries();
        if (items.size() != combo.getItemCount()) {
            combo.removeAllItems();
            for (String s : items) {
                combo.appendItem(s);
            }
        }
    }
}
Also used : Combobox(org.adempiere.webui.component.Combobox)

Example 9 with Combobox

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

the class WStringEditor method init.

private void init(String obscureType) {
    if (gridField != null) {
        getComponent().setMaxlength(gridField.getFieldLength());
        int displayLength = gridField.getDisplayLength();
        if (displayLength <= 0 || displayLength > MAX_DISPLAY_LENGTH) {
            displayLength = MAX_DISPLAY_LENGTH;
        }
        getComponent().setCols(displayLength);
        if (gridField.getDisplayType() == DisplayType.Text) {
            getComponent().setMultiline(true);
            getComponent().setRows(3);
            ((HtmlBasedComponent) getComponent()).setSclass("field-text");
        } else if (gridField.getDisplayType() == DisplayType.TextLong) {
            getComponent().setMultiline(true);
            getComponent().setRows(5);
            ((HtmlBasedComponent) getComponent()).setSclass("field-textlong");
        } else if (gridField.getDisplayType() == DisplayType.Memo) {
            getComponent().setMultiline(true);
            getComponent().setRows(8);
            ((HtmlBasedComponent) getComponent()).setSclass("field-memo");
        }
        if (getComponent() instanceof org.zkoss.zul.api.Textbox)
            ((StringBox) component).setObscureType(obscureType);
        popupMenu = new WEditorPopupMenu(false, false, true);
        Menuitem editor = new Menuitem(Msg.getMsg(Env.getCtx(), "Editor"), "images/Editor16.png");
        editor.setAttribute("EVENT", EDITOR_EVENT);
        editor.addEventListener(Events.ON_CLICK, popupMenu);
        popupMenu.appendChild(editor);
        if (gridField != null && gridField.getGridTab() != null) {
            WRecordInfo.addMenu(popupMenu);
        }
        getComponent().setContext(popupMenu.getId());
        if (gridField.isAutocomplete()) {
            Combobox combo = (Combobox) getComponent();
            combo.setAutodrop(true);
            combo.setAutocomplete(true);
            combo.setButtonVisible(false);
            List<String> items = gridField.getEntries();
            for (String s : items) {
                combo.appendItem(s);
            }
        }
    }
}
Also used : Menuitem(org.zkoss.zul.Menuitem) Combobox(org.adempiere.webui.component.Combobox) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent)

Example 10 with Combobox

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

the class FindWindow method initAdvanced.

/**
     * initialise Advanced Tab
     * @throws IOException 
     *
    **/
private void initAdvanced() throws IOException {
    ToolBarButton btnNew = new ToolBarButton();
    btnNew.setImage("/images/New24.png");
    btnNew.setAttribute("name", "btnNewAdv");
    btnNew.addEventListener(Events.ON_CLICK, this);
    ToolBarButton btnDelete = new ToolBarButton();
    btnDelete.setAttribute("name", "btnDeleteAdv");
    btnDelete.setImage("/images/Delete24.png");
    btnDelete.addEventListener(Events.ON_CLICK, this);
    ToolBarButton btnSave = new ToolBarButton();
    btnSave.setAttribute("name", "btnSaveAdv");
    btnSave.setImage("/images/Save24.png");
    btnSave.addEventListener(Events.ON_CLICK, this);
    fQueryName = new Combobox();
    fQueryName.setTooltiptext(m_sToolTipText);
    fQueryName.setReadonly(false);
    fQueryName.addEventListener(Events.ON_FOCUS, this);
    fQueryName.addEventListener(Events.ON_BLUR, this);
    fQueryName.addEventListener(Events.ON_SELECT, this);
    //	Get from Action
    WAppsAction action = new WAppsAction(ConfirmPanel.A_OK, null, ConfirmPanel.A_OK);
    Button btnOk = action.getButton();
    btnOk.setName("btnOkAdv");
    btnOk.addEventListener(Events.ON_CLICK, this);
    //	
    action = new WAppsAction(ConfirmPanel.A_CANCEL, null, ConfirmPanel.A_CANCEL);
    Button btnCancel = action.getButton();
    btnCancel.setName("btnCancel");
    btnCancel.addEventListener(Events.ON_CLICK, this);
    Panel pnlButtonRight = new Panel();
    //	Change to Standard button order
    pnlButtonRight.appendChild(btnCancel);
    pnlButtonRight.appendChild(btnOk);
    pnlButtonRight.setAlign("right");
    ToolBar toolBar = new ToolBar();
    toolBar.appendChild(btnNew);
    toolBar.appendChild(btnDelete);
    toolBar.appendChild(fQueryName);
    toolBar.appendChild(btnSave);
    toolBar.setWidth("100%");
    fQueryName.setStyle("margin-left: 3px; margin-right: 3px; position: relative; top: 5px;");
    btnSave.setDisabled(m_AD_Tab_ID <= 0);
    Hbox confirmPanel = new Hbox();
    confirmPanel.appendChild(pnlButtonRight);
    confirmPanel.setWidth("100%");
    advancedPanel = new Listbox();
    ListHead listhead = new ListHead();
    listhead.setSizable(true);
    ListHeader lstHAndOr = new ListHeader();
    lstHAndOr.setLabel(Msg.getMsg(Env.getCtx(), "And/Or"));
    lstHAndOr.setWidth("40px");
    ListHeader lstHLeftBracket = new ListHeader();
    lstHLeftBracket.setLabel("(");
    lstHLeftBracket.setWidth("20px");
    ListHeader lstHColumn = new ListHeader();
    lstHColumn.setLabel(Msg.translate(Env.getCtx(), "AD_Column_ID"));
    lstHColumn.setWidth("100px");
    ListHeader lstHOperator = new ListHeader();
    lstHOperator.setLabel(Msg.getMsg(Env.getCtx(), "Operator"));
    ListHeader lstHQueryValue = new ListHeader();
    lstHQueryValue.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue"));
    lstHQueryValue.setWidth("170px");
    ListHeader lstHQueryTo = new ListHeader();
    lstHQueryTo.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue2"));
    lstHQueryTo.setWidth("170px");
    ListHeader lstHRightBracket = new ListHeader();
    lstHRightBracket.setLabel(")");
    lstHRightBracket.setWidth("20px");
    listhead.appendChild(lstHAndOr);
    listhead.appendChild(lstHLeftBracket);
    listhead.appendChild(lstHColumn);
    listhead.appendChild(lstHOperator);
    listhead.appendChild(lstHQueryValue);
    listhead.appendChild(lstHQueryTo);
    listhead.appendChild(lstHRightBracket);
    advancedPanel.appendChild(listhead);
    advancedPanel.setVflex(true);
    Borderlayout layout = new Borderlayout();
    layout.setStyle("height: 100%; width: 99%; position: relative;");
    winAdvanced.appendChild(layout);
    North north = new North();
    layout.appendChild(north);
    north.appendChild(toolBar);
    Center center = new Center();
    layout.appendChild(center);
    center.appendChild(advancedPanel);
    center.setFlex(true);
    South south = new South();
    layout.appendChild(south);
    south.appendChild(confirmPanel);
    winAdvanced.setHeight("100%");
    winAdvanced.setWidth("100%");
    winAdvanced.addEventListener(Events.ON_OK, this);
}
Also used : Hbox(org.zkoss.zul.Hbox) Center(org.zkoss.zkex.zul.Center) ToolBarButton(org.adempiere.webui.component.ToolBarButton) Combobox(org.adempiere.webui.component.Combobox) South(org.zkoss.zkex.zul.South) Borderlayout(org.zkoss.zkex.zul.Borderlayout) WAppsAction(org.adempiere.webui.component.WAppsAction) Panel(org.adempiere.webui.component.Panel) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) Button(org.adempiere.webui.component.Button) ToolBarButton(org.adempiere.webui.component.ToolBarButton) ListHead(org.adempiere.webui.component.ListHead) ToolBar(org.adempiere.webui.component.ToolBar) ListHeader(org.adempiere.webui.component.ListHeader) North(org.zkoss.zkex.zul.North) Listbox(org.adempiere.webui.component.Listbox)

Aggregations

Combobox (org.adempiere.webui.component.Combobox)11 Checkbox (org.adempiere.webui.component.Checkbox)3 Label (org.adempiere.webui.component.Label)3 Textbox (org.adempiere.webui.component.Textbox)3 Component (org.zkoss.zk.ui.Component)3 Button (org.adempiere.webui.component.Button)2 ToolBar (org.adempiere.webui.component.ToolBar)2 ToolBarButton (org.adempiere.webui.component.ToolBarButton)2 WTableDirEditor (org.adempiere.webui.editor.WTableDirEditor)2 UserPreference (org.adempiere.webui.util.UserPreference)2 Language (org.compiere.util.Language)2 BigDecimal (java.math.BigDecimal)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ResourceBundle (java.util.ResourceBundle)1 MBrowseField (org.adempiere.model.MBrowseField)1 ComboItem (org.adempiere.webui.component.ComboItem)1