use of org.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class POSQuantityPanel method init.
@Override
protected void init() {
// Content
setLayout(new GridBagLayout());
// Button Panel
buttonPanel = new CPanel(new GridBagLayout());
//
topPadding = 0;
leftPadding = 1;
bottonPadding = 0;
rightPadding = 1;
buttonDelete = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_F3, Event.CTRL_MASK));
buttonDelete.setToolTipText("CTL+F3-" + Msg.translate(ctx, "DeleteLine"));
buttonDelete.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
buttonDelete.addActionListener(posPanel.getUserPinListener());
buttonPanel.add(buttonDelete, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
buttonPlus = createButtonAction("Plus", KeyStroke.getKeyStroke(KeyEvent.VK_1, Event.CTRL_MASK));
buttonPlus.setToolTipText("CTL+1-" + Msg.translate(ctx, "add"));
buttonPlus.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
buttonPanel.add(buttonPlus, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
buttonMinus = createButtonAction("Minus", KeyStroke.getKeyStroke(KeyEvent.VK_0, Event.CTRL_MASK));
// TODO: Create message for decrementing qty by 1
buttonMinus.setToolTipText("CTL+0-" + Msg.translate(ctx, "decrement"));
buttonMinus.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
buttonPanel.add(buttonMinus, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
buttonUp = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, Event.ALT_MASK));
buttonUp.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
buttonUp.setToolTipText("ALT+up-" + Msg.translate(ctx, "Previous"));
buttonPanel.add(buttonUp, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
buttonDown = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, Event.ALT_MASK));
buttonDown.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
buttonDown.setToolTipText("ALT+down-" + Msg.translate(ctx, "Next"));
buttonPanel.add(buttonDown, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
if (posPanel.isPresentElectronicScales()) {
buttonScales = createButtonAction("Calculator", KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK));
buttonScales.setToolTipText("ALT+down-" + Msg.translate(ctx, "Calculator"));
buttonScales.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
buttonPanel.add(buttonScales, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
buttonScales.addActionListener(posPanel.getScalesListener());
}
CLabel qtyLabel = new CLabel(Msg.translate(Env.getCtx(), "Qty"));
qtyLabel.setDisplayedMnemonic(KeyEvent.VK_Q);
buttonPanel.add(qtyLabel, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
Dimension preferredSize = new Dimension(70, posPanel.getButtonSize());
Dimension minimumSize = new Dimension(70, posPanel.getButtonSize());
//
fieldQuantity = new VNumber();
fieldQuantity.addActionListener(this);
fieldQuantity.setFont(posPanel.getFont());
fieldQuantity.setPreferredSize(preferredSize);
fieldQuantity.setMinimumSize(minimumSize);
fieldQuantity.setDisplayType(DisplayType.Quantity);
fieldQuantity.setValue(Env.ZERO);
qtyLabel.setLabelFor(fieldQuantity);
buttonPanel.add(fieldQuantity, new GridBagConstraints(7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
CLabel priceLabel = new CLabel(Msg.translate(Env.getCtx(), "Price"));
priceLabel.setDisplayedMnemonic(KeyEvent.VK_P);
buttonPanel.add(priceLabel, new GridBagConstraints(8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
//
fieldPrice = new VNumber();
fieldPrice.setValue(Env.ZERO);
fieldPrice.setFont(posPanel.getFont());
fieldPrice.setName(priceLabel.getName());
fieldPrice.setPreferredSize(preferredSize);
fieldPrice.setMinimumSize(minimumSize);
fieldPrice.addActionListener(this);
if (!posPanel.isModifyPrice())
fieldPrice.setReadWrite(false);
else {
fieldPrice.addActionListener(posPanel.getUserPinListener());
fieldPrice.addActionListener(this);
}
priceLabel.setLabelFor(fieldPrice);
buttonPanel.add(fieldPrice, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
CLabel discountPercentageLabel = new CLabel(Msg.translate(Env.getCtx(), "Discount"));
discountPercentageLabel.setDisplayedMnemonic(KeyEvent.VK_T);
buttonPanel.add(discountPercentageLabel, new GridBagConstraints(10, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
fieldDiscountPercentage = new VNumber();
fieldDiscountPercentage.setValue(Env.ZERO);
fieldDiscountPercentage.addActionListener(this);
fieldDiscountPercentage.setName(discountPercentageLabel.getName());
fieldDiscountPercentage.setFont(posPanel.getFont());
fieldDiscountPercentage.setPreferredSize(preferredSize);
fieldDiscountPercentage.setMinimumSize(minimumSize);
if (!posPanel.isModifyPrice())
fieldDiscountPercentage.setReadWrite(false);
else {
fieldDiscountPercentage.addActionListener(posPanel.getUserPinListener());
fieldDiscountPercentage.addActionListener(this);
}
discountPercentageLabel.setLabelFor(fieldDiscountPercentage);
buttonPanel.add(fieldDiscountPercentage, new GridBagConstraints(11, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
add(buttonPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(11, 0, 0, 0), 0, 0));
changeStatus(false);
}
use of org.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class POSUserPinListener method doPerformAction.
protected void doPerformAction(ActionEvent actionEvent) {
if (!"KeyEvent".equals(actionEvent.getActionCommand().toString()) || !actionEvent.getActionCommand().toString().equals("Cancel"))
return;
Object objectSource = actionEvent.getSource();
VNumber number = null;
CButton button = null;
if (objectSource instanceof VNumber)
number = (VNumber) objectSource;
if (objectSource instanceof CButton)
button = (CButton) objectSource;
if (!pos.isRequiredPIN())
return;
if (//Number field validation
(number != null && (Msg.translate(Env.getCtx(), "Discount").equals(number.getName()) || Msg.translate(Env.getCtx(), "PriceActual").equals(number.getName())) || //Button validation
(button != null && ("Cancel".equals(button.getName()))))) {
POSUserPinDialog.show(pos);
}
}
use of org.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class VProductConfigurationBOM method cmd_selection.
// actionPerformed
/**
* Enable/disable qty based on selection
* @param source JCheckBox or JRadioButton
*/
private void cmd_selection(Object source) {
for (int i = 0; i < m_selectionList.size(); i++) {
if (source == m_selectionList.get(i)) {
boolean selected = isSelectionSelected(source);
VNumber qty = (VNumber) m_qtyList.get(i);
qty.setReadWrite(selected);
return;
}
}
log.log(Level.SEVERE, "not found - " + source);
}
use of org.compiere.grid.ed.VNumber 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));
}
use of org.compiere.grid.ed.VNumber 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;
}
Aggregations