001 package market.stdform; 002 003 import java.util.Hashtable; 004 005 import market.CIArticle; 006 import market.Conversions; 007 import sale.FormSheet; 008 import sale.FormSheetContentCreator; 009 import util.swing.AbstractTableEntryDescriptor; 010 import data.CountingStock; 011 import data.stdforms.SingleTableFormSheet; 012 import data.swing.CountingStockTableModel; 013 014 /** 015 * This FormSheet displays the order of a customer in a table 016 * with one further column to tick off the articles, it is used by workers to execute the order. 017 */ 018 public class FSWorkerOrder{ 019 020 /** 021 * @param customer the customer who`s order gets executed. 022 * @param order the order that gets executed. 023 * @param done Hashtable with boolean values used for the tick-off column. 024 */ 025 public static SingleTableFormSheet getOrderTable(String customer, CountingStock order, final Hashtable done){ 026 027 AbstractTableEntryDescriptor ted = new AbstractTableEntryDescriptor(){ 028 public int getColumnCount() { 029 return 3; 030 } 031 032 public String getColumnName(int nIdx) { 033 return (new String[]{ "Artikel", "Anzahl", "Erledigt"}) [nIdx]; 034 } 035 036 public Class getColumnClass(int nIdx) { 037 return (new Class[] {String.class, Number.class, Boolean.class}) [nIdx]; 038 } 039 040 public Object getValueAt(Object oRecord, int nIdx) { 041 CIArticle article = Conversions.recordToCIArticle(oRecord); 042 int count = ((CountingStockTableModel.Record)oRecord).getCount(); 043 switch (nIdx) { 044 case 0: return article.getArticleName(); 045 case 1: return new Integer(count).toString(); 046 case 2: return done.get(article); 047 } 048 return null; 049 } 050 051 public boolean canSortByColumn(int nIndex) { 052 return false; 053 } 054 055 public boolean isElementEditable(Object oRecord, int nIdx) { 056 return nIdx == 2; 057 } 058 059 public void setValueAt(Object oRecord, int nIndex, Object oValue) { 060 if (nIndex == 2) { 061 done.put(Conversions.recordToCIArticle(oRecord), oValue); 062 } 063 } 064 }; 065 066 final SingleTableFormSheet stfs = SingleTableFormSheet.create( 067 "Kundenauftrag von "+ customer, 068 order, 069 null, 070 ted); 071 072 stfs.addContentCreator(new FormSheetContentCreator() { 073 protected void createFormSheetContent(final FormSheet fs) { 074 fs.removeAllButtons(); 075 fs.addButton("Auftrag abschliessen", ButtonIDs.BTN_ACCEPT, null); 076 fs.addButton("Fehlbestand", ButtonIDs.BTN_EDIT, null); 077 fs.addButton("Zurück", ButtonIDs.BTN_BACK, null); 078 } 079 }); 080 return stfs; 081 } 082 }