Search in sources :

Example 1 with Textbox

use of org.zkoss.zul.Textbox in project collect by openforis.

the class SchemaVM method refreshNodeForm.

protected void refreshNodeForm() {
    nodeFormInclude.setSrc(null);
    if (editedNode != null) {
        nodeFormInclude.setDynamicProperty("parentEntity", editedNodeParentEntity);
        nodeFormInclude.setDynamicProperty("item", editedNode);
        nodeFormInclude.setDynamicProperty("newItem", newNode);
        String nodeNameTextboxPath;
        String location;
        if (editedNode instanceof UITab) {
            location = Resources.Component.TAB.getLocation();
            nodeNameTextboxPath = TAB_NAME_LABEL_PATH;
        } else if (editedNode instanceof EntityDefinition) {
            location = Resources.Component.ENTITY.getLocation();
            nodeNameTextboxPath = ENTITY_NAME_TEXTBOX_PATH;
        } else {
            AttributeType attributeType = AttributeType.valueOf((AttributeDefinition) editedNode);
            String locationFormat = Resources.Component.ATTRIBUTE.getLocation();
            String attributeTypeShort = attributeType.name().toLowerCase(Locale.ENGLISH);
            location = MessageFormat.format(locationFormat, attributeTypeShort);
            nodeNameTextboxPath = ATTRIBUTE_NAME_TEXTBOX_PATH;
        }
        nodeFormInclude.setSrc(location);
        // set focus on name textbox
        Textbox nodeNameTextbox = (Textbox) Path.getComponent(nodeFormInclude.getSpaceOwner(), nodeNameTextboxPath);
        nodeNameTextbox.setFocus(true);
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) AttributeType(org.openforis.collect.designer.metamodel.AttributeType) Textbox(org.zkoss.zul.Textbox) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 2 with Textbox

use of org.zkoss.zul.Textbox 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)

Example 3 with Textbox

use of org.zkoss.zul.Textbox in project adempiere by adempiere.

the class InfoPAttributePanel method setDisplay.

/**
	 *   Set the display text
	 */
private void setDisplay() {
    StringBuffer display = new StringBuffer();
    if (serNoField != null && serNoField.getValue().toString().length() > 0)
        display.append(serNoField.getValue().toString() + "-");
    if (lotField != null && lotField.getValue().toString().length() > 0)
        display.append(lotField.getValue().toString() + "-");
    if (lotSelection != null && lotSelection.getSelectedItem().getValue().toString().length() > 0)
        display.append(lotSelection.getSelectedItem().getValue().toString() + "-");
    if (guaranteeDateField != null && guaranteeDateField.getValue() != null)
        display.append(guaranteeDateSelection.getSelectedItem().getValue().toString() + guaranteeDateField.getValue().toString() + "-");
    for (int i = 0; i < m_productEditors.size(); i++) {
        Component c = (Component) m_productEditors.get(i);
        Component cTo = (Component) m_productEditorsTo.get(i);
        if (c instanceof Listbox) {
            Listbox field = (Listbox) c;
            display.append(field.getSelectedItem().getValue().toString() + "-");
        } else if (c instanceof NumberBox) {
            NumberBox field = (NumberBox) c;
            if (field.getValue() != null)
                display.append(field.getValue().toString() + "-");
            NumberBox fieldTo = (NumberBox) cTo;
            if (fieldTo.getValue() != null)
                display.append(fieldTo.getValue().toString() + "-");
        } else {
            Textbox field = (Textbox) c;
            display.append(field.getValue() + "-");
        }
    }
    for (int i = 0; i < m_instanceEditors.size(); i++) {
        Component c = (Component) m_instanceEditors.get(i);
        Component cTo = (Component) m_instanceEditorsTo.get(i);
        if (c instanceof Listbox) {
            Listbox field = (Listbox) c;
            display.append(field.getSelectedItem().getValue().toString() + "-");
        } else if (c instanceof NumberBox) {
            NumberBox field = (NumberBox) c;
            if (field.getValue() != null)
                display.append(field.getValue().toString() + "-");
            NumberBox fieldTo = (NumberBox) cTo;
            if (fieldTo.getValue() != null)
                display.append(fieldTo.getValue().toString() + "-");
        } else {
            Textbox field = (Textbox) c;
            display.append(field.getValue() + "-");
        }
    }
    //  TODO - there is a more elegant way to do this.
    while (display.toString().contains("--") && display.length() > 1) {
        display.delete(display.indexOf("--"), display.indexOf("--") + 1);
    }
    while (display.toString().startsWith("-") && display.length() > 1) {
        display.delete(0, 1);
    }
    while (display.toString().endsWith("-") && display.length() > 1) {
        display.delete(display.length() - 1, display.length());
    }
    m_display = display.toString();
}
Also used : Textbox(org.zkoss.zul.Textbox) NumberBox(org.adempiere.webui.component.NumberBox) Component(org.zkoss.zk.ui.Component) Listbox(org.adempiere.webui.component.Listbox)

Aggregations

Textbox (org.zkoss.zul.Textbox)3 Listbox (org.adempiere.webui.component.Listbox)2 NumberBox (org.adempiere.webui.component.NumberBox)2 Component (org.zkoss.zk.ui.Component)2 BigDecimal (java.math.BigDecimal)1 Timestamp (java.sql.Timestamp)1 ListItem (org.adempiere.webui.component.ListItem)1 KeyNamePair (org.compiere.util.KeyNamePair)1 AttributeType (org.openforis.collect.designer.metamodel.AttributeType)1 UITab (org.openforis.collect.metamodel.ui.UITab)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)1