001    package data.stdforms;
002    
003    import sale.*;
004    import data.*;
005    import data.stdforms.singletableformsheet.*;
006    import data.swing.*;
007    import util.swing.*;
008    
009    import java.util.Comparator;
010    import javax.swing.*;
011    import javax.swing.table.TableModel; //for Javadoc
012    
013    /**
014     * A FormSheet displaying the contents of a {@link Catalog}, {@link Stock} or {@link DataBasket}.
015     *
016     * <p>The FormSheet will comprise one table that renders the contents of the container to be displayed.
017     * Additionally, there can be to extra buttons in the FormSheet's button bar that can be used to add or
018     * remove records to/from the container. The actions linked to these buttons will be represented as
019     * sub-processes to the process which displayed the FormSheet. The actual sub-process will be created by a
020     * {@link EditButtonStrategy strategy object}.</p>
021     *
022     * <p>SingleTableFormSheets assume to be displayed at a {@link UIGate user interface gate}. However, if you
023     * do not want to add editing capabilities, you may set this parameter to <code>null</code> and use the
024             * FormSheet as you would any other FormSheet. If you need editing capabilities, you must set the FormSheet at
025     * a UIGate.</p>
026     *
027     * <p>Various <code>create()</code> methods are offered that cover the entire spectrum of possible
028             * SingleTableFormSheets. All you need to do is select the <code>create()</code> method that fits your purpose
029     * and use it in your application.</p>
030     *
031     * @author Steffen Zschaler
032     * @version 2.0 20/08/1999
033     * @since v2.0
034     */
035    public class SingleTableFormSheet extends FormSheet {
036    
037        /**
038             * ID for serialization.
039             */
040            private static final long serialVersionUID = -7384199228823885354L;
041    
042            /**
043         * The button id that is used for the &quot;Add&quot; button.
044         */
045        public static final int BTNID_ADD = -100;
046    
047        /**
048         * The button id that is used for the &quot;Remove&quot; button.
049         */
050        public static final int BTNID_REMOVE = -101;
051    
052        /**
053         * Reference to the currently selected index.
054         *
055         * @serial
056         */
057        private int[] m_anSelection = new int[] {
058                 -1};
059    
060        /**
061         * The displayed table.
062         */
063        private JTable m_table;
064    
065        /**
066         * The source of the displayed table, can be Catalog, CountingStock, StoringStock, Databasket...
067         */
068        private Object m_source;
069    
070        /**
071         * The DataBasket assigned to the table.
072         */
073        private DataBasket m_db;
074    
075        /**
076         * The {@link TableModel} of the table displayed.
077         */
078        private transient util.swing.AbstractTableModel m_atmModel;
079    
080        /**
081         * The {@link Gate} at which the FormSheet is being displayed.
082         *
083         * @serial
084         */
085        private UIGate m_uigGate;
086    
087        /**
088         * Create a new SingleTableFormSheet. The &quot;{@link FormSheet#waitResponse}&quot; property will default
089         * to true.
090         *
091         * <p>Instead of calling this method, call one of the <code>create()</code> methods provided.
092         *
093         * @param sCaption the FormSheet's caption.
094         * @param uigGate the Gate at which the FormSheet is displayed.
095         * @param fscc the content creator to be used to create the FormSheet's contents.
096         */
097        protected SingleTableFormSheet(String sCaption, UIGate uigGate, FormSheetContentCreator fscc) {
098            super(sCaption, (JComponent)null, true);
099    
100            setGate(uigGate);
101    
102            // we call addContentCreator here to allow for m_anSelection to be initialized before.
103            // We cannot give fscc as a parameter to the superclass constructor, as m_anSelection would then not
104            // be initialized when the content creator is called to create the FormSheet's contents.
105            addContentCreator(fscc);
106        }
107    
108        /**
109         * Set the gate at which to display the FormSheet. This will also move the FormSheet to that gate, i.e. make
110         * the FormSheet the FormSheet of the given gate.
111         *
112         * @param uigGate the new Gate.
113         *
114         * @override Never
115         *
116         * @see UIGate#setFormSheet
117         */
118        public void setGate(UIGate uigGate) {
119            if (m_uigGate != null) {
120                m_uigGate.setFormSheet(null);
121            }
122    
123            m_uigGate = uigGate;
124    
125            if (m_uigGate != null) {
126                m_uigGate.setFormSheet(this);
127            }
128        }
129    
130        /**
131         * Get the Gate this FormSheet is currently being displayed at.
132         *
133         * @override Never
134         */
135        public UIGate getGate() {
136            return m_uigGate;
137        }
138    
139        /**
140         * Get the record currently selected.
141         *
142         * <p>The actual class of the record depends on the concrete type of
143         * TableModel used. See the TableModel's <code>getRecord()</code> method for
144         * details. To find out, which TableModel is used by your specific instance
145         * of <code>SingleTableFormSheet</code> refer to the documentation of the
146         * <code>create()</code> method you used to instantiate it.</p>
147         */
148        public Object getSelectedRecord() {
149            return m_atmModel.getRecord(m_anSelection[0]);
150        }
151    
152        /**
153         * Get the currently attached DataBasket.
154         *
155         * @override Never
156         */
157        public DataBasket getDataBasket() {
158            return m_db;
159        }
160    
161        /**
162         * Get the table's source.
163         *
164         * @override Never
165         */
166        public Object getTableSource() {
167            return m_source;
168        }
169    
170        /**
171         * Get the table.
172         *
173         * @override Never
174         */
175        public JTable getTable() {
176            return m_table;
177        }
178    
179        /**
180         * Changes the {@link TableModel} of a table.
181         * @param tm the new TableModel
182         */
183        public void setTableModel(AbstractTableModel tm) {
184            m_atmModel.fireTableDataChanged(); //unselect a possibly selected record
185            if (tm instanceof TableSorter) {
186                m_atmModel = tm;
187            } else {
188                m_atmModel = new TableSorter(tm);
189            }
190            m_table.setModel(m_atmModel);
191    
192            ((JAbstractTable)m_table).initialize();
193        }
194    
195        /**
196         * Convenience method. Equivalent to:
197         *
198         * <pre>
199         * {@link #addAddButton addAddButton} (ebsAdd);
200         * {@link #addRemoveButton addRemoveButton} (ebsRemove);
201         * </pre>
202         *
203         * <p>This method must be called from within a content creator if you need serializability.</p>
204         *
205         * @override Never
206         */
207        public void addEditingButtons(EditButtonStrategy ebsAdd, EditButtonStrategy ebsRemove) {
208            addAddButton(ebsAdd);
209            addRemoveButton(ebsRemove);
210        }
211    
212        /**
213         * Add to the FormSheet a button that will allow the user to add records to the container being displayed.
214         *
215         * <p>The button will by default have a caption of &quot;Add&quot; and a button id of {@link #BTNID_ADD}.
216         * The button's action will trigger the sub-process defined by <code>ebsAdd</code>.</p>
217         *
218         * <p>This method must be called from within a content creator if you need serializability.</p>
219         *
220         * @param ebsAdd a strategy defining the sub-process to be used for adding a record. For a
221         * SingleTableFormSheet displaying a Catalog, {@link AbstractAddCatalogItemStrategy} is already part of the
222         * Framework.
223         *
224         * @override Never
225         */
226        public void addAddButton(final EditButtonStrategy ebsAdd) {
227            removeButton(BTNID_ADD);
228    
229            addButton("Add", BTNID_ADD, new sale.Action() {
230                            private static final long serialVersionUID = 170542126570025997L;
231    
232                            public void doAction(SaleProcess p, SalesPoint sp) {
233                    getGate().setNextTransition(ebsAdd.getEditProcess(SingleTableFormSheet.this, p, sp));
234                }
235            });
236        }
237    
238        /**
239         * Add to the FormSheet a button that will allow the user to remove the currently selected record from the
240         * container being displayed.
241         *
242         * <p>The button will by default have a caption of &quot;Remove&quot; and a button id of
243         * {@link #BTNID_REMOVE}. The button's action will trigger the sub-process defined by
244         * <code>ebsRemove</code>.</p>
245         *
246         * <p>This method must be called from within a content creator if you need serializability.</p>
247         *
248         * @param ebsRemove a strategy defining the sub-process to be used for removing a record. For a
249         * SingleTableFormSheet displaying a Catalog, {@link DefaultRemoveCatalogItemStrategy} is already part of
250         * the Framework.
251         *
252         * @override Never
253         */
254        public void addRemoveButton(final EditButtonStrategy ebsRemove) {
255            removeButton(BTNID_REMOVE);
256    
257            addButton("Remove", BTNID_REMOVE, new sale.Action() {
258                            private static final long serialVersionUID = 5594880584595305771L;
259    
260                            public void doAction(SaleProcess p, SalesPoint sp) {
261                    getGate().setNextTransition(ebsRemove.getEditProcess(SingleTableFormSheet.this, p, sp));
262                }
263            });
264        }
265    
266        /**
267         * Convenience method for removing the &quot;Add&quot; and the &quot;Remove&quot; button.
268         *
269         * @override Never
270         */
271        public void removeEditButtons() {
272            removeButton(BTNID_REMOVE);
273            removeButton(BTNID_ADD);
274        }
275    
276        /**
277         * Helper class forming the foundation of all SingleTableFormSheet content creators.
278         *
279         * @author Steffen Zschaler
280         * @version 2.0 20/08/1999
281         * @since v2.0
282         */
283        private static abstract class STFSContentCreator extends FormSheetContentCreator {
284    
285            /**
286             * Set the given table to be the component of the given FormSheet. Also, link the FormSheet's selection
287             * observer accordingly.
288             *
289             * @override Never
290             */
291            protected void setFormSheetComponent(SingleTableFormSheet stfs, JAbstractTable jat) {
292                stfs.setComponent(new JScrollPane(jat));
293    
294                stfs.m_atmModel = (util.swing.AbstractTableModel)jat.getModel();
295                stfs.m_table = jat;
296    
297                jat.setSelectionObserver(stfs.m_anSelection);
298            }
299        }
300    
301        // JCatalogTable FormSheet creators
302    
303        /**
304         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
305         *
306         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
307         * {@link CatalogItem CatalogItems}.</p>
308         *
309         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
310         * order defaults to the natural ordering of the CatalogItems. If <code>c</code> is a {@link Currency},
311         * the {@link TableEntryDescriptor} defaults to a {@link DefaultCurrencyItemTED} using <code>c</code> to
312         * format values. Otherwise, it defaults to a {@link DefaultCatalogItemTED}.</p>
313         *
314         * @param sCaption the caption of the new FormSheet.
315         * @param c the Catalog whose contents are to be displayed.
316         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
317         * performed through the FormSheet.
318         */
319        public static SingleTableFormSheet create(String sCaption, Catalog c, UIGate uigGate) {
320            return create(sCaption, c, uigGate, null, null,
321                    ((c instanceof data.Currency) ? (new DefaultCurrencyItemTED((data.Currency)c)) :
322                    (new DefaultCatalogItemTED())));
323        }
324    
325        /**
326         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
327         *
328         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
329         * {@link CatalogItem CatalogItems}.</p>
330         *
331         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
332         * order defaults to the natural ordering of the CatalogItems.</p>
333         *
334         * @param sCaption the caption of the new FormSheet.
335         * @param c the Catalog whose contents are to be displayed.
336         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
337         * performed through the FormSheet.
338         * @param ted a TableEntryDescriptor that can split individual CatalogItems into a table's cells. Must not
339         * be <code>null</code>.
340         */
341        public static SingleTableFormSheet create(String sCaption, Catalog c, UIGate uigGate,
342                TableEntryDescriptor ted) {
343            return create(sCaption, c, uigGate, null, null, ted);
344        }
345    
346        /**
347         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
348         *
349         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
350         * {@link CatalogItem CatalogItems}.</p>
351         *
352         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>. If
353         * <code>c</code> is a {@link Currency}, the {@link TableEntryDescriptor} defaults to a
354         * {@link DefaultCurrencyItemTED} using <code>c</code> to format values. Otherwise, it defaults to a
355         * {@link DefaultCatalogItemTED}.</p>
356         *
357         * @param sCaption the caption of the new FormSheet.
358         * @param c the Catalog whose contents are to be displayed.
359         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
360         * performed through the FormSheet.
361         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
362         * the natural ordering of the CatalogItems will be followed.
363         */
364        public static SingleTableFormSheet create(String sCaption, Catalog c, UIGate uigGate, Comparator<CatalogItem> cmp) {
365            return create(sCaption, c, uigGate, null, cmp,
366                    ((c instanceof data.Currency) ? (new DefaultCurrencyItemTED((data.Currency)c)) :
367                    (new DefaultCatalogItemTED())));
368        }
369    
370        /**
371         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
372         *
373         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
374         * {@link CatalogItem CatalogItems}.</p>
375         *
376         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>.</p>
377         *
378         * @param sCaption the caption of the new FormSheet.
379         * @param c the Catalog whose contents are to be displayed.
380         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
381         * performed through the FormSheet.
382         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
383         * the natural ordering of the CatalogItems will be followed.
384         * @param ted a TableEntryDescriptor that can split individual CatalogItems into a table's cells. Must not
385         * be <code>null</code>.
386         */
387        public static SingleTableFormSheet create(String sCaption, Catalog c, UIGate uigGate, Comparator<CatalogItem> cmp,
388                TableEntryDescriptor ted) {
389            return create(sCaption, c, uigGate, null, cmp, ted);
390        }
391    
392        /**
393         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
394         *
395         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
396         * {@link CatalogItem CatalogItems}.</p>
397         *
398         * <p>The sorting order defaults to the natural ordering of the CatalogItems. If <code>c</code> is a
399         * {@link Currency}, the {@link TableEntryDescriptor} defaults to a {@link DefaultCurrencyItemTED} using
400         * <code>c</code> to format values. Otherwise, it defaults to a {@link DefaultCatalogItemTED}.</p>
401         *
402         * @param sCaption the caption of the new FormSheet.
403         * @param c the Catalog whose contents are to be displayed.
404         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
405         * performed through the FormSheet.
406         * @param db the DataBasket that is used to determine visibility of items.
407         */
408        public static SingleTableFormSheet create(String sCaption, Catalog c, UIGate uigGate, DataBasket db) {
409            return create(sCaption, c, uigGate, db, null,
410                    ((c instanceof data.Currency) ? (new DefaultCurrencyItemTED((data.Currency)c)) :
411                    (new DefaultCatalogItemTED())));
412        }
413    
414        /**
415         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
416         *
417         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
418         * {@link CatalogItem CatalogItems}.</p>
419         *
420         * <p>The sorting order defaults to the natural ordering of the CatalogItems.</p>
421         *
422         * @param sCaption the caption of the new FormSheet.
423         * @param c the Catalog whose contents are to be displayed.
424         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
425         * performed through the FormSheet.
426         * @param db the DataBasket that is used to determine visibility of items.
427         * @param ted a TableEntryDescriptor that can split individual CatalogItems into a table's cells. Must not
428         * be <code>null</code>.
429         */
430        public static SingleTableFormSheet create(String sCaption, Catalog c, UIGate uigGate, DataBasket db,
431                TableEntryDescriptor ted) {
432            return create(sCaption, c, uigGate, db, null, ted);
433        }
434    
435        /**
436         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
437         *
438         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
439         * {@link CatalogItem CatalogItems}.</p>
440         *
441         * <p>If <code>c</code> is a {@link Currency}, the {@link TableEntryDescriptor} defaults to a
442         * {@link DefaultCurrencyItemTED} using <code>c</code> to format values. Otherwise, it defaults to a
443         * {@link DefaultCatalogItemTED}.</p>
444         *
445         * @param sCaption the caption of the new FormSheet.
446         * @param c the Catalog whose contents are to be displayed.
447         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
448         * performed through the FormSheet.
449         * @param db the DataBasket that is used to determine visibility of items.
450         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
451         * the natural ordering of the CatalogItems will be followed.
452         */
453        public static SingleTableFormSheet create(String sCaption, Catalog c, UIGate uigGate, DataBasket db,
454                Comparator<CatalogItem> cmp) {
455            return create(sCaption, c, uigGate, db, cmp,
456                    ((c instanceof data.Currency) ? (new DefaultCurrencyItemTED((data.Currency)c)) :
457                    (new DefaultCatalogItemTED())));
458        }
459    
460        /**
461         * Create and return a new SingleTableFormSheet that will display the contents of a Catalog.
462         *
463         * <p>The FormSheet will contain a {@link JCatalogTable}, the individual records are
464         * {@link CatalogItem CatalogItems}.</p>
465         *
466         * @param sCaption the caption of the new FormSheet.
467         * @param c the Catalog whose contents are to be displayed.
468         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
469         * performed through the FormSheet.
470         * @param db the DataBasket that is used to determine visibility of items.
471         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
472         * the natural ordering of the CatalogItems will be followed.
473         * @param ted a TableEntryDescriptor that can split individual CatalogItems into a table's cells. Must not
474         * be <code>null</code>.
475         */
476        public static SingleTableFormSheet create(String sCaption, final Catalog c, UIGate uigGate,
477                final DataBasket db, final Comparator<CatalogItem> cmp, final TableEntryDescriptor ted) {
478            return new SingleTableFormSheet(sCaption, uigGate, new STFSContentCreator() {
479                            private static final long serialVersionUID = 2315488565898437009L;
480    
481                            protected void createFormSheetContent(FormSheet fs) {
482                    final SingleTableFormSheet stfs = (SingleTableFormSheet)fs;
483                    JCatalogTable jct = new JCatalogTable(c, db, cmp, ted);
484    
485                    setFormSheetComponent((SingleTableFormSheet)fs, jct);
486                    stfs.m_source = c;
487                    stfs.m_db = db;
488                }
489            });
490        }
491    
492        // JCountingStockTable FormSheet creators
493    
494        /**
495         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
496         *
497         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
498         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
499         *
500         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
501         * order defaults to the natural ordering of the keys. Lines containing '0' in the &quot;Count&quot; column
502         * will by default be hidden. If <code>cs</code> is a {@link MoneyBag}, the {@link TableEntryDescriptor}
503         * defaults to a {@link DefaultMoneyBagItemTED} using <code>cs.getCatalog()</code> to format values.
504         * Otherwise, it defaults to a {@link DefaultCountingStockItemTED}.</p>
505         *
506         * @param sCaption the caption of the new FormSheet.
507         * @param cs the CountingStock whose contents are to be displayed.
508         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
509         * performed through the FormSheet.
510         */
511        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate) {
512            return create(sCaption, cs, uigGate, null, null, false,
513                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(null))) :
514                    (new DefaultCountingStockItemTED())));
515        }
516    
517        /**
518         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
519         *
520         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
521         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
522         *
523         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
524         * order defaults to the natural ordering of the keys. Lines containing '0' in the &quot;Count&quot; column
525         * will by default be hidden.</p>
526         *
527         * @param sCaption the caption of the new FormSheet.
528         * @param cs the CountingStock whose contents are to be displayed.
529         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
530         * performed through the FormSheet.
531         * @param ted a TableEntryDescriptor that can split individual
532         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
533         * <code>null</code>.
534         */
535        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
536                TableEntryDescriptor ted) {
537            return create(sCaption, cs, uigGate, null, null, false, ted);
538        }
539    
540        /**
541         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
542         *
543         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
544         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
545         *
546         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
547         * order defaults to the natural ordering of the keys. If <code>cs</code> is a {@link MoneyBag}, the
548         * {@link TableEntryDescriptor} defaults to a {@link DefaultMoneyBagItemTED} using
549         * <code>cs.getCatalog()</code> to format values. Otherwise, it defaults to a
550         * {@link DefaultCountingStockItemTED}.</p>
551         *
552         * @param sCaption the caption of the new FormSheet.
553         * @param cs the CountingStock whose contents are to be displayed.
554         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
555         * performed through the FormSheet.
556         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
557         */
558        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
559                boolean fShowZeros) {
560            return create(sCaption, cs, uigGate, null, null, fShowZeros,
561                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(null))) :
562                    (new DefaultCountingStockItemTED())));
563        }
564    
565        /**
566         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
567         *
568         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
569         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
570         *
571         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
572         * order defaults to the natural ordering of the keys.</p>
573         *
574         * @param sCaption the caption of the new FormSheet.
575         * @param cs the CountingStock whose contents are to be displayed.
576         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
577         * performed through the FormSheet.
578         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
579         * @param ted a TableEntryDescriptor that can split individual
580         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
581         * <code>null</code>.
582         */
583        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
584                boolean fShowZeros, TableEntryDescriptor ted) {
585            return create(sCaption, cs, uigGate, null, null, fShowZeros, ted);
586        }
587    
588        /**
589         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
590         *
591         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
592         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
593         *
594         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>. Lines
595         * containing '0' in the &quot;Count&quot; column will by default be hidden. If <code>cs</code> is a
596         * {@link MoneyBag}, the {@link TableEntryDescriptor} defaults to a {@link DefaultMoneyBagItemTED} using
597         * <code>cs.getCatalog()</code> to format values. Otherwise, it defaults to a
598         * {@link DefaultCountingStockItemTED}.</p>
599         *
600         * @param sCaption the caption of the new FormSheet.
601         * @param cs the CountingStock whose contents are to be displayed.
602         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
603         * performed through the FormSheet.
604         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
605         * the records will be ordered by their keys.
606         */
607        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
608                Comparator<CatalogItem> cmp) {
609            return create(sCaption, cs, uigGate, null, cmp, false,
610                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(null))) :
611                    (new DefaultCountingStockItemTED())));
612        }
613    
614        /**
615         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
616         *
617         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
618         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
619         *
620         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>. Lines
621         * containing '0' in the &quot;Count&quot; column will by default be hidden.</p>
622         *
623         * @param sCaption the caption of the new FormSheet.
624         * @param cs the CountingStock whose contents are to be displayed.
625         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
626         * performed through the FormSheet.
627         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
628         * the records will be ordered by their keys.
629         * @param ted a TableEntryDescriptor that can split individual
630         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
631         * <code>null</code>.
632         */
633        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
634                Comparator<CatalogItem> cmp, TableEntryDescriptor ted) {
635            return create(sCaption, cs, uigGate, null, cmp, false, ted);
636        }
637    
638        /**
639         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
640         *
641         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
642         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
643         *
644         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>. If
645         * <code>cs</code> is a {@link MoneyBag}, the {@link TableEntryDescriptor} defaults to a
646         * {@link DefaultMoneyBagItemTED} using <code>cs.getCatalog()</code> to format values. Otherwise, it
647         * defaults to a {@link DefaultCountingStockItemTED}.</p>
648         *
649         * @param sCaption the caption of the new FormSheet.
650         * @param cs the CountingStock whose contents are to be displayed.
651         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
652         * performed through the FormSheet.
653         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
654         * the records will be ordered by their keys.
655         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
656         */
657        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
658                Comparator<CatalogItem> cmp, boolean fShowZeros) {
659            return create(sCaption, cs, uigGate, null, cmp, fShowZeros,
660                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(null))) :
661                    (new DefaultCountingStockItemTED())));
662        }
663    
664        /**
665         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
666         *
667         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
668         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
669         *
670         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>.</p>
671         *
672         * @param sCaption the caption of the new FormSheet.
673         * @param cs the CountingStock whose contents are to be displayed.
674         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
675         * performed through the FormSheet.
676         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
677         * the records will be ordered by their keys.
678         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
679         * @param ted a TableEntryDescriptor that can split individual
680         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
681         * <code>null</code>.
682         */
683        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
684                Comparator<CatalogItem> cmp, boolean fShowZeros, TableEntryDescriptor ted) {
685            return create(sCaption, cs, uigGate, null, cmp, fShowZeros, ted);
686        }
687    
688        /**
689         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
690         *
691         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
692         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
693         *
694         * <p>The sorting order defaults to the natural ordering of the keys. Lines containing '0' in the
695         * &quot;Count&quot; column will by default be hidden. If <code>cs</code> is a {@link MoneyBag}, the
696         * {@link TableEntryDescriptor} defaults to a {@link DefaultMoneyBagItemTED} using
697         * <code>cs.getCatalog()</code> to format values. Otherwise, it defaults to a
698         * {@link DefaultCountingStockItemTED}.</p>
699         *
700         * @param sCaption the caption of the new FormSheet.
701         * @param cs the CountingStock whose contents are to be displayed.
702         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
703         * performed through the FormSheet.
704         * @param db the DataBasket that is used to determine visibility of items.
705         */
706        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
707                DataBasket db) {
708            return create(sCaption, cs, uigGate, db, null, false,
709                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(db))) :
710                    (new DefaultCountingStockItemTED())));
711        }
712    
713        /**
714         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
715         *
716         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
717         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
718         *
719         * <p>The sorting order defaults to the natural ordering of the keys. Lines containing '0' in the
720         * &quot;Count&quot; column will by default be hidden.</p>
721         *
722         * @param sCaption the caption of the new FormSheet.
723         * @param cs the CountingStock whose contents are to be displayed.
724         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
725         * performed through the FormSheet.
726         * @param db the DataBasket that is used to determine visibility of items.
727         * @param ted a TableEntryDescriptor that can split individual
728         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
729         * <code>null</code>.
730         */
731        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
732                DataBasket db, TableEntryDescriptor ted) {
733            return create(sCaption, cs, uigGate, db, null, false, ted);
734        }
735    
736        /**
737         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
738         *
739         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
740         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
741         *
742         * <p>The sorting order defaults to the natural ordering of the keys. If <code>cs</code> is a
743         * {@link MoneyBag}, the {@link TableEntryDescriptor} defaults to a {@link DefaultMoneyBagItemTED} using
744         * <code>cs.getCatalog()</code> to format values. Otherwise, it defaults to a
745         * {@link DefaultCountingStockItemTED}.</p>
746         *
747         * @param sCaption the caption of the new FormSheet.
748         * @param cs the CountingStock whose contents are to be displayed.
749         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
750         * performed through the FormSheet.
751         * @param db the DataBasket that is used to determine visibility of items.
752         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
753         */
754        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
755                DataBasket db, boolean fShowZeros) {
756            return create(sCaption, cs, uigGate, db, null, fShowZeros,
757                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(db))) :
758                    (new DefaultCountingStockItemTED())));
759        }
760    
761        /**
762         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
763         *
764         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
765         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
766         *
767         * <p>The sorting order defaults to the natural ordering of the keys.</p>
768         *
769         * @param sCaption the caption of the new FormSheet.
770         * @param cs the CountingStock whose contents are to be displayed.
771         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
772         * performed through the FormSheet.
773         * @param db the DataBasket that is used to determine visibility of items.
774         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
775         * @param ted a TableEntryDescriptor that can split individual
776         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
777         * <code>null</code>.
778         */
779        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
780                DataBasket db, boolean fShowZeros, TableEntryDescriptor ted) {
781            return create(sCaption, cs, uigGate, db, null, fShowZeros, ted);
782        }
783    
784        /**
785         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
786         *
787         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
788         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
789         *
790         * <p>Lines containing '0' in the &quot;Count&quot; column will by default be hidden. If <code>cs</code> is
791         * a {@link MoneyBag}, the {@link TableEntryDescriptor} defaults to a {@link DefaultMoneyBagItemTED} using
792         * <code>cs.getCatalog()</code> to format values. Otherwise, it defaults to a
793         * {@link DefaultCountingStockItemTED}.</p>
794         *
795         * @param sCaption the caption of the new FormSheet.
796         * @param cs the CountingStock whose contents are to be displayed.
797         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
798         * performed through the FormSheet.
799         * @param db the DataBasket that is used to determine visibility of items.
800         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
801         * the records will be ordered by their keys.
802         */
803        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
804                DataBasket db, Comparator<CatalogItem> cmp) {
805            return create(sCaption, cs, uigGate, db, cmp, false,
806                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(db))) :
807                    (new DefaultCountingStockItemTED())));
808        }
809    
810        /**
811         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
812         *
813         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
814         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
815         *
816         * <p>Lines containing '0' in the &quot;Count&quot; column will by default be hidden.</p>
817         *
818         * @param sCaption the caption of the new FormSheet.
819         * @param cs the CountingStock whose contents are to be displayed.
820         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
821         * performed through the FormSheet.
822         * @param db the DataBasket that is used to determine visibility of items.
823         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
824         * the records will be ordered by their keys.
825         * @param ted a TableEntryDescriptor that can split individual
826         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
827         * <code>null</code>.
828         */
829        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
830                DataBasket db, Comparator<CatalogItem> cmp, TableEntryDescriptor ted) {
831            return create(sCaption, cs, uigGate, db, cmp, false, ted);
832        }
833    
834        /**
835         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
836         *
837         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
838         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
839         *
840         * <p>If <code>cs</code> is a {@link MoneyBag}, the {@link TableEntryDescriptor} defaults to a
841         * {@link DefaultMoneyBagItemTED} using <code>cs.getCatalog()</code> to format values. Otherwise, it
842         * defaults to a {@link DefaultCountingStockItemTED}.</p>
843         *
844         * @param sCaption the caption of the new FormSheet.
845         * @param cs the CountingStock whose contents are to be displayed.
846         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
847         * performed through the FormSheet.
848         * @param db the DataBasket that is used to determine visibility of items.
849         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
850         * the records will be ordered by their keys.
851         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
852         */
853        public static SingleTableFormSheet create(String sCaption, CountingStock cs, UIGate uigGate,
854                DataBasket db, Comparator<CatalogItem> cmp, boolean fShowZeros) {
855            return create(sCaption, cs, uigGate, db, cmp, fShowZeros,
856                    ((cs instanceof MoneyBag) ? (new DefaultMoneyBagItemTED((data.Currency)cs.getCatalog(db))) :
857                    (new DefaultCountingStockItemTED())));
858        }
859    
860        /**
861         * Create and return a new SingleTableFormSheet that will display the contents of a CountingStock.
862         *
863         * <p>The FormSheet will contain a {@link JCountingStockTable}, the individual records are
864         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records}.</p>
865         *
866         * @param sCaption the caption of the new FormSheet.
867         * @param cs the CountingStock whose contents are to be displayed.
868         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
869         * performed through the FormSheet.
870         * @param db the DataBasket that is used to determine visibility of items.
871         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
872         * the records will be ordered by their keys.
873         * @param fShowZeros if false, lines containing a '0' in the &quot;Count&quot; field will be hidden.
874         * @param ted a TableEntryDescriptor that can split individual
875         * {@link data.swing.CountingStockTableModel.Record CountingStockTableModel records} into a table's cells. Must not be
876         * <code>null</code>.
877         */
878        public static SingleTableFormSheet create(String sCaption, final CountingStock cs, UIGate uigGate,
879                final DataBasket db, final Comparator<CatalogItem> cmp, final boolean fShowZeros,
880                final TableEntryDescriptor ted) {
881            return new SingleTableFormSheet(sCaption, uigGate, new STFSContentCreator() {
882                            private static final long serialVersionUID = 4972958646893917497L;
883    
884                            protected void createFormSheetContent(FormSheet fs) {
885                    final SingleTableFormSheet stfs = (SingleTableFormSheet)fs;
886                    JCountingStockTable jcst = new JCountingStockTable(cs, db, cmp, fShowZeros, ted);
887                    setFormSheetComponent((SingleTableFormSheet)fs, jcst);
888                    stfs.m_source = cs;
889                    stfs.m_db = db;
890                }
891            });
892        }
893    
894        // JStoringStockTable FormSheet creators
895    
896        /**
897         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
898         *
899         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
900         * {@link StockItem StockItems}.</p>
901         *
902         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
903         * order defaults to the natural ordering of the StockItems. The {@link TableEntryDescriptor} defaults to a
904         * {@link DefaultStockItemTED}.</p>
905         *
906         * @param sCaption the caption of the new FormSheet.
907         * @param ss the StoringStock whose contents are to be displayed.
908         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
909         * performed through the FormSheet.
910         */
911        public static SingleTableFormSheet create(String sCaption, StoringStock ss, UIGate uigGate) {
912            return create(sCaption, ss, uigGate, null, null, new DefaultStockItemTED());
913        }
914    
915        /**
916         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
917         *
918         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
919         * {@link StockItem StockItems}.</p>
920         *
921         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>, the sorting
922         * order defaults to the natural ordering of the StockItems.</p>
923         *
924         * @param sCaption the caption of the new FormSheet.
925         * @param ss the StoringStock whose contents are to be displayed.
926         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
927         * performed through the FormSheet.
928         * @param ted a TableEntryDescriptor that can split individual {@link StockItem StockItems} into a table's
929         * cells. Must not be <code>null</code>.
930         */
931        public static SingleTableFormSheet create(String sCaption, StoringStock ss, UIGate uigGate,
932                TableEntryDescriptor ted) {
933            return create(sCaption, ss, uigGate, null, null, ted);
934        }
935    
936        /**
937         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
938         *
939         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
940         * {@link StockItem StockItems}.</p>
941         *
942         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>. The
943         * {@link TableEntryDescriptor} defaults to a {@link DefaultStockItemTED}.</p>
944         *
945         * @param sCaption the caption of the new FormSheet.
946         * @param ss the StoringStock whose contents are to be displayed.
947         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
948         * performed through the FormSheet.
949         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
950         * the natural order of the StockItems will be applied.
951         */
952        public static SingleTableFormSheet create(String sCaption, StoringStock ss, UIGate uigGate,
953                Comparator<StockItem> cmp) {
954            return create(sCaption, ss, uigGate, null, cmp, new DefaultStockItemTED());
955        }
956    
957        /**
958         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
959         *
960         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
961         * {@link StockItem StockItems}.</p>
962         *
963         * <p>The {@link DataBasket} used to determine visibility will default to <code>null</code>.</p>
964         *
965         * @param sCaption the caption of the new FormSheet.
966         * @param ss the StoringStock whose contents are to be displayed.
967         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
968         * performed through the FormSheet.
969         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
970         * the natural order of the StockItems will be applied.
971         * @param ted a TableEntryDescriptor that can split individual {@link StockItem StockItems} into a table's
972         * cells. Must not be <code>null</code>.
973         */
974        public static SingleTableFormSheet create(String sCaption, StoringStock ss, UIGate uigGate,
975                Comparator<StockItem> cmp, TableEntryDescriptor ted) {
976            return create(sCaption, ss, uigGate, null, cmp, ted);
977        }
978    
979        /**
980         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
981         *
982         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
983         * {@link StockItem StockItems}.</p>
984         *
985         * <p>The sorting order defaults to the natural ordering of the StockItems. The {@link TableEntryDescriptor}
986         * defaults to a {@link DefaultStockItemTED}.</p>
987         *
988         * @param sCaption the caption of the new FormSheet.
989         * @param ss the StoringStock whose contents are to be displayed.
990         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
991         * performed through the FormSheet.
992         * @param db the DataBasket that is used to determine visibility of items.
993         */
994        public static SingleTableFormSheet create(String sCaption, StoringStock ss, UIGate uigGate, DataBasket db) {
995            return create(sCaption, ss, uigGate, db, null, new DefaultStockItemTED());
996        }
997    
998        /**
999         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
1000         *
1001         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
1002         * {@link StockItem StockItems}.</p>
1003         *
1004         * <p>The sorting order defaults to the natural ordering of the StockItems.</p>
1005         *
1006         * @param sCaption the caption of the new FormSheet.
1007         * @param ss the StoringStock whose contents are to be displayed.
1008         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1009         * performed through the FormSheet.
1010         * @param db the DataBasket that is used to determine visibility of items.
1011         * @param ted a TableEntryDescriptor that can split individual {@link StockItem StockItems} into a table's
1012         * cells. Must not be <code>null</code>.
1013         */
1014        public static SingleTableFormSheet create(String sCaption, StoringStock ss, UIGate uigGate, DataBasket db,
1015                TableEntryDescriptor ted) {
1016            return create(sCaption, ss, uigGate, db, null, ted);
1017        }
1018    
1019        /**
1020         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
1021         *
1022         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
1023         * {@link StockItem StockItems}.</p>
1024         *
1025         * <p>The {@link TableEntryDescriptor} defaults to a {@link DefaultStockItemTED}.</p>
1026         *
1027         * @param sCaption the caption of the new FormSheet.
1028         * @param ss the StoringStock whose contents are to be displayed.
1029         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1030         * performed through the FormSheet.
1031         * @param db the DataBasket that is used to determine visibility of items.
1032         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
1033         * the natural order of the StockItems will be applied.
1034         */
1035        public static SingleTableFormSheet create(String sCaption, StoringStock ss, UIGate uigGate, DataBasket db,
1036                Comparator<StockItem> cmp) {
1037            return create(sCaption, ss, uigGate, db, cmp, new DefaultStockItemTED());
1038        }
1039    
1040        /**
1041         * Create and return a new SingleTableFormSheet that will display the contents of a StoringStock.
1042         *
1043         * <p>The FormSheet will contain a {@link JStoringStockTable}, the individual records are
1044         * {@link StockItem StockItems}.</p>
1045         *
1046         * @param sCaption the caption of the new FormSheet.
1047         * @param ss the StoringStock whose contents are to be displayed.
1048         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1049         * performed through the FormSheet.
1050         * @param db the DataBasket that is used to determine visibility of items.
1051         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
1052         * the natural order of the StockItems will be applied.
1053         * @param ted a TableEntryDescriptor that can split individual {@link StockItem StockItems} into a table's
1054         * cells. Must not be <code>null</code>.
1055         */
1056        public static SingleTableFormSheet create(String sCaption, final StoringStock ss, UIGate uigGate,
1057                final DataBasket db, final Comparator<StockItem> cmp, final TableEntryDescriptor ted) {
1058            return new SingleTableFormSheet(sCaption, uigGate, new STFSContentCreator() {
1059                            private static final long serialVersionUID = -2093620574395551989L;
1060    
1061                            protected void createFormSheetContent(FormSheet fs) {
1062                    final SingleTableFormSheet stfs = (SingleTableFormSheet)fs;
1063                    JStoringStockTable jsst = new JStoringStockTable(ss, db, cmp, ted);
1064                    setFormSheetComponent((SingleTableFormSheet)fs, jsst);
1065                    stfs.m_source = ss;
1066                    stfs.m_db = db;
1067                }
1068            });
1069        }
1070    
1071        // JDataBasketTable FormSheet creators
1072    
1073        /**
1074         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1075         *
1076         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1077         * {@link DataBasketEntry DataBasketEntries}.</p>
1078         *
1079         * <p>The default is to show all entries and apply no grouping. The default sorting order sorts entries by
1080         * their main keys and then by their secondary keys.</p>
1081         *
1082         * @param sCaption the caption of the new FormSheet.
1083         * @param db the DataBasket whose contents are to be displayed.
1084         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1085         * performed through the FormSheet.
1086         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1087         * into a table's cells. Must not be <code>null</code>.
1088         */
1089        public static SingleTableFormSheet create(String sCaption, DataBasket db, UIGate uigGate,
1090                TableEntryDescriptor ted) {
1091            return create(sCaption, db, uigGate, DataBasketConditionImpl.ALL_ENTRIES, null, null, ted);
1092        }
1093    
1094        /**
1095         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1096         *
1097         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1098         * {@link DataBasketEntry DataBasketEntries}.</p>
1099         *
1100         * <p>The default is to show all entries and apply no grouping.</p>
1101         *
1102         * @param sCaption the caption of the new FormSheet.
1103         * @param db the DataBasket whose contents are to be displayed.
1104         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1105         * performed through the FormSheet.
1106         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
1107         * entries will be sorted first by their main and then by their secondary keys.
1108         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1109         * into a table's cells. Must not be <code>null</code>.
1110         */
1111        public static SingleTableFormSheet create(String sCaption, DataBasket db, UIGate uigGate, Comparator<DataBasketEntry> cmp,
1112                TableEntryDescriptor ted) {
1113            return create(sCaption, db, uigGate, DataBasketConditionImpl.ALL_ENTRIES, null, cmp, ted);
1114        }
1115    
1116        /**
1117         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1118         *
1119         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1120         * {@link DataBasketEntry DataBasketEntries}.</p>
1121         *
1122         * <p>The default is to show all entries. The default sorting order sorts entries by their main keys and
1123         * then by their secondary keys.</p>
1124         *
1125         * @param sCaption the caption of the new FormSheet.
1126         * @param db the DataBasket whose contents are to be displayed.
1127         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1128         * performed through the FormSheet.
1129         * @param dbeg a grouper that can be used to combine several entries into one for display.
1130         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1131         * into a table's cells. Must not be <code>null</code>.
1132         */
1133        public static SingleTableFormSheet create(String sCaption, DataBasket db, UIGate uigGate,
1134                DataBasketEntryGrouper dbeg, TableEntryDescriptor ted) {
1135            return create(sCaption, db, uigGate, DataBasketConditionImpl.ALL_ENTRIES, dbeg, null, ted);
1136        }
1137    
1138        /**
1139         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1140         *
1141         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1142         * {@link DataBasketEntry DataBasketEntries}.</p>
1143         *
1144         * <p>The default is to show all entries.</p>
1145         *
1146         * @param sCaption the caption of the new FormSheet.
1147         * @param db the DataBasket whose contents are to be displayed.
1148         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1149         * performed through the FormSheet.
1150         * @param dbeg a grouper that can be used to combine several entries into one for display.
1151         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
1152         * entries will be sorted first by their main and then by their secondary keys.
1153         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1154         * into a table's cells. Must not be <code>null</code>.
1155         */
1156        public static SingleTableFormSheet create(String sCaption, DataBasket db, UIGate uigGate,
1157                DataBasketEntryGrouper dbeg, Comparator<DataBasketEntry> cmp, TableEntryDescriptor ted) {
1158            return create(sCaption, db, uigGate, DataBasketConditionImpl.ALL_ENTRIES, dbeg, cmp, ted);
1159        }
1160    
1161        /**
1162         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1163         *
1164         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1165         * {@link DataBasketEntry DataBasketEntries}.</p>
1166         *
1167         * <p>The default is to apply no grouping. The default sorting order sorts entries by
1168         * their main keys and then by their secondary keys.</p>
1169         *
1170         * @param sCaption the caption of the new FormSheet.
1171         * @param db the DataBasket whose contents are to be displayed.
1172         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1173         * performed through the FormSheet.
1174         * @param dbc a condition specifying the entries to be displayed.
1175         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1176         * into a table's cells. Must not be <code>null</code>.
1177         */
1178        public static SingleTableFormSheet create(String sCaption, DataBasket db, UIGate uigGate,
1179                DataBasketCondition dbc, TableEntryDescriptor ted) {
1180            return create(sCaption, db, uigGate, dbc, null, null, ted);
1181        }
1182    
1183        /**
1184         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1185         *
1186         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1187         * {@link DataBasketEntry DataBasketEntries}.</p>
1188         *
1189         * <p>The default is to apply no grouping.</p>
1190         *
1191         * @param sCaption the caption of the new FormSheet.
1192         * @param db the DataBasket whose contents are to be displayed.
1193         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1194         * performed through the FormSheet.
1195         * @param dbc a condition specifying the entries to be displayed.
1196         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
1197         * entries will be sorted first by their main and then by their secondary keys.
1198         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1199         * into a table's cells. Must not be <code>null</code>.
1200         */
1201        public static SingleTableFormSheet create(String sCaption, DataBasket db, UIGate uigGate,
1202                DataBasketCondition dbc, Comparator<DataBasketEntry> cmp, TableEntryDescriptor ted) {
1203            return create(sCaption, db, uigGate, dbc, null, cmp, ted);
1204        }
1205    
1206        /**
1207         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1208         *
1209         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1210         * {@link DataBasketEntry DataBasketEntries}.</p>
1211         *
1212         * <p>The default sorting order sorts entries by their main keys and then by their secondary keys.</p>
1213         *
1214         * @param sCaption the caption of the new FormSheet.
1215         * @param db the DataBasket whose contents are to be displayed.
1216         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1217         * performed through the FormSheet.
1218         * @param dbc a condition specifying the entries to be displayed.
1219         * @param dbeg a grouper that can be used to combine several entries into one for display.
1220         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1221         * into a table's cells. Must not be <code>null</code>.
1222         */
1223        public static SingleTableFormSheet create(String sCaption, DataBasket db, UIGate uigGate,
1224                DataBasketCondition dbc, DataBasketEntryGrouper dbeg, TableEntryDescriptor ted) {
1225            return create(sCaption, db, uigGate, dbc, dbeg, null, ted);
1226        }
1227    
1228        /**
1229         * Create and return a new SingleTableFormSheet that will display the contents of a DataBasket.
1230         *
1231         * <p>The FormSheet will contain a {@link JDataBasketTable}, the individual records are
1232         * {@link DataBasketEntry DataBasketEntries}.</p>
1233         *
1234         * @param sCaption the caption of the new FormSheet.
1235         * @param db the DataBasket whose contents are to be displayed.
1236         * @param uigGate the gate at which to display the FormSheet. May be <code>null</code> only if no editing is
1237         * performed through the FormSheet.
1238         * @param dbc a condition specifying the entries to be displayed.
1239         * @param dbeg a grouper that can be used to combine several entries into one for display.
1240         * @param cmp a comparator defining the order in which to display the individual items. If <code>null</code>
1241         * entries will be sorted first by their main and then by their secondary keys.
1242         * @param ted a TableEntryDescriptor that can split individual {@link DataBasketEntry DataBasketEntries}
1243         * into a table's cells. Must not be <code>null</code>.
1244         */
1245        public static SingleTableFormSheet create(String sCaption, final DataBasket db, UIGate uigGate,
1246                final DataBasketCondition dbc, final DataBasketEntryGrouper dbeg, final Comparator<DataBasketEntry> cmp,
1247                final TableEntryDescriptor ted) {
1248            return new SingleTableFormSheet(sCaption, uigGate, new STFSContentCreator() {
1249                            private static final long serialVersionUID = 5243720296332530319L;
1250    
1251                            protected void createFormSheetContent(FormSheet fs) {
1252                    final SingleTableFormSheet stfs = (SingleTableFormSheet)fs;
1253                    JDataBasketTable jdbt = new JDataBasketTable(db, dbc, dbeg, cmp, ted);
1254                    setFormSheetComponent((SingleTableFormSheet)fs, jdbt);
1255                    stfs.m_source = db;
1256                    stfs.m_db = db;
1257                }
1258            });
1259        }
1260    
1261    }