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.Box;
008 import javax.swing.BoxLayout;
009 import javax.swing.JLabel;
010 import javax.swing.JPanel;
011
012 import market.Conversions;
013 import market.SMarket;
014 import market.VCPositiveDouble;
015 import market.VCPositiveInteger;
016 import market.swing.ComponentFactory;
017 import market.swing.JTFCheckable;
018 import sale.FormSheet;
019 import sale.FormSheetContentCreator;
020
021 /**
022 * This FormSheet is used by the manager to set special calculation variables such as the maximal discount
023 * for customers or the monthly costs of the market.
024 */
025 public class FSManagerOptions extends FormSheet {
026
027 /**
028 * ID for serialization.
029 */
030 private static final long serialVersionUID = 6718181117229432033L;
031
032 public static final int JTFC_DISCOUNT_RANGE = 0;
033 public static final int JTFC_DISCOUNT_VALUE = 1;
034 public static final int JTFC_MAX_DISCOUNT = 2;
035 public static final int JTFC_FRACTION_OF_WAGES = 3;
036 public static final int JTFC_SENIORITY = 4;
037 public static final int JTFC_COSTS = 5;
038
039 private JTFCheckable jtfcDiscountRange = new JTFCheckable(
040 JTFC_DISCOUNT_RANGE, new VCPositiveInteger("Anrechnung"), 10);
041 private JTFCheckable jtfcDiscountValue = new JTFCheckable(
042 JTFC_DISCOUNT_VALUE, new VCPositiveInteger("Umsatz"), 10);
043 private JTFCheckable jtfcMaxDiscount = new JTFCheckable(
044 JTFC_MAX_DISCOUNT, new VCPositiveDouble("Maximaler Rabatt"), 10);
045 private JTFCheckable jtfcFractionOfWages = new JTFCheckable(
046 JTFC_FRACTION_OF_WAGES, new VCPositiveDouble("Lohnanteil"), 10);
047 private JTFCheckable jtfcSeniority = new JTFCheckable(
048 JTFC_SENIORITY, new VCPositiveDouble("Betriebszugehörigkeit"), 10);
049 private JTFCheckable jtfcCosts = new JTFCheckable(
050 JTFC_COSTS, new VCPositiveDouble("Sonstige Kosten"), 10);
051
052 public FSManagerOptions() {
053 super("Einstellungen", null);
054 addContentCreator(new FormSheetContentCreator() {
055 private static final long serialVersionUID = -7780200572237344151L;
056 protected void createFormSheetContent(FormSheet fs) {
057 //define components
058 JPanel jpMain = new JPanel();
059 JPanel jpData = new JPanel();
060 JPanel jpDiscount = new JPanel();
061 JPanel jpEmployees = new JPanel();
062 JPanel jpCostCentres = new JPanel();
063 GridBagLayout gridBag = new GridBagLayout();
064 GridBagConstraints c = new GridBagConstraints();
065 jpMain.setLayout(gridBag);
066 c.weighty = 1;
067 c.anchor = GridBagConstraints.CENTER;
068 gridBag.setConstraints(jpData, c);
069
070 jpMain.add(jpData);
071 jpData.setLayout(new BoxLayout(jpData, BoxLayout.Y_AXIS));
072 jpData.add(jpDiscount);
073 jpDiscount.setLayout(new BoxLayout(jpDiscount, BoxLayout.Y_AXIS));
074 jpDiscount.setBorder(ComponentFactory.createInsetBorder("Kundenrabatt"));
075 jpDiscount.setLayout(new GridLayout(3, 3));
076 jpDiscount.add(new JLabel("Anrechnung: "));
077 jpDiscount.add(jtfcDiscountRange);
078 jpDiscount.add(new JLabel(" Monate"));
079 jpDiscount.add(new JLabel("Umsatz für 1% Rabatt: "));
080 jpDiscount.add(jtfcDiscountValue);
081 jpDiscount.add(new JLabel(" Euro"));
082 jpDiscount.add(new JLabel("Maximaler Rabatt: "));
083 jpDiscount.add(jtfcMaxDiscount);
084 jpDiscount.add(new JLabel(" Prozent"));
085 jpData.add(Box.createVerticalStrut(10));
086 jpData.add(jpEmployees);
087 jpEmployees.setLayout(new GridLayout(2, 3));
088 jpEmployees.setBorder(ComponentFactory.createInsetBorder(
089 "Faktoren zur Berechnung des Entlassungsausgleichs"));
090 jpEmployees.add(new JLabel("Lohnanteil: "));
091 jpEmployees.add(jtfcFractionOfWages);
092 jpEmployees.add(new JLabel(" Prozent"));
093 jpEmployees.add(new JLabel("Betriebszugehörigkeit: "));
094 jpEmployees.add(jtfcSeniority);
095 jpEmployees.add(new JLabel(" Prozent"));
096 jpData.add(Box.createVerticalStrut(10));
097 jpData.add(jpCostCentres);
098 jpCostCentres.setBorder(ComponentFactory.createInsetBorder("Kostenstellen"));
099 jpCostCentres.setLayout(new GridLayout(1, 3));
100 jpCostCentres.add(new JLabel("Sonstige Kosten: "));
101 jpCostCentres.add(jtfcCosts);
102 jpCostCentres.add(new JLabel(" Euro"));
103
104 fs.setComponent(jpMain);
105 fs.removeAllButtons();
106 fs.addButton("Übernehmen", ButtonIDs.BTN_ACCEPT, null);
107
108 jtfcDiscountRange.setText(Integer.toString(SMarket.getOptions().getDiscountRange()));
109 jtfcDiscountValue.setText(Integer.toString(SMarket.getOptions().getDiscountValue()));
110 jtfcMaxDiscount.setText(Conversions.fixedDecimal(100 * SMarket.getOptions().getMaxDiscount(), 3));
111 jtfcFractionOfWages.setText(Conversions.fixedDecimal(100 * SMarket.getOptions().
112 getFractionOfWages(), 3));
113 jtfcSeniority.setText(Conversions.fixedDecimal(100 * SMarket.getOptions().getTimeOfEmployment(), 3));
114 jtfcCosts.setText(Conversions.doubleToCurrency(SMarket.getMonthlySalesStats().getCosts()));
115 }
116 });
117 }
118
119 }