Search in sources :

Example 16 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class VPaySelect method loadTableInfo.

//  loadBankInfo
/**
	 *  Query and create TableInfo
	 */
private void loadTableInfo() {
    Timestamp payDate = (Timestamp) fieldPayDate.getValue();
    miniTable.setColorCompare(payDate);
    log.config("PayDate=" + payDate);
    BankInfo bi = (BankInfo) fieldBankAccount.getSelectedItem();
    ValueNamePair paymentRule = (ValueNamePair) fieldPaymentRule.getSelectedItem();
    KeyNamePair docType = (KeyNamePair) fieldDtype.getSelectedItem();
    int c_bpartner_id = 0;
    if (fieldBPartner.getValue() != null)
        c_bpartner_id = ((Integer) fieldBPartner.getValue()).intValue();
    loadTableInfo(bi, payDate, paymentRule, onlyDue.isSelected(), c_bpartner_id, docType, miniTable);
    calculateSelection();
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) KeyNamePair(org.compiere.util.KeyNamePair) Timestamp(java.sql.Timestamp)

Example 17 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class FolderBrowser method onEvent.

public void onEvent(Event e) throws Exception {
    if (e.getName() == Events.ON_DOUBLE_CLICK && e.getTarget() instanceof ListItem) {
        int index = listDir.getSelectedIndex();
        ValueNamePair vnp = listDir.getItemAtIndex(index).toValueNamePair();
        getFileListing(vnp.getValue());
    }
    if (e.getTarget() == confirmPanel.getButton(ConfirmPanel.A_OK)) {
        path = txtPath.getValue();
        if (path != null) {
            File file = new File(path);
            if (showDirOnly) {
                if (!file.isDirectory() || !file.exists()) {
                    FDialog.error(0, "Invalid directory");
                    return;
                }
            } else {
                if (!file.isFile() || !file.exists()) {
                    FDialog.error(0, "Invalid file");
                    return;
                }
            }
            path = file.getAbsolutePath();
        }
        dispose();
    } else if (e.getTarget() == confirmPanel.getButton(ConfirmPanel.A_CANCEL)) {
        path = null;
        dispose();
    }
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) File(java.io.File)

Example 18 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class FindWindow method addOperators.

//    addOperators
/**
     * add Operators
     * @param op array of operators
    **/
private void addOperators(ValueNamePair[] op, Listbox listOperator) {
    List<?> itemList = listOperator.getChildren();
    itemList.clear();
    for (ValueNamePair item : op) {
        listOperator.appendItem(item.getName(), item.getValue());
    }
    listOperator.setSelectedIndex(0);
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair)

Example 19 with ValueNamePair

use of org.compiere.util.ValueNamePair 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 20 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class M_PriceList_Create method raiseError.

// del doIt
private void raiseError(String string, String sql) throws Exception {
    // DB.rollback(false, get_TrxName());
    String msg = string;
    ValueNamePair pp = CLogger.retrieveError();
    if (pp != null)
        msg = pp.getName() + " - ";
    msg += sql;
    throw new AdempiereUserError(msg);
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) ValueNamePair(org.compiere.util.ValueNamePair)

Aggregations

ValueNamePair (org.compiere.util.ValueNamePair)109 KeyNamePair (org.compiere.util.KeyNamePair)35 SQLException (java.sql.SQLException)22 ArrayList (java.util.ArrayList)22 PreparedStatement (java.sql.PreparedStatement)20 ResultSet (java.sql.ResultSet)19 Timestamp (java.sql.Timestamp)9 GridField (org.compiere.model.GridField)7 BigDecimal (java.math.BigDecimal)5 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)5 MetalTheme (javax.swing.plaf.metal.MetalTheme)5 MInvoice (org.compiere.model.MInvoice)5 MLookup (org.compiere.model.MLookup)5 MLookupInfo (org.compiere.model.MLookupInfo)5 HRPayPrint (org.eevolution.service.HRPayPrint)5 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)4 ListItem (org.adempiere.webui.component.ListItem)4 MCashLine (org.compiere.model.MCashLine)4 AdempiereUserError (org.compiere.util.AdempiereUserError)4 NamePair (org.compiere.util.NamePair)4