// $Id: UserTableFormSheet.java,v 1.4 2001/06/22 10:17:59 tm11 Exp $ /* * UserTableFormSheet.java * * Created on 13. Juni 2001, 11:36 */ package users.stdforms; import sale.*; import users.*; import users.swing.*; import util.swing.*; import javax.swing.*; import javax.swing.table.*; import java.util.*; import java.awt.event.*; /** * A FormSheet displaying the contents of a {@link UserManager}. * * @author Thomas Medack * @version 3.0 13/06/2001 * @since v3.0 */ public class UserTableFormSheet extends FormSheet { /** * Reference to the currently selected index. * * @serial */ private int[] m_anSelection = new int[] { -1 }; /** * The {@link TableModel} of the table displayed. */ private transient util.swing.AbstractTableModel m_atmModel; /** * The {@link TableColumnModel} of the table displayed. */ private transient TableColumnModel m_tcmModel; /** * The {@link ListSelectionModel} of the table displayed. */ private transient ListSelectionModel m_lsmModel; /** * The {@link Gate} at which the FormSheet is being displayed. * * @serial */ private UIGate m_uigGate; private transient JComponent m_jcComp; private transient UserManager m_umMan; /** * Create a new UserTableFormSheet. The "{@link FormSheet#waitResponse}" property will default * to true. * * @param sCaption the FormSheet's caption. * @param um the UserManager which will be displayed * @param c a JComponent which can be optionally displayed with the JUserTable. The * JComponent of the FormSheet will be a JPanel. The JPanels contains a JSplitPane. * The first JComponent of the JPanel is the JUserTable and the second is this JComponent. * If it is null, only the JUserTable will be displayed. * @param uigGate the Gate at which the FormSheet is displayed. * @param cmp a comparator defining the order in which to display the individual users. If <code>null</code> * the Userrecords will be ordered by their names. * @param ted a TableEntryDescriptor that can split individual * {@link UserTableModel.Record UserTableModel records} into a table's cells. Must not be * <code>null</code>. */ public UserTableFormSheet (String sCaption, UserManager um, JComponent c, UIGate uigGate, final UserTableModel.UserComparator cmp, final TableEntryDescriptor ted) { super (sCaption, (JComponent) null, true); setGate (uigGate); m_umMan = um; m_jcComp = c; addContentCreator (new FormSheetContentCreator() { protected void createFormSheetContent (FormSheet fs) { JUserTable jut = new JUserTable (m_umMan, cmp, ted); if (m_jcComp == null) { fs.setComponent (new JScrollPane (jut)); } else { JSplitPane p = new JSplitPane (JSplitPane.VERTICAL_SPLIT, new JScrollPane (jut), m_jcComp); p.setDividerSize (4); p.setDividerLocation (200); fs.setComponent (p); } ((UserTableFormSheet)fs).m_atmModel = (util.swing.AbstractTableModel) jut.getModel(); ((UserTableFormSheet)fs).m_lsmModel = jut.getSelectionModel(); ((UserTableFormSheet)fs).m_tcmModel = jut.getColumnModel(); jut.setSelectionObserver (((UserTableFormSheet)fs).m_anSelection); } }); } /** * Set the gate at which to display the FormSheet. This will also move the FormSheet to that gate, i.e. make * the FormSheet the FormSheet of the given gate. * * @param uigGate the new Gate. * * @override Never * * @see UIGate#setFormSheet */ public void setGate (UIGate uigGate) { if (m_uigGate != null) { m_uigGate.setFormSheet (null); } m_uigGate = uigGate; if (m_uigGate != null) { m_uigGate.setFormSheet (this); } } /** * Get the Gate this FormSheet is currently being displayed at. * * @override Never */ public UIGate getGate() { return m_uigGate; } /** * Get the record currently selected. * * <p>The actual class of the record depends on the concrete type of * TableModel used. See the TableModel's <code>getRecord()</code> method for * details. */ public User getSelectedRecord() { return (User)m_atmModel.getRecord (m_anSelection[0]); } /** * Get the ListSelectionModel of the JUserTable which is displayed. */ public ListSelectionModel getSelectionModel() { return m_lsmModel; } /** * Get the TableColumnModel of the JUserTable which is displayed. */ public TableColumnModel getColumnModel() { return m_tcmModel; } } /* * $Log: UserTableFormSheet.java,v $ * Revision 1.4 2001/06/22 10:17:59 tm11 * Fehlerkorrektur-TwoTableFormSheet(StockFilter), UserTableModel * (Comparators), SalesPoint(quit-Methode). * * Revision 1.3 2001/06/20 10:40:19 tm11 * Änderungen: classes19062001.jar - Bugs gefixt, Features erweitert * * Revision 1.2 2001/06/13 16:58:46 tm11 * Layout des FormSheets geändert (JSplitPane) * * Revision 1.1 2001/06/13 16:20:00 tm11 * Neues Standardformular hinzugefügt, welches User eines UserManagers * in einer JUserTable darstellt. * */