Search in sources :

Example 41 with ListItem

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

the class WLocatorDialog method isChanged.

// getValue
/**
	 *	Get result
	 *  @return true if changed
	 */
public boolean isChanged() {
    if (m_change) {
        ListItem listitem = lstLocator.getSelectedItem();
        MLocator l = (MLocator) listitem.getValue();
        if (l != null)
            return l.getM_Locator_ID() == m_M_Locator_ID;
    }
    return m_change;
}
Also used : MLocator(org.compiere.model.MLocator) ListItem(org.adempiere.webui.component.ListItem)

Example 42 with ListItem

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

the class WLocatorDialog method createValue.

// getWarehouseInfo
/**
	 *	Create Locator-Value
	 */
private void createValue() {
    // Get Warehouse Info
    ListItem listitem = lstWarehouse.getSelectedItem();
    KeyNamePair pp = (KeyNamePair) listitem.getValue();
    if (pp == null)
        return;
    getWarehouseInfo(pp.getKey());
    StringBuffer buf = new StringBuffer(m_M_WarehouseValue);
    buf.append(m_Separator).append(txtAisleX.getText());
    buf.append(m_Separator).append(txtBinY.getText());
    buf.append(m_Separator).append(txtLevelZ.getText());
    txtKey.setText(buf.toString());
}
Also used : ListItem(org.adempiere.webui.component.ListItem) KeyNamePair(org.compiere.util.KeyNamePair)

Example 43 with ListItem

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

the class WLocatorDialog method displayLocator.

// initLocator
private void displayLocator() {
    MLocator l = null;
    ListItem listitem = lstLocator.getSelectedItem();
    if (listitem != null)
        l = (MLocator) listitem.getValue();
    if (l == null)
        return;
    m_M_Locator_ID = l.getM_Locator_ID();
    txtWarehouse.setText(l.getWarehouseName());
    txtAisleX.setText(l.getX());
    txtBinY.setText(l.getY());
    txtLevelZ.setText(l.getZ());
    txtKey.setText(l.getValue());
    getWarehouseInfo(l.getM_Warehouse_ID());
    //	Set Warehouse
    int size = lstWarehouse.getItemCount();
    for (int i = 0; i < size; i++) {
        ListItem listItem = lstWarehouse.getItemAtIndex(i);
        KeyNamePair pp = (KeyNamePair) listItem.getValue();
        if (pp.getKey() == l.getM_Warehouse_ID()) {
            lstWarehouse.setSelectedIndex(i);
            continue;
        }
    }
}
Also used : MLocator(org.compiere.model.MLocator) ListItem(org.adempiere.webui.component.ListItem) KeyNamePair(org.compiere.util.KeyNamePair)

Example 44 with ListItem

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

the class WWFPanelManufacturing method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
        this.detach();
    else if (event.getTarget().getId().equals(ConfirmPanel.A_OK))
        this.detach();
    else if (event.getTarget() == workflowList) {
        ListItem item = workflowList.getSelectedItem();
        KeyNamePair knp = item != null ? item.toKeyNamePair() : null;
        if (knp != null && knp.getKey() > 0) {
            load(knp.getKey());
        } else {
            Image dummy = null;
            imageMap.setContent(dummy);
        }
    }
}
Also used : ListItem(org.adempiere.webui.component.ListItem) KeyNamePair(org.compiere.util.KeyNamePair) AImage(org.zkoss.image.AImage) BufferedImage(java.awt.image.BufferedImage) Image(org.zkoss.image.Image)

Example 45 with ListItem

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

the class InfoPAttributePanel method createQuery.

//	actionPerformed
/**
	 * 	Create Query
	 *  <code>
	 * 	Available synonyms:
	 *		M_Product p
	 *		M_ProductPrice pr
	 *		M_AttributeSet pa
	 *	</code>
	 *	@return query
	 */
private String createQuery() {
    /** Base Query
		SELECT *
		FROM M_Product p
 		 INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID)
 		 LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID)
		WHERE
		**/
    /***	Instance Attributes		*/
    StringBuffer sb = new StringBuffer();
    //	Serial No
    String s = serNoField.getComponent().getText();
    if (s != null && s.length() > 0) {
        sb.append(" AND asi.SerNo");
        if (s.indexOf('%') == -1 && s.indexOf('_') == 1)
            sb.append("=");
        else
            sb.append(" LIKE ");
        sb.append(DB.TO_STRING(s));
    }
    //	Lot Number
    s = lotField.getComponent().getText();
    if (s != null && s.length() > 0) {
        sb.append(" AND asi.Lot");
        if (s.indexOf('%') == -1 && s.indexOf('_') == 1)
            sb.append("=");
        else
            sb.append(" LIKE ");
        sb.append(DB.TO_STRING(s));
    }
    //	Lot ID
    ListItem li = lotSelection.getSelectedItem();
    if (li != null && li.getValue() != null) {
        KeyNamePair pp = (KeyNamePair) li.getValue();
        if (pp != null && pp.getKey() != -1) {
            int ID = pp.getKey();
            sb.append(" AND asi.M_Lot_ID=").append(ID);
        }
    }
    //	Guarantee Date
    Timestamp ts = (Timestamp) guaranteeDateField.getValue();
    if (ts != null) {
        sb.append(" AND TRUNC(asi.GuaranteeDate, 'DD')");
        //	 < = >
        int index = guaranteeDateSelection.getSelectedIndex();
        if (index == 0)
            sb.append("<");
        else if (index == 1)
            sb.append("=");
        else
            sb.append(">");
        sb.append(DB.TO_DATE(ts, true));
    }
    //	Instance Editors
    for (int i = 0; i < m_instanceEditors.size(); i++) {
        StringBuffer iAttr = new StringBuffer();
        Component c = (Component) m_instanceEditors.get(i);
        Component cTo = (Component) m_instanceEditorsTo.get(i);
        int M_Attribute_ID = Integer.parseInt(c.getId());
        if (c instanceof Listbox) {
            Listbox field = (Listbox) c;
            li = field.getSelectedItem();
            if (li != null && li.getValue() != null) {
                KeyNamePair pp = (KeyNamePair) li.getValue();
                if (pp != null && pp.getKey() != -1) {
                    iAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND M_AttributeValue_ID=").append(pp.getKey());
                }
            }
        } else if (c instanceof NumberBox) {
            NumberBox field = (NumberBox) c;
            BigDecimal value = (BigDecimal) field.getValue();
            NumberBox fieldTo = (NumberBox) cTo;
            BigDecimal valueTo = (BigDecimal) fieldTo.getValue();
            if (value != null || valueTo != null) {
                iAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND ValueNumber");
                if (value != null && valueTo == null)
                    iAttr.append("=").append(value);
                else if (value == null && valueTo != null)
                    iAttr.append("<=").append(valueTo);
                else if (value != null && valueTo != null)
                    iAttr.append(" BETWEEN ").append(value).append(" AND ").append(valueTo);
            }
        } else {
            Textbox field = (Textbox) c;
            String value = field.getText();
            if (value != null && value.length() > 0) {
                iAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND Value");
                if (value.indexOf('%') == -1 && value.indexOf('_') == -1)
                    iAttr.append("=");
                else
                    iAttr.append(" LIKE ");
                iAttr.append(DB.TO_STRING(value));
            }
        }
        //	Add to where
        if (iAttr.length() > 0)
            sb.append(" AND asi.M_AttributeSetInstance_ID IN " + "(SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance " + "WHERE ").append(iAttr).append(")");
    }
    //	finish Instance Attributes
    if (sb.length() > 0) {
        sb.insert(0, " AND EXISTS (SELECT * FROM M_Storage s" + " INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) " + "WHERE s.M_Product_ID=p.M_Product_ID");
        sb.append(")");
    }
    //	Product Attributes 
    for (int i = 0; i < m_productEditors.size(); i++) {
        StringBuffer pAttr = new StringBuffer();
        Component c = (Component) m_productEditors.get(i);
        Component cTo = (Component) m_productEditorsTo.get(i);
        int M_Attribute_ID = Integer.parseInt(c.getId());
        if (c instanceof Listbox) {
            Listbox field = (Listbox) c;
            li = field.getSelectedItem();
            if (li != null && li.getValue() != null) {
                KeyNamePair pp = (KeyNamePair) li.getValue();
                if (pp != null && pp.getKey() != -1) {
                    pAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND M_AttributeValue_ID=").append(pp.getKey());
                }
            }
        } else if (c instanceof NumberBox) {
            NumberBox field = (NumberBox) c;
            BigDecimal value = (BigDecimal) field.getValue();
            NumberBox fieldTo = (NumberBox) cTo;
            BigDecimal valueTo = (BigDecimal) fieldTo.getValue();
            if (value != null || valueTo != null) {
                pAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND ValueNumber");
                if (value != null && valueTo == null)
                    pAttr.append("=").append(value);
                else if (value == null && valueTo != null)
                    pAttr.append("<=").append(valueTo);
                else if (value != null && valueTo != null)
                    pAttr.append(" BETWEEN ").append(value).append(" AND ").append(valueTo);
            }
        } else {
            Textbox field = (Textbox) c;
            String value = field.getText();
            if (value != null && value.length() > 0) {
                pAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND Value");
                if (value.indexOf('%') == -1 && value.indexOf('_') == -1)
                    pAttr.append("=");
                else
                    pAttr.append(" LIKE ");
                pAttr.append(DB.TO_STRING(value));
            }
        }
        //	Add to Where
        if (pAttr.length() > 0)
            sb.append(" AND p.M_AttributeSetInstance_ID IN " + "(SELECT M_AttributeSetInstance_ID " + "FROM M_AttributeInstance WHERE ").append(pAttr).append(")");
    }
    //
    m_query = null;
    if (sb.length() > 0)
        m_query = sb.toString();
    log.config(m_query);
    return m_query;
}
Also used : Textbox(org.zkoss.zul.Textbox) ListItem(org.adempiere.webui.component.ListItem) KeyNamePair(org.compiere.util.KeyNamePair) NumberBox(org.adempiere.webui.component.NumberBox) Component(org.zkoss.zk.ui.Component) Listbox(org.adempiere.webui.component.Listbox) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal)

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