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