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 * ID for serialization.
024 */
025 private static final long serialVersionUID = -8477647559976563324L;
026
027 /**
028 * @param toPay the value of the purchase.
029 */
030 public FSManagerPurchaseConfirm(final int toPay) {
031 super("Bestätigung", new FormSheetContentCreator() {
032 private static final long serialVersionUID = -6132671082385601251L;
033 public void createFormSheetContent(final FormSheet fs) {
034 JPanel jpMain = new JPanel();
035 JPanel jpText = new JPanel();
036 JPanel jpData = new JPanel();
037 GridBagConstraints c = new GridBagConstraints();
038 GridBagLayout gridbag = new GridBagLayout();
039 jpMain.setLayout(gridbag);
040 c.gridy = 0;
041 c.weighty = 0.1;
042 c.anchor = GridBagConstraints.CENTER;
043 gridbag.setConstraints(jpText, c);
044 c.gridy = 1;
045 c.weighty = 0.8;
046 c.anchor = GridBagConstraints.CENTER;
047 gridbag.setConstraints(jpData, c);
048
049 jpMain.add(jpText);
050 jpText.add(new JLabel("Soll diese Bestellung wirklich abgeschickt werden?"));
051 jpMain.add(jpData);
052 jpData.setLayout(new GridLayout(2,2,5,5));
053 jpData.setBorder(ComponentFactory.createInsetBorder());
054 jpData.add(new JLabel("Gesamtpreis"));
055 jpData.add(ComponentFactory.createTextField(Conversions.doubleToCurrency(toPay, " Euro"),
056 10, false, ComponentFactory.RIGHT, false));
057 jpData.add(new JLabel("Vermögen"));
058 jpData.add(ComponentFactory.createTextField(Conversions.valueToCurrency(
059 SMarket.getAccount(), " Euro"),10,false,ComponentFactory.RIGHT, false));
060 fs.setComponent(jpMain);
061 fs.removeAllButtons();
062 fs.addButton("Bestätigen", ButtonIDs.BTN_OK, null);
063 fs.addButton("Zurück", ButtonIDs.BTN_BACK, null);
064 fs.addButton("Abbrechen", ButtonIDs.BTN_CANCEL, null);
065 }}, false);
066 }
067 }