001 package market.stdform;
002
003 import java.awt.GridLayout;
004
005 import javax.swing.Box;
006 import javax.swing.BoxLayout;
007 import javax.swing.JLabel;
008 import javax.swing.JPanel;
009 import javax.swing.JTextField;
010
011 import market.CIArticle;
012 import market.VCPositiveInteger;
013 import market.swing.ComponentFactory;
014 import market.swing.JTFCheckable;
015 import sale.FormSheet;
016 import sale.FormSheetContentCreator;
017
018 /**
019 * This FormSheet displays the count of an article in the database and
020 * has a checkable textfield were the real count can be filled in.
021 */
022 public class FSWorkerEdit extends FormSheet{
023
024 /**
025 * ID for serialization.
026 */
027 private static final long serialVersionUID = -6763771561857370346L;
028
029 public static final int JTFC_REAL = 0;
030
031 private CIArticle ci_article;
032 private int database;
033
034 /**
035 * @param article the CIArticle which`s count is incorrect.
036 * @param db the count of this article in the database.
037 */
038 public FSWorkerEdit(CIArticle article, int db) {
039 super("Fehlbestand", null);
040 ci_article = article;
041 database = db;
042 FormSheetContentCreator fscc = new FormSheetContentCreator(){
043 private static final long serialVersionUID = -6991790995674960736L;
044 protected void createFormSheetContent(FormSheet fs) {
045 JPanel jp_main = new JPanel();
046 JPanel jp_grid = new JPanel();
047 jp_main.setLayout(new BoxLayout(jp_main, BoxLayout.Y_AXIS));
048 jp_grid.setLayout(new GridLayout(2,2));
049
050 JTextField jt_database = new JTextField(5);
051 jt_database.setText(String.valueOf(database));
052 jt_database.setEditable(false);
053 JTFCheckable jtfc_real = new JTFCheckable(JTFC_REAL, new VCPositiveInteger("realer Bestand"), 5);
054
055 jp_grid.setBorder(ComponentFactory.createInsetBorder("Artikel: "+ci_article.getArticleName()));
056 jp_grid.add(new JLabel("Datenbank-Bestand"));
057 jp_grid.add(jt_database);
058 jp_grid.add(new JLabel("realer Bestand"));
059 jp_grid.add(jtfc_real);
060
061 jp_main.add(Box.createVerticalStrut(160));
062 jp_main.add(jp_grid);
063 jp_main.add(Box.createVerticalStrut(160));
064
065 fs.setComponent(jp_main);
066 fs.removeAllButtons();
067 fs.addButton("Korrigiere", ButtonIDs.BTN_OK, null);
068 fs.addButton("Zurück", ButtonIDs.BTN_BACK, null);
069 }
070 };
071 this.addContentCreator(fscc);
072 }
073
074 /**
075 * @return a new {@link FSCheckable} that takes a FSWorkerEdit as argument
076 *
077 * @param article the CIArticle which`s count is incorrect.
078 * @param database the count of this article in the database.
079 */
080 public static FSCheckable create(CIArticle article, int database){
081 return new FSCheckable(new FSWorkerEdit(article, database));
082 }
083 }