Search in sources :

Example 16 with ListItem

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

the class WBrowserTable method setValueAt.

/**
	 * Set the cell value at <code>row</code> and <code>column</code>.
	 *
	 * @param value		The value to set
     * @param row    	the index of the row whose value is to be set
     * @param column	the index of the column whose value is to be set
	 */
public void setValueAt(Object value, int row, int column) {
    getModel().setDataAt(value, row, convertColumnIndexToModel(column));
    if (value instanceof IDColumn) {
        IDColumn id = (IDColumn) value;
        boolean selected = id.isSelected();
        ListItem listItem = this.getItemAtIndex(row);
        if (listItem != null && !listItem.isSelected() && selected) {
            listItem.setSelected(true);
        }
    }
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) ListItem(org.adempiere.webui.component.ListItem)

Example 17 with ListItem

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

the class WBrowserListItemRenderer method getRowPosition.

/**
	 * Get the row index of the given <code>source</code> component.
	 *
	 * @param source	The component for which the row index is to be found.
	 * @return The row index of the given component.
	 */
protected int getRowPosition(Component source) {
    Listcell cell;
    ListItem item;
    int row = -1;
    cell = findListcell(source);
    item = (ListItem) cell.getParent();
    row = item.getIndex();
    return row;
}
Also used : Listcell(org.zkoss.zul.Listcell) ListItem(org.adempiere.webui.component.ListItem)

Example 18 with ListItem

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

the class FindWindow method createFields.

/**
     * create respective fields in the advanced window tab
     *
    **/
private void createFields(String[] fields, int row) {
    ListItem listItem = new ListItem();
    listItem.setWidth("100%");
    Listbox listColumn = new Listbox();
    listColumn.setId("listColumn" + listItem.getId());
    listColumn.setName("listColumn");
    listColumn.setMold("select");
    listColumn.setRows(0);
    listColumn.addEventListener(Events.ON_SELECT, this);
    Listbox listOperator = new Listbox();
    listOperator.setId("listOperator" + listItem.getId());
    listOperator.setName("listOperator");
    listOperator.setMold("select");
    listOperator.setRows(0);
    listOperator.addEventListener(Events.ON_SELECT, this);
    Listbox listAndOr = new Listbox();
    listAndOr.setId("listAndOr" + listItem.getId());
    listAndOr.setName("listAndOr");
    listAndOr.setMold("select");
    listAndOr.setRows(0);
    listAndOr.addEventListener(Events.ON_SELECT, this);
    Listbox listLeftBracket = new Listbox();
    listLeftBracket.setId("listLeftBracket" + listItem.getId());
    listLeftBracket.setName("listLeftBracket");
    listLeftBracket.setMold("select");
    listLeftBracket.setRows(0);
    listLeftBracket.addEventListener(Events.ON_SELECT, this);
    Listbox listRightBracket = new Listbox();
    listRightBracket.setId("listRightBracket" + listItem.getId());
    listRightBracket.setName("listRightBracket");
    listRightBracket.setMold("select");
    listRightBracket.setRows(0);
    listRightBracket.addEventListener(Events.ON_SELECT, this);
    setValues(listColumn, listOperator, fields);
    // And Or
    ValueNamePair[] andOr = new ValueNamePair[] { new ValueNamePair("", ""), new ValueNamePair("AND", Msg.getMsg(Env.getCtx(), "AND")), new ValueNamePair("OR", Msg.getMsg(Env.getCtx(), "OR")) };
    for (ValueNamePair item : andOr) listAndOr.appendItem(item.getName(), item.getValue());
    if (row <= 0) {
        // don't show item on the first row.
        listAndOr.setSelectedIndex(0);
        listAndOr.setVisible(false);
    } else {
        //And - default
        listAndOr.setSelectedIndex(1);
        listAndOr.setVisible(true);
    }
    // Left Bracket
    ValueNamePair[] leftBracket = new ValueNamePair[] { new ValueNamePair("", ""), new ValueNamePair("(", "("), new ValueNamePair("((", "(("), new ValueNamePair("(((", "(((") };
    for (ValueNamePair item : leftBracket) listLeftBracket.appendItem(item.getName(), item.getValue());
    listLeftBracket.setSelectedIndex(0);
    // Right Bracket
    ValueNamePair[] rightBracket = new ValueNamePair[] { new ValueNamePair("", ""), new ValueNamePair(")", ")"), new ValueNamePair("))", "))"), new ValueNamePair(")))", ")))") };
    for (ValueNamePair item : rightBracket) listRightBracket.appendItem(item.getName(), item.getValue());
    listRightBracket.setSelectedIndex(0);
    ListCell cellColumn = new ListCell();
    cellColumn.appendChild(listColumn);
    cellColumn.setId("cellColumn" + listItem.getId());
    ListCell cellOperator = new ListCell();
    cellOperator.appendChild(listOperator);
    cellOperator.setId("cellOperator" + listItem.getId());
    ListCell cellQueryFrom = new ListCell();
    cellQueryFrom.setId("cellQueryFrom" + listItem.getId());
    ListCell cellQueryTo = new ListCell();
    cellQueryTo.setId("cellQueryTo" + listItem.getId());
    ListCell cellAndOr = new ListCell();
    cellAndOr.appendChild(listAndOr);
    cellAndOr.setId("cellAndOr" + listItem.getId());
    ListCell cellLeftBracket = new ListCell();
    cellLeftBracket.appendChild(listLeftBracket);
    cellLeftBracket.setId("cellLeftBracket" + listItem.getId());
    ListCell cellRightBracket = new ListCell();
    cellRightBracket.appendChild(listRightBracket);
    cellRightBracket.setId("cellRightBracket" + listItem.getId());
    listItem.appendChild(cellAndOr);
    listItem.appendChild(cellLeftBracket);
    listItem.appendChild(cellColumn);
    listItem.appendChild(cellOperator);
    listItem.appendChild(cellQueryFrom);
    listItem.appendChild(cellQueryTo);
    listItem.appendChild(cellRightBracket);
    advancedPanel.appendChild(listItem);
    advancedPanel.setSelectedItem(listItem);
    if (fields != null) {
        // QueryFrom
        String columnName = listColumn.getSelectedItem().getValue().toString();
        if (columnName == null || columnName == "")
            return;
        String value = fields.length > INDEX_VALUE ? fields[INDEX_VALUE] : "";
        if (value.length() > 0) {
            // Elaine 2009/03/16 - set attribute value
            cellQueryFrom.setAttribute("value", value);
            cellQueryFrom.appendChild(parseString(getTargetMField(columnName), value, listItem, false));
        }
        // QueryTo
        String value2 = fields.length > INDEX_VALUE2 ? fields[INDEX_VALUE2] : "";
        if (value2.length() > 0) {
            // Elaine 2009/03/16 - set attribute value
            cellQueryTo.setAttribute("value", value);
            cellQueryTo.appendChild(parseString(getTargetMField(columnName), value2, listItem, true));
        }
        // AndOr
        String sandOr = fields.length > INDEX_ANDOR ? fields[INDEX_ANDOR] : "";
        if (sandOr.length() > 0) {
            for (int i = 0; i < listAndOr.getItems().size(); i++) {
                if (listAndOr.getItemAtIndex(i).getValue().equals(sandOr)) {
                    listAndOr.setSelectedIndex(i);
                    break;
                }
            }
        }
        // Left Bracket
        String sLeftBracket = fields.length > INDEX_LEFTBRACKET ? fields[INDEX_LEFTBRACKET] : "";
        if (sLeftBracket.length() > 0) {
            for (int i = 0; i < listLeftBracket.getItems().size(); i++) {
                if (listLeftBracket.getItemAtIndex(i).getValue().equals(sLeftBracket)) {
                    listLeftBracket.setSelectedIndex(i);
                    break;
                }
            }
        }
        // Right Bracket
        String sRightBracket = fields.length > INDEX_RIGHTBRACKET ? fields[INDEX_RIGHTBRACKET] : "";
        if (sRightBracket.length() > 0) {
            for (int i = 0; i < listRightBracket.getItems().size(); i++) {
                if (listRightBracket.getItemAtIndex(i).getValue().equals(sRightBracket)) {
                    listRightBracket.setSelectedIndex(i);
                    break;
                }
            }
        }
    }
}
Also used : ListCell(org.adempiere.webui.component.ListCell) ListItem(org.adempiere.webui.component.ListItem) ValueNamePair(org.compiere.util.ValueNamePair) Listbox(org.adempiere.webui.component.Listbox)

Example 19 with ListItem

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

the class FindWindow method onEvent.

// addSelectionColumn
public void onEvent(Event event) throws Exception {
    if (Events.ON_SELECT.equals(event.getName())) {
        if (event.getTarget() instanceof Listbox) {
            ListItem row = (ListItem) (event.getTarget().getParent().getParent());
            Listbox listbox = (Listbox) event.getTarget();
            advancedPanel.setSelectedItem(row);
            Listbox listColumn = (Listbox) row.getFellow("listColumn" + row.getId());
            Listbox listOperator = (Listbox) row.getFellow("listOperator" + row.getId());
            if (listbox.getId().equals(listColumn.getId()) || listbox.getId().equals(listOperator.getId())) {
                if (listbox.getId().equals(listColumn.getId())) {
                    ListItem column = listColumn.getSelectedItem();
                    if (column != null) {
                        addOperators(column, listOperator);
                    }
                }
                Component componentFrom = getEditorCompQueryFrom(row);
                Component componentTo = getEditorCompQueryTo(row);
                addRowEditor(componentFrom, (ListCell) row.getFellow("cellQueryFrom" + row.getId()));
                addRowEditor(componentTo, (ListCell) row.getFellow("cellQueryTo" + row.getId()));
            }
        } else if (event.getTarget() == fQueryName) {
            int index = fQueryName.getSelectedIndex();
            if (index < 0) {
                if (fQueryName.getSelectedItem() == null || fQueryName.getSelectedItem().equals(m_sTipText)) {
                    return;
                }
            } else if (index == 0) {
                // no query - wipe and start over.
                List<?> rowList = advancedPanel.getChildren();
                for (int rowIndex = rowList.size() - 1; rowIndex >= 1; rowIndex--) rowList.remove(rowIndex);
                createFields();
                fQueryName.setSelectedIndex(-1);
                fQueryName.setText(m_sTipText);
            } else
                parseUserQuery(userQueries[index - 1]);
        }
    } else //
    if (Events.ON_CLICK.equals(event.getName())) {
        //  Toolbar Buttons actions
        if (event.getTarget() instanceof ToolBarButton) {
            ToolBarButton button = (ToolBarButton) event.getTarget();
            if ("btnNewAdv".equals(button.getAttribute("name").toString())) {
                createFields();
            } else if ("btnDeleteAdv".equals(button.getAttribute("name").toString())) {
                int index = advancedPanel.getSelectedIndex();
                if (index >= 0) {
                    cmd_delete();
                }
            } else if ("btnSaveAdv".equals(button.getAttribute("name").toString())) {
                // Save the query but don't overwrite the Last query
                cmd_save(false);
            }
        } else //  Confirm panel actions
        if (event.getTarget() instanceof Button) {
            Button btn = (Button) event.getTarget();
            if ("btnOkSimple".equals(btn.getName())) {
                cmd_ok_Simple();
                dispose();
            } else if ("btnOkAdv".equals(btn.getName())) {
                cmd_ok_Advanced();
                dispose();
            } else if ("btnCancel".equals(btn.getName())) {
                m_isCancel = true;
                dispose();
            } else if ("btnNew".equals(btn.getName())) {
                m_query = MQuery.getNoRecordQuery(m_tableName, true);
                m_total = 0;
                m_createNew = true;
                dispose();
            }
        }
    } else if (Events.ON_OK.equals(event.getName())) {
        if (winLookupRecord.equals(event.getTarget())) {
            cmd_ok_Simple();
            dispose();
        } else if (winAdvanced.equals(event.getTarget())) {
            cmd_ok_Advanced();
            dispose();
        }
        // Check simple panel fields
        for (WEditor editor : m_sEditors) {
            if (editor.getComponent() == event.getTarget()) {
                cmd_ok_Simple();
                dispose();
            }
        }
        // Check simple panel fields
        for (WEditor editor : m_sEditors2) {
            if (editor != null && editor.getComponent() == event.getTarget()) {
                cmd_ok_Simple();
                dispose();
            }
        }
    } else if (Events.ON_FOCUS.equals(event.getName())) {
        if (event.getTarget() == fQueryName) {
            // fQueryName received the focus - delete the tip text so the user can type without 
            // having to delete the tip.
            int index = fQueryName.getSelectedIndex();
            if (index < 0) {
                if (fQueryName.getSelectedItem() == null || fQueryName.getSelectedItem().equals(m_sTipText)) {
                    fQueryName.setSelectedIndex(-1);
                    fQueryName.setText("");
                }
            }
        }
    } else if (Events.ON_BLUR.equals(event.getName())) {
        if (event.getTarget() == fQueryName) {
            // fQueryName lost the focus. If the field is blank, replace the tip text.
            if (fQueryName.getSelectedItem() != null && fQueryName.getSelectedItem().equals("")) {
                fQueryName.setText(m_sTipText);
            }
        }
    }
}
Also used : ToolBarButton(org.adempiere.webui.component.ToolBarButton) Button(org.adempiere.webui.component.Button) ToolBarButton(org.adempiere.webui.component.ToolBarButton) ListItem(org.adempiere.webui.component.ListItem) WEditor(org.adempiere.webui.editor.WEditor) Listbox(org.adempiere.webui.component.Listbox) Component(org.zkoss.zk.ui.Component)

Example 20 with ListItem

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

the class InfoSchedule method displayCalendar.

//	fillResource
/**
	 * 	Display Calendar for selected Resource, Time(day/week/month) and Date
	 */
private void displayCalendar() {
    //	Get Values
    ListItem listItem = fieldResource.getSelectedItem();
    if (listItem == null)
        return;
    KeyNamePair pp = new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel());
    int S_Resource_ID = pp.getKey();
    m_mAssignment.setS_Resource_ID(S_Resource_ID);
    // Elaine 2008/12/12
    Date date = fieldDate.getValue();
    if (date == null)
        date = new Timestamp(System.currentTimeMillis());
    //		Date date = m_dateFrom;
    //
    //	Set Info
    m_loading = true;
    schedulePane.recreate(S_Resource_ID, date);
    m_loading = false;
    invalidate();
}
Also used : ListItem(org.adempiere.webui.component.ListItem) KeyNamePair(org.compiere.util.KeyNamePair) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Aggregations

ListItem (org.adempiere.webui.component.ListItem)52 KeyNamePair (org.compiere.util.KeyNamePair)22 Timestamp (java.sql.Timestamp)8 Listbox (org.adempiere.webui.component.Listbox)8 SQLException (java.sql.SQLException)7 BigDecimal (java.math.BigDecimal)6 Label (org.adempiere.webui.component.Label)5 ResultSet (java.sql.ResultSet)4 Date (java.util.Date)4 MLocator (org.compiere.model.MLocator)4 ValueNamePair (org.compiere.util.ValueNamePair)4 Charset (java.nio.charset.Charset)3 PreparedStatement (java.sql.PreparedStatement)3 Calendar (java.util.Calendar)3 GregorianCalendar (java.util.GregorianCalendar)3 NumberBox (org.adempiere.webui.component.NumberBox)3 Row (org.adempiere.webui.component.Row)3 Textbox (org.adempiere.webui.component.Textbox)3 MAttributeValue (org.compiere.model.MAttributeValue)3 BufferedImage (java.awt.image.BufferedImage)2