use of javax.swing.DefaultCellEditor in project JMRI by JMRI.
the class RouteTableAction method addPressed.
@Override
protected void addPressed(ActionEvent e) {
pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
if (editMode) {
cancelEdit();
}
jmri.TurnoutManager tm = InstanceManager.turnoutManagerInstance();
List<String> systemNameList = tm.getSystemNameList();
_turnoutList = new ArrayList<>(systemNameList.size());
Iterator<String> iter = systemNameList.iterator();
while (iter.hasNext()) {
String systemName = iter.next();
String userName = tm.getBySystemName(systemName).getUserName();
_turnoutList.add(new RouteTurnout(systemName, userName));
}
jmri.SensorManager sm = InstanceManager.sensorManagerInstance();
systemNameList = sm.getSystemNameList();
_sensorList = new ArrayList<>(systemNameList.size());
iter = systemNameList.iterator();
while (iter.hasNext()) {
String systemName = iter.next();
Sensor s = sm.getBySystemName(systemName);
if (s != null) {
String userName = s.getUserName();
_sensorList.add(new RouteSensor(systemName, userName));
} else {
log.error("Failed to get sensor {}", systemName);
}
}
initializeIncludedList();
// Set up window
if (addFrame == null) {
turnoutsAlignedSensor = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
sensor1 = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
sensor2 = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
sensor3 = new JmriBeanComboBox(InstanceManager.sensorManagerInstance());
cTurnout = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance());
cLockTurnout = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance());
addFrame = new JmriJFrame(Bundle.getMessage("TitleAddRoute"), false, true);
addFrame.addHelpMenu("package.jmri.jmrit.beantable.RouteAddEdit", true);
addFrame.setLocation(100, 30);
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
// add system name
JPanel ps = new JPanel();
ps.setLayout(new FlowLayout());
ps.add(nameLabel);
ps.add(_systemName);
ps.add(_autoSystemName);
_autoSystemName.addActionListener((ActionEvent e1) -> {
autoSystemName();
});
if (pref.getSimplePreferenceState(systemNameAuto)) {
_autoSystemName.setSelected(true);
}
_systemName.setToolTipText(Bundle.getMessage("TooltipRouteSystemName"));
ps.add(fixedSystemName);
fixedSystemName.setVisible(false);
contentPanel.add(ps);
// add user name
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
p.add(userLabel);
p.add(_userName);
_userName.setToolTipText(Bundle.getMessage("TooltipRouteUserName"));
contentPanel.add(p);
// add Turnout Display Choice
JPanel py = new JPanel();
py.add(new JLabel(Bundle.getMessage("Show") + ":"));
selGroup = new ButtonGroup();
allButton = new JRadioButton(Bundle.getMessage("All"), true);
selGroup.add(allButton);
py.add(allButton);
allButton.addActionListener((ActionEvent e1) -> {
// Setup for display of all Turnouts, if needed
if (!showAll) {
showAll = true;
_routeTurnoutModel.fireTableDataChanged();
_routeSensorModel.fireTableDataChanged();
}
});
includedButton = new JRadioButton(Bundle.getMessage("Included"), false);
selGroup.add(includedButton);
py.add(includedButton);
includedButton.addActionListener((ActionEvent e1) -> {
// Setup for display of included Turnouts only, if needed
if (showAll) {
showAll = false;
initializeIncludedList();
_routeTurnoutModel.fireTableDataChanged();
_routeSensorModel.fireTableDataChanged();
}
});
py.add(new JLabel(Bundle.getMessage("_and_", Bundle.getMessage("Turnouts"), Bundle.getMessage("Sensors"))));
// keys are in jmri.jmrit.Bundle
contentPanel.add(py);
// add Turnout table
p2xt = new JPanel();
JPanel p2xtSpace = new JPanel();
p2xtSpace.setLayout(new BoxLayout(p2xtSpace, BoxLayout.Y_AXIS));
p2xtSpace.add(new JLabel("XXX"));
p2xt.add(p2xtSpace);
JPanel p21t = new JPanel();
p21t.setLayout(new BoxLayout(p21t, BoxLayout.Y_AXIS));
p21t.add(new JLabel(Bundle.getMessage("SelectInRoute", Bundle.getMessage("Turnouts"))));
p2xt.add(p21t);
_routeTurnoutModel = new RouteTurnoutModel();
JTable routeTurnoutTable = new JTable(_routeTurnoutModel);
TableRowSorter<RouteTurnoutModel> rtSorter = new TableRowSorter<>(_routeTurnoutModel);
rtSorter.setComparator(RouteTurnoutModel.SNAME_COLUMN, new SystemNameComparator());
RowSorterUtil.setSortOrder(rtSorter, RouteTurnoutModel.SNAME_COLUMN, SortOrder.ASCENDING);
routeTurnoutTable.setRowSorter(rtSorter);
routeTurnoutTable.setRowSelectionAllowed(false);
routeTurnoutTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 80));
ROW_HEIGHT = routeTurnoutTable.getRowHeight();
JComboBox<String> stateTCombo = new JComboBox<>();
stateTCombo.addItem(SET_TO_CLOSED);
stateTCombo.addItem(SET_TO_THROWN);
stateTCombo.addItem(SET_TO_TOGGLE);
TableColumnModel routeTurnoutColumnModel = routeTurnoutTable.getColumnModel();
TableColumn includeColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.INCLUDE_COLUMN);
includeColumnT.setResizable(false);
includeColumnT.setMinWidth(50);
includeColumnT.setMaxWidth(60);
TableColumn sNameColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.SNAME_COLUMN);
sNameColumnT.setResizable(true);
sNameColumnT.setMinWidth(75);
sNameColumnT.setMaxWidth(95);
TableColumn uNameColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.UNAME_COLUMN);
uNameColumnT.setResizable(true);
uNameColumnT.setMinWidth(210);
uNameColumnT.setMaxWidth(260);
TableColumn stateColumnT = routeTurnoutColumnModel.getColumn(RouteTurnoutModel.STATE_COLUMN);
stateColumnT.setCellEditor(new DefaultCellEditor(stateTCombo));
stateColumnT.setResizable(false);
stateColumnT.setMinWidth(90);
stateColumnT.setMaxWidth(100);
_routeTurnoutScrollPane = new JScrollPane(routeTurnoutTable);
p2xt.add(_routeTurnoutScrollPane, BorderLayout.CENTER);
contentPanel.add(p2xt);
p2xt.setVisible(true);
// add Sensor table
p2xs = new JPanel();
JPanel p2xsSpace = new JPanel();
p2xsSpace.setLayout(new BoxLayout(p2xsSpace, BoxLayout.Y_AXIS));
p2xsSpace.add(new JLabel("XXX"));
p2xs.add(p2xsSpace);
JPanel p21s = new JPanel();
p21s.setLayout(new BoxLayout(p21s, BoxLayout.Y_AXIS));
p21s.add(new JLabel(Bundle.getMessage("SelectInRoute", Bundle.getMessage("Sensors"))));
p2xs.add(p21s);
_routeSensorModel = new RouteSensorModel();
JTable routeSensorTable = new JTable(_routeSensorModel);
TableRowSorter<RouteSensorModel> rsSorter = new TableRowSorter<>(_routeSensorModel);
rsSorter.setComparator(RouteSensorModel.SNAME_COLUMN, new SystemNameComparator());
RowSorterUtil.setSortOrder(rsSorter, RouteSensorModel.SNAME_COLUMN, SortOrder.ASCENDING);
routeSensorTable.setRowSorter(rsSorter);
routeSensorTable.setRowSelectionAllowed(false);
routeSensorTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 80));
JComboBox<String> stateSCombo = new JComboBox<>();
stateSCombo.addItem(SET_TO_ACTIVE);
stateSCombo.addItem(SET_TO_INACTIVE);
stateSCombo.addItem(SET_TO_TOGGLE);
TableColumnModel routeSensorColumnModel = routeSensorTable.getColumnModel();
TableColumn includeColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.INCLUDE_COLUMN);
includeColumnS.setResizable(false);
includeColumnS.setMinWidth(50);
includeColumnS.setMaxWidth(60);
TableColumn sNameColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.SNAME_COLUMN);
sNameColumnS.setResizable(true);
sNameColumnS.setMinWidth(75);
sNameColumnS.setMaxWidth(95);
TableColumn uNameColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.UNAME_COLUMN);
uNameColumnS.setResizable(true);
uNameColumnS.setMinWidth(210);
uNameColumnS.setMaxWidth(260);
TableColumn stateColumnS = routeSensorColumnModel.getColumn(RouteSensorModel.STATE_COLUMN);
stateColumnS.setCellEditor(new DefaultCellEditor(stateSCombo));
stateColumnS.setResizable(false);
stateColumnS.setMinWidth(90);
stateColumnS.setMaxWidth(100);
_routeSensorScrollPane = new JScrollPane(routeSensorTable);
p2xs.add(_routeSensorScrollPane, BorderLayout.CENTER);
contentPanel.add(p2xs);
p2xs.setVisible(true);
// Enter filenames for sound, script
JPanel p25 = new JPanel();
p25.setLayout(new FlowLayout());
p25.add(new JLabel(Bundle.getMessage("LabelPlaySound")));
p25.add(soundFile);
//NO18N
JButton ss = new JButton("...");
ss.addActionListener((ActionEvent e1) -> {
setSoundPressed();
});
ss.setToolTipText(Bundle.getMessage("TooltipOpenFile", Bundle.getMessage("BeanNameAudio")));
p25.add(ss);
p25.add(new JLabel(Bundle.getMessage("LabelRunScript")));
p25.add(scriptFile);
//NO18N
ss = new JButton("...");
ss.addActionListener((ActionEvent e1) -> {
setScriptPressed();
});
ss.setToolTipText(Bundle.getMessage("TooltipOpenFile", Bundle.getMessage("Script")));
p25.add(ss);
contentPanel.add(p25);
//add turnouts aligned Sensor
JPanel p27 = new JPanel();
p27.setLayout(new FlowLayout());
p27.add(new JLabel(Bundle.getMessage("LabelEnterSensorAligned")));
p27.add(turnoutsAlignedSensor);
turnoutsAlignedSensor.setFirstItemBlank(true);
turnoutsAlignedSensor.setSelectedBean(null);
turnoutsAlignedSensor.setToolTipText(Bundle.getMessage("TooltipEnterSensor"));
contentPanel.add(p27);
// add Control Sensor table
JPanel p3 = new JPanel();
p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
JPanel p31 = new JPanel();
p31.add(new JLabel(Bundle.getMessage("LabelEnterSensors")));
p3.add(p31);
JPanel p32 = new JPanel();
//Sensor 1
JPanel pS = new JPanel();
pS.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BeanNameSensor") + " 1"));
pS.add(sensor1);
pS.add(sensor1mode);
p32.add(pS);
//Sensor 2
pS = new JPanel();
pS.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BeanNameSensor") + " 2"));
pS.add(sensor2);
pS.add(sensor2mode);
p32.add(pS);
//Sensor 3
pS = new JPanel();
pS.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BeanNameSensor") + " 3"));
pS.add(sensor3);
pS.add(sensor3mode);
p32.add(pS);
sensor1.setFirstItemBlank(true);
sensor2.setFirstItemBlank(true);
sensor3.setFirstItemBlank(true);
sensor1.setSelectedBean(null);
sensor2.setSelectedBean(null);
sensor3.setSelectedBean(null);
String sensorHint = Bundle.getMessage("TooltipEnterSensors");
sensor1.setToolTipText(sensorHint);
sensor2.setToolTipText(sensorHint);
sensor3.setToolTipText(sensorHint);
p3.add(p32);
// add control turnout
JPanel p33 = new JPanel();
p33.add(new JLabel(Bundle.getMessage("LabelEnterTurnout")));
p3.add(p33);
JPanel p34 = new JPanel();
p34.add(new JLabel(Bundle.getMessage("BeanNameTurnout") + ":"));
p34.add(cTurnout);
cTurnout.setFirstItemBlank(true);
cTurnout.setSelectedBean(null);
cTurnout.setToolTipText(Bundle.getMessage("TooltipEnterTurnout"));
p34.add(new JLabel(" " + Bundle.getMessage("LabelCondition") + ":"));
cTurnoutStateBox.setToolTipText(Bundle.getMessage("TooltipTurnoutCondition"));
p34.add(cTurnoutStateBox);
p3.add(p34);
// add added delay
JPanel p36 = new JPanel();
p36.add(new JLabel(Bundle.getMessage("LabelTurnoutDelay") + ":"));
p36.add(timeDelay);
timeDelay.setText("0");
timeDelay.setToolTipText(Bundle.getMessage("TooltipTurnoutDelay"));
p36.add(new JLabel(" " + Bundle.getMessage("LabelMilliseconds")));
p3.add(p36);
// complete this panel
Border p3Border = BorderFactory.createEtchedBorder();
p3.setBorder(p3Border);
contentPanel.add(p3);
// add lock control table
JPanel p4 = new JPanel();
p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS));
// add lock control turnout
JPanel p43 = new JPanel();
p43.add(new JLabel(Bundle.getMessage("LabelLockTurnout")));
p4.add(p43);
JPanel p44 = new JPanel();
p44.add(new JLabel(Bundle.getMessage("BeanNameTurnout") + ":"));
p44.add(cLockTurnout);
cLockTurnout.setFirstItemBlank(true);
cLockTurnout.setSelectedBean(null);
cLockTurnout.setToolTipText(Bundle.getMessage("TooltipEnterTurnout"));
p44.add(new JLabel(" " + Bundle.getMessage("LabelCondition") + ":"));
cLockTurnoutStateBox.setToolTipText(Bundle.getMessage("TooltipLockTurnout"));
p44.add(cLockTurnoutStateBox);
p4.add(p44);
// complete this panel
Border p4Border = BorderFactory.createEtchedBorder();
p4.setBorder(p4Border);
contentPanel.add(p4);
// add notes panel
JPanel pa = new JPanel();
pa.setLayout(new BoxLayout(pa, BoxLayout.Y_AXIS));
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(status1);
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.add(status2);
pa.add(p1);
pa.add(p2);
Border pBorder = BorderFactory.createEtchedBorder();
pa.setBorder(pBorder);
contentPanel.add(pa);
// add Buttons panel
JPanel pb = new JPanel();
pb.setLayout(new FlowLayout(FlowLayout.TRAILING));
// Cancel (Add) button
pb.add(cancelButton);
cancelButton.addActionListener(this::cancelAddPressed);
// CancelEdit button
pb.add(cancelEditButton);
cancelEditButton.addActionListener(this::cancelPressed);
cancelEditButton.setToolTipText(Bundle.getMessage("TooltipCancelRoute"));
// Add Create Route button
pb.add(createButton);
createButton.addActionListener(this::createPressed);
createButton.setToolTipText(Bundle.getMessage("TooltipCreateRoute"));
// Edit Route button
pb.add(editButton);
editButton.addActionListener(this::editPressed);
editButton.setToolTipText(Bundle.getMessage("TooltipEditRoute"));
// Delete Route button
pb.add(deleteButton);
deleteButton.addActionListener(this::deletePressed);
deleteButton.setToolTipText(Bundle.getMessage("TooltipDeleteRoute"));
// Update Route button
pb.add(updateButton);
updateButton.addActionListener((ActionEvent e1) -> {
updatePressed(e1, false);
});
updateButton.setToolTipText(Bundle.getMessage("TooltipUpdateRoute"));
// Export button
pb.add(exportButton);
exportButton.addActionListener(this::exportPressed);
exportButton.setToolTipText(Bundle.getMessage("TooltipExportRoute"));
// Show the initial buttons, and hide the others
exportButton.setVisible(false);
// show CancelAdd button
cancelButton.setVisible(true);
cancelEditButton.setVisible(false);
updateButton.setVisible(true);
editButton.setVisible(true);
createButton.setVisible(true);
deleteButton.setVisible(false);
contentPanel.add(pb);
addFrame.getContentPane().add(new JScrollPane(contentPanel), BorderLayout.CENTER);
// pack and release space
addFrame.pack();
p2xsSpace.setVisible(false);
p2xtSpace.setVisible(false);
}
// set listener for window closing
addFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
// remind to save, if Route was created or edited
if (routeDirty) {
InstanceManager.getDefault(jmri.UserPreferencesManager.class).showInfoMessage(Bundle.getMessage("ReminderTitle"), Bundle.getMessage("ReminderSaveString", Bundle.getMessage("MenuItemRouteTable")), getClassName(), //NOI18N
"remindSaveRoute");
routeDirty = false;
}
// hide addFrame
if (addFrame != null) {
addFrame.setVisible(false);
// addFrame.dispose(); // causes multiple empty Routes next time
}
// if in Edit, cancel edit mode
if (editMode) {
cancelEdit();
}
_routeSensorModel.dispose();
_routeTurnoutModel.dispose();
}
});
// display the window
addFrame.setVisible(true);
autoSystemName();
}
use of javax.swing.DefaultCellEditor in project JMRI by JMRI.
the class NodeConfigFrame method initComponents.
/**
* Initialize the config window
*/
@SuppressFBWarnings(value = "SBSC_USE_STRINGBUFFER_CONCATENATION")
// though it would be good to fix it if you're working in this area
@Override
public void initComponents() {
setTitle(rb.getString("WindowTitle"));
// Container contentPane = getContentPane();
contentPane = getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
// Set up node address and node type
JPanel panel1 = new JPanel();
panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));
// Copy and pasted from the info button
String nodesstring = "";
int tempnumnodes = _memo.getTrafficController().getNumNodes();
for (int i = 0; i < tempnumnodes; i++) {
AcelaNode tempnode;
tempnode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(i);
nodesstring = nodesstring + " " + tempnode.getNodeTypeString();
}
thenodesStaticC.setText(nodesstring);
// panelthenodes displays the current node configuration and polling result
JPanel panelthenodes = new JPanel();
panelthenodes.setLayout(new BoxLayout(panelthenodes, BoxLayout.Y_AXIS));
JPanel panelthenodes1 = new JPanel();
panelthenodes1.setLayout(new FlowLayout());
panelthenodes1.add(new JLabel(" The nodes: "));
panelthenodes1.add(thenodesStaticH);
panelthenodes.add(panelthenodes1);
JPanel panelthenodes2 = new JPanel();
panelthenodes2.setLayout(new FlowLayout());
panelthenodes2.add(new JLabel("As Configured: "));
panelthenodes2.add(thenodesStaticC);
panelthenodes.add(panelthenodes2);
JPanel panelthenodes3 = new JPanel();
panelthenodes3.setLayout(new FlowLayout());
panelthenodes3.add(new JLabel(" As Polled: "));
panelthenodes3.add(thenodesStaticP);
panelthenodes.add(panelthenodes3);
Border panelthenodesBorder = BorderFactory.createEtchedBorder();
Border panelthenodesTitled = BorderFactory.createTitledBorder(panelthenodesBorder, rb.getString("BoxLabelNodes"));
panelthenodes.setBorder(panelthenodesTitled);
contentPane.add(panelthenodes);
// panel11 is the node address
JPanel panel11 = new JPanel();
panel11.setLayout(new FlowLayout());
panel11.add(new JLabel(rb.getString("LabelNodeAddress") + " "));
nodeAddrBox = new JComboBox<String>(AcelaNode.getNodeNames());
nodeAddrBox.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent event) {
infoButtonActionPerformed();
}
});
panel11.add(nodeAddrBox);
panel11.add(nodeAddrField);
// nodeAddrField.setToolTipText(rb.getString("TipNodeAddress"));
nodeAddrField.setText("0");
panel11.add(nodeAddrStatic);
nodeAddrField.setVisible(false);
nodeAddrStatic.setVisible(false);
contentPane.add(panel11);
// panelNodeInfo is the node type
JPanel panelNodeInfo = new JPanel();
panelNodeInfo.add(new JLabel(" " + rb.getString("LabelNodeType") + " "));
nodeTypeBox = new JComboBox<String>(AcelaNode.getModuleNames());
nodeTypeBox.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent event) {
String s = (String) nodeTypeBox.getSelectedItem();
if (s.equals("Acela")) {
panelAcela.setVisible(true);
panelTBrain.setVisible(false);
panelDash8.setVisible(false);
panelWatchman.setVisible(false);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(false);
panelSentry.setVisible(false);
} else if (s.equals("TrainBrain")) {
panelAcela.setVisible(false);
panelTBrain.setVisible(true);
panelDash8.setVisible(false);
panelWatchman.setVisible(false);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(false);
panelSentry.setVisible(false);
} else if (s.equals("Dash-8")) {
panelAcela.setVisible(false);
panelTBrain.setVisible(false);
panelDash8.setVisible(true);
panelWatchman.setVisible(false);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(false);
panelSentry.setVisible(false);
} else if (s.equals("Watchman")) {
panelAcela.setVisible(false);
panelTBrain.setVisible(false);
panelDash8.setVisible(false);
panelWatchman.setVisible(true);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(false);
panelSentry.setVisible(false);
} else if (s.equals("SignalMan")) {
panelAcela.setVisible(false);
panelTBrain.setVisible(false);
panelDash8.setVisible(false);
panelWatchman.setVisible(false);
panelSignalman.setVisible(true);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(false);
panelSentry.setVisible(false);
} else if (s.equals("SwitchMan")) {
panelAcela.setVisible(false);
panelTBrain.setVisible(false);
panelDash8.setVisible(false);
panelWatchman.setVisible(false);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(true);
panelYardMaster.setVisible(false);
panelSentry.setVisible(false);
} else if (s.equals("YardMaster")) {
panelAcela.setVisible(false);
panelTBrain.setVisible(false);
panelDash8.setVisible(false);
panelWatchman.setVisible(false);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(true);
panelSentry.setVisible(false);
} else if (s.equals("Sentry")) {
panelAcela.setVisible(false);
panelTBrain.setVisible(false);
panelDash8.setVisible(false);
panelWatchman.setVisible(false);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(false);
panelSentry.setVisible(true);
} else // Add code here for other types of nodes
{
panelAcela.setVisible(false);
panelTBrain.setVisible(false);
panelDash8.setVisible(false);
panelWatchman.setVisible(false);
panelSignalman.setVisible(false);
panelSwitchman.setVisible(false);
panelYardMaster.setVisible(false);
panelSentry.setVisible(false);
}
}
});
panelNodeInfo.add(nodeTypeBox);
nodeTypeBox.setToolTipText(rb.getString("TipNodeType"));
panelNodeInfo.add(nodeTypeStatic);
nodeTypeBox.setVisible(false);
nodeTypeStatic.setVisible(true);
contentPane.add(panelNodeInfo);
// Set up the Acela nodes
panelAcela.setLayout(new BoxLayout(panelAcela, BoxLayout.Y_AXIS));
JPanel panelAcela1 = new JPanel();
panelAcela1.setLayout(new FlowLayout());
statusTextAcela1.setText(stdStatusAcela1);
statusTextAcela1.setVisible(true);
panelAcela1.add(statusTextAcela1);
panelAcela.add(panelAcela1);
JPanel panelAcela2 = new JPanel();
panelAcela2.setLayout(new FlowLayout());
statusTextAcela2.setText(stdStatusAcela2);
statusTextAcela2.setVisible(true);
panelAcela2.add(statusTextAcela2);
panelAcela.add(panelAcela2);
JPanel panelAcela3 = new JPanel();
panelAcela3.setLayout(new FlowLayout());
statusTextAcela3.setText(stdStatusAcela3);
statusTextAcela3.setVisible(true);
panelAcela3.add(statusTextAcela3);
panelAcela.add(panelAcela3);
JPanel panelAcela4 = new JPanel();
panelAcela4.setLayout(new FlowLayout());
statusTextAcela4.setText(stdStatusAcela4);
statusTextAcela4.setVisible(true);
panelAcela4.add(statusTextAcela4);
panelAcela.add(panelAcela4);
JPanel panelAcela5 = new JPanel();
panelAcela5.setLayout(new FlowLayout());
statusTextAcela5.setText(stdStatusAcela5);
statusTextAcela5.setVisible(true);
panelAcela5.add(statusTextAcela5);
panelAcela.add(panelAcela5);
JPanel panelAcela6 = new JPanel();
panelAcela6.setLayout(new FlowLayout());
statusTextAcela6.setText(stdStatusAcela6);
statusTextAcela6.setVisible(true);
panelAcela6.add(statusTextAcela6);
panelAcela.add(panelAcela6);
JPanel panelAcela7 = new JPanel();
panelAcela7.setLayout(new FlowLayout());
statusTextAcela7.setText(stdStatusAcela7);
statusTextAcela7.setVisible(true);
panelAcela7.add(statusTextAcela7);
panelAcela.add(panelAcela7);
JPanel panelAcela8 = new JPanel();
panelAcela8.setLayout(new FlowLayout());
statusTextAcela8.setText(stdStatusAcela8);
statusTextAcela8.setVisible(true);
panelAcela8.add(statusTextAcela8);
panelAcela.add(panelAcela8);
JPanel panelAcela9 = new JPanel();
panelAcela9.setLayout(new FlowLayout());
statusTextAcela9.setText(stdStatusAcela9);
statusTextAcela9.setVisible(true);
panelAcela9.add(statusTextAcela9);
panelAcela.add(panelAcela9);
JPanel panelAcela10 = new JPanel();
panelAcela10.setLayout(new FlowLayout());
statusTextAcela10.setText(stdStatusAcela10);
statusTextAcela10.setVisible(true);
panelAcela10.add(statusTextAcela10);
panelAcela.add(panelAcela10);
JPanel panelAcela11 = new JPanel();
panelAcela11.setLayout(new FlowLayout());
statusTextAcela11.setText(stdStatusAcela11);
statusTextAcela11.setVisible(true);
panelAcela11.add(statusTextAcela11);
panelAcela.add(panelAcela11);
Border panelAcelaBorder = BorderFactory.createEtchedBorder();
Border panelAcelaTitled = BorderFactory.createTitledBorder(panelAcelaBorder, rb.getString("BoxLabelNodeSpecific"));
panelAcela.setBorder(panelAcelaTitled);
contentPane.add(panelAcela);
// Set up the Dash8 nodes
panelDash8.setLayout(new BoxLayout(panelDash8, BoxLayout.Y_AXIS));
JPanel panelDash81 = new JPanel();
panelDash81.setLayout(new FlowLayout());
statusTextDash81.setText(stdStatusDash81);
statusTextDash81.setVisible(true);
panelDash81.add(statusTextDash81);
panelDash8.add(panelDash81);
JPanel panelDash82 = new JPanel();
panelDash82.setLayout(new FlowLayout());
statusTextDash82.setText(stdStatusDash82);
statusTextDash82.setVisible(true);
panelDash82.add(statusTextDash82);
panelDash8.add(panelDash82);
JPanel panelDash83 = new JPanel();
panelDash83.setLayout(new FlowLayout());
statusTextDash83.setText(stdStatusDash83);
statusTextDash83.setVisible(true);
panelDash83.add(statusTextDash83);
panelDash8.add(panelDash83);
// Output circuit configuration
d8outputConfigModel = new OutputConfigModel();
d8outputConfigModel.setNumRows(8);
d8outputConfigModel.setEditMode(false);
JTable d8outputConfigTable = new JTable(d8outputConfigModel);
d8outputConfigTable.setRowSelectionAllowed(false);
d8outputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125));
JComboBox<String> d8outputWiredCombo = new JComboBox<String>();
d8outputWiredCombo.addItem(rb.getString("OutputWiredNC"));
d8outputWiredCombo.addItem(rb.getString("OutputWiredNO"));
JComboBox<String> d8initialStateCombo = new JComboBox<String>();
d8initialStateCombo.addItem(rb.getString("InitialStateOn"));
d8initialStateCombo.addItem(rb.getString("InitialStateOff"));
JComboBox<String> d8outputTypeCombo = new JComboBox<String>();
d8outputTypeCombo.addItem(rb.getString("OutputTypeONOFF"));
d8outputTypeCombo.addItem(rb.getString("OutputTypePULSE"));
d8outputTypeCombo.addItem(rb.getString("OutputTypeBLINK"));
JComboBox<String> d8outputLengthCombo = new JComboBox<String>();
for (int t = 0; t < 255; t++) {
d8outputLengthCombo.addItem(String.valueOf(t));
}
TableColumnModel d8outputColumnModel = d8outputConfigTable.getColumnModel();
TableColumn d8outputCircuitAddressColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN);
d8outputCircuitAddressColumn.setMinWidth(70);
d8outputCircuitAddressColumn.setMaxWidth(80);
TableColumn d8outputWiredColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN);
d8outputWiredColumn.setCellEditor(new DefaultCellEditor(d8outputWiredCombo));
d8outputWiredColumn.setResizable(false);
d8outputWiredColumn.setMinWidth(90);
d8outputWiredColumn.setMaxWidth(100);
TableColumn d8initialStateColumn = d8outputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN);
d8initialStateColumn.setCellEditor(new DefaultCellEditor(d8initialStateCombo));
d8initialStateColumn.setResizable(false);
d8initialStateColumn.setMinWidth(90);
d8initialStateColumn.setMaxWidth(100);
TableColumn d8outputTypeColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN);
d8outputTypeColumn.setCellEditor(new DefaultCellEditor(d8outputTypeCombo));
d8outputTypeColumn.setResizable(false);
d8outputTypeColumn.setMinWidth(90);
d8outputTypeColumn.setMaxWidth(100);
TableColumn d8outputLengthColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN);
d8outputLengthColumn.setCellEditor(new DefaultCellEditor(d8outputLengthCombo));
d8outputLengthColumn.setResizable(false);
d8outputLengthColumn.setMinWidth(90);
d8outputLengthColumn.setMaxWidth(100);
TableColumn d8outputaddressColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN);
d8outputaddressColumn.setMinWidth(110);
d8outputaddressColumn.setMaxWidth(120);
// Finish Set up the Dash8 nodes
JScrollPane d8outputScrollPane = new JScrollPane(d8outputConfigTable);
JPanel panelDash8Table = new JPanel();
panelDash8Table.setLayout(new BoxLayout(panelDash8Table, BoxLayout.Y_AXIS));
panelDash8Table.add(d8outputScrollPane, BorderLayout.CENTER);
panelDash8.add(panelDash8Table, BoxLayout.Y_AXIS);
Border panelDash8Border = BorderFactory.createEtchedBorder();
Border panelDash8Titled = BorderFactory.createTitledBorder(panelDash8Border, rb.getString("BoxLabelNodeSpecific"));
panelDash8.setBorder(panelDash8Titled);
panelDash8.setVisible(false);
contentPane.add(panelDash8);
// Set up the TBrain nodes
panelTBrain.setLayout(new BoxLayout(panelTBrain, BoxLayout.Y_AXIS));
JPanel panelTBrain1 = new JPanel();
statusTextTBrain1.setText(stdStatusTBrain1);
statusTextTBrain1.setVisible(true);
panelTBrain1.add(statusTextTBrain1);
panelTBrain.add(panelTBrain1);
JPanel panelTBrain2 = new JPanel();
statusTextTBrain2.setText(stdStatusTBrain2);
statusTextTBrain2.setVisible(true);
panelTBrain2.add(statusTextTBrain2);
panelTBrain.add(panelTBrain2);
JPanel panelTBrain3 = new JPanel();
statusTextTBrain3.setText(stdStatusTBrain3);
statusTextTBrain3.setVisible(true);
panelTBrain3.add(statusTextTBrain3);
panelTBrain.add(panelTBrain3);
TBoutputConfigModel = new OutputConfigModel();
TBoutputConfigModel.setNumRows(4);
TBoutputConfigModel.setEditMode(false);
JTable TBoutputConfigTable = new JTable(TBoutputConfigModel);
TBoutputConfigTable.setRowSelectionAllowed(false);
TBoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 62));
JComboBox<String> TBoutputWiredCombo = new JComboBox<String>();
TBoutputWiredCombo.addItem(rb.getString("OutputWiredNC"));
TBoutputWiredCombo.addItem(rb.getString("OutputWiredNO"));
JComboBox<String> TBoutputTypeCombo = new JComboBox<String>();
TBoutputTypeCombo.addItem(rb.getString("OutputTypeONOFF"));
TBoutputTypeCombo.addItem(rb.getString("OutputTypePULSE"));
TBoutputTypeCombo.addItem(rb.getString("OutputTypeBLINK"));
JComboBox<String> TBinitialStateCombo = new JComboBox<String>();
TBinitialStateCombo.addItem(rb.getString("InitialStateOn"));
TBinitialStateCombo.addItem(rb.getString("InitialStateOff"));
JComboBox<String> TBoutputLengthCombo = new JComboBox<String>();
for (int t = 0; t < 255; t++) {
TBoutputLengthCombo.addItem(String.valueOf(t));
}
TableColumnModel TBoutputColumnModel = TBoutputConfigTable.getColumnModel();
TableColumn TBoutputCircuitAddressColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN);
TBoutputCircuitAddressColumn.setMinWidth(70);
TBoutputCircuitAddressColumn.setMaxWidth(80);
TableColumn TBoutputWiredColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN);
TBoutputWiredColumn.setCellEditor(new DefaultCellEditor(TBoutputWiredCombo));
TBoutputWiredColumn.setResizable(false);
TBoutputWiredColumn.setMinWidth(90);
TBoutputWiredColumn.setMaxWidth(100);
TableColumn TBinitialStateColumn = TBoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN);
TBinitialStateColumn.setCellEditor(new DefaultCellEditor(TBinitialStateCombo));
TBinitialStateColumn.setResizable(false);
TBinitialStateColumn.setMinWidth(90);
TBinitialStateColumn.setMaxWidth(100);
TableColumn TBoutputTypeColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN);
TBoutputTypeColumn.setCellEditor(new DefaultCellEditor(TBoutputTypeCombo));
TBoutputTypeColumn.setResizable(false);
TBoutputTypeColumn.setMinWidth(90);
TBoutputTypeColumn.setMaxWidth(100);
TableColumn TBoutputLengthColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN);
TBoutputLengthColumn.setCellEditor(new DefaultCellEditor(TBoutputLengthCombo));
TBoutputLengthColumn.setResizable(false);
TBoutputLengthColumn.setMinWidth(90);
TBoutputLengthColumn.setMaxWidth(100);
TableColumn TBoutputaddressColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN);
TBoutputaddressColumn.setMinWidth(110);
TBoutputaddressColumn.setMaxWidth(120);
JScrollPane TBoutputScrollPane = new JScrollPane(TBoutputConfigTable);
JPanel panelTrainBrainTable = new JPanel();
panelTrainBrainTable.setLayout(new BoxLayout(panelTrainBrainTable, BoxLayout.Y_AXIS));
panelTrainBrainTable.add(TBoutputScrollPane, BorderLayout.CENTER);
panelTBrain.add(panelTrainBrainTable, BoxLayout.Y_AXIS);
TBsensorConfigModel = new SensorConfigModel();
TBsensorConfigModel.setNumRows(4);
TBsensorConfigModel.setEditMode(false);
JTable TBsensorConfigTable = new JTable(TBsensorConfigModel);
TBsensorConfigTable.setRowSelectionAllowed(false);
TBsensorConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 62));
JComboBox<String> TBfilterTypeCombo = new JComboBox<String>();
TBfilterTypeCombo.addItem(rb.getString("FilterTypeNoise"));
TBfilterTypeCombo.addItem(rb.getString("FilterTypeDebounce"));
TBfilterTypeCombo.addItem(rb.getString("FilterTypeCarGap"));
TBfilterTypeCombo.addItem(rb.getString("FilterTypeDirtyTrack"));
JComboBox<String> TBfilterPolarityCombo = new JComboBox<String>();
TBfilterPolarityCombo.addItem(rb.getString("FilterNormalPolarity"));
TBfilterPolarityCombo.addItem(rb.getString("FilterInversePolarity"));
JComboBox<String> TBfilterThresholdCombo = new JComboBox<String>();
for (int t = 0; t < 32; t++) {
TBfilterThresholdCombo.addItem(String.valueOf(t));
}
TableColumnModel TBtypeColumnModel = TBsensorConfigTable.getColumnModel();
TableColumn TBcircuitAddressColumn = TBtypeColumnModel.getColumn(SensorConfigModel.SENSORCIRCUITADDRESS_COLUMN);
TBcircuitAddressColumn.setMinWidth(70);
TBcircuitAddressColumn.setMaxWidth(80);
TableColumn TBcardTypeColumn = TBtypeColumnModel.getColumn(SensorConfigModel.TYPE_COLUMN);
TBcardTypeColumn.setCellEditor(new DefaultCellEditor(TBfilterTypeCombo));
TBcardTypeColumn.setResizable(false);
TBcardTypeColumn.setMinWidth(90);
TBcardTypeColumn.setMaxWidth(100);
TableColumn TBcardPolarityColumn = TBtypeColumnModel.getColumn(SensorConfigModel.POLARITY_COLUMN);
TBcardPolarityColumn.setCellEditor(new DefaultCellEditor(TBfilterPolarityCombo));
TBcardPolarityColumn.setResizable(false);
TBcardPolarityColumn.setMinWidth(90);
TBcardPolarityColumn.setMaxWidth(100);
TableColumn TBcardThresholdColumn = TBtypeColumnModel.getColumn(SensorConfigModel.THRESHOLD_COLUMN);
TBcardThresholdColumn.setCellEditor(new DefaultCellEditor(TBfilterThresholdCombo));
TBcardThresholdColumn.setResizable(false);
TBcardThresholdColumn.setMinWidth(90);
TBcardThresholdColumn.setMaxWidth(100);
TableColumn TBsensorAddressColumn = TBtypeColumnModel.getColumn(SensorConfigModel.SENSORADDRESS_COLUMN);
TBsensorAddressColumn.setMinWidth(110);
TBsensorAddressColumn.setMaxWidth(1200);
JScrollPane TBsensorScrollPane = new JScrollPane(TBsensorConfigTable);
JPanel panelTBsensortable = new JPanel();
panelTBsensortable.setLayout(new BoxLayout(panelTBsensortable, BoxLayout.Y_AXIS));
panelTBsensortable.add(TBsensorScrollPane, BorderLayout.CENTER);
panelTBrain.add(panelTBsensortable, BoxLayout.Y_AXIS);
// Finish Set up the TrainBrain nodes
Border panelTBrainBorder = BorderFactory.createEtchedBorder();
Border panelTBrainTitled = BorderFactory.createTitledBorder(panelTBrainBorder, rb.getString("BoxLabelNodeSpecific"));
panelTBrain.setBorder(panelTBrainTitled);
contentPane.add(panelTBrain);
panelTBrain.setVisible(false);
// Set up the Watchman nodes
panelWatchman.setLayout(new BoxLayout(panelWatchman, BoxLayout.Y_AXIS));
JPanel panelWatchman1 = new JPanel();
panelWatchman1.setLayout(new FlowLayout());
statusTextWatchman1.setText(stdStatusWatchman1);
statusTextWatchman1.setVisible(true);
panelWatchman1.add(statusTextWatchman1);
panelWatchman.add(panelWatchman1);
JPanel panelWatchman2 = new JPanel();
panelWatchman2.setLayout(new FlowLayout());
statusTextWatchman2.setText(stdStatusWatchman2);
statusTextWatchman2.setVisible(true);
panelWatchman2.add(statusTextWatchman2);
panelWatchman.add(panelWatchman2);
JPanel panelWatchman3 = new JPanel();
panelWatchman3.setLayout(new FlowLayout());
statusTextWatchman3.setText(stdStatusWatchman3);
statusTextWatchman3.setVisible(true);
panelWatchman3.add(statusTextWatchman3);
panelWatchman.add(panelWatchman3);
wmsensorConfigModel = new SensorConfigModel();
wmsensorConfigModel.setNumRows(8);
wmsensorConfigModel.setEditMode(false);
JTable wmsensorConfigTable = new JTable(wmsensorConfigModel);
wmsensorConfigTable.setRowSelectionAllowed(false);
wmsensorConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125));
JComboBox<String> wmfilterTypeCombo = new JComboBox<String>();
wmfilterTypeCombo.addItem(rb.getString("FilterTypeNoise"));
wmfilterTypeCombo.addItem(rb.getString("FilterTypeDebounce"));
wmfilterTypeCombo.addItem(rb.getString("FilterTypeCarGap"));
wmfilterTypeCombo.addItem(rb.getString("FilterTypeDirtyTrack"));
JComboBox<String> wmfilterPolarityCombo = new JComboBox<String>();
wmfilterPolarityCombo.addItem(rb.getString("FilterNormalPolarity"));
wmfilterPolarityCombo.addItem(rb.getString("FilterInversePolarity"));
JComboBox<String> wmfilterThresholdCombo = new JComboBox<String>();
for (int t = 0; t < 32; t++) {
wmfilterThresholdCombo.addItem(String.valueOf(t));
}
TableColumnModel wmtypeColumnModel = wmsensorConfigTable.getColumnModel();
TableColumn wmcircuitAddressColumn = wmtypeColumnModel.getColumn(SensorConfigModel.SENSORCIRCUITADDRESS_COLUMN);
wmcircuitAddressColumn.setMinWidth(70);
wmcircuitAddressColumn.setMaxWidth(80);
TableColumn wmcardTypeColumn = wmtypeColumnModel.getColumn(SensorConfigModel.TYPE_COLUMN);
wmcardTypeColumn.setCellEditor(new DefaultCellEditor(wmfilterTypeCombo));
wmcardTypeColumn.setResizable(false);
wmcardTypeColumn.setMinWidth(90);
wmcardTypeColumn.setMaxWidth(100);
TableColumn wmcardPolarityColumn = wmtypeColumnModel.getColumn(SensorConfigModel.POLARITY_COLUMN);
wmcardPolarityColumn.setCellEditor(new DefaultCellEditor(wmfilterPolarityCombo));
wmcardPolarityColumn.setResizable(false);
wmcardPolarityColumn.setMinWidth(90);
wmcardPolarityColumn.setMaxWidth(100);
TableColumn wmcardThresholdColumn = wmtypeColumnModel.getColumn(SensorConfigModel.THRESHOLD_COLUMN);
wmcardThresholdColumn.setCellEditor(new DefaultCellEditor(wmfilterThresholdCombo));
wmcardThresholdColumn.setResizable(false);
wmcardThresholdColumn.setMinWidth(90);
wmcardThresholdColumn.setMaxWidth(100);
TableColumn wmsensorAddressColumn = wmtypeColumnModel.getColumn(SensorConfigModel.SENSORADDRESS_COLUMN);
wmsensorAddressColumn.setMinWidth(110);
wmsensorAddressColumn.setMaxWidth(1200);
// Finish Set up the Watchman nodes
JScrollPane wmsensorScrollPane = new JScrollPane(wmsensorConfigTable);
JPanel panelWatchmantable = new JPanel();
panelWatchmantable.setLayout(new BoxLayout(panelWatchmantable, BoxLayout.Y_AXIS));
panelWatchmantable.add(wmsensorScrollPane, BorderLayout.CENTER);
panelWatchman.add(panelWatchmantable, BoxLayout.Y_AXIS);
Border panelWatchmanBorder = BorderFactory.createEtchedBorder();
Border panelWatchmanTitled = BorderFactory.createTitledBorder(panelWatchmanBorder, rb.getString("BoxLabelNodeSpecific"));
panelWatchman.setBorder(panelWatchmanTitled);
contentPane.add(panelWatchman);
panelWatchman.setVisible(false);
// Set up the Signalman nodes
panelSignalman.setLayout(new BoxLayout(panelSignalman, BoxLayout.Y_AXIS));
JPanel panelSignalman1 = new JPanel();
panelSignalman1.setLayout(new FlowLayout());
statusTextSignalman1.setText(stdStatusSignalman1);
statusTextSignalman1.setVisible(true);
panelSignalman1.add(statusTextSignalman1);
panelSignalman.add(panelSignalman1);
JPanel panelSignalman2 = new JPanel();
panelSignalman2.setLayout(new FlowLayout());
statusTextSignalman2.setText(stdStatusSignalman2);
statusTextSignalman2.setVisible(true);
panelSignalman2.add(statusTextSignalman2);
panelSignalman.add(panelSignalman2);
JPanel panelSignalman3 = new JPanel();
panelSignalman3.setLayout(new FlowLayout());
statusTextSignalman3.setText(stdStatusSignalman3);
statusTextSignalman3.setVisible(true);
panelSignalman3.add(statusTextSignalman3);
panelSignalman.add(panelSignalman3);
// Output circuit configuration
smoutputConfigModel = new OutputConfigModel();
smoutputConfigModel.setNumRows(16);
smoutputConfigModel.setEditMode(false);
JTable smoutputConfigTable = new JTable(smoutputConfigModel);
smoutputConfigTable.setRowSelectionAllowed(false);
smoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125));
JComboBox<String> smoutputWiredCombo = new JComboBox<String>();
smoutputWiredCombo.addItem(rb.getString("OutputWiredNC"));
smoutputWiredCombo.addItem(rb.getString("OutputWiredNO"));
JComboBox<String> sminitialStateCombo = new JComboBox<String>();
sminitialStateCombo.addItem(rb.getString("InitialStateOn"));
sminitialStateCombo.addItem(rb.getString("InitialStateOff"));
JComboBox<String> smoutputTypeCombo = new JComboBox<String>();
smoutputTypeCombo.addItem(rb.getString("OutputTypeONOFF"));
smoutputTypeCombo.addItem(rb.getString("OutputTypePULSE"));
smoutputTypeCombo.addItem(rb.getString("OutputTypeBLINK"));
JComboBox<String> smoutputLengthCombo = new JComboBox<String>();
for (int t = 0; t < 255; t++) {
smoutputLengthCombo.addItem(String.valueOf(t));
}
TableColumnModel smoutputColumnModel = smoutputConfigTable.getColumnModel();
TableColumn smoutputCircuitAddressColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN);
smoutputCircuitAddressColumn.setMinWidth(70);
smoutputCircuitAddressColumn.setMaxWidth(80);
TableColumn smoutputWiredColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN);
smoutputWiredColumn.setCellEditor(new DefaultCellEditor(smoutputWiredCombo));
smoutputWiredColumn.setResizable(false);
smoutputWiredColumn.setMinWidth(90);
smoutputWiredColumn.setMaxWidth(100);
TableColumn sminitialStateColumn = smoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN);
sminitialStateColumn.setCellEditor(new DefaultCellEditor(sminitialStateCombo));
sminitialStateColumn.setResizable(false);
sminitialStateColumn.setMinWidth(90);
sminitialStateColumn.setMaxWidth(100);
TableColumn smoutputTypeColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN);
smoutputTypeColumn.setCellEditor(new DefaultCellEditor(smoutputTypeCombo));
smoutputTypeColumn.setResizable(false);
smoutputTypeColumn.setMinWidth(90);
smoutputTypeColumn.setMaxWidth(100);
TableColumn smoutputLengthColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN);
smoutputLengthColumn.setCellEditor(new DefaultCellEditor(smoutputLengthCombo));
smoutputLengthColumn.setResizable(false);
smoutputLengthColumn.setMinWidth(90);
smoutputLengthColumn.setMaxWidth(100);
TableColumn smoutputaddressColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN);
smoutputaddressColumn.setMinWidth(110);
smoutputaddressColumn.setMaxWidth(120);
// Finish Set up the Signalman nodes
JScrollPane smoutputScrollPane = new JScrollPane(smoutputConfigTable);
JPanel panelSignalmanTable = new JPanel();
panelSignalmanTable.setLayout(new BoxLayout(panelSignalmanTable, BoxLayout.Y_AXIS));
panelSignalmanTable.add(smoutputScrollPane, BorderLayout.CENTER);
panelSignalman.add(panelSignalmanTable, BoxLayout.Y_AXIS);
Border panelSignalmanBorder = BorderFactory.createEtchedBorder();
Border panelSignalmanTitled = BorderFactory.createTitledBorder(panelSignalmanBorder, rb.getString("BoxLabelNodeSpecific"));
panelSignalman.setBorder(panelSignalmanTitled);
panelSignalman.setVisible(false);
contentPane.add(panelSignalman);
// Set up the YardMaster nodes
panelYardMaster.setLayout(new BoxLayout(panelYardMaster, BoxLayout.Y_AXIS));
JPanel panelYardMaster1 = new JPanel();
panelYardMaster1.setLayout(new FlowLayout());
statusTextYardMaster1.setText(stdStatusYardMaster1);
statusTextYardMaster1.setVisible(true);
panelYardMaster1.add(statusTextYardMaster1);
panelYardMaster.add(panelYardMaster1);
JPanel panelYardMaster2 = new JPanel();
panelYardMaster2.setLayout(new FlowLayout());
statusTextYardMaster2.setText(stdStatusYardMaster2);
statusTextYardMaster2.setVisible(true);
panelYardMaster2.add(statusTextYardMaster2);
panelYardMaster.add(panelYardMaster2);
JPanel panelYardMaster3 = new JPanel();
panelYardMaster3.setLayout(new FlowLayout());
statusTextYardMaster3.setText(stdStatusYardMaster3);
statusTextYardMaster3.setVisible(true);
panelYardMaster3.add(statusTextYardMaster3);
panelYardMaster.add(panelYardMaster3);
// Output circuit configuration
ymoutputConfigModel = new OutputConfigModel();
ymoutputConfigModel.setNumRows(16);
ymoutputConfigModel.setEditMode(false);
JTable ymoutputConfigTable = new JTable(ymoutputConfigModel);
ymoutputConfigTable.setRowSelectionAllowed(false);
ymoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125));
JComboBox<String> ymoutputWiredCombo = new JComboBox<String>();
ymoutputWiredCombo.addItem(rb.getString("OutputWiredNC"));
ymoutputWiredCombo.addItem(rb.getString("OutputWiredNO"));
JComboBox<String> yminitialStateCombo = new JComboBox<String>();
yminitialStateCombo.addItem(rb.getString("InitialStateOn"));
yminitialStateCombo.addItem(rb.getString("InitialStateOff"));
JComboBox<String> ymoutputTypeCombo = new JComboBox<String>();
ymoutputTypeCombo.addItem(rb.getString("OutputTypeONOFF"));
ymoutputTypeCombo.addItem(rb.getString("OutputTypePULSE"));
ymoutputTypeCombo.addItem(rb.getString("OutputTypeBLINK"));
JComboBox<String> ymoutputLengthCombo = new JComboBox<String>();
for (int t = 0; t < 255; t++) {
ymoutputLengthCombo.addItem(String.valueOf(t));
}
TableColumnModel ymoutputColumnModel = ymoutputConfigTable.getColumnModel();
TableColumn ymoutputCircuitAddressColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN);
ymoutputCircuitAddressColumn.setMinWidth(70);
ymoutputCircuitAddressColumn.setMaxWidth(80);
TableColumn ymoutputWiredColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN);
ymoutputWiredColumn.setCellEditor(new DefaultCellEditor(ymoutputWiredCombo));
ymoutputWiredColumn.setResizable(false);
ymoutputWiredColumn.setMinWidth(90);
ymoutputWiredColumn.setMaxWidth(100);
TableColumn yminitialStateColumn = ymoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN);
yminitialStateColumn.setCellEditor(new DefaultCellEditor(yminitialStateCombo));
yminitialStateColumn.setResizable(false);
yminitialStateColumn.setMinWidth(90);
yminitialStateColumn.setMaxWidth(100);
TableColumn ymoutputTypeColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN);
ymoutputTypeColumn.setCellEditor(new DefaultCellEditor(ymoutputTypeCombo));
ymoutputTypeColumn.setResizable(false);
ymoutputTypeColumn.setMinWidth(90);
ymoutputTypeColumn.setMaxWidth(100);
TableColumn ymoutputLengthColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN);
ymoutputLengthColumn.setCellEditor(new DefaultCellEditor(ymoutputLengthCombo));
ymoutputLengthColumn.setResizable(false);
ymoutputLengthColumn.setMinWidth(90);
ymoutputLengthColumn.setMaxWidth(100);
TableColumn ymoutputaddressColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN);
ymoutputaddressColumn.setMinWidth(110);
ymoutputaddressColumn.setMaxWidth(120);
// Finish Set up the YardMaster nodes
JScrollPane ymoutputScrollPane = new JScrollPane(ymoutputConfigTable);
JPanel panelYardMasterTable = new JPanel();
panelYardMasterTable.setLayout(new BoxLayout(panelYardMasterTable, BoxLayout.Y_AXIS));
panelYardMasterTable.add(ymoutputScrollPane, BorderLayout.CENTER);
panelYardMaster.add(panelYardMasterTable, BoxLayout.Y_AXIS);
Border panelYardMasterBorder = BorderFactory.createEtchedBorder();
Border panelYardMasterTitled = BorderFactory.createTitledBorder(panelYardMasterBorder, rb.getString("BoxLabelNodeSpecific"));
panelYardMaster.setBorder(panelYardMasterTitled);
panelYardMaster.setVisible(false);
contentPane.add(panelYardMaster);
// Set up the SwitchMan nodes
panelSwitchman.setLayout(new BoxLayout(panelSwitchman, BoxLayout.Y_AXIS));
JPanel panelSwitchman1 = new JPanel();
panelSwitchman1.setLayout(new FlowLayout());
statusTextSwitchman1.setText(stdStatusSwitchman1);
statusTextSwitchman1.setVisible(true);
panelSwitchman1.add(statusTextSwitchman1);
panelSwitchman.add(panelSwitchman1);
JPanel panelSwitchman2 = new JPanel();
panelSwitchman2.setLayout(new FlowLayout());
statusTextSwitchman2.setText(stdStatusSwitchman2);
statusTextSwitchman2.setVisible(true);
panelSwitchman2.add(statusTextSwitchman2);
panelSwitchman.add(panelSwitchman2);
JPanel panelSwitchman3 = new JPanel();
panelSwitchman3.setLayout(new FlowLayout());
statusTextSwitchman3.setText(stdStatusSwitchman3);
statusTextSwitchman3.setVisible(true);
panelSwitchman3.add(statusTextSwitchman3);
panelSwitchman.add(panelSwitchman3);
// Output circuit configuration
swoutputConfigModel = new OutputConfigModel();
swoutputConfigModel.setNumRows(16);
swoutputConfigModel.setEditMode(false);
JTable swoutputConfigTable = new JTable(swoutputConfigModel);
swoutputConfigTable.setRowSelectionAllowed(false);
swoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125));
JComboBox<String> swoutputWiredCombo = new JComboBox<String>();
swoutputWiredCombo.addItem(rb.getString("OutputWiredNC"));
swoutputWiredCombo.addItem(rb.getString("OutputWiredNO"));
JComboBox<String> swinitialStateCombo = new JComboBox<String>();
swinitialStateCombo.addItem(rb.getString("InitialStateOn"));
swinitialStateCombo.addItem(rb.getString("InitialStateOff"));
JComboBox<String> swoutputTypeCombo = new JComboBox<String>();
swoutputTypeCombo.addItem(rb.getString("OutputTypeONOFF"));
swoutputTypeCombo.addItem(rb.getString("OutputTypePULSE"));
swoutputTypeCombo.addItem(rb.getString("OutputTypeBLINK"));
JComboBox<String> swoutputLengthCombo = new JComboBox<String>();
for (int t = 0; t < 255; t++) {
swoutputLengthCombo.addItem(String.valueOf(t));
}
TableColumnModel swoutputColumnModel = swoutputConfigTable.getColumnModel();
TableColumn swoutputCircuitAddressColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN);
swoutputCircuitAddressColumn.setMinWidth(70);
swoutputCircuitAddressColumn.setMaxWidth(80);
TableColumn swoutputWiredColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN);
swoutputWiredColumn.setCellEditor(new DefaultCellEditor(swoutputWiredCombo));
swoutputWiredColumn.setResizable(false);
swoutputWiredColumn.setMinWidth(90);
swoutputWiredColumn.setMaxWidth(100);
TableColumn swinitialStateColumn = swoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN);
swinitialStateColumn.setCellEditor(new DefaultCellEditor(swinitialStateCombo));
swinitialStateColumn.setResizable(false);
swinitialStateColumn.setMinWidth(90);
swinitialStateColumn.setMaxWidth(100);
TableColumn swoutputTypeColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN);
swoutputTypeColumn.setCellEditor(new DefaultCellEditor(swoutputTypeCombo));
swoutputTypeColumn.setResizable(false);
swoutputTypeColumn.setMinWidth(90);
swoutputTypeColumn.setMaxWidth(100);
TableColumn swoutputLengthColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN);
swoutputLengthColumn.setCellEditor(new DefaultCellEditor(swoutputLengthCombo));
swoutputLengthColumn.setResizable(false);
swoutputLengthColumn.setMinWidth(90);
swoutputLengthColumn.setMaxWidth(100);
TableColumn swoutputaddressColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN);
swoutputaddressColumn.setMinWidth(110);
swoutputaddressColumn.setMaxWidth(120);
// Finish Set up the Switchman nodes
JScrollPane swoutputScrollPane = new JScrollPane(swoutputConfigTable);
JPanel panelSwitchmanTable = new JPanel();
panelSwitchmanTable.setLayout(new BoxLayout(panelSwitchmanTable, BoxLayout.Y_AXIS));
panelSwitchmanTable.add(swoutputScrollPane, BorderLayout.CENTER);
panelSwitchman.add(panelSwitchmanTable, BoxLayout.Y_AXIS);
Border panelSwitchmanBorder = BorderFactory.createEtchedBorder();
Border panelSwitchmanTitled = BorderFactory.createTitledBorder(panelSwitchmanBorder, rb.getString("BoxLabelNodeSpecific"));
panelSwitchman.setBorder(panelSwitchmanTitled);
panelSwitchman.setVisible(false);
contentPane.add(panelSwitchman);
// Set up the Sentry nodes
panelSentry.setLayout(new BoxLayout(panelSentry, BoxLayout.Y_AXIS));
JPanel panelSentry1 = new JPanel();
panelSentry1.setLayout(new FlowLayout());
statusTextSentry1.setText(stdStatusSentry1);
statusTextSentry1.setVisible(true);
panelSentry1.add(statusTextSentry1);
panelSentry.add(panelSentry1);
JPanel panelSentry2 = new JPanel();
panelSentry2.setLayout(new FlowLayout());
statusTextSentry2.setText(stdStatusSentry2);
statusTextSentry2.setVisible(true);
panelSentry2.add(statusTextSentry2);
panelSentry.add(panelSentry2);
JPanel panelSentry3 = new JPanel();
panelSentry3.setLayout(new FlowLayout());
statusTextSentry3.setText(stdStatusSentry3);
statusTextSentry3.setVisible(true);
panelSentry3.add(statusTextSentry3);
panelSentry.add(panelSentry3);
sysensorConfigModel = new SensorConfigModel();
sysensorConfigModel.setNumRows(16);
sysensorConfigModel.setEditMode(false);
JTable sysensorConfigTable = new JTable(sysensorConfigModel);
sysensorConfigTable.setRowSelectionAllowed(false);
sysensorConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125));
JComboBox<String> syfilterTypeCombo = new JComboBox<String>();
syfilterTypeCombo.addItem(rb.getString("FilterTypeNoise"));
syfilterTypeCombo.addItem(rb.getString("FilterTypeDebounce"));
syfilterTypeCombo.addItem(rb.getString("FilterTypeCarGap"));
syfilterTypeCombo.addItem(rb.getString("FilterTypeDirtyTrack"));
JComboBox<String> syfilterPolarityCombo = new JComboBox<String>();
syfilterPolarityCombo.addItem(rb.getString("FilterNormalPolarity"));
syfilterPolarityCombo.addItem(rb.getString("FilterInversePolarity"));
JComboBox<String> syfilterThresholdCombo = new JComboBox<String>();
for (int t = 0; t < 32; t++) {
syfilterThresholdCombo.addItem(String.valueOf(t));
}
TableColumnModel sytypeColumnModel = sysensorConfigTable.getColumnModel();
TableColumn sycircuitAddressColumn = sytypeColumnModel.getColumn(SensorConfigModel.SENSORCIRCUITADDRESS_COLUMN);
sycircuitAddressColumn.setMinWidth(70);
sycircuitAddressColumn.setMaxWidth(80);
TableColumn sycardTypeColumn = sytypeColumnModel.getColumn(SensorConfigModel.TYPE_COLUMN);
sycardTypeColumn.setCellEditor(new DefaultCellEditor(syfilterTypeCombo));
sycardTypeColumn.setResizable(false);
sycardTypeColumn.setMinWidth(90);
sycardTypeColumn.setMaxWidth(100);
TableColumn sycardPolarityColumn = sytypeColumnModel.getColumn(SensorConfigModel.POLARITY_COLUMN);
sycardPolarityColumn.setCellEditor(new DefaultCellEditor(syfilterPolarityCombo));
sycardPolarityColumn.setResizable(false);
sycardPolarityColumn.setMinWidth(90);
sycardPolarityColumn.setMaxWidth(100);
TableColumn sycardThresholdColumn = sytypeColumnModel.getColumn(SensorConfigModel.THRESHOLD_COLUMN);
sycardThresholdColumn.setCellEditor(new DefaultCellEditor(syfilterThresholdCombo));
sycardThresholdColumn.setResizable(false);
sycardThresholdColumn.setMinWidth(90);
sycardThresholdColumn.setMaxWidth(100);
TableColumn sysensorAddressColumn = sytypeColumnModel.getColumn(SensorConfigModel.SENSORADDRESS_COLUMN);
sysensorAddressColumn.setMinWidth(110);
sysensorAddressColumn.setMaxWidth(1200);
// Finish Set up the Sentry nodes
JScrollPane sysensorScrollPane = new JScrollPane(sysensorConfigTable);
JPanel panelSentrytable = new JPanel();
panelSentrytable.setLayout(new BoxLayout(panelSentrytable, BoxLayout.Y_AXIS));
panelSentrytable.add(sysensorScrollPane, BorderLayout.CENTER);
panelSentry.add(panelSentrytable, BoxLayout.Y_AXIS);
Border panelSentryBorder = BorderFactory.createEtchedBorder();
Border panelSentryTitled = BorderFactory.createTitledBorder(panelSentryBorder, rb.getString("BoxLabelNodeSpecific"));
panelSentry.setBorder(panelSentryTitled);
contentPane.add(panelSentry);
panelSentry.setVisible(false);
// Set up the notes panel
JPanel panel3 = new JPanel();
panel3.setLayout(new BoxLayout(panel3, BoxLayout.Y_AXIS));
JPanel panel31 = new JPanel();
panel31.setLayout(new FlowLayout());
statusText1.setText(stdStatus1);
statusText1.setVisible(true);
panel31.add(statusText1);
JPanel panel32 = new JPanel();
panel32.setLayout(new FlowLayout());
statusText2.setText(stdStatus2);
statusText2.setVisible(true);
panel32.add(statusText2);
JPanel panel33 = new JPanel();
panel33.setLayout(new FlowLayout());
statusText3.setText(stdStatus3);
statusText3.setVisible(true);
panel33.add(statusText3);
panel3.add(panel31);
panel3.add(panel32);
panel3.add(panel33);
Border panel3Border = BorderFactory.createEtchedBorder();
Border panel3Titled = BorderFactory.createTitledBorder(panel3Border, rb.getString("BoxLabelNotes"));
panel3.setBorder(panel3Titled);
contentPane.add(panel3);
// Set up buttons
JPanel panel4 = new JPanel();
panel4.setLayout(new FlowLayout());
addButton.setText(rb.getString("ButtonAdd"));
addButton.setVisible(true);
addButton.setToolTipText(rb.getString("TipAddButton"));
addButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
addButtonActionPerformed();
}
});
panel4.add(addButton);
editButton.setText(rb.getString("ButtonEdit"));
editButton.setVisible(true);
editButton.setToolTipText(rb.getString("TipEditButton"));
panel4.add(editButton);
editButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
editButtonActionPerformed();
}
});
panel4.add(deleteButton);
deleteButton.setText(rb.getString("ButtonDelete"));
deleteButton.setVisible(true);
deleteButton.setToolTipText(rb.getString("TipDeleteButton"));
panel4.add(deleteButton);
deleteButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
deleteButtonActionPerformed();
}
});
panel4.add(doneButton);
doneButton.setText(rb.getString("ButtonDone"));
doneButton.setVisible(true);
doneButton.setToolTipText(rb.getString("TipDoneButton"));
panel4.add(doneButton);
doneButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doneButtonActionPerformed();
}
});
panel4.add(updateButton);
updateButton.setText(rb.getString("ButtonUpdate"));
updateButton.setVisible(true);
updateButton.setToolTipText(rb.getString("TipUpdateButton"));
panel4.add(updateButton);
updateButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
updateButtonActionPerformed();
}
});
updateButton.setVisible(false);
panel4.add(cancelButton);
cancelButton.setText(rb.getString("ButtonCancel"));
cancelButton.setVisible(true);
cancelButton.setToolTipText(rb.getString("TipCancelButton"));
panel4.add(cancelButton);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
cancelButtonActionPerformed();
}
});
cancelButton.setVisible(false);
contentPane.add(panel4);
// add help menu to window
addHelpMenu("package.jmri.jmrix.acela.nodeconfig.NodeConfigFrame", true);
// pack for display
pack();
}
use of javax.swing.DefaultCellEditor in project processdash by dtuma.
the class SizeMetricsTableModel method createJTable.
public JTable createJTable() {
JTable table = new ItemListJTable(this);
// adjust column widths
table.getColumnModel().getColumn(0).setPreferredWidth(100);
table.getColumnModel().getColumn(1).setPreferredWidth(200);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
table.setRowHeight(table.getRowHeight() + 4);
// draw read-only phases with a different appearance
table.setDefaultRenderer(String.class, new ItemTableCellRenderer());
// install a combo box as the editor for the "phase type" column
TableColumn unitsColumn = table.getColumnModel().getColumn(UNITS_COL);
JComboBox unitsEditor = new JComboBox(UNITS_TYPES);
unitsEditor.setRenderer(new UnitsCellRenderer());
unitsEditor.setFont(unitsEditor.getFont().deriveFont(Font.PLAIN));
unitsColumn.setCellEditor(new DefaultCellEditor(unitsEditor));
return table;
}
use of javax.swing.DefaultCellEditor in project processdash by dtuma.
the class ProcessPhaseTableModel method createPhaseTypeEditor.
private DefaultCellEditor createPhaseTypeEditor() {
JComboBox phaseTypeEditor = new JComboBox(PHASE_TYPES);
phaseTypeEditor.setRenderer(new PhaseListCellRenderer());
phaseTypeEditor.setFont(phaseTypeEditor.getFont().deriveFont(Font.PLAIN));
return new DefaultCellEditor(phaseTypeEditor);
}
use of javax.swing.DefaultCellEditor in project zaproxy by zaproxy.
the class PolicyAllCategoryPanel method getTableTest.
/**
* This method initializes tableTest
*
* @return javax.swing.JTable
*/
private JTable getTableTest() {
if (tableTest == null) {
tableTest = new JTable();
tableTest.setModel(getAllCategoryTableModel());
tableTest.setRowHeight(DisplayUtils.getScaledSize(18));
tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1));
tableTest.setAutoCreateRowSorter(true);
//Default sort by name (column 0)
List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1);
sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
tableTest.getRowSorter().setSortKeys(sortKeys);
for (int i = 0; i < tableTest.getColumnCount() - 1; i++) {
TableColumn column = tableTest.getColumnModel().getColumn(i);
column.setPreferredWidth(width[i]);
}
JComboBox<String> jcb1 = new JComboBox<>();
// Always show a blank one for where they are not all the same
jcb1.addItem("");
for (AlertThreshold level : AlertThreshold.values()) {
jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
}
tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));
JComboBox<String> jcb2 = new JComboBox<>();
// Always show a blank one for where they are not all the same
jcb2.addItem("");
for (AttackStrength level : AttackStrength.values()) {
jcb2.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
}
tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2));
}
return tableTest;
}
Aggregations