Search in sources :

Example 6 with VComboBox

use of org.compiere.grid.ed.VComboBox in project adempiere by adempiere.

the class VHRActionNotice method dynInit.

//  jbInit
/**
	 *	Fill Picks.
	 *		Column_ID from C_Order
	 *  @throws Exception if Lookups cannot be initialized
	 */
public void dynInit() throws Exception {
    // Process
    fieldProcess = new VComboBox(getProcess());
    fieldProcess.addActionListener(this);
    fieldProcess.setMandatory(true);
    // Employee
    fieldEmployee.addActionListener(this);
    fieldEmployee.setReadWrite(false);
    fieldEmployee.setMandatory(true);
    // Concept
    fieldConcept.addActionListener(this);
    fieldConcept.setReadWrite(false);
    fieldConcept.setMandatory(true);
    // ValidFrom
    fieldValidFrom.setReadWrite(false);
    fieldValidFrom.setMandatory(true);
    fieldValidFrom.addVetoableChangeListener(this);
    // Description
    fieldDescription.setValue("");
    fieldDescription.setReadWrite(false);
    // ColumnType
    fieldColumnType = new VLookup("ColumnType", true, true, false, getColumnTypeLookup());
    fieldColumnType.setReadWrite(false);
    //	For Text Message like reference
    fieldTextLookup.setReadWrite(true);
    // Qty-Amount-Date-Text-RuleEngine
    fieldQty.setReadWrite(false);
    fieldQty.setDisplayType(DisplayType.Quantity);
    fieldQty.setVisible(true);
    fieldAmount.setDisplayType(DisplayType.Amount);
    fieldAmount.setVisible(false);
    fieldDate.setVisible(false);
    fieldText.setVisible(false);
    fieldTextLookup.setVisible(false);
    fieldRuleE.setVisible(false);
    //
    bOk.addActionListener(this);
    //	Yamel Senih 2013-03-11
    //	Fixed columns increment in minitable
    miniTable = new MiniTable();
    //	End Yamel Senih
    configureMiniTable(miniTable);
}
Also used : VLookup(org.compiere.grid.ed.VLookup) VComboBox(org.compiere.grid.ed.VComboBox) MiniTable(org.compiere.minigrid.MiniTable)

Example 7 with VComboBox

use of org.compiere.grid.ed.VComboBox in project adempiere by adempiere.

the class VCollectDetail method loadCreditPanel.

/**
	 * Load for Credit Card
	 * @return void
	 */
private void loadCreditPanel() {
    creditPanel = new CPanel(layout);
    //	For Credit Card
    //C_Payment_v.CreditCardType
    int columnId = 8374;
    MLookup cardlookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnId, DisplayType.List);
    fieldCreditCardType = new VLookup("CreditCardType", true, false, true, cardlookup);
    //	For Credit Card Type
    ((VComboBox) fieldCreditCardType.getCombo()).setRenderer(new POSLookupListCellRenderer(font));
    fieldCreditCardType.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    ((VComboBox) fieldCreditCardType.getCombo()).setFont(font);
    fieldCreditCardType.addVetoableChangeListener(this);
    //	For Months
    //	For Card No
    String creditCardNumber = Msg.translate(ctx, "CreditCardNumber");
    fieldCreditCardNumber = new POSTextField(creditCardNumber, parentCollect.getKeyboard());
    fieldCreditCardNumber.setPlaceholder(creditCardNumber);
    fieldCreditCardNumber.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    fieldCreditCardNumber.setFont(font);
    fieldCreditCardNumber.addKeyListener(this);
    fieldCreditCardNumber.addActionListener(this);
    //	For Card Name
    String name = Msg.translate(ctx, "A_Name");
    fieldName = new POSTextField(name, parentCollect.getKeyboard());
    fieldName.setPlaceholder(name);
    fieldName.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    fieldName.setFont(font);
    fieldName.addKeyListener(this);
    fieldName.addActionListener(this);
    //	For Card Month
    fieldCreditCardExpMM = new VComboBox(getCCMonths());
    fieldCreditCardExpMM.setName("CreditCardExpMM");
    fieldCreditCardExpMM.setValue(-1);
    fieldCreditCardExpMM.setMandatory(true);
    fieldCreditCardExpMM.setPreferredSize(new Dimension(FIELD_WIDTH / 2, FIELD_HEIGHT));
    fieldCreditCardExpMM.setRenderer(new POSLookupListCellRenderer(font));
    fieldCreditCardExpMM.setFont(font);
    fieldCreditCardExpMM.addActionListener(this);
    //	For Card Year
    fieldCreditCardExpYY = new VComboBox(getCCYears());
    fieldCreditCardExpYY.setName("CreditCardExpYY");
    fieldCreditCardExpYY.setValue(-1);
    fieldCreditCardExpYY.setMandatory(true);
    fieldCreditCardExpYY.setPreferredSize(new Dimension(FIELD_WIDTH / 2, FIELD_HEIGHT));
    fieldCreditCardExpYY.setRenderer(new POSLookupListCellRenderer(font));
    fieldCreditCardExpYY.setFont(font);
    fieldCreditCardExpYY.addActionListener(this);
    //	For Card VV
    String creditCardVV = Msg.translate(ctx, "CreditCardVV");
    fieldCreditCardVV = new POSTextField(creditCardVV, parentCollect.getKeyboard());
    fieldCreditCardVV.setPlaceholder(creditCardVV);
    fieldCreditCardVV.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    fieldCreditCardVV.setFont(font);
    fieldCreditCardVV.addKeyListener(this);
    fieldCreditCardVV.addActionListener(this);
    //	Add to Panel
    creditPanel.add(fieldCreditCardType, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldName, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardNumber, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardVV, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardExpMM, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardExpYY, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    //	Default visible false
    creditPanel.setVisible(false);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MLookup(org.compiere.model.MLookup) CPanel(org.compiere.swing.CPanel) VLookup(org.compiere.grid.ed.VLookup) VComboBox(org.compiere.grid.ed.VComboBox) Dimension(java.awt.Dimension)

Example 8 with VComboBox

use of org.compiere.grid.ed.VComboBox in project adempiere by adempiere.

the class VCollectDetail method loadStandardPanel.

/**
	 * Load Standard Fields for Collect
	 * @return void
	 */
private void loadStandardPanel() {
    standardPanel = new CPanel(layout);
    //	For Tender Type
    //  C_Payment_v.TenderType
    int columnId = 8416;
    MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnId, DisplayType.List);
    fieldTenderType = new VLookup("TenderType", true, false, true, lookup);
    ((VComboBox) fieldTenderType.getCombo()).setRenderer(new POSLookupListCellRenderer(font));
    fieldTenderType.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    ((VComboBox) fieldTenderType.getCombo()).setFont(font);
    fieldTenderType.addVetoableChangeListener(this);
    //	For Amount
    fieldPayAmt = new VNumber("PayAmt", true, false, true, DisplayType.Amount, "");
    fieldPayAmt.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    fieldPayAmt.setFont(font);
    fieldPayAmt.setValue(Env.ZERO);
    fieldPayAmt.addVetoableChangeListener(this);
    fieldPayAmt.addKeyListener(this);
    //	Button
    AppsAction action = new AppsAction("Minus", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2), false);
    action.setDelegate(this);
    buttonMinus = (CButton) action.getButton();
    buttonMinus.setPreferredSize(new Dimension(FIELD_HEIGHT, FIELD_HEIGHT));
    buttonMinus.setFocusable(false);
    //	Add Tender Type
    standardPanel.add(fieldTenderType, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    standardPanel.add(fieldPayAmt, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
}
Also used : AppsAction(org.compiere.apps.AppsAction) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MLookup(org.compiere.model.MLookup) CPanel(org.compiere.swing.CPanel) VLookup(org.compiere.grid.ed.VLookup) VNumber(org.compiere.grid.ed.VNumber) VComboBox(org.compiere.grid.ed.VComboBox) Dimension(java.awt.Dimension)

Example 9 with VComboBox

use of org.compiere.grid.ed.VComboBox in project adempiere by adempiere.

the class InfoPAttribute method addAttributes.

//	dynInit
/**
	 * 	Add Attributes
	 *	@return rows
	 */
private int addAttributes() {
    int row = 0;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String whereAttributeSet;
    if (p_M_AttributeSet_ID > 0)
        whereAttributeSet = "AND M_Attribute_ID IN (SELECT M_Attribute_ID FROM M_AttributeUse WHERE M_AttributeSet_ID=" + p_M_AttributeSet_ID + ")";
    else
        whereAttributeSet = "";
    String sql = MRole.getDefault().addAccessSQL("SELECT M_Attribute_ID, Name, Description, AttributeValueType, IsInstanceAttribute " + "FROM M_Attribute " + "WHERE IsActive='Y' " + whereAttributeSet + " ORDER BY IsInstanceAttribute, Name", "M_Attribute", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    boolean instanceLine = false;
    boolean productLine = false;
    try {
        pstmt = DB.prepareStatement(sql, null);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            int attribute_ID = rs.getInt(1);
            String name = rs.getString(2);
            String description = rs.getString(3);
            String attributeValueType = rs.getString(4);
            boolean isInstanceAttribute = "Y".equals(rs.getString(5));
            // Add label for product attributes if there are any
            if (!productLine && !isInstanceAttribute) {
                CPanel group = new CPanel();
                group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsProductAttribute")));
                group.add(Box.createVerticalStrut(VLine.SPACE));
                centerPanel.add(group, new ALayoutConstraint(row++, 0));
                productLine = true;
            }
            //	Add label for Instances attributes
            if (!instanceLine && isInstanceAttribute) {
                CPanel group = new CPanel();
                group.add(Box.createVerticalStrut(VLine.SPACE));
                group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsInstanceAttribute")));
                group.add(Box.createVerticalStrut(VLine.SPACE));
                centerPanel.add(group, new ALayoutConstraint(row++, 0));
                instanceLine = true;
            }
            //
            CLabel label = new CLabel(name);
            if (description != null && description.length() > 0)
                label.setToolTipText(description);
            centerPanel.add(label, new ALayoutConstraint(row++, 0));
            Component field = null;
            if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributeValueType))
                field = new VComboBox(getAttributeList(attribute_ID));
            else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType))
                field = new VNumber(name, false, false, true, DisplayType.Number, name);
            else
                field = new VString(name, false, false, true, 10, 40, null, null);
            label.setLabelFor(field);
            centerPanel.add(field, null);
            //
            field.setName(String.valueOf(attribute_ID));
            if (isInstanceAttribute)
                m_instanceEditors.add(field);
            else
                m_productEditors.add(field);
            //	To (numbers)
            Component fieldTo = null;
            if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType)) {
                fieldTo = new VNumber(name, false, false, true, DisplayType.Number, name);
                centerPanel.add(new CLabel("-"), null);
                centerPanel.add(fieldTo, null);
            }
            if (isInstanceAttribute)
                m_instanceEditorsTo.add(fieldTo);
            else
                m_productEditorsTo.add(fieldTo);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    // print instance line if not printed
    if (!instanceLine) {
        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();
        }
        if (isGuarantee || isSerial || isLot) {
            CPanel group = new CPanel();
            group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsInstanceAttribute")));
            group.add(Box.createVerticalStrut(VLine.SPACE));
            centerPanel.add(group, new ALayoutConstraint(row++, 0));
            instanceLine = true;
        }
    }
    return row;
}
Also used : CLabel(org.compiere.swing.CLabel) CPanel(org.compiere.swing.CPanel) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) PreparedStatement(java.sql.PreparedStatement) VLine(org.compiere.grid.ed.VLine) VNumber(org.compiere.grid.ed.VNumber) VString(org.compiere.grid.ed.VString) VComboBox(org.compiere.grid.ed.VComboBox) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) MAttributeSet(org.compiere.model.MAttributeSet) VString(org.compiere.grid.ed.VString) ResultSet(java.sql.ResultSet) Component(java.awt.Component)

Example 10 with VComboBox

use of org.compiere.grid.ed.VComboBox in project adempiere by adempiere.

the class InfoProduct method actionPerformed.

/**************************************************************************
	 *  Action Listener
	 *	@param e event
	 */
public void actionPerformed(ActionEvent e) {
    if (!p_loadedOK)
        return;
    String cmd = e.getActionCommand();
    Object source = null;
    if (e.getSource() != null) {
        source = e.getSource();
        if (cmd.equals(ConfirmPanel.A_PATTRIBUTE)) {
            // when the attribute window is closed.
            if (p_table.isMultiSelection()) {
                int row = p_table.getSelectionModel().getLeadSelectionIndex();
                p_table.setRowChecked(row, true);
            }
            MProduct mp = MProduct.get(Env.getCtx(), m_M_Product_ID);
            //  Set title and parameters for the PattributeInstance window
            String title = "";
            int wh_id = 0;
            if (isValidVObject(fWarehouse_ID)) {
                title = fWarehouse_ID.getDisplay() + " - " + mp.getName();
                wh_id = ((Integer) (fWarehouse_ID.getValue())).intValue();
            }
            //  Get the business partner from the context - it may be different than the Vendor
            int bp_id = 0;
            String s_bp_id = Env.getContext(Env.getCtx(), p_WindowNo, p_TabNo, "C_BPartner_ID", false);
            if (s_bp_id != null && s_bp_id.length() != 0 && (new Integer(s_bp_id).intValue() > 0))
                bp_id = new Integer(s_bp_id).intValue();
            //  Display the window
            PAttributeInstance pai = new PAttributeInstance(this, title, wh_id, 0, p_table.getLeadRowKey(), bp_id);
            if (!pai.wasCancelled()) {
                //  Get the results and update the fASI criteria field
                m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
                m_M_Locator_ID = pai.getM_Locator_ID();
                if (m_M_AttributeSetInstance_ID > 0)
                    fASI_ID.setValue(m_M_AttributeSetInstance_ID);
                else
                    //  No instance
                    fASI_ID.setValue(0);
            }
            //  looking around.
            if (//  If the results are saved, we can save now - an ASI is product specific
            p_saveResults && m_M_AttributeSetInstance_ID != -1 && !pai.wasCancelled()) {
                dispose(p_saveResults);
                return;
            }
            return;
        } else if (source instanceof VComboBox) {
            if (((VComboBox) source).getParent() instanceof VLookup) {
                // Works for VLookups using DisplayType.TableDir
                source = ((VComboBox) source).getParent();
                VLookup vl = ((VLookup) source);
                m_heldLastFocus = vl;
                if (cmd.equals("comboBoxEdited")) {
                    if (!vl.hasChanged() && !hasOutstandingChanges()) {
                        vl.requestFocus();
                        return;
                    }
                    p_triggerRefresh = true;
                    //  perform field-specific changes
                    if (vl == fWarehouse_ID) {
                        if (!isValidVObject(fWarehouse_ID)) {
                            //  Disable the stock button
                            checkOnlyStock.setSelected(false);
                            checkOnlyStock.setEnabled(false);
                        } else
                            checkOnlyStock.setEnabled(true);
                    }
                }
            }
        } else if (source instanceof CTextField) {
            CTextField tf = ((CTextField) source);
            if (tf.getParent() instanceof VPAttribute) {
                source = tf.getParent();
                VPAttribute vpa = ((VPAttribute) source);
                //  The VPAttribute field can't hold the focus effectively
                m_heldLastFocus = fieldValue;
                if (vpa.hasChanged()) {
                    p_triggerRefresh = true;
                }
            }
        } else if (e.getSource() instanceof VCheckBox) {
            //  Check box changes generally always cause a refresh
            //  Capture changes that don't 	
            VCheckBox cb = (VCheckBox) e.getSource();
            //  ShowDetail check box
            if (cb.getName().equals("ShowDetail")) {
                // Refresh only the ATP tab 
                refreshAtpTab();
                return;
            }
        }
    }
    //  e.getSource() is null
    //  Let the info class decide what to do.
    super.actionPerformed(e);
}
Also used : MProduct(org.compiere.model.MProduct) VPAttribute(org.compiere.grid.ed.VPAttribute) CTextField(org.compiere.swing.CTextField) VLookup(org.compiere.grid.ed.VLookup) VComboBox(org.compiere.grid.ed.VComboBox) VCheckBox(org.compiere.grid.ed.VCheckBox) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Aggregations

VComboBox (org.compiere.grid.ed.VComboBox)11 VLookup (org.compiere.grid.ed.VLookup)6 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)5 VString (org.compiere.grid.ed.VString)5 VNumber (org.compiere.grid.ed.VNumber)4 Component (java.awt.Component)3 Dimension (java.awt.Dimension)3 VCheckBox (org.compiere.grid.ed.VCheckBox)3 CPanel (org.compiere.swing.CPanel)3 CTextField (org.compiere.swing.CTextField)3 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 BigDecimal (java.math.BigDecimal)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 MAttributeSet (org.compiere.model.MAttributeSet)2 MLookup (org.compiere.model.MLookup)2 KeyNamePair (org.compiere.util.KeyNamePair)2 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1