Search in sources :

Example 1 with ALayoutConstraint

use of org.compiere.apps.ALayoutConstraint 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 2 with ALayoutConstraint

use of org.compiere.apps.ALayoutConstraint in project adempiere by adempiere.

the class VPAttributeDialog method addAttributeLine.

//	initAttribute
/**
	 * 	Add Attribute Line
	 *	@param attribute attribute
	 * 	@param product product level attribute
	 * 	@param readOnly value is read only
	 */
private void addAttributeLine(MAttribute attribute, boolean product, boolean readOnly) {
    log.fine(attribute + ", Product=" + product + ", R/O=" + readOnly);
    CLabel label = new CLabel(attribute.getName());
    if (product)
        label.setFont(new Font(label.getFont().getFontName(), Font.BOLD, label.getFont().getSize()));
    if (attribute.getDescription() != null)
        label.setToolTipText(attribute.getDescription());
    centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
    //
    MAttributeInstance instance = attribute.getMAttributeInstance(m_M_AttributeSetInstance_ID);
    if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attribute.getAttributeValueType())) {
        //	optional = null
        MAttributeValue[] values = attribute.getMAttributeValues();
        CComboBox editor = new CComboBox(values);
        boolean found = false;
        if (instance != null) {
            for (int i = 0; i < values.length; i++) {
                if (values[i] != null && values[i].getM_AttributeValue_ID() == instance.getM_AttributeValue_ID()) {
                    editor.setSelectedIndex(i);
                    found = true;
                    break;
                }
            }
            if (found)
                log.fine("Attribute=" + attribute.getName() + " #" + values.length + " - found: " + instance);
            else
                log.warning("Attribute=" + attribute.getName() + " #" + values.length + " - NOT found: " + instance);
        } else
            //	setComboBox
            log.fine("Attribute=" + attribute.getName() + " #" + values.length + " no instance");
        label.setLabelFor(editor);
        centerPanel.add(editor, null);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    } else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attribute.getAttributeValueType())) {
        VNumber editor = new VNumber(attribute.getName(), attribute.isMandatory(), readOnly, !readOnly, DisplayType.Number, attribute.getName());
        if (instance != null)
            editor.setValue(instance.getValueNumber());
        else
            editor.setValue(Env.ZERO);
        label.setLabelFor(editor);
        centerPanel.add(editor, null);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    } else //	Text Field
    {
        VString editor = new VString(attribute.getName(), attribute.isMandatory(), false, true, 20, INSTANCE_VALUE_LENGTH, null, null);
        if (instance != null)
            editor.setText(instance.getValue());
        label.setLabelFor(editor);
        centerPanel.add(editor, null);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    }
}
Also used : CLabel(org.compiere.swing.CLabel) MAttributeInstance(org.compiere.model.MAttributeInstance) CComboBox(org.compiere.swing.CComboBox) MAttributeValue(org.compiere.model.MAttributeValue) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) Font(java.awt.Font) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 3 with ALayoutConstraint

use of org.compiere.apps.ALayoutConstraint in project adempiere by adempiere.

the class VMRPDetailed method statInit.

/**
	 * Static Setup - add fields to parameterPanel
	 * @throws Exception if Lookups cannot be initialized
	 */
private void statInit() throws Exception {
    // Resource Lookup
    // Base Language
    Language language = Language.getLoginLanguage();
    MLookup resourceL = MLookupFactory.get(getCtx(), p_WindowNo, MColumn.getColumn_ID(MResource.Table_Name, MResource.COLUMNNAME_S_Resource_ID), DisplayType.TableDir, language, MResource.COLUMNNAME_S_Resource_ID, 0, false, MResource.Table_Name + "." + MResource.COLUMNNAME_ManufacturingResourceType + "= '" + MResource.MANUFACTURINGRESOURCETYPE_Plant + "'");
    fResource_ID = new VLookup(MPPMRP.COLUMNNAME_S_Resource_ID, false, false, true, resourceL) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    lResource_ID.setLabelFor(fResource_ID);
    fResource_ID.setBackground(AdempierePLAF.getInfoBackground());
    // Planner Lookup
    fPlanner_ID = new VLookup(MPPMRP.COLUMNNAME_Planner_ID, false, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPPProductPlanning.Table_Name, MPPMRP.COLUMNNAME_Planner_ID), DisplayType.Table)) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    lPlanner_ID.setLabelFor(fPlanner_ID);
    fPlanner_ID.setBackground(AdempierePLAF.getInfoBackground());
    // Wahrehouse Lookup
    fWarehouse_ID = new VLookup(MPPMRP.COLUMNNAME_M_Warehouse_ID, true, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MWarehouse.Table_Name, MPPMRP.COLUMNNAME_M_Warehouse_ID), DisplayType.TableDir)) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    lWarehouse_ID.setLabelFor(fWarehouse_ID);
    fWarehouse_ID.setBackground(AdempierePLAF.getInfoBackground());
    fMaster.setSelected(false);
    fMaster.setReadWrite(false);
    fMRPReq.setSelected(false);
    fMRPReq.setReadWrite(false);
    fCreatePlan.setSelected(false);
    fCreatePlan.setReadWrite(false);
    lUOM.setText(Msg.translate(getCtx(), MUOM.COLUMNNAME_C_UOM_ID));
    fUOM.setBackground(AdempierePLAF.getInfoBackground());
    fUOM.setReadWrite(false);
    lType.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Policy));
    fType.setBackground(AdempierePLAF.getInfoBackground());
    fType.setReadWrite(false);
    lOrderPeriod.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Period));
    fOrderPeriod.setBackground(AdempierePLAF.getInfoBackground());
    fOrderPeriod.setReadWrite(false);
    lTimefence.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_TimeFence));
    fTimefence.setBackground(AdempierePLAF.getInfoBackground());
    fTimefence.setReadWrite(false);
    lLeadtime.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_DeliveryTime_Promised));
    fLeadtime.setBackground(AdempierePLAF.getInfoBackground());
    fLeadtime.setReadWrite(false);
    lMinOrd.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Min));
    fMinOrd.setBackground(AdempierePLAF.getInfoBackground());
    fMinOrd.setReadWrite(false);
    lMaxOrd.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Max));
    fMaxOrd.setBackground(AdempierePLAF.getInfoBackground());
    fMaxOrd.setReadWrite(false);
    lOrdMult.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Pack));
    fOrdMult.setBackground(AdempierePLAF.getInfoBackground());
    fOrdMult.setReadWrite(false);
    lOrderQty.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Qty));
    fOrderQty.setBackground(AdempierePLAF.getInfoBackground());
    fOrderQty.setReadWrite(false);
    lYield.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Yield));
    fYield.setBackground(AdempierePLAF.getInfoBackground());
    fYield.setReadWrite(false);
    lOnhand.setText(Msg.translate(getCtx(), MStorage.COLUMNNAME_QtyOnHand));
    fOnhand.setBackground(AdempierePLAF.getInfoBackground());
    fOnhand.setReadWrite(false);
    lSafetyStock.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_SafetyStock));
    fSafetyStock.setBackground(AdempierePLAF.getInfoBackground());
    fSafetyStock.setReadWrite(false);
    lReserved.setText(Msg.translate(getCtx(), MStorage.COLUMNNAME_QtyReserved));
    fReserved.setBackground(AdempierePLAF.getInfoBackground());
    fReserved.setReadWrite(false);
    lAvailable.setText(Msg.translate(getCtx(), "QtyAvailable"));
    fAvailable.setBackground(AdempierePLAF.getInfoBackground());
    fAvailable.setReadWrite(false);
    lOrdered.setText(Msg.translate(getCtx(), MPPOrder.COLUMNNAME_QtyOrdered));
    fOrdered.setBackground(AdempierePLAF.getInfoBackground());
    fOrdered.setReadWrite(false);
    // Product Lookup
    fProduct_ID = new VLookup(MPPMRP.COLUMNNAME_M_Product_ID, true, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MProduct.Table_Name, MPPMRP.COLUMNNAME_M_Product_ID), DisplayType.Search)) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
            fAttrSetInstance_ID.setValue(new Integer(0));
        }

        ;
    };
    fAttrSetInstance_ID = new CButton() {

        private static final long serialVersionUID = 1L;

        private Object value;

        public Object getValue() {
            return value;
        }

        ;

        public void setText(String text) {
            if (text == null) {
                text = "---";
            }
            if (text.length() > 23) {
                text = text.substring(0, 20) + "...";
            }
            super.setText(text);
        }

        ;

        public void setValue(Object arg0) {
            value = arg0;
            int i = (arg0 instanceof Integer) ? ((Integer) arg0).intValue() : 0;
            if (i == 0) {
                setText(null);
            }
        }

        ;
    };
    fAttrSetInstance_ID.setValue(new Integer(0));
    fAttrSetInstance_ID.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            selectAttributeSetInstance();
        }
    });
    lProduct_ID.setLabelFor(fProduct_ID);
    fProduct_ID.setBackground(AdempierePLAF.getInfoBackground());
    //
    lDateFrom.setLabelFor(fDateFrom);
    fDateFrom.setBackground(AdempierePLAF.getInfoBackground());
    fDateFrom.setToolTipText(Msg.translate(getCtx(), MLot.COLUMNNAME_DateFrom));
    lDateTo.setLabelFor(fDateTo);
    fDateTo.setBackground(AdempierePLAF.getInfoBackground());
    fDateTo.setToolTipText(Msg.translate(getCtx(), MLot.COLUMNNAME_DateTo));
    fSupplyType = new VLookup(MPPMRP.COLUMNNAME_TypeMRP, false, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPPMRP.Table_Name, MPPMRP.COLUMNNAME_TypeMRP), DisplayType.List));
    lSupplyType.setLabelFor(fSupplyType);
    fSupplyType.setBackground(AdempierePLAF.getInfoBackground());
    //
    parameterPanel.setLayout(new ALayout());
    // 1st Row
    parameterPanel.add(lProduct_ID, new ALayoutConstraint(0, 0));
    parameterPanel.add(fProduct_ID, new ALayoutConstraint(0, 1));
    parameterPanel.add(lUOM, new ALayoutConstraint(0, 2));
    parameterPanel.add(fUOM, new ALayoutConstraint(0, 3));
    parameterPanel.add(lType, new ALayoutConstraint(0, 4));
    parameterPanel.add(fType, new ALayoutConstraint(0, 5));
    // 2nd Row
    parameterPanel.add(lAttrSetInstance_ID, new ALayoutConstraint(1, 0));
    parameterPanel.add(fAttrSetInstance_ID, new ALayoutConstraint(1, 1));
    parameterPanel.add(lOnhand, new ALayoutConstraint(1, 2));
    parameterPanel.add(fOnhand, new ALayoutConstraint(1, 3));
    parameterPanel.add(lOrderPeriod, new ALayoutConstraint(1, 4));
    parameterPanel.add(fOrderPeriod, new ALayoutConstraint(1, 5));
    // 3rd Row
    parameterPanel.add(lPlanner_ID, new ALayoutConstraint(2, 0));
    parameterPanel.add(fPlanner_ID, new ALayoutConstraint(2, 1));
    parameterPanel.add(lSafetyStock, new ALayoutConstraint(2, 2));
    parameterPanel.add(fSafetyStock, new ALayoutConstraint(2, 3));
    parameterPanel.add(lMinOrd, new ALayoutConstraint(2, 4));
    parameterPanel.add(fMinOrd, new ALayoutConstraint(2, 5));
    // 4th Row
    parameterPanel.add(lWarehouse_ID, new ALayoutConstraint(3, 0));
    parameterPanel.add(fWarehouse_ID, new ALayoutConstraint(3, 1));
    parameterPanel.add(lReserved, new ALayoutConstraint(3, 2));
    parameterPanel.add(fReserved, new ALayoutConstraint(3, 3));
    parameterPanel.add(lMaxOrd, new ALayoutConstraint(3, 4));
    parameterPanel.add(fMaxOrd, new ALayoutConstraint(3, 5));
    // 5th Row
    parameterPanel.add(lResource_ID, new ALayoutConstraint(4, 0));
    parameterPanel.add(fResource_ID, new ALayoutConstraint(4, 1));
    parameterPanel.add(lAvailable, new ALayoutConstraint(4, 2));
    parameterPanel.add(fAvailable, new ALayoutConstraint(4, 3));
    parameterPanel.add(lOrdMult, new ALayoutConstraint(4, 4));
    parameterPanel.add(fOrdMult, new ALayoutConstraint(4, 5));
    // 6th Row
    parameterPanel.add(lDateFrom, new ALayoutConstraint(5, 0));
    parameterPanel.add(fDateFrom, new ALayoutConstraint(5, 1));
    parameterPanel.add(lOrdered, new ALayoutConstraint(5, 2));
    parameterPanel.add(fOrdered, new ALayoutConstraint(5, 3));
    parameterPanel.add(lOrderQty, new ALayoutConstraint(5, 4));
    parameterPanel.add(fOrderQty, new ALayoutConstraint(5, 5));
    // 7th Row
    parameterPanel.add(lDateTo, new ALayoutConstraint(6, 0));
    parameterPanel.add(fDateTo, new ALayoutConstraint(6, 1));
    parameterPanel.add(lTimefence, new ALayoutConstraint(6, 4));
    parameterPanel.add(fTimefence, new ALayoutConstraint(6, 5));
    // 8th Row
    parameterPanel.add(fMaster, new ALayoutConstraint(7, 1));
    parameterPanel.add(fCreatePlan, new ALayoutConstraint(7, 3));
    parameterPanel.add(lLeadtime, new ALayoutConstraint(7, 4));
    parameterPanel.add(fLeadtime, new ALayoutConstraint(7, 5));
    // 9th Row
    parameterPanel.add(fMRPReq, new ALayoutConstraint(8, 3));
    parameterPanel.add(lYield, new ALayoutConstraint(8, 4));
    parameterPanel.add(fYield, new ALayoutConstraint(8, 5));
}
Also used : Language(org.compiere.util.Language) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) CButton(org.compiere.swing.CButton) ALayout(org.compiere.apps.ALayout)

Example 4 with ALayoutConstraint

use of org.compiere.apps.ALayoutConstraint in project adempiere by adempiere.

the class InfoProduct method statInit.

/**
	 *	Static Setup - add fields to parameterPanel
	 */
private void statInit() {
    labelValue.setText(Msg.getMsg(Env.getCtx(), "Value"));
    fieldValue.setBackground(AdempierePLAF.getInfoBackground());
    fieldValue.addActionListener(this);
    labelName.setText(Msg.getMsg(Env.getCtx(), "Name"));
    fieldName.setBackground(AdempierePLAF.getInfoBackground());
    fieldName.addActionListener(this);
    labelUPC.setText(Msg.translate(Env.getCtx(), "UPC"));
    fieldUPC.setBackground(AdempierePLAF.getInfoBackground());
    fieldUPC.addActionListener(this);
    labelSKU.setText(Msg.translate(Env.getCtx(), "SKU"));
    fieldSKU.setBackground(AdempierePLAF.getInfoBackground());
    fieldSKU.addActionListener(this);
    labelWarehouse.setText(Msg.getMsg(Env.getCtx(), "Warehouse"));
    fWarehouse_ID = new VLookup("M_Warehouse_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MWarehouse.Table_Name, MWarehouse.COLUMNNAME_M_Warehouse_ID), DisplayType.TableDir));
    fWarehouse_ID.setBackground(AdempierePLAF.getInfoBackground());
    fWarehouse_ID.addActionListener(this);
    checkOnlyStock.setText(Msg.getMsg(Env.getCtx(), "OnlyStock"));
    checkOnlyStock.setName("OnlyStock");
    checkOnlyStock.setToolTipText(Msg.getMsg(Env.getCtx(), "OnlyStockTip"));
    // Info may open when searching for non-stock as well.
    checkOnlyStock.setSelected(false);
    checkOnlyStock.addActionListener(this);
    checkShowDetail.setText(Msg.getMsg(Env.getCtx(), "ShowDetail"));
    checkShowDetail.setName("ShowDetail");
    checkShowDetail.setToolTipText(Msg.getMsg(Env.getCtx(), "ShowAttributeDetails"));
    checkShowDetail.setSelected(false);
    checkShowDetail.setEnabled(false);
    checkShowDetail.addActionListener(this);
    checkAND.setText(Msg.getMsg(Env.getCtx(), "SearchAND"));
    checkAND.setName("SearchAND");
    checkAND.setToolTipText(Msg.getMsg(Env.getCtx(), "SearchANDInfo"));
    checkAND.setSelected(true);
    checkAND.addActionListener(this);
    labelPriceList.setText(Msg.getMsg(Env.getCtx(), "PriceListVersion"));
    fPriceList_ID = new VLookup("M_PriceList_Version_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPriceListVersion.Table_Name, MPriceListVersion.COLUMNNAME_M_PriceList_Version_ID), DisplayType.TableDir));
    fPriceList_ID.setBackground(AdempierePLAF.getInfoBackground());
    fPriceList_ID.addActionListener(this);
    labelProductCategory.setText(Msg.translate(Env.getCtx(), "M_Product_Category_ID"));
    fProductCategory_ID = new VLookup("M_Product_Category_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MProductCategory.Table_Name, MProductCategory.COLUMNNAME_M_Product_Category_ID), DisplayType.TableDir));
    fProductCategory_ID.setBackground(AdempierePLAF.getInfoBackground());
    fProductCategory_ID.addActionListener(this);
    // @Trifon
    labelAS.setText(Msg.translate(Env.getCtx(), "M_AttributeSet_ID"));
    fAS_ID = new VLookup("M_AttributeSet_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MAttributeSet.Table_Name, MAttributeSet.COLUMNNAME_M_AttributeSet_ID), DisplayType.TableDir));
    fAS_ID.setBackground(AdempierePLAF.getInfoBackground());
    fAS_ID.addActionListener(this);
    //
    labelASI.setText(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"));
    MPAttributeLookup mpaLookup = new MPAttributeLookup(Env.getCtx(), p_WindowNo);
    fASI_ID = new VPAttribute((GridTab) null, false, false, true, p_WindowNo, mpaLookup, true);
    fASI_ID.setBackground(AdempierePLAF.getInfoBackground());
    fASI_ID.addActionListener(this);
    labelVendor.setText(Msg.translate(Env.getCtx(), "Vendor"));
    fVendor_ID = new VLookup("C_BPartner_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MProductPO.Table_Name, MProductPO.COLUMNNAME_C_BPartner_ID), DisplayType.Search));
    fVendor_ID.setBackground(AdempierePLAF.getInfoBackground());
    fVendor_ID.addActionListener(this);
    // Override the isSOTrx context, Vendors only
    fVendor_ID.setIsSOTrx(true, false);
    //  Setup the Grid
    //	Line 1
    p_criteriaGrid.add(labelValue, new ALayoutConstraint(0, 0));
    p_criteriaGrid.add(fieldValue, null);
    p_criteriaGrid.add(labelWarehouse, null);
    p_criteriaGrid.add(fWarehouse_ID, null);
    p_criteriaGrid.add(checkOnlyStock, new ALayoutConstraint(0, 5));
    //	Line 2
    p_criteriaGrid.add(labelName, new ALayoutConstraint(1, 0));
    p_criteriaGrid.add(fieldName, null);
    p_criteriaGrid.add(labelPriceList, null);
    p_criteriaGrid.add(fPriceList_ID, null);
    // @Trifon
    p_criteriaGrid.add(labelAS, null);
    // @Trifon
    p_criteriaGrid.add(fAS_ID, null);
    // Line 3
    p_criteriaGrid.add(labelUPC, new ALayoutConstraint(2, 0));
    p_criteriaGrid.add(fieldUPC, null);
    p_criteriaGrid.add(labelProductCategory, null);
    p_criteriaGrid.add(fProductCategory_ID, null);
    p_criteriaGrid.add(labelASI, null);
    p_criteriaGrid.add(fASI_ID, null);
    //  Line 4
    p_criteriaGrid.add(labelSKU, new ALayoutConstraint(3, 0));
    p_criteriaGrid.add(fieldSKU, null);
    p_criteriaGrid.add(labelVendor, null);
    p_criteriaGrid.add(fVendor_ID, null);
    p_criteriaGrid.add(checkAND, new ALayoutConstraint(3, 5));
    //	Product Attribute Instance
    m_PAttributeButton = ConfirmPanel.createPAttributeButton(true);
    confirmPanel.addButton(m_PAttributeButton);
    m_PAttributeButton.addActionListener(this);
    m_PAttributeButton.setEnabled(false);
    //Begin - fer_luck @ centuryon
    //add taskpane
    fieldDescription.setBackground(AdempierePLAF.getInfoBackground());
    fieldDescription.setEditable(false);
    fieldDescription.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100));
    fieldPAttributes.setBackground(AdempierePLAF.getInfoBackground());
    fieldPAttributes.setEditable(false);
    fieldPAttributes.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100));
    ColumnInfo[] s_layoutWarehouse = new ColumnInfo[] { new ColumnInfo(" ", "M_Warehouse_ID", IDColumn.class), new ColumnInfo(Msg.translate(Env.getCtx(), "WarehouseName"), "WarehouseName", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "sum(QtyAvailable)", Double.class, true, true, null), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "sum(QtyOnHand)", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "sum(QtyReserved)", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "sum(QtyOrdered)", Double.class) };
    //        		new ColumnInfo(Msg.translate(Env.getCtx(), "DocumentNote"), "DocumentNote", String.class)};
    /**	From Clause							*/
    String s_sqlFrom = " M_PRODUCT_STOCK_V ";
    /** Where Clause						*/
    String s_sqlWhere = "(QtyOnHand <> 0 OR QtyAvailable <> 0 OR QtyReserved <> 0 OR QtyOrdered <> 0) AND M_Product_ID = ?";
    m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V");
    m_sqlWarehouse += " Group By M_Warehouse_ID, WarehouseName ";
    m_sqlWarehouse += " Order By sum(QtyOnHand) DESC, WarehouseName ";
    warehouseTbl.setRowSelectionAllowed(true);
    warehouseTbl.setMultiSelection(false);
    warehouseTbl.addMouseListener(this);
    warehouseTbl.setShowTotals(true);
    warehouseTbl.autoSize();
    ColumnInfo[] s_layoutSubstitute = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "description", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "value", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class, true, true, null), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class) };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'S'";
    m_sqlSubstitute = substituteTbl.prepareTable(s_layoutSubstitute, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    substituteTbl.setRowSelectionAllowed(false);
    substituteTbl.setMultiSelection(false);
    substituteTbl.addMouseListener(this);
    substituteTbl.setShowTotals(false);
    substituteTbl.autoSize();
    ColumnInfo[] s_layoutRelated = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "description", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "value", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class, true, true, null), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class) };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'R'";
    m_sqlRelated = relatedTbl.prepareTable(s_layoutRelated, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    relatedTbl.setRowSelectionAllowed(false);
    relatedTbl.setMultiSelection(false);
    relatedTbl.addMouseListener(this);
    relatedTbl.setShowTotals(false);
    relatedTbl.autoSize();
    //Available to Promise Tab
    initAtpTab();
    m_tableAtp.setRowSelectionAllowed(false);
    m_tableAtp.setMultiSelection(false);
    //Vendor tab
    ColumnInfo[] s_layoutVendor = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Vendor"), "(SELECT bp.Name FROM C_BPartner bp WHERE bp.C_BPartner_ID = M_PRODUCT_PO.C_BPartner_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsCurrentVendor"), "IsCurrentVendor", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_UOM_ID"), "(SELECT Name FROM C_UOM WHERE C_UOM_ID = M_PRODUCT_PO.C_UOM_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_Currency_ID"), "(SELECT iso_code FROM C_Currency WHERE C_Currency_ID = M_PRODUCT_PO.C_Currency_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceList"), "PriceList", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PricePO"), "PricePO", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "VendorProductNo"), "VendorProductNo", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Order_Min"), "Order_Min", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "DeliveryTime_Promised"), "DeliveryTime_Promised", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "DeliveryTime_Actual"), "DeliveryTime_Actual", Double.class) };
    s_sqlFrom = "M_PRODUCT_PO";
    s_sqlWhere = "M_Product_ID = ?";
    m_sqlVendor = vendorTbl.prepareTable(s_layoutVendor, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_PO");
    vendorTbl.setRowSelectionAllowed(false);
    vendorTbl.setMultiSelection(false);
    vendorTbl.addMouseListener(this);
    vendorTbl.setShowTotals(false);
    vendorTbl.autoSize();
    jTab.addTab(Msg.translate(Env.getCtx(), "Warehouse"), new JScrollPane(warehouseTbl));
    jTab.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 250 : 105));
    jTab.addTab(Msg.translate(Env.getCtx(), "Description"), new JScrollPane(fieldDescription));
    jTab.addTab(Msg.translate(Env.getCtx(), "ProductAttribute"), new JScrollPane(fieldPAttributes));
    jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl));
    jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl));
    jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp));
    jTab.addTab(Msg.translate(Env.getCtx(), "Vendor"), new JScrollPane(vendorTbl));
    jTab.addChangeListener(this);
    tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110));
    tablePanel.setLayout(new BorderLayout());
    tablePanel.add(jTab, BorderLayout.CENTER);
    //  Add the details to the p_detailPanel
    p_detailTaskPane.setTitle(Msg.translate(Env.getCtx(), "WarehouseStock"));
    p_detailTaskPane.add(checkShowDetail, BorderLayout.NORTH);
    p_detailTaskPane.add(tablePanel, BorderLayout.CENTER);
    p_detailTaskPane.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) VPAttribute(org.compiere.grid.ed.VPAttribute) BorderLayout(java.awt.BorderLayout) GridTab(org.compiere.model.GridTab) VLookup(org.compiere.grid.ed.VLookup) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) ColumnInfo(org.compiere.minigrid.ColumnInfo) Dimension(java.awt.Dimension) MPAttributeLookup(org.compiere.model.MPAttributeLookup)

Example 5 with ALayoutConstraint

use of org.compiere.apps.ALayoutConstraint in project adempiere by adempiere.

the class InfoPAttribute method dynInit.

//	jbInit
/**
	 * 	Dynamic Init of the Center Panel
	 */
private void dynInit() {
    int row = addAttributes();
    boolean isGuarantee = true;
    boolean isSerial = true;
    boolean isLot = true;
    if (p_M_AttributeSet_ID > 0) {
        MAttributeSet as = new MAttributeSet(Env.getCtx(), p_M_AttributeSet_ID, null);
        isGuarantee = as.isGuaranteeDate();
        isSerial = as.isSerNo();
        isLot = as.isLot();
    }
    //
    String s = Msg.translate(Env.getCtx(), "GuaranteeDate");
    guaranteeDateSelection = new VComboBox(new Object[] { s + " <", s + " =", s + " >" });
    //	guaranteeDateSelection.setPreferredSize();
    initLotSelection();
    //	Fixed Instance Selection Fields		
    if (isSerial) {
        centerPanel.add(serNoLabel, new ALayoutConstraint(row++, 0));
        centerPanel.add(serNoField, null);
    }
    if (isLot) {
        centerPanel.add(lotLabel, new ALayoutConstraint(row++, 0));
        centerPanel.add(lotField, null);
        centerPanel.add(lotLabel2, new ALayoutConstraint(row++, 0));
        centerPanel.add(lotSelection, null);
    }
    if (isGuarantee) {
        centerPanel.add(guaranteeDateSelection, new ALayoutConstraint(row++, 0));
        centerPanel.add(guaranteeDateField, null);
    }
    //
    Dimension d = centerPanel.getPreferredSize();
    d.width = 400;
    centerPanel.setPreferredSize(d);
}
Also used : ALayoutConstraint(org.compiere.apps.ALayoutConstraint) VString(org.compiere.grid.ed.VString) VComboBox(org.compiere.grid.ed.VComboBox) Dimension(java.awt.Dimension) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) MAttributeSet(org.compiere.model.MAttributeSet)

Aggregations

ALayoutConstraint (org.compiere.apps.ALayoutConstraint)24 Dimension (java.awt.Dimension)11 ALayout (org.compiere.apps.ALayout)10 VLookup (org.compiere.grid.ed.VLookup)9 CLabel (org.compiere.swing.CLabel)8 CPanel (org.compiere.swing.CPanel)7 BorderLayout (java.awt.BorderLayout)5 CComboBox (org.compiere.swing.CComboBox)5 JScrollPane (javax.swing.JScrollPane)3 MAttributeSet (org.compiere.model.MAttributeSet)3 ButtonGroup (javax.swing.ButtonGroup)2 JCheckBox (javax.swing.JCheckBox)2 JRadioButton (javax.swing.JRadioButton)2 TitledBorder (javax.swing.border.TitledBorder)2 VComboBox (org.compiere.grid.ed.VComboBox)2 VNumber (org.compiere.grid.ed.VNumber)2 VString (org.compiere.grid.ed.VString)2 ColumnInfo (org.compiere.minigrid.ColumnInfo)2 KeyNamePair (org.compiere.util.KeyNamePair)2 Component (java.awt.Component)1