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 classPickListModel.AudioPickModel(package private) static classPickListModel.BlockPickModel(package private) static classPickListModel.EntryExitPickModel(package private) static classPickListModel.GlobalVariablePickModel(package private) static classPickListModel.LightPickModel(package private) static classPickListModel.LogixPickModel(package private) static classPickListModel.MemoryPickModel(package private) static classPickListModel.MultiSensorPickModel(package private) static classPickListModel.OBlockPickModel(package private) static classPickListModel.ReporterPickModel(package private) static classPickListModel.SensorPickModel(package private) static classPickListModel.SignalHeadPickModel(package private) static classPickListModel.SignalMastPickModel(package private) static classPickListModel.TurnoutPickModel(package private) static classPickListModel.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>_listMapprotected java.lang.String_nameprotected java.util.ArrayList<E>_pickListprotected javax.swing.table.TableRowSorter<PickListModel<E>>_sorterstatic intPOSITION_COLstatic java.util.ResourceBundlerbstatic intSNAME_COLUMNstatic intUNAME_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 EaddBean(java.lang.String name)Return bean with name given in parameter.abstract EaddBean(java.lang.String sysName, java.lang.String userName)static PickListModel<Audio>audioPickModelInstance()static PickListModel<Block>blockPickModelInstance()abstract booleancanAddBean()Check if beans can be added by this model.voidclickOn(E t)Process a click on The value cell.voiddispose()Removes property change listeners from Beans.static PickListModel<DestinationPoints>entryExitPickModelInstance()EgetBeanAt(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.StringgetBeanType()Get String of the Single Bean Type.EgetBySystemName(java.lang.String name)protected EgetByUserName(java.lang.String name)java.lang.Class<?>getColumnClass(int c)intgetColumnCount()Get Column Count INCLUDING Bean Property Columns.java.lang.StringgetColumnName(int c)intgetIndexOf(E bean)abstract Manager<E>getManager()Get the Table Model Bean Manager.protected java.lang.StringgetMasterClassName()java.lang.StringgetName()protected java.util.SortedSet<E>getNamedBeanSet()static intgetNumInstances(java.lang.String type)intgetRowCount()javax.swing.JTablegetTable()java.lang.StringgetValue(java.lang.String systemName)Get the current Bean state value in human readable form.java.lang.ObjectgetValueAt(int r, int c)SYSNAMECOL returns the actual Bean, NOT the System Name.static PickListModel<GlobalVariable>globalVariablePickModelInstance()booleanisCellEditable(int r, int c)static PickListModel<Light>lightPickModelInstance()static PickListModel<Logix>logixPickModelInstance()javax.swing.JTablemakePickTable()Make pick table, DND enabled.voidmakeSorter(javax.swing.JTable table)static PickListModel<Memory>memoryPickModelInstance()static PickListModel<Sensor>multiSensorPickModelInstance()static PickListModel<OBlock>oBlockPickModelInstance()voidpropertyChange(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()voidsetValueAt(java.lang.Object type, int r, int c)static PickListModel<SignalHead>signalHeadPickModelInstance()static PickListModel<SignalMast>signalMastPickModelInstance()static PickListModel<Turnout>turnoutPickModelInstance()protected voidupdateNameList()override BeanTableDataModel only lists SystemNamestatic PickListModel<Warrant>warrantPickModelInstance()-
Methods inherited from class jmri.jmrit.beantable.BeanTableDataModel
addMouseListenerToHeader, configDeleteColumn, configureButton, configureJTable, configureTable, configValueColumn, copySystemName, copyUserName, deleteBean, doDelete, editComment, exportToCSV, 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:
updateNameListin 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:
getBySystemNamein classBeanTableDataModel<E extends NamedBean>
-
getByUserName
@CheckForNull protected E getByUserName(@Nonnull java.lang.String name)
- Specified by:
getByUserNamein 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:
getManagerin 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:
getMasterClassNamein classBeanTableDataModel<E extends NamedBean>
-
clickOn
public void clickOn(E t)
Process a click on The value cell.- Specified by:
clickOnin classBeanTableDataModel<E extends NamedBean>- Parameters:
t- the Bean that has been clicked.
-
getColumnClass
public java.lang.Class<?> getColumnClass(int c)
- Specified by:
getColumnClassin interfacejavax.swing.table.TableModel- Overrides:
getColumnClassin classBeanTableDataModel<E extends NamedBean>
-
getColumnCount
public int getColumnCount()
Get Column Count INCLUDING Bean Property Columns.- Specified by:
getColumnCountin interfacejavax.swing.table.TableModel- Overrides:
getColumnCountin classBeanTableDataModel<E extends NamedBean>
-
getColumnName
public java.lang.String getColumnName(int c)
- Specified by:
getColumnNamein interfacejavax.swing.table.TableModel- Overrides:
getColumnNamein classBeanTableDataModel<E extends NamedBean>
-
isCellEditable
public boolean isCellEditable(int r, int c)
- Specified by:
isCellEditablein interfacejavax.swing.table.TableModel- Overrides:
isCellEditablein classBeanTableDataModel<E extends NamedBean>
-
getRowCount
public int getRowCount()
- Specified by:
getRowCountin interfacejavax.swing.table.TableModel- Overrides:
getRowCountin 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:
getValueAtin interfacejavax.swing.table.TableModel- Overrides:
getValueAtin classBeanTableDataModel<E extends NamedBean>
-
setValueAt
public void setValueAt(java.lang.Object type, int r, int c)
- Specified by:
setValueAtin interfacejavax.swing.table.TableModel- Overrides:
setValueAtin 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:
getValuein 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:
getBeanTypein 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:
propertyChangein interfacejava.beans.PropertyChangeListener- Overrides:
propertyChangein 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:
disposein 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()
-
-