Package jmri.jmrit.picker
Class PickListModel<E extends NamedBean>
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- jmri.jmrit.beantable.BeanTableDataModel<E>
-
- jmri.jmrit.picker.PickListModel<E>
-
- Type Parameters:
E
- the supported type of NamedBean
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.io.Serializable
,java.util.EventListener
,javax.swing.table.TableModel
- Direct Known Subclasses:
PickListModel.AudioPickModel
,PickListModel.BlockPickModel
,PickListModel.EntryExitPickModel
,PickListModel.GlobalVariablePickModel
,PickListModel.LightPickModel
,PickListModel.LogixPickModel
,PickListModel.MemoryPickModel
,PickListModel.OBlockPickModel
,PickListModel.ReporterPickModel
,PickListModel.SensorPickModel
,PickListModel.SignalHeadPickModel
,PickListModel.SignalMastPickModel
,PickListModel.TurnoutPickModel
,PickListModel.WarrantPickModel
public abstract class PickListModel<E extends NamedBean> extends BeanTableDataModel<E>
Abstract class to make pick lists for NamedBeans; Table model for pick lists in IconAdderConcrete pick list class for many beans are include at the end of this file. This class also has instantiation methods serve as a factory for those classes.
Note: Extensions of this class must call init() after instantiation.
This file is part of JMRI.JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
PickListModel.AudioPickModel
(package private) static class
PickListModel.BlockPickModel
(package private) static class
PickListModel.EntryExitPickModel
(package private) static class
PickListModel.GlobalVariablePickModel
(package private) static class
PickListModel.LightPickModel
(package private) static class
PickListModel.LogixPickModel
(package private) static class
PickListModel.MemoryPickModel
(package private) static class
PickListModel.MultiSensorPickModel
(package private) static class
PickListModel.OBlockPickModel
(package private) static class
PickListModel.ReporterPickModel
(package private) static class
PickListModel.SensorPickModel
(package private) static class
PickListModel.SignalHeadPickModel
(package private) static class
PickListModel.SignalMastPickModel
(package private) static class
PickListModel.TurnoutPickModel
(package private) static class
PickListModel.WarrantPickModel
-
Nested classes/interfaces inherited from class jmri.jmrit.beantable.BeanTableDataModel
BeanTableDataModel.BeanTableTooltipHeaderRenderer
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.HashMap<java.lang.String,java.lang.Integer>
_listMap
protected java.lang.String
_name
protected java.util.ArrayList<E>
_pickList
protected javax.swing.table.TableRowSorter<PickListModel<E>>
_sorter
static int
POSITION_COL
static java.util.ResourceBundle
rb
static int
SNAME_COLUMN
static int
UNAME_COLUMN
-
Fields inherited from class jmri.jmrit.beantable.BeanTableDataModel
COMMENTCOL, DELETECOL, NUMCOLUMN, SYSNAMECOL, sysNameList, USERNAMECOL, VALUECOL
-
-
Constructor Summary
Constructors Constructor Description PickListModel()
Default constructor makes a table sorted by System Name.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract E
addBean(java.lang.String name)
Return bean with name given in parameter.abstract E
addBean(java.lang.String sysName, java.lang.String userName)
static PickListModel<Audio>
audioPickModelInstance()
static PickListModel<Block>
blockPickModelInstance()
abstract boolean
canAddBean()
Check if beans can be added by this model.void
clickOn(E t)
Process a click on The value cell.void
dispose()
Removes property change listeners from Beans.static PickListModel<DestinationPoints>
entryExitPickModelInstance()
E
getBeanAt(int index)
If table has been sorted table row no longer is the same as array index.java.util.List<E>
getBeanList()
This method is overridden if only a limited set of the beans should be retrieved.protected java.lang.String
getBeanType()
Get String of the Single Bean Type.E
getBySystemName(java.lang.String name)
protected E
getByUserName(java.lang.String name)
java.lang.Class<?>
getColumnClass(int c)
int
getColumnCount()
Get Column Count INCLUDING Bean Property Columns.java.lang.String
getColumnName(int c)
int
getIndexOf(E bean)
abstract Manager<E>
getManager()
Get the Table Model Bean Manager.protected java.lang.String
getMasterClassName()
java.lang.String
getName()
protected java.util.SortedSet<E>
getNamedBeanSet()
static int
getNumInstances(java.lang.String type)
int
getRowCount()
javax.swing.JTable
getTable()
java.lang.String
getValue(java.lang.String systemName)
Get the current Bean state value in human readable form.java.lang.Object
getValueAt(int r, int c)
SYSNAMECOL returns the actual Bean, NOT the System Name.static PickListModel<GlobalVariable>
globalVariablePickModelInstance()
boolean
isCellEditable(int r, int c)
static PickListModel<Light>
lightPickModelInstance()
static PickListModel<Logix>
logixPickModelInstance()
javax.swing.JTable
makePickTable()
Make pick table, DND enabled.void
makeSorter(javax.swing.JTable table)
static PickListModel<Memory>
memoryPickModelInstance()
static PickListModel<Sensor>
multiSensorPickModelInstance()
static PickListModel<OBlock>
oBlockPickModelInstance()
void
propertyChange(java.beans.PropertyChangeEvent e)
Handle additions and deletions in the table and changes to beans within the table.static PickListModel<Reporter>
reporterPickModelInstance()
static PickListModel<Sensor>
sensorPickModelInstance()
void
setValueAt(java.lang.Object type, int r, int c)
static PickListModel<SignalHead>
signalHeadPickModelInstance()
static PickListModel<SignalMast>
signalMastPickModelInstance()
static PickListModel<Turnout>
turnoutPickModelInstance()
protected void
updateNameList()
override BeanTableDataModel only lists SystemNamestatic PickListModel<Warrant>
warrantPickModelInstance()
-
Methods inherited from class jmri.jmrit.beantable.BeanTableDataModel
addMouseListenerToHeader, configDeleteColumn, configureButton, configureJTable, configureTable, configValueColumn, copyName, deleteBean, doDelete, editComment, formatToolTip, getCellToolTip, getDisplayDeleteMsg, getFilter, getHeaderTooltip, getPreferredWidth, getPropertyColumnCount, getPropertyColumnDescriptor, isClearUserNameAllowed, makeJTable, matchPropertyName, moveBean, persistTable, printColumns, printTable, removeName, renameBean, setColumnIdentities, setColumnToHoldButton, setDisplayDeleteMsg, setFilter, setManager, setPropertyColumnsVisible, showPopup, showTableHeaderPopup, stopPersistingTable
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
-
-
-
Field Detail
-
_name
protected java.lang.String _name
-
_sorter
protected javax.swing.table.TableRowSorter<PickListModel<E extends NamedBean>> _sorter
-
SNAME_COLUMN
public static final int SNAME_COLUMN
- See Also:
- Constant Field Values
-
UNAME_COLUMN
public static final int UNAME_COLUMN
- See Also:
- Constant Field Values
-
POSITION_COL
public static final int POSITION_COL
- See Also:
- Constant Field Values
-
rb
public static final java.util.ResourceBundle rb
-
_listMap
static java.util.HashMap<java.lang.String,java.lang.Integer> _listMap
-
-
Constructor Detail
-
PickListModel
public PickListModel()
Default constructor makes a table sorted by System Name.
-
-
Method Detail
-
getNumInstances
public static int getNumInstances(@Nonnull java.lang.String type)
-
getBeanAt
@CheckForNull public E getBeanAt(int index)
If table has been sorted table row no longer is the same as array index.- Parameters:
index
- row of table- Returns:
- bean at index or null if index is out of range
-
getIndexOf
public int getIndexOf(@Nonnull E bean)
-
getBeanList
@Nonnull public java.util.List<E> getBeanList()
This method is overridden if only a limited set of the beans should be retrieved.- Returns:
- the list of beans
-
updateNameList
protected void updateNameList()
override BeanTableDataModel only lists SystemName- Overrides:
updateNameList
in classBeanTableDataModel<E extends NamedBean>
-
getNamedBeanSet
@CheckReturnValue @Nonnull protected java.util.SortedSet<E> getNamedBeanSet()
-
getBySystemName
@CheckForNull public E getBySystemName(@Nonnull java.lang.String name)
- Specified by:
getBySystemName
in classBeanTableDataModel<E extends NamedBean>
-
getByUserName
@CheckForNull protected E getByUserName(@Nonnull java.lang.String name)
- Specified by:
getByUserName
in classBeanTableDataModel<E extends NamedBean>
-
getManager
@Nonnull public abstract Manager<E> 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<E extends NamedBean>
- Returns:
- current Manager in use by the Model.
-
addBean
@CheckForNull public abstract E addBean(@Nonnull java.lang.String name) throws java.lang.IllegalArgumentException
Return bean with name given in parameter. Create if needed and possible.- Parameters:
name
- the System name for the Bean.- Returns:
- the Bean or null if not made.
- Throws:
java.lang.IllegalArgumentException
- with reason why Bean cannot be created.
-
addBean
@CheckForNull public abstract E addBean(@Nonnull java.lang.String sysName, java.lang.String userName) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
canAddBean
public abstract boolean canAddBean()
Check if beans can be added by this model.- Returns:
- true if model can create beans; false otherwise
-
getMasterClassName
protected java.lang.String getMasterClassName()
- Specified by:
getMasterClassName
in classBeanTableDataModel<E extends NamedBean>
-
clickOn
public void clickOn(E t)
Process a click on The value cell.- Specified by:
clickOn
in classBeanTableDataModel<E extends NamedBean>
- Parameters:
t
- the Bean that has been clicked.
-
getColumnClass
public java.lang.Class<?> getColumnClass(int c)
- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classBeanTableDataModel<E extends NamedBean>
-
getColumnCount
public int getColumnCount()
Get Column Count INCLUDING Bean Property Columns.- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnCount
in classBeanTableDataModel<E extends NamedBean>
-
getColumnName
public java.lang.String getColumnName(int c)
- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classBeanTableDataModel<E extends NamedBean>
-
isCellEditable
public boolean isCellEditable(int r, int c)
- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classBeanTableDataModel<E extends NamedBean>
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
- Overrides:
getRowCount
in classBeanTableDataModel<E extends NamedBean>
-
getValueAt
public java.lang.Object getValueAt(int r, int c)
SYSNAMECOL returns the actual Bean, NOT the System Name.- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
getValueAt
in classBeanTableDataModel<E extends NamedBean>
-
setValueAt
public void setValueAt(java.lang.Object type, int r, int c)
- Specified by:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in classBeanTableDataModel<E extends NamedBean>
-
getValue
public java.lang.String getValue(java.lang.String systemName)
Get the current Bean state value in human readable form.- Specified by:
getValue
in classBeanTableDataModel<E extends NamedBean>
- Parameters:
systemName
- System name of Bean.- Returns:
- state value in localised human readable form.
-
getName
public java.lang.String getName()
-
getBeanType
protected java.lang.String getBeanType()
Get String of the Single Bean Type. In many cases the return is Bundle localised so should not be used for matching Bean types.- Overrides:
getBeanType
in classBeanTableDataModel<E extends NamedBean>
- Returns:
- Bean Type String.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
Handle additions and deletions in the table and changes to beans within the table.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Overrides:
propertyChange
in classBeanTableDataModel<E extends NamedBean>
- Parameters:
e
- the change
-
makePickTable
public javax.swing.JTable makePickTable()
Make pick table, DND enabled.- Returns:
- the table
-
makeSorter
public void makeSorter(@Nonnull javax.swing.JTable table)
-
dispose
public void dispose()
Removes property change listeners from Beans.- Overrides:
dispose
in classBeanTableDataModel<E extends NamedBean>
-
turnoutPickModelInstance
@Nonnull public static PickListModel<Turnout> turnoutPickModelInstance()
-
sensorPickModelInstance
@Nonnull public static PickListModel<Sensor> sensorPickModelInstance()
-
multiSensorPickModelInstance
@Nonnull public static PickListModel<Sensor> multiSensorPickModelInstance()
-
signalHeadPickModelInstance
@Nonnull public static PickListModel<SignalHead> signalHeadPickModelInstance()
-
signalMastPickModelInstance
@Nonnull public static PickListModel<SignalMast> signalMastPickModelInstance()
-
memoryPickModelInstance
@Nonnull public static PickListModel<Memory> memoryPickModelInstance()
-
globalVariablePickModelInstance
@Nonnull public static PickListModel<GlobalVariable> globalVariablePickModelInstance()
-
blockPickModelInstance
@Nonnull public static PickListModel<Block> blockPickModelInstance()
-
reporterPickModelInstance
@Nonnull public static PickListModel<Reporter> reporterPickModelInstance()
-
lightPickModelInstance
@Nonnull public static PickListModel<Light> lightPickModelInstance()
-
oBlockPickModelInstance
@Nonnull public static PickListModel<OBlock> oBlockPickModelInstance()
-
warrantPickModelInstance
@Nonnull public static PickListModel<Warrant> warrantPickModelInstance()
-
entryExitPickModelInstance
@Nonnull public static PickListModel<DestinationPoints> entryExitPickModelInstance()
-
logixPickModelInstance
public static PickListModel<Logix> logixPickModelInstance()
-
audioPickModelInstance
@Nonnull public static PickListModel<Audio> audioPickModelInstance()
-
-