Package jmri.jmrit.beantable.turnout
Class TurnoutTableDataModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- jmri.jmrit.beantable.BeanTableDataModel<Turnout>
-
- jmri.jmrit.beantable.turnout.TurnoutTableDataModel
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.io.Serializable
,java.util.EventListener
,javax.swing.table.TableModel
public class TurnoutTableDataModel extends BeanTableDataModel<Turnout>
Data model for a Turnout Table. Code originally within TurnoutTableAction.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
TurnoutTableDataModel.ImageIconRenderer
Visualize state in table as a graphic, customized for Turnouts (4 states).-
Nested classes/interfaces inherited from class jmri.jmrit.beantable.BeanTableDataModel
BeanTableDataModel.BeanTableTooltipHeaderRenderer
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
bothText
(package private) java.lang.String
cabOnlyText
(package private) java.lang.String
closedText
java.lang.String
defaultClosedSpeedText
java.lang.String
defaultThrownSpeedText
static int
DIVERGCOL
static int
EDITCOL
protected static java.util.concurrent.atomic.AtomicBoolean
editingOps
static int
FORGETCOL
static int
INVERTCOL
static int
KNOWNCOL
static int
LOCKCOL
static int
LOCKDECCOL
static int
LOCKOPRCOL
static int
MODECOL
(package private) java.lang.String
noneText
static int
OPSEDITCOL
static int
OPSONOFFCOL
(package private) java.lang.String
pushbutText
static int
QUERYCOL
static int
SENSOR1COL
static int
SENSOR2COL
java.util.Vector<java.lang.String>
speedListClosed
java.util.Vector<java.lang.String>
speedListThrown
static int
STRAIGHTCOL
(package private) java.lang.String
thrownText
(package private) java.lang.String
useBlockSpeed
-
Fields inherited from class jmri.jmrit.beantable.BeanTableDataModel
COMMENTCOL, DELETECOL, NUMCOLUMN, SYSNAMECOL, sysNameList, USERNAMECOL, VALUECOL
-
-
Constructor Summary
Constructors Constructor Description TurnoutTableDataModel()
TurnoutTableDataModel(Manager<Turnout> mgr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clickOn(Turnout t)
Process a click on The value cell.void
configureTable(javax.swing.JTable tbl)
Configure a table to have our standard rows and columns.protected void
configValueColumn(javax.swing.JTable table)
Customize the turnout table Value (State) column to show an appropriate graphic for the turnout state if _graphicState = true, or (default) just show the localized state text when the TableDataModel is being called from ListedTableAction.protected javax.swing.JButton
editButton()
Create a JButton to edit a turnout's operation.(package private) void
editButton(Turnout t)
Create action to edit a turnout in Edit pane.protected void
editTurnoutOperation(Turnout t, javax.swing.JComboBox<java.lang.String> box)
Pop up a TurnoutOperationConfig for the turnout.Turnout
getBySystemName(java.lang.String name)
Turnout
getByUserName(java.lang.String name)
protected java.lang.String
getClassName()
java.lang.Class<?>
getColumnClass(int col)
int
getColumnCount()
Get Column Count INCLUDING Bean Property Columns.java.lang.String
getColumnName(int col)
protected java.lang.String
getHeaderTooltip(int col)
Get a ToolTip for a Table Column Header.Manager<Turnout>
getManager()
Get the Table Model Bean Manager.protected java.lang.String
getMasterClassName()
int
getPreferredWidth(int col)
java.lang.String
getValue(java.lang.String name)
Get the current Bean state value in human readable form.java.lang.Object
getValueAt(int row, int col)
SYSNAMECOL returns the actual Bean, NOT the System Name.boolean
isCellEditable(int row, int col)
protected javax.swing.JComboBox<java.lang.String>
makeAutomationBox(Turnout t)
Create a JComboBox<String> containing all the options for turnout automation parameters for this turnout.javax.swing.JTable
makeJTable(java.lang.String name, javax.swing.table.TableModel model, javax.swing.RowSorter<? extends javax.swing.table.TableModel> sorter)
Create and configure a new table using the given model and row sorter.protected boolean
matchPropertyName(java.beans.PropertyChangeEvent e)
Is this property event announcing a change this table should display?void
propertyChange(java.beans.PropertyChangeEvent e)
protected void
setColumnIdentities(javax.swing.JTable table)
Set identities for any columns that need an identity.protected void
setManager(Manager<Turnout> manager)
Set the Model Bean Manager.protected void
setTurnoutOperation(Turnout t, javax.swing.JComboBox<java.lang.String> cb)
Set the turnout's operation info based on the contents of the combo box.void
setValueAt(java.lang.Object value, int row, int col)
void
showFeedbackChanged(boolean visible, javax.swing.JTable table)
void
showLockChanged(boolean visible, javax.swing.JTable table)
void
showStateForgetAndQueryChanged(boolean visible, javax.swing.JTable table)
void
showTurnoutSpeedChanged(boolean visible, javax.swing.JTable table)
-
Methods inherited from class jmri.jmrit.beantable.BeanTableDataModel
addMouseListenerToHeader, configDeleteColumn, configureButton, configureJTable, copyName, deleteBean, dispose, doDelete, editComment, exportToCSV, formatToolTip, getBeanType, getCellToolTip, getDisplayDeleteMsg, getFilter, getPropertyColumnCount, getPropertyColumnDescriptor, getRowCount, isClearUserNameAllowed, moveBean, persistTable, printColumns, printTable, removeName, renameBean, setColumnToHoldButton, setDisplayDeleteMsg, setFilter, setPropertyColumnsVisible, showPopup, showTableHeaderPopup, stopPersistingTable, updateNameList
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
-
-
-
Field Detail
-
INVERTCOL
public static final int INVERTCOL
- See Also:
- Constant Field Values
-
LOCKCOL
public static final int LOCKCOL
- See Also:
- Constant Field Values
-
EDITCOL
public static final int EDITCOL
- See Also:
- Constant Field Values
-
KNOWNCOL
public static final int KNOWNCOL
- See Also:
- Constant Field Values
-
MODECOL
public static final int MODECOL
- See Also:
- Constant Field Values
-
SENSOR1COL
public static final int SENSOR1COL
- See Also:
- Constant Field Values
-
SENSOR2COL
public static final int SENSOR2COL
- See Also:
- Constant Field Values
-
OPSONOFFCOL
public static final int OPSONOFFCOL
- See Also:
- Constant Field Values
-
OPSEDITCOL
public static final int OPSEDITCOL
- See Also:
- Constant Field Values
-
LOCKOPRCOL
public static final int LOCKOPRCOL
- See Also:
- Constant Field Values
-
LOCKDECCOL
public static final int LOCKDECCOL
- See Also:
- Constant Field Values
-
STRAIGHTCOL
public static final int STRAIGHTCOL
- See Also:
- Constant Field Values
-
DIVERGCOL
public static final int DIVERGCOL
- See Also:
- Constant Field Values
-
FORGETCOL
public static final int FORGETCOL
- See Also:
- Constant Field Values
-
QUERYCOL
public static final int QUERYCOL
- See Also:
- Constant Field Values
-
closedText
java.lang.String closedText
-
thrownText
java.lang.String thrownText
-
defaultThrownSpeedText
public java.lang.String defaultThrownSpeedText
-
defaultClosedSpeedText
public java.lang.String defaultClosedSpeedText
-
useBlockSpeed
java.lang.String useBlockSpeed
-
bothText
java.lang.String bothText
-
cabOnlyText
java.lang.String cabOnlyText
-
pushbutText
java.lang.String pushbutText
-
noneText
java.lang.String noneText
-
speedListClosed
public final java.util.Vector<java.lang.String> speedListClosed
-
speedListThrown
public final java.util.Vector<java.lang.String> speedListThrown
-
editingOps
protected static java.util.concurrent.atomic.AtomicBoolean editingOps
-
-
Constructor Detail
-
TurnoutTableDataModel
public TurnoutTableDataModel()
-
TurnoutTableDataModel
public TurnoutTableDataModel(Manager<Turnout> mgr)
-
-
Method Detail
-
getColumnCount
public int getColumnCount()
Get Column Count INCLUDING Bean Property Columns.- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnCount
in classBeanTableDataModel<Turnout>
-
getColumnName
public java.lang.String getColumnName(int col)
- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classBeanTableDataModel<Turnout>
-
getHeaderTooltip
protected java.lang.String getHeaderTooltip(int col)
Get a ToolTip for a Table Column Header.- Overrides:
getHeaderTooltip
in classBeanTableDataModel<Turnout>
- Parameters:
col
- the model column number.- Returns:
- ToolTip, else null.
-
getColumnClass
public java.lang.Class<?> getColumnClass(int col)
- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classBeanTableDataModel<Turnout>
-
getPreferredWidth
public int getPreferredWidth(int col)
- Overrides:
getPreferredWidth
in classBeanTableDataModel<Turnout>
-
isCellEditable
public boolean isCellEditable(int row, int col)
- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classBeanTableDataModel<Turnout>
-
getValueAt
public java.lang.Object getValueAt(int row, int col)
SYSNAMECOL returns the actual Bean, NOT the System Name.- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
getValueAt
in classBeanTableDataModel<Turnout>
-
setValueAt
public void setValueAt(java.lang.Object value, int row, int col)
- Specified by:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in classBeanTableDataModel<Turnout>
-
getValue
public java.lang.String getValue(@Nonnull java.lang.String name)
Get the current Bean state value in human readable form.- Specified by:
getValue
in classBeanTableDataModel<Turnout>
- Parameters:
name
- System name of Bean.- Returns:
- state value in localised human readable form.
-
getManager
public Manager<Turnout> getManager()
Get the Table Model Bean Manager. In many cases, especially around Model startup, this will be the Proxy Manager, which is then changed to the hardware specific manager.- Specified by:
getManager
in classBeanTableDataModel<Turnout>
- Returns:
- current Manager in use by the Model.
-
setManager
protected final void setManager(@Nonnull Manager<Turnout> manager)
Set the Model Bean Manager. Note that for many Models this may not work as the manager is currently obtained directly from the Action class.- Overrides:
setManager
in classBeanTableDataModel<Turnout>
- Parameters:
manager
- Bean Manager that the Model should use.
-
getBySystemName
public Turnout getBySystemName(@Nonnull java.lang.String name)
- Specified by:
getBySystemName
in classBeanTableDataModel<Turnout>
-
getByUserName
public Turnout getByUserName(@Nonnull java.lang.String name)
- Specified by:
getByUserName
in classBeanTableDataModel<Turnout>
-
getMasterClassName
protected java.lang.String getMasterClassName()
- Specified by:
getMasterClassName
in classBeanTableDataModel<Turnout>
-
getClassName
protected java.lang.String getClassName()
-
clickOn
public void clickOn(Turnout t)
Description copied from class:BeanTableDataModel
Process a click on The value cell.- Specified by:
clickOn
in classBeanTableDataModel<Turnout>
- Parameters:
t
- the Bean that has been clicked.
-
configureTable
public void configureTable(javax.swing.JTable tbl)
Description copied from class:BeanTableDataModel
Configure a table to have our standard rows and columns. This is optional, in that other table formats can use this table model. But we put it here to help keep it consistent. This also persists the table user interface state.- Overrides:
configureTable
in classBeanTableDataModel<Turnout>
- Parameters:
tbl
-JTable
to configure
-
matchPropertyName
protected boolean matchPropertyName(java.beans.PropertyChangeEvent e)
Description copied from class:BeanTableDataModel
Is this property event announcing a change this table should display?Note that events will come both from the NamedBeans and also from the manager
- Overrides:
matchPropertyName
in classBeanTableDataModel<Turnout>
- Parameters:
e
- the event to match- Returns:
- true if the property name is of interest, false otherwise
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
Description copied from class:BeanTableDataModel
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Overrides:
propertyChange
in classBeanTableDataModel<Turnout>
-
configValueColumn
protected void configValueColumn(javax.swing.JTable table)
Customize the turnout table Value (State) column to show an appropriate graphic for the turnout state if _graphicState = true, or (default) just show the localized state text when the TableDataModel is being called from ListedTableAction.- Overrides:
configValueColumn
in classBeanTableDataModel<Turnout>
- Parameters:
table
- a JTable of Turnouts
-
makeJTable
public javax.swing.JTable makeJTable(@Nonnull java.lang.String name, @Nonnull javax.swing.table.TableModel model, @CheckForNull javax.swing.RowSorter<? extends javax.swing.table.TableModel> sorter)
Description copied from class:BeanTableDataModel
Create and configure a new table using the given model and row sorter.- Overrides:
makeJTable
in classBeanTableDataModel<Turnout>
- Parameters:
name
- the name of the tablemodel
- the data model for the tablesorter
- the row sorter for the table; if null, the table will not be sortable- Returns:
- the table
-
setColumnIdentities
protected void setColumnIdentities(javax.swing.JTable table)
Description copied from class:BeanTableDataModel
Set identities for any columns that need an identity. It is recommended that all columns get a constant identity to prevent identities from being subject to changes due to translation.The default implementation sets column identities to the String
Column#
where#
is the model index for the column. Note that if the TableColumnModel is aXTableColumnModel
, the index includes hidden columns.- Overrides:
setColumnIdentities
in classBeanTableDataModel<Turnout>
- Parameters:
table
- the table to set identities for.
-
editTurnoutOperation
protected void editTurnoutOperation(@Nonnull Turnout t, javax.swing.JComboBox<java.lang.String> box)
Pop up a TurnoutOperationConfig for the turnout.- Parameters:
t
- turnoutbox
- JComboBox that triggered the edit
-
makeAutomationBox
protected javax.swing.JComboBox<java.lang.String> makeAutomationBox(Turnout t)
Create a JComboBox<String> containing all the options for turnout automation parameters for this turnout.- Parameters:
t
- the turnout- Returns:
- the JComboBox
-
setTurnoutOperation
protected void setTurnoutOperation(@Nonnull Turnout t, javax.swing.JComboBox<java.lang.String> cb)
Set the turnout's operation info based on the contents of the combo box.- Parameters:
t
- turnout being configuredcb
- JComboBox for ops for t in the TurnoutTable
-
editButton
void editButton(Turnout t)
Create action to edit a turnout in Edit pane. (also used in windowTest)- Parameters:
t
- the turnout to be edited
-
editButton
protected javax.swing.JButton editButton()
Create a JButton to edit a turnout's operation.- Returns:
- the JButton
-
showFeedbackChanged
public void showFeedbackChanged(boolean visible, javax.swing.JTable table)
-
showLockChanged
public void showLockChanged(boolean visible, javax.swing.JTable table)
-
showTurnoutSpeedChanged
public void showTurnoutSpeedChanged(boolean visible, javax.swing.JTable table)
-
showStateForgetAndQueryChanged
public void showStateForgetAndQueryChanged(boolean visible, javax.swing.JTable table)
-
-