Search in sources :

Example 1 with MAttributeSet

use of org.compiere.model.MAttributeSet in project adempiere by adempiere.

the class VPAttribute method actionPerformed.

//  addActionListener
/**
	 * 	Action Listener - start dialog
	 * 	@param e Event
	 */
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(RecordInfo.CHANGE_LOG_COMMAND)) {
        RecordInfo.start(m_GridField);
        return;
    }
    if (!m_button.isEnabled())
        return;
    m_button.setEnabled(false);
    //
    Integer oldValue = 0;
    try {
        oldValue = (Integer) getValue();
    } catch (ClassCastException cce) {
    // Possible Invalid Cast exception if getValue() return new instance of Object.
    }
    int oldValueInt = oldValue == null ? 0 : oldValue.intValue();
    int M_AttributeSetInstance_ID = oldValueInt;
    int M_Product_ID = 0;
    int M_ProductBOM_ID = 0;
    if (m_GridTab != null) {
        M_Product_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, m_GridTab.getTabNo(), "M_Product_ID");
        M_ProductBOM_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, m_GridTab.getTabNo(), "M_ProductBOM_ID");
    } else {
        M_Product_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_Product_ID");
        M_ProductBOM_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_ProductBOM_ID");
    }
    int M_Locator_ID = -1;
    log.config("M_Product_ID=" + M_Product_ID + "/" + M_ProductBOM_ID + ",M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID + ", AD_Column_ID=" + m_AD_Column_ID);
    //	M_Product.M_AttributeSetInstance_ID = 8418
    //	HARDCODED
    boolean productWindow = m_AD_Column_ID == 8418;
    //	Exclude ability to enter ASI
    boolean exclude = false;
    if (M_Product_ID != 0) {
        MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
        int M_AttributeSet_ID = product.getM_AttributeSet_ID();
        if (M_AttributeSet_ID != 0) {
            MAttributeSet mas = MAttributeSet.get(Env.getCtx(), M_AttributeSet_ID);
            exclude = mas.excludeEntry(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNo));
        }
    }
    boolean changed = false;
    if (//	Use BOM Component
    M_ProductBOM_ID != 0)
        M_Product_ID = M_ProductBOM_ID;
    // If the VPAttribute component is in a dialog, use the search
    if (m_searchOnly) {
        // The component is an element in a CPanel, which is part of a JPanel
        // which is in a JLayeredPane which is in ...  the InfoProduct window
        Container me = ((Container) this).getParent();
        while (me != null) {
            if (me instanceof InfoProduct)
                break;
            me = me.getParent();
        }
        InfoPAttribute ia = new InfoPAttribute((CDialog) me);
        m_pAttributeWhere = ia.getWhereClause();
        String oldText = m_text.getText();
        m_text.setText(ia.getDisplay());
        // The text can be long.  Use the tooltip to help display the info.
        m_text.setToolTipText(m_text.getText());
        ActionEvent ae = new ActionEvent(m_text, 1001, "updated");
        //  TODO not the generally correct way to fire an event
        ((InfoProduct) me).actionPerformed(ae);
    } else if (!productWindow && (M_Product_ID == 0 || exclude)) {
        changed = true;
        m_text.setText(null);
        M_AttributeSetInstance_ID = 0;
    } else {
        VPAttributeDialog vad = new VPAttributeDialog(Env.getFrame(this), M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID, productWindow, m_AD_Column_ID, m_WindowNo, isReadWrite());
        if (vad.isChanged()) {
            m_text.setText(vad.getM_AttributeSetInstanceName());
            // The text can be long.  Use the tooltip to help display the info.
            m_text.setToolTipText(vad.getM_AttributeSetInstanceName());
            M_AttributeSetInstance_ID = vad.getM_AttributeSetInstance_ID();
            if (!productWindow && vad.getM_Locator_ID() > 0) {
                M_Locator_ID = vad.getM_Locator_ID();
            }
            changed = true;
        }
    }
    //	Set Value
    if (changed) {
        log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID);
        //	force re-query display
        m_value = new Object();
        if (M_AttributeSetInstance_ID == 0)
            setValue(null);
        else
            setValue(new Integer(M_AttributeSetInstance_ID));
        // Change Locator
        if (m_GridTab != null && M_Locator_ID > 0) {
            log.finest("Change M_Locator_ID=" + M_Locator_ID);
            m_GridTab.setValue("M_Locator_ID", M_Locator_ID);
        }
        //
        try {
            String columnName = "M_AttributeSetInstance_ID";
            if (m_GridField != null) {
                columnName = m_GridField.getColumnName();
            }
            fireVetoableChange(columnName, new Object(), getValue());
        } catch (PropertyVetoException pve) {
            log.log(Level.SEVERE, "", pve);
        }
        if (M_AttributeSetInstance_ID == oldValueInt && m_GridTab != null && m_GridField != null) {
            //  force Change - user does not realize that embedded object is already saved.
            m_GridTab.processFieldChange(m_GridField);
        }
    }
    //	change
    m_button.setEnabled(true);
    requestFocus();
}
Also used : MProduct(org.compiere.model.MProduct) ActionEvent(java.awt.event.ActionEvent) MAttributeSet(org.compiere.model.MAttributeSet) PropertyVetoException(java.beans.PropertyVetoException) Container(java.awt.Container) InfoProduct(org.compiere.apps.search.InfoProduct) InfoPAttribute(org.compiere.apps.search.InfoPAttribute)

Example 2 with MAttributeSet

use of org.compiere.model.MAttributeSet in project adempiere by adempiere.

the class VPAttributeDialog method initAttributes.

//	jbInit
/**
	 *	Dyanmic Init.
	 *  @return true if initialized
	 */
private boolean initAttributes() {
    if (m_M_Product_ID == 0 && !m_productWindow)
        return false;
    MAttributeSet as = null;
    if (m_M_Product_ID != 0) {
        //	Get Model
        m_product = MProduct.get(Env.getCtx(), m_M_Product_ID);
        if (m_product.getM_AttributeSetInstance_ID() > 0) {
            m_productASI = true;
            //  The product has an instance associated with it.
            if (m_M_AttributeSetInstance_ID != m_product.getM_AttributeSetInstance_ID()) {
                log.fine("Different ASI than what is specified on Product!");
            }
        } else {
            // Only show product attributes when in the product window.
            m_productASI = m_productWindow;
        }
        m_masi = MAttributeSetInstance.get(Env.getCtx(), m_M_AttributeSetInstance_ID, m_M_Product_ID);
        if (m_masi == null) {
            log.severe("No Model for M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID + ", M_Product_ID=" + m_M_Product_ID);
            return false;
        }
        Env.setContext(Env.getCtx(), m_WindowNo, "M_AttributeSet_ID", m_masi.getM_AttributeSet_ID());
        //	Get Attribute Set
        as = m_masi.getMAttributeSet();
    } else {
        int M_AttributeSet_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_AttributeSet_ID");
        m_masi = new MAttributeSetInstance(Env.getCtx(), 0, M_AttributeSet_ID, null);
        as = m_masi.getMAttributeSet();
    }
    //	Product has no Attribute Set
    if (as == null) {
    //ADialog.error(m_WindowNo, this, "PAttributeNoAttributeSet");
    //return false;
    }
    //  always read/write.  The two are exclusive and can't co-exist.  
    if (//	Set Instance Attributes and dialog controls
    !m_productWindow || !m_productASI) {
        if (// Instance attributes possible.  Set up controls.
        !m_productASI) {
            //	New/Edit - Selection
            if (//	new
            m_M_AttributeSetInstance_ID == 0)
                cbNewEdit.setText(Msg.getMsg(Env.getCtx(), "NewRecord"));
            else
                cbNewEdit.setText(Msg.getMsg(Env.getCtx(), "EditRecord"));
            cbNewEdit.addActionListener(this);
            centerPanel.add(cbNewEdit, new ALayoutConstraint(m_row++, 0));
            bSelect.setText(Msg.getMsg(Env.getCtx(), "SelectExisting"));
            bSelect.addActionListener(this);
            centerPanel.add(bSelect, null);
        }
        //	Add the Instance Attributes if any.  If its a product attribute set
        //  this will do nothing.
        MAttribute[] attributes = as.getMAttributes(true);
        log.fine("Instance Attributes=" + attributes.length);
        for (int i = 0; i < attributes.length; i++) addAttributeLine(attributes[i], false, false);
    }
    if (as != null) {
        //  Product attributes can be shown in any window but are read/write in the Product window only.
        //  This will do nothing if it is an instance attribute set. 
        // False = product attribute instances
        MAttribute[] attributes = as.getMAttributes(false);
        log.fine("Product Attributes=" + attributes.length);
        for (int i = 0; i < attributes.length; i++) addAttributeLine(attributes[i], true, !m_productWindow);
    }
    //	Lot
    if ((!m_productWindow || !m_productASI) && as.isLot()) {
        CLabel label = new CLabel(Msg.translate(Env.getCtx(), "Lot"));
        label.setLabelFor(fieldLotString);
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldLotString, null);
        fieldLotString.setText(m_masi.getLot());
        //	M_Lot_ID
        //	int AD_Column_ID = 9771;	//	M_AttributeSetInstance.M_Lot_ID
        //	fieldLot = new VLookup ("M_Lot_ID", false,false, true, 
        //		MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir));
        String sql = "SELECT M_Lot_ID, Name " + "FROM M_Lot l " + "WHERE EXISTS (SELECT M_Product_ID FROM M_Product p " + "WHERE p.M_AttributeSet_ID=" + m_masi.getM_AttributeSet_ID() + " AND p.M_Product_ID=l.M_Product_ID)";
        fieldLot = new CComboBox(DB.getKeyNamePairs(sql, true));
        label = new CLabel(Msg.translate(Env.getCtx(), "M_Lot_ID"));
        label.setLabelFor(fieldLot);
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldLot, null);
        if (m_masi.getM_Lot_ID() != 0) {
            for (int i = 1; i < fieldLot.getItemCount(); i++) {
                KeyNamePair pp = (KeyNamePair) fieldLot.getItemAt(i);
                if (pp.getKey() == m_masi.getM_Lot_ID()) {
                    fieldLot.setSelectedIndex(i);
                    fieldLotString.setEditable(false);
                    break;
                }
            }
        }
        fieldLot.addActionListener(this);
        //	New Lot Button
        if (m_masi.getMAttributeSet().getM_LotCtl_ID() != 0 && m_readWrite) {
            if (MRole.getDefault().isTableAccess(MLot.Table_ID, false) && MRole.getDefault().isTableAccess(MLotCtl.Table_ID, false) && !m_masi.isExcludeLot(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) {
                centerPanel.add(bLot, null);
                bLot.addActionListener(this);
            }
        }
        //	Popup 
        //  popup
        fieldLot.addMouseListener(new VPAttributeDialog_mouseAdapter(this));
        mZoom = new CMenuItem(Msg.getMsg(Env.getCtx(), "Zoom"), Env.getImageIcon("Zoom16.gif"));
        mZoom.addActionListener(this);
        popupMenu.add(mZoom);
    }
    //	SerNo
    if ((!m_productWindow || !m_productASI) && as.isSerNo()) {
        CLabel label = new CLabel(Msg.translate(Env.getCtx(), "SerNo"));
        label.setLabelFor(fieldSerNo);
        fieldSerNo.setText(m_masi.getSerNo());
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldSerNo, null);
        //	New SerNo Button
        if (m_masi.getMAttributeSet().getM_SerNoCtl_ID() != 0 && m_readWrite) {
            if (MRole.getDefault().isTableAccess(MSerNoCtl.Table_ID, false) && !m_masi.isExcludeSerNo(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) {
                centerPanel.add(bSerNo, null);
                bSerNo.addActionListener(this);
            }
        }
    }
    //	GuaranteeDate
    if ((!m_productWindow || !m_productASI) && as.isGuaranteeDate()) {
        CLabel label = new CLabel(Msg.translate(Env.getCtx(), "GuaranteeDate"));
        label.setLabelFor(fieldGuaranteeDate);
        if (m_M_AttributeSetInstance_ID == 0)
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate(true));
        else
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate());
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldGuaranteeDate, null);
    }
    if (m_row == 0) {
        ADialog.error(m_WindowNo, this, "PAttributeNoInfo");
    //return false;
    }
    //	New/Edit Window
    if ((!m_productWindow || !m_productASI) && m_AD_Column_ID != 0 && m_readWrite) {
        cbNewEdit.setSelected(m_M_AttributeSetInstance_ID == 0);
        cmd_newEdit();
    }
    //	Attribute Set Instance Description
    CLabel label = new CLabel(Msg.translate(Env.getCtx(), "Description"));
    label.setLabelFor(fieldDescription);
    fieldDescription.setText(m_masi.getDescription());
    fieldDescription.setEditable(false);
    centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
    centerPanel.add(fieldDescription, null);
    //	Window usually to wide (??)
    Dimension dd = centerPanel.getPreferredSize();
    dd.width = Math.min(500, dd.width);
    centerPanel.setPreferredSize(dd);
    return true;
}
Also used : CLabel(org.compiere.swing.CLabel) CComboBox(org.compiere.swing.CComboBox) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) Dimension(java.awt.Dimension) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) MAttributeSet(org.compiere.model.MAttributeSet) CMenuItem(org.compiere.swing.CMenuItem) KeyNamePair(org.compiere.util.KeyNamePair) MAttribute(org.compiere.model.MAttribute)

Example 3 with MAttributeSet

use of org.compiere.model.MAttributeSet in project adempiere by adempiere.

the class WPAttributeDialog method saveSelection.

//	cmd_zoom
/**
	 *	Save Selection
	 *	@return true if saved
	 */
private boolean saveSelection() {
    log.info("");
    MAttributeSet as = m_masi.getMAttributeSet();
    if (as == null)
        return true;
    //
    m_changed = false;
    String mandatory = "";
    if (!m_productWindow && as.isLot()) {
        log.fine("Lot=" + fieldLotString.getText());
        String text = fieldLotString.getText();
        m_masi.setLot(text);
        if (as.isLotMandatory() && (text == null || text.length() == 0))
            mandatory += " - " + Msg.translate(Env.getCtx(), "Lot");
        m_changed = true;
    }
    //	Lot
    if (!m_productWindow && as.isSerNo()) {
        log.fine("SerNo=" + fieldSerNo.getText());
        String text = fieldSerNo.getText();
        m_masi.setSerNo(text);
        if (as.isSerNoMandatory() && (text == null || text.length() == 0))
            mandatory += " - " + Msg.translate(Env.getCtx(), "SerNo");
        m_changed = true;
    }
    //	SerNo
    if (!m_productWindow && as.isGuaranteeDate()) {
        log.fine("GuaranteeDate=" + fieldGuaranteeDate.getValue());
        Date gDate = fieldGuaranteeDate.getValue();
        Timestamp ts = gDate != null ? new Timestamp(gDate.getTime()) : null;
        m_masi.setGuaranteeDate(ts);
        if (as.isGuaranteeDateMandatory() && ts == null)
            mandatory += " - " + Msg.translate(Env.getCtx(), "GuaranteeDate");
        m_changed = true;
    }
    //	New Instance
    if (m_changed || m_masi.getM_AttributeSetInstance_ID() == 0) {
        m_masi.save();
        m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID();
        m_M_AttributeSetInstanceName = m_masi.getDescription();
    }
    //  Save attributes
    if (m_M_AttributeSetInstance_ID > 0) {
        //	Save Instance Attributes
        MAttribute[] attributes = as.getMAttributes(!m_productASI);
        for (int i = 0; i < attributes.length; i++) {
            if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributes[i].getAttributeValueType())) {
                Listbox editor = (Listbox) m_editors.get(i);
                ListItem item = editor.getSelectedItem();
                MAttributeValue value = item != null ? (MAttributeValue) item.getValue() : null;
                log.fine(attributes[i].getName() + "=" + value);
                if (attributes[i].isMandatory() && value == null)
                    mandatory += " - " + attributes[i].getName();
                attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
            } else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributes[i].getAttributeValueType())) {
                NumberBox editor = (NumberBox) m_editors.get(i);
                BigDecimal value = editor.getValue();
                log.fine(attributes[i].getName() + "=" + value);
                if (attributes[i].isMandatory() && value == null)
                    mandatory += " - " + attributes[i].getName();
                //setMAttributeInstance doesn't work without decimal point
                if (value != null && value.scale() == 0)
                    value = value.setScale(1, BigDecimal.ROUND_HALF_UP);
                attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
            } else {
                Textbox editor = (Textbox) m_editors.get(i);
                String value = editor.getText();
                log.fine(attributes[i].getName() + "=" + value);
                if (attributes[i].isMandatory() && (value == null || value.length() == 0))
                    mandatory += " - " + attributes[i].getName();
                attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
            }
        }
        m_changed = true;
    }
    //	Save Model
    if (m_changed) {
        m_masi.setDescription();
        m_masi.save();
    }
    m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID();
    m_M_AttributeSetInstanceName = m_masi.getDescription();
    //
    if (mandatory.length() > 0) {
        FDialog.error(m_WindowNo, this, "FillMandatory", mandatory);
        return false;
    }
    return true;
}
Also used : Textbox(org.adempiere.webui.component.Textbox) NumberBox(org.adempiere.webui.component.NumberBox) Timestamp(java.sql.Timestamp) Date(java.util.Date) BigDecimal(java.math.BigDecimal) MAttributeSet(org.compiere.model.MAttributeSet) MAttributeValue(org.compiere.model.MAttributeValue) ListItem(org.adempiere.webui.component.ListItem) Listbox(org.adempiere.webui.component.Listbox) MAttribute(org.compiere.model.MAttribute)

Example 4 with MAttributeSet

use of org.compiere.model.MAttributeSet in project adempiere by adempiere.

the class WPAttributeDialog method initAttributes.

//	init
/**
	 *	Dyanmic Init.
	 *  @return true if initialized
	 */
private boolean initAttributes() {
    Rows rows = new Rows();
    rows.setParent(centerLayout);
    if (m_M_Product_ID == 0 && !m_productWindow)
        return false;
    MAttributeSet as = null;
    if (m_M_Product_ID != 0) {
        //	Get Model
        m_product = MProduct.get(Env.getCtx(), m_M_Product_ID);
        if (m_product.getM_AttributeSetInstance_ID() > 0) {
            m_productASI = true;
            //  The product has an instance associated with it.
            if (m_M_AttributeSetInstance_ID != m_product.getM_AttributeSetInstance_ID()) {
                log.fine("Different ASI than what is specified on Product!");
            }
        } else {
            // Only show product attributes when in the product window.
            m_productASI = m_productWindow;
        }
        m_masi = MAttributeSetInstance.get(Env.getCtx(), m_M_AttributeSetInstance_ID, m_M_Product_ID);
        if (m_masi == null) {
            log.severe("No Model for M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID + ", M_Product_ID=" + m_M_Product_ID);
            return false;
        }
        Env.setContext(Env.getCtx(), m_WindowNo, "M_AttributeSet_ID", m_masi.getM_AttributeSet_ID());
        //	Get Attribute Set
        as = m_masi.getMAttributeSet();
    } else {
        int M_AttributeSet_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_AttributeSet_ID");
        m_masi = new MAttributeSetInstance(Env.getCtx(), 0, M_AttributeSet_ID, null);
        as = m_masi.getMAttributeSet();
    }
    //	Product has no Attribute Set
    if (as == null) {
        FDialog.error(m_WindowNo, this, "PAttributeNoAttributeSet");
        return false;
    }
    //  always read/write.  The two are exclusive and can't co-exists.  
    if (//	Set Instance Attributes and dialog controls
    !m_productWindow || !m_productASI) {
        if (// Instance attributes possible.  Set up controls.
        !m_productASI) {
            Row row = new Row();
            //	New/Edit - Selection
            if (//	new
            m_M_AttributeSetInstance_ID == 0)
                cbNewEdit.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "NewRecord")));
            else
                cbNewEdit.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord")));
            cbNewEdit.addEventListener(Events.ON_CHECK, this);
            row.appendChild(cbNewEdit);
            bSelect.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "SelectExisting")));
            bSelect.setImage(ServletFns.resolveThemeURL("~./images/PAttribute16.png"));
            bSelect.addEventListener(Events.ON_CLICK, this);
            row.appendChild(bSelect);
            rows.appendChild(row);
        }
        //	Add the Instance Attributes if any.  If its a product attribute set
        //  this will do nothing.
        // True = Instances
        MAttribute[] attributes = as.getMAttributes(true);
        log.fine("Instance Attributes=" + attributes.length);
        for (int i = 0; i < attributes.length; i++) addAttributeLine(rows, attributes[i], false, false);
    }
    //  Product attributes can be shown in any window but are read/write in the Product window only.
    //  This will do nothing if it is an instance attribute set. 
    // False = products
    MAttribute[] attributes = as.getMAttributes(false);
    log.fine("Product Attributes=" + attributes.length);
    for (int i = 0; i < attributes.length; i++) addAttributeLine(rows, attributes[i], true, !m_productWindow);
    //	Lot
    if ((!m_productWindow || !m_productASI) && as.isLot()) {
        Row row = new Row();
        row.setParent(rows);
        m_row++;
        Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "Lot")));
        row.appendChild(label);
        row.appendChild(fieldLotString);
        fieldLotString.setText(m_masi.getLot());
        //	M_Lot_ID
        //	int AD_Column_ID = 9771;	//	M_AttributeSetInstance.M_Lot_ID
        //	fieldLot = new VLookup ("M_Lot_ID", false,false, true, 
        //		MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir));
        String sql = "SELECT M_Lot_ID, Name " + "FROM M_Lot l " + "WHERE EXISTS (SELECT M_Product_ID FROM M_Product p " + "WHERE p.M_AttributeSet_ID=" + m_masi.getM_AttributeSet_ID() + " AND p.M_Product_ID=l.M_Product_ID)";
        fieldLot = new Listbox();
        fieldLot.setMold("select");
        KeyNamePair[] keyNamePairs = DB.getKeyNamePairs(sql, true);
        for (KeyNamePair pair : keyNamePairs) {
            fieldLot.appendItem(pair.getName(), pair.getKey());
        }
        label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "M_Lot_ID")));
        row = new Row();
        row.setParent(rows);
        m_row++;
        row.appendChild(label);
        row.appendChild(fieldLot);
        if (m_masi.getM_Lot_ID() != 0) {
            for (int i = 1; i < fieldLot.getItemCount(); i++) {
                ListItem pp = fieldLot.getItemAtIndex(i);
                if ((Integer) pp.getValue() == m_masi.getM_Lot_ID()) {
                    fieldLot.setSelectedIndex(i);
                    fieldLotString.setReadonly(true);
                    break;
                }
            }
        }
        fieldLot.addEventListener(Events.ON_SELECT, this);
        //	New Lot Button
        if (m_masi.getMAttributeSet().getM_LotCtl_ID() != 0) {
            if (MRole.getDefault().isTableAccess(MLot.Table_ID, false) && MRole.getDefault().isTableAccess(MLotCtl.Table_ID, false) && !m_masi.isExcludeLot(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) {
                row = new Row();
                row.setParent(rows);
                m_row++;
                row.appendChild(bLot);
                bLot.addEventListener(Events.ON_CLICK, this);
            }
        }
        //	Popup 
        //			fieldLot.addMouseListener(new VPAttributeDialog_mouseAdapter(this));    //  popup
        mZoom = new Menuitem(Msg.getMsg(Env.getCtx(), "Zoom"), ServletFns.resolveThemeURL("~./images/Zoom16.png"));
        mZoom.addEventListener(Events.ON_CLICK, this);
        popupMenu.appendChild(mZoom);
        this.appendChild(popupMenu);
    }
    //	SerNo
    if ((!m_productWindow || !m_productASI) && as.isSerNo()) {
        Row row = new Row();
        row.setParent(rows);
        m_row++;
        Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "SerNo")));
        row.appendChild(label);
        row.appendChild(fieldSerNo);
        fieldSerNo.setText(m_masi.getSerNo());
        //	New SerNo Button
        if (m_masi.getMAttributeSet().getM_SerNoCtl_ID() != 0) {
            if (MRole.getDefault().isTableAccess(MSerNoCtl.Table_ID, false) && !m_masi.isExcludeSerNo(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) {
                row = new Row();
                row.setParent(rows);
                m_row++;
                row.appendChild(bSerNo);
                bSerNo.addEventListener(Events.ON_CLICK, this);
            }
        }
    }
    //	GuaranteeDate
    if ((!m_productWindow || !m_productASI) && as.isGuaranteeDate()) {
        Row row = new Row();
        row.setParent(rows);
        m_row++;
        Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "GuaranteeDate")));
        if (m_M_AttributeSetInstance_ID == 0)
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate(true));
        else
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate());
        row.appendChild(label);
        row.appendChild(fieldGuaranteeDate);
    }
    if (m_row == 0) {
        FDialog.error(m_WindowNo, this, "PAttributeNoInfo");
        return false;
    }
    //	New/Edit Window
    if (!m_productWindow) {
        cbNewEdit.setChecked(m_M_AttributeSetInstance_ID == 0);
        cmd_newEdit();
    }
    //	Attrribute Set Instance Description
    Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "Description")));
    //		label.setLabelFor(fieldDescription);
    fieldDescription.setText(m_masi.getDescription());
    fieldDescription.setReadonly(true);
    Row row = new Row();
    row.setParent(rows);
    row.appendChild(label);
    row.appendChild(fieldDescription);
    return true;
}
Also used : Label(org.adempiere.webui.component.Label) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) MAttributeSet(org.compiere.model.MAttributeSet) Menuitem(org.zkoss.zul.Menuitem) Row(org.adempiere.webui.component.Row) KeyNamePair(org.compiere.util.KeyNamePair) ListItem(org.adempiere.webui.component.ListItem) Listbox(org.adempiere.webui.component.Listbox) Rows(org.adempiere.webui.component.Rows) MAttribute(org.compiere.model.MAttribute)

Example 5 with MAttributeSet

use of org.compiere.model.MAttributeSet in project adempiere by adempiere.

the class ExpressReceiptScanBar method isLot.

public boolean isLot() {
    if (isLot == null) {
        MAttributeSet attributeUse = null;
        if (product.getM_AttributeSet_ID() > 0) {
            attributeUse = (MAttributeSet) product.getM_AttributeSet();
            isLot = attributeUse.isLot();
        } else
            isLot = false;
    }
    return isLot;
}
Also used : MAttributeSet(org.compiere.model.MAttributeSet)

Aggregations

MAttributeSet (org.compiere.model.MAttributeSet)22 BigDecimal (java.math.BigDecimal)7 MAttribute (org.compiere.model.MAttribute)7 MProduct (org.compiere.model.MProduct)6 MAttributeSetInstance (org.compiere.model.MAttributeSetInstance)5 Listbox (org.adempiere.webui.component.Listbox)4 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 Timestamp (java.sql.Timestamp)3 Row (org.adempiere.webui.component.Row)3 MAttributeInstance (org.compiere.model.MAttributeInstance)3 MAttributeValue (org.compiere.model.MAttributeValue)3 KeyNamePair (org.compiere.util.KeyNamePair)3 Dimension (java.awt.Dimension)2 Label (org.adempiere.webui.component.Label)2 ListItem (org.adempiere.webui.component.ListItem)2 NumberBox (org.adempiere.webui.component.NumberBox)2 VComboBox (org.compiere.grid.ed.VComboBox)2 VString (org.compiere.grid.ed.VString)2