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 public static final int JTFC_REAL = 0; 025 026 private CIArticle ci_article; 027 private int database; 028 029 /** 030 * @param article the CIArticle which`s count is incorrect. 031 * @param db the count of this article in the database. 032 */ 033 public FSWorkerEdit(CIArticle article, int db) { 034 super("Fehlbestand", null); 035 ci_article = article; 036 database = db; 037 FormSheetContentCreator fscc = new FormSheetContentCreator(){ 038 protected void createFormSheetContent(FormSheet fs) { 039 JPanel jp_main = new JPanel(); 040 JPanel jp_grid = new JPanel(); 041 jp_main.setLayout(new BoxLayout(jp_main, BoxLayout.Y_AXIS)); 042 jp_grid.setLayout(new GridLayout(2,2)); 043 044 JTextField jt_database = new JTextField(5); 045 jt_database.setText(String.valueOf(database)); 046 jt_database.setEditable(false); 047 JTFCheckable jtfc_real = new JTFCheckable(JTFC_REAL, new VCPositiveInteger("realer Bestand"), 5); 048 049 jp_grid.setBorder(ComponentFactory.createInsetBorder("Artikel: "+ci_article.getArticleName())); 050 jp_grid.add(new JLabel("Datenbank-Bestand")); 051 jp_grid.add(jt_database); 052 jp_grid.add(new JLabel("realer Bestand")); 053 jp_grid.add(jtfc_real); 054 055 jp_main.add(Box.createVerticalStrut(160)); 056 jp_main.add(jp_grid); 057 jp_main.add(Box.createVerticalStrut(160)); 058 059 fs.setComponent(jp_main); 060 fs.removeAllButtons(); 061 fs.addButton("Korrigiere", ButtonIDs.BTN_OK, null); 062 fs.addButton("Zurück", ButtonIDs.BTN_BACK, null); 063 } 064 }; 065 this.addContentCreator(fscc); 066 } 067 068 /** 069 * @return a new {@link FSCheckable} that takes a FSWorkerEdit as argument 070 * 071 * @param article the CIArticle which`s count is incorrect. 072 * @param database the count of this article in the database. 073 */ 074 public static FSCheckable create(CIArticle article, int database){ 075 return new FSCheckable(new FSWorkerEdit(article, database)); 076 } 077 }