use of jmri.jmrit.signalling.SignallingPanel.SignalMastModel in project JMRI by JMRI.
the class SignallingPanel method buildSignalMastPanel.
/**
* Compose GUI for setting up the Signal Masts tab for an SML.
*
* @return a JPanel containing the SML control signal masts configuration interface
*/
JPanel buildSignalMastPanel() {
JPanel SignalMastPanel = new JPanel();
SignalMastPanel.setLayout(new BoxLayout(SignalMastPanel, BoxLayout.Y_AXIS));
jmri.SignalMastManager bm = jmri.InstanceManager.getDefault(jmri.SignalMastManager.class);
List<String> systemNameList = bm.getSystemNameList();
_manualSignalMastList = new ArrayList<ManualSignalMastList>(systemNameList.size());
Iterator<String> iter = systemNameList.iterator();
while (iter.hasNext()) {
String systemName = iter.next();
_manualSignalMastList.add(new ManualSignalMastList(bm.getBySystemName(systemName)));
}
p2xm = new JPanel();
JPanel p2xmSpace = new JPanel();
p2xmSpace.setLayout(new BoxLayout(p2xmSpace, BoxLayout.Y_AXIS));
p2xmSpace.add(new JLabel("XXX"));
p2xm.add(p2xmSpace);
JPanel p21c = new JPanel();
p21c.setLayout(new BoxLayout(p21c, BoxLayout.Y_AXIS));
p21c.add(new JLabel(Bundle.getMessage("LabelSelectChecked", Bundle.getMessage("SignalMasts"))));
p2xm.add(p21c);
_signalMastModel = new SignalMastModel();
TableRowSorter<SignalMastModel> sorter = new TableRowSorter<>(_signalMastModel);
// don't use makeTable() since 4.7.1
JTable manualSignalMastTable = new JTable(_signalMastModel);
// configure (extra) row height for comboBox
manualSignalMastTable.setRowHeight(Sizer.getPreferredSize().height - 2);
// row height has to be greater than plain tables to properly show comboBox shape, but tightened a bit over preferred
// create mast (row) specific comboBox in Aspect column
_signalMastModel.configStateColumn(manualSignalMastTable);
manualSignalMastTable.setRowSorter(sorter);
manualSignalMastTable.setRowSelectionAllowed(false);
manualSignalMastTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 100));
TableColumnModel _manualSignalMastColumnModel = manualSignalMastTable.getColumnModel();
TableColumn includeColumnC = _manualSignalMastColumnModel.getColumn(SignalMastModel.INCLUDE_COLUMN);
includeColumnC.setResizable(false);
// was fixed 60
includeColumnC.setMinWidth(9 * Bundle.getMessage("Include").length());
includeColumnC.setMaxWidth(includeColumnC.getMinWidth() + 5);
TableColumn sNameColumnC = _manualSignalMastColumnModel.getColumn(SignalMastModel.SNAME_COLUMN);
sNameColumnC.setResizable(true);
sNameColumnC.setMinWidth(75);
sNameColumnC.setMaxWidth(95);
TableColumn stateColumnC = _manualSignalMastColumnModel.getColumn(SensorModel.STATE_COLUMN);
stateColumnC.setResizable(false);
stateColumnC.setMinWidth(9 * ("Diverging Approach Medium").length() + 20);
// was fixed 100
stateColumnC.setMaxWidth(stateColumnC.getMinWidth() + 10);
// remaining space is filled by UserName
_manualSignalMastScrollPane = new JScrollPane(manualSignalMastTable);
p2xm.add(_manualSignalMastScrollPane, BorderLayout.CENTER);
SignalMastPanel.add(p2xm);
p2xm.setVisible(true);
ROW_HEIGHT = manualSignalMastTable.getRowHeight();
p2xmSpace.setVisible(false);
JPanel p2xaSpace = new JPanel();
p2xaSpace.setLayout(new BoxLayout(p2xaSpace, BoxLayout.Y_AXIS));
p2xaSpace.add(new JLabel("XXX"));
p2xsm.add(p2xaSpace);
JPanel p21a = new JPanel();
p21a.setLayout(new BoxLayout(p21a, BoxLayout.Y_AXIS));
p21a.add(new JLabel(Bundle.getMessage("LabelAutogenerated", Bundle.getMessage("SignalMasts"))));
p2xsm.add(p21a);
_autoSignalMastModel = new AutoMastModel();
JTable autoMastTable = new JTable(_autoSignalMastModel);
TableRowSorter<AutoMastModel> autoMastSorter = new TableRowSorter<>(_autoSignalMastModel);
autoMastSorter.setComparator(AutoMastModel.SNAME_COLUMN, new SystemNameComparator());
RowSorterUtil.setSortOrder(autoMastSorter, AutoMastModel.SNAME_COLUMN, SortOrder.ASCENDING);
autoMastTable.setRowSorter(autoMastSorter);
autoMastTable.setRowSelectionAllowed(false);
autoMastTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 100));
TableColumnModel _autoMastColumnModel = autoMastTable.getColumnModel();
TableColumn sNameColumnA = _autoMastColumnModel.getColumn(AutoMastModel.SNAME_COLUMN);
sNameColumnA.setResizable(true);
sNameColumnA.setMinWidth(75);
sNameColumnA.setMaxWidth(95);
TableColumn stateColumnA = _autoMastColumnModel.getColumn(AutoMastModel.STATE_COLUMN);
stateColumnA.setResizable(false);
stateColumnA.setMinWidth(90);
stateColumnA.setMaxWidth(100);
_autoSignalMastScrollPane = new JScrollPane(autoMastTable);
p2xsm.add(_autoSignalMastScrollPane, BorderLayout.CENTER);
SignalMastPanel.add(p2xsm);
p2xsm.setVisible(true);
ROW_HEIGHT = autoMastTable.getRowHeight();
p2xaSpace.setVisible(false);
return SignalMastPanel;
}
Aggregations