use of org.compiere.swing.CPanel in project adempiere by adempiere.
the class POSKeyPanel method createCard.
/**
* @return
*/
private CPanel createCard(int posKeyLayoutId) {
// already added
if (keyMaps.containsKey(posKeyLayoutId)) {
return null;
}
CPanel card = new CPanel();
card.setLayout(new MigLayout("fill, ins 0"));
MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), posKeyLayoutId);
Color stdColor = Color.lightGray;
if (keyLayout.getAD_PrintColor_ID() != 0) {
MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID());
stdColor = color.getColor();
}
Font stdFont = AdempierePLAF.getFont_Field();
if (keyLayout.getAD_PrintFont_ID() != 0) {
MPrintFont font = MPrintFont.get(keyLayout.getAD_PrintFont_ID());
stdFont = font.getFont();
}
if (keyLayout.get_ID() == 0)
return null;
MPOSKey[] keys = keyLayout.getKeys(false);
HashMap<Integer, MPOSKey> map = new HashMap<Integer, MPOSKey>(keys.length);
keyMaps.put(posKeyLayoutId, map);
// Min Columns
int COLUMNS = 3;
// Min Rows
int ROWS = 3;
int noKeys = keys.length;
int cols = keyLayout.getColumns();
if (cols == 0)
cols = COLUMNS;
int buttons = 0;
log.fine("PosSubFunctionKeys.init - NoKeys=" + noKeys + ", Cols=" + cols);
// Content
CPanel content = new CPanel(new MigLayout("fill, wrap " + Math.max(cols, 3)));
String buttonSize = "h 50, w 50, growx, growy, sg button,";
for (MPOSKey key : keys) {
if (key.getSubKeyLayout_ID() > 0) {
CPanel subCard = createCard(key.getSubKeyLayout_ID());
if (subCard != null)
add(subCard, Integer.toString(key.getSubKeyLayout_ID()));
}
map.put(key.getC_POSKey_ID(), key);
Color keyColor = stdColor;
Font keyFont = stdFont;
StringBuffer buttonHTML = new StringBuffer("<html><p>");
if (key.getAD_PrintColor_ID() != 0) {
MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
keyColor = color.getColor();
}
if (key.getAD_PrintFont_ID() != 0) {
MPrintFont font = MPrintFont.get(key.getAD_PrintFont_ID());
keyFont = font.getFont();
}
buttonHTML.append(key.getName());
buttonHTML.append("</p></html>");
log.fine("#" + map.size() + " - " + keyColor);
CButton button = new CButton(buttonHTML.toString());
button.setBackground(keyColor);
button.setFont(keyFont);
if (key.getAD_Image_ID() != 0) {
MImage image = MImage.get(Env.getCtx(), key.getAD_Image_ID());
Image img = image.getImage();
// https://github.com/erpcya/AD-POS-WebUI/issues/29
// Change Image Size
Image imgResized = img.getScaledInstance(IMAGE_SIZE, IMAGE_SIZE, Image.SCALE_SMOOTH);
button.setIcon(new ImageIcon(imgResized));
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setHorizontalTextPosition(SwingConstants.CENTER);
}
button.setFocusable(false);
if (!key.isActive())
button.setEnabled(false);
button.setActionCommand(String.valueOf(key.getC_POSKey_ID()));
button.addActionListener(this);
String constraints = buttonSize;
int size = 1;
if (key.getSpanX() > 1) {
constraints += "spanx " + key.getSpanX() + ",";
size = key.getSpanX();
}
if (key.getSpanY() > 1) {
constraints += "spany " + key.getSpanY() + ",";
size = size * key.getSpanY();
}
buttons = buttons + size;
content.add(button, constraints);
}
int rows = Math.max((buttons / cols), ROWS);
if (buttons % cols > 0)
rows = rows + 1;
for (int i = buttons; i < rows * cols; i++) {
CButton button = new CButton("");
button.setFocusable(false);
button.setReadWrite(false);
content.add(button, buttonSize);
}
CScrollPane scroll = new CScrollPane(content);
// scroll.setPreferredSize(new Dimension( 600 - 20, 400-20));
card.add(scroll, "growx, growy");
// increase scrollbar width for touchscreen
scroll.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 30));
return card;
}
use of org.compiere.swing.CPanel 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.swing.CPanel in project adempiere by adempiere.
the class POSScalesPanel method init.
public void init() {
dialog = new CPanel();
dialog.setName(Msg.translate(pos.getCtx(), "@ElectronicScales@"));
mainLayout = new BorderLayout();
parameterLayout = new GridBagLayout();
mainPanel = new CPanel();
parameterPanel = new CPanel();
centerPanel = new CPanel();
scrollPane = new JScrollPane();
Dimension screenSize = pos.getSize();
int widthSize = (screenSize.width * 40) / 100;
int heightSize = (screenSize.height * 70) / 100;
scrollPane.setPreferredSize(new Dimension(widthSize, heightSize));
mainPanel.setLayout(mainLayout);
parameterPanel.setLayout(parameterLayout);
centerPanel.setLayout(parameterLayout);
mainPanel.add(scrollPane);
scrollPane.getViewport().add(centerPanel);
dialog.add(mainPanel, BorderLayout.CENTER);
if (!dynInit()) {
dialog.setVisible(false);
return;
}
}
use of org.compiere.swing.CPanel in project adempiere by adempiere.
the class POSUserPinDialog method show.
public static void show(VPOS pos) {
JPasswordField passwordField = new JPasswordField(20);
GridBagLayout grid = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets.top = 4;
constraints.insets.bottom = 4;
CPanel passwordPanel = new CPanel(grid);
passwordPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));
constraints.anchor = GridBagConstraints.WEST;
String msg = Msg.parseTranslation(pos.getCtx(), "@UserPIN@");
passwordPanel.add(new JLabel(msg), constraints);
constraints.gridy = 1;
passwordPanel.add(passwordField, constraints);
JOptionPane optionPane = new JOptionPane(passwordPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
JDialog dialog = optionPane.createDialog(msg);
dialog.addComponentListener(new java.awt.event.ComponentListener() {
@Override
public void componentShown(java.awt.event.ComponentEvent e) {
passwordField.requestFocusInWindow();
}
@Override
public void componentHidden(java.awt.event.ComponentEvent e) {
}
@Override
public void componentResized(java.awt.event.ComponentEvent e) {
}
@Override
public void componentMoved(java.awt.event.ComponentEvent e) {
}
});
dialog.setVisible(true);
int result = (Integer) optionPane.getValue();
if (result == JOptionPane.OK_OPTION)
pos.validateAndSetUserPin(passwordField.getPassword());
}
use of org.compiere.swing.CPanel in project adempiere by adempiere.
the class InfoPayment method statInit.
/**
* Static Setup - add fields to parameterPanel
*/
private void statInit() {
lDocumentNo.setLabelFor(fDocumentNo);
fDocumentNo.setBackground(AdempierePLAF.getInfoBackground());
fDocumentNo.addActionListener(this);
fcheckReceipt.setSelected(true);
fcheckReceipt.setActionCommand("OnlyReceipt");
fcheckReceipt.addActionListener(this);
fcheckPayment.setSelected(false);
fcheckPayment.setActionCommand("OnlyPayment");
fcheckPayment.addActionListener(this);
//
fBankAccount_ID = new VLookup("C_BankAccount_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_BankAccount_ID), DisplayType.TableDir));
lBankAccount_ID.setLabelFor(fBankAccount_ID);
fBankAccount_ID.setBackground(AdempierePLAF.getInfoBackground());
fBankAccount_ID.addActionListener(this);
fBPartner_ID = new VLookup("C_BPartner_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_BPartner_ID), DisplayType.Search));
lBPartner_ID.setLabelFor(fBPartner_ID);
fBPartner_ID.setBackground(AdempierePLAF.getInfoBackground());
fBPartner_ID.addActionListener(this);
//
lDateFrom.setLabelFor(fDateFrom);
fDateFrom.setBackground(AdempierePLAF.getInfoBackground());
fDateFrom.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom"));
fDateFrom.addActionListener(this);
lDateTo.setLabelFor(fDateTo);
fDateTo.setBackground(AdempierePLAF.getInfoBackground());
fDateTo.setToolTipText(Msg.translate(Env.getCtx(), "DateTo"));
fDateTo.addActionListener(this);
lAmtFrom.setLabelFor(fAmtFrom);
fAmtFrom.setBackground(AdempierePLAF.getInfoBackground());
fAmtFrom.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom"));
// Not sure why this is necessary? The border is not visible otherwise.
fAmtFrom.setBorder(fDateFrom.getBorder());
fAmtFrom.addActionListener(this);
lAmtTo.setLabelFor(fAmtTo);
fAmtTo.setBackground(AdempierePLAF.getInfoBackground());
fAmtTo.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo"));
// Not sure why this is necessary? The border is not visible otherwise.
fAmtTo.setBorder(fDateFrom.getBorder());
fAmtTo.addActionListener(this);
//
CPanel amtPanel = new CPanel();
CPanel datePanel = new CPanel();
amtPanel.setLayout(new ALayout(0, 0, true));
amtPanel.add(fAmtFrom, new ALayoutConstraint(0, 0));
amtPanel.add(lAmtTo, null);
amtPanel.add(fAmtTo, null);
datePanel.setLayout(new ALayout(0, 0, true));
datePanel.add(fDateFrom, new ALayoutConstraint(0, 0));
datePanel.add(lDateTo, null);
datePanel.add(fDateTo, null);
//
// First Row
p_criteriaGrid.add(lDocumentNo, new ALayoutConstraint(0, 0));
p_criteriaGrid.add(fDocumentNo, null);
p_criteriaGrid.add(lBPartner_ID, null);
p_criteriaGrid.add(fBPartner_ID, null);
p_criteriaGrid.add(fcheckReceipt, new ALayoutConstraint(0, 5));
// 2nd Row
p_criteriaGrid.add(lBankAccount_ID, new ALayoutConstraint(1, 0));
p_criteriaGrid.add(fBankAccount_ID);
p_criteriaGrid.add(lDateFrom, null);
p_criteriaGrid.add(datePanel, null);
p_criteriaGrid.add(fcheckPayment, new ALayoutConstraint(1, 5));
// 3rd Row
p_criteriaGrid.add(lAmtFrom, new ALayoutConstraint(2, 2));
p_criteriaGrid.add(amtPanel, null);
}
Aggregations