001 package market.stdform;
002
003 import java.awt.GridBagConstraints;
004 import java.awt.GridBagLayout;
005 import java.awt.GridLayout;
006
007 import javax.swing.JLabel;
008 import javax.swing.JPanel;
009
010 import market.Conversions;
011 import market.SMarket;
012 import market.swing.ComponentFactory;
013 import sale.FormSheet;
014 import sale.FormSheetContentCreator;
015
016 /**
017 * This FormSheet gives a short overview of the {@link FSManagerPurchase purchase} the manger wants to
018 * send and asks for confirmation.
019 */
020 public class FSManagerPurchaseConfirm extends FormSheet {
021
022 /**
023 * @param toPay the value of the purchase.
024 */
025 public FSManagerPurchaseConfirm(final int toPay) {
026 super("Bestätigung", new FormSheetContentCreator() {public void createFormSheetContent(final FormSheet fs) {
027 JPanel jpMain = new JPanel();
028 JPanel jpText = new JPanel();
029 JPanel jpData = new JPanel();
030 GridBagConstraints c = new GridBagConstraints();
031 GridBagLayout gridbag = new GridBagLayout();
032 jpMain.setLayout(gridbag);
033 c.gridy = 0;
034 c.weighty = 0.1;
035 c.anchor = GridBagConstraints.CENTER;
036 gridbag.setConstraints(jpText, c);
037 c.gridy = 1;
038 c.weighty = 0.8;
039 c.anchor = GridBagConstraints.CENTER;
040 gridbag.setConstraints(jpData, c);
041
042 jpMain.add(jpText);
043 jpText.add(new JLabel("Soll diese Bestellung wirklich abgeschickt werden?"));
044 jpMain.add(jpData);
045 jpData.setLayout(new GridLayout(2,2,5,5));
046 jpData.setBorder(ComponentFactory.createInsetBorder());
047 jpData.add(new JLabel("Gesamtpreis"));
048 jpData.add(ComponentFactory.createTextField(Conversions.doubleToCurrency(toPay, " Euro"),
049 10, false, ComponentFactory.RIGHT, false));
050 jpData.add(new JLabel("Vermögen"));
051 jpData.add(ComponentFactory.createTextField(Conversions.valueToCurrency(
052 SMarket.getAccount(), " Euro"),10,false,ComponentFactory.RIGHT, false));
053 fs.setComponent(jpMain);
054 fs.removeAllButtons();
055 fs.addButton("Bestätigen", ButtonIDs.BTN_OK, null);
056 fs.addButton("Zurück", ButtonIDs.BTN_BACK, null);
057 fs.addButton("Abbrechen", ButtonIDs.BTN_CANCEL, null);
058 }}, false);
059 }
060 }