001package jmri.jmrix.acela.nodeconfig; 002 003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 004 005import java.awt.BorderLayout; 006import java.awt.Container; 007import java.awt.FlowLayout; 008import java.awt.event.ActionEvent; 009import java.awt.event.ActionListener; 010 011import javax.swing.BorderFactory; 012import javax.swing.BoxLayout; 013import javax.swing.DefaultCellEditor; 014import javax.swing.JComboBox; 015import javax.swing.JLabel; 016import javax.swing.JPanel; 017import javax.swing.JScrollPane; 018import javax.swing.JTable; 019import javax.swing.border.Border; 020import javax.swing.table.TableColumn; 021import javax.swing.table.TableColumnModel; 022 023import jmri.jmrix.acela.AcelaNode; 024import jmri.jmrix.acela.AcelaSystemConnectionMemo; 025import jmri.util.swing.JmriJOptionPane; 026 027/** 028 * Frame for user configuration of Acela nodes 029 * 030 * @author Bob Jacobsen Copyright (C) 2004, 2007, 2008 031 * @author Dave Duchamp Copyright (C) 2004, 2006 032 */ 033public class NodeConfigFrame extends jmri.util.JmriJFrame { 034 035 private AcelaSystemConnectionMemo _memo = null; 036 037 protected Container contentPane; 038 protected NodeConfigModel d8outputConfigModel; 039 protected NodeConfigModel swoutputConfigModel; 040 protected NodeConfigModel ymoutputConfigModel; 041 protected NodeConfigModel TBoutputConfigModel; 042 protected NodeConfigModel TBsensorConfigModel; 043 protected NodeConfigModel smoutputConfigModel; 044 protected NodeConfigModel wmsensorConfigModel; 045 protected NodeConfigModel sysensorConfigModel; 046 047 protected JLabel thenodesStaticH = new JLabel(" 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19"); 048 protected JLabel thenodesStaticC = new JLabel(""); 049 protected JLabel thenodesStaticP = new JLabel(" " + Bundle.getMessage("HwNotYet")); 050 051 protected javax.swing.JTextField nodeAddrField = new javax.swing.JTextField(3); 052 protected JLabel nodeAddrStatic = new JLabel("000"); 053 protected JLabel nodeTypeStatic = new JLabel("Acela"); // NOI18N 054 protected javax.swing.JComboBox<String> nodeAddrBox; 055 protected javax.swing.JComboBox<String> nodeTypeBox; 056 057 protected javax.swing.JButton addButton = new javax.swing.JButton(Bundle.getMessage("ButtonAdd")); 058 protected javax.swing.JButton editButton = new javax.swing.JButton(Bundle.getMessage("ButtonEdit")); 059 protected javax.swing.JButton deleteButton = new javax.swing.JButton(Bundle.getMessage("ButtonDelete")); 060 protected javax.swing.JButton doneButton = new javax.swing.JButton(Bundle.getMessage("ButtonDone")); 061 protected javax.swing.JButton updateButton = new javax.swing.JButton(Bundle.getMessage("ButtonUpdate")); 062 protected javax.swing.JButton cancelButton = new javax.swing.JButton(Bundle.getMessage("ButtonCancel")); 063 064 protected JLabel statusText1 = new JLabel(); 065 protected JLabel statusText2 = new JLabel(); 066 protected JLabel statusText3 = new JLabel(); 067 068 protected JLabel statusTextAcela1 = new JLabel(); 069 protected JLabel statusTextAcela2 = new JLabel(); 070 protected JLabel statusTextAcela3 = new JLabel(); 071 protected JLabel statusTextAcela4 = new JLabel(); 072 protected JLabel statusTextAcela5 = new JLabel(); 073 protected JLabel statusTextAcela6 = new JLabel(); 074 protected JLabel statusTextAcela7 = new JLabel(); 075 protected JLabel statusTextAcela8 = new JLabel(); 076 protected JLabel statusTextAcela9 = new JLabel(); 077 protected JLabel statusTextAcela10 = new JLabel(); 078 protected JLabel statusTextAcela11 = new JLabel(); 079 protected JLabel statusTextTBrain1 = new JLabel(); 080 protected JLabel statusTextTBrain2 = new JLabel(); 081 protected JLabel statusTextTBrain3 = new JLabel(); 082 protected JLabel statusTextDash81 = new JLabel(); 083 protected JLabel statusTextDash82 = new JLabel(); 084 protected JLabel statusTextDash83 = new JLabel(); 085 protected JLabel statusTextWatchman1 = new JLabel(); 086 protected JLabel statusTextWatchman2 = new JLabel(); 087 protected JLabel statusTextWatchman3 = new JLabel(); 088 protected JLabel statusTextSignalman1 = new JLabel(); 089 protected JLabel statusTextSignalman2 = new JLabel(); 090 protected JLabel statusTextSignalman3 = new JLabel(); 091 protected JLabel statusTextSwitchman1 = new JLabel(); 092 protected JLabel statusTextSwitchman2 = new JLabel(); 093 protected JLabel statusTextSwitchman3 = new JLabel(); 094 protected JLabel statusTextYardMaster1 = new JLabel(); 095 protected JLabel statusTextYardMaster2 = new JLabel(); 096 protected JLabel statusTextYardMaster3 = new JLabel(); 097 protected JLabel statusTextSentry1 = new JLabel(); 098 protected JLabel statusTextSentry2 = new JLabel(); 099 protected JLabel statusTextSentry3 = new JLabel(); 100 101 protected JPanel panelAcela = new JPanel(); 102 protected JPanel panelTBrain = new JPanel(); 103 protected JPanel panelDash8 = new JPanel(); 104 protected JPanel panelWatchman = new JPanel(); 105 protected JPanel panelSignalman = new JPanel(); 106 protected JPanel panelSwitchman = new JPanel(); 107 protected JPanel panelYardMaster = new JPanel(); 108 protected JPanel panelSentry = new JPanel(); 109 110 protected boolean changedNode = false; // true if a node was changed, deleted, or added 111 protected boolean editMode = false; // true if in edit mode 112 private boolean checkEnabled = jmri.InstanceManager.getDefault(jmri.configurexml.ShutdownPreferences.class).isStoreCheckEnabled(); 113 114 protected AcelaNode curNode = null; // Acela Node being editted 115 protected int nodeAddress = 0; // Node address 116 protected int nodeType = AcelaNode.UN; // Node type 117 118 protected boolean errorInStatus1 = false; 119 protected boolean errorInStatus2 = false; 120 protected String stdStatus1 = Bundle.getMessage("NotesStd1"); 121 protected String stdStatus2 = Bundle.getMessage("NotesStd2"); 122 protected String stdStatus3 = Bundle.getMessage("NotesStd3"); 123 protected String stdStatusAcela1 = Bundle.getMessage("NotesStdAcela1"); 124 protected String stdStatusAcela2 = Bundle.getMessage("NotesStdAcela2"); 125 protected String stdStatusAcela3 = Bundle.getMessage("NotesStdAcela3"); 126 protected String stdStatusAcela4 = Bundle.getMessage("NotesStdAcela4"); 127 protected String stdStatusAcela5 = Bundle.getMessage("NotesStdAcela5"); 128 protected String stdStatusAcela6 = Bundle.getMessage("NotesStdAcela6"); 129 protected String stdStatusAcela7 = Bundle.getMessage("NotesStdAcela7"); 130 protected String stdStatusAcela8 = Bundle.getMessage("NotesStdAcela8"); 131 protected String stdStatusAcela9 = Bundle.getMessage("NotesStdAcela9"); 132 protected String stdStatusAcela10 = Bundle.getMessage("NotesStdAcela10"); 133 protected String stdStatusAcela11 = Bundle.getMessage("NotesStdAcela11"); 134 protected String stdStatusTBrain1 = Bundle.getMessage("NotesStdTBrain1"); 135 protected String stdStatusTBrain2 = Bundle.getMessage("NotesStdTBrain2"); 136 protected String stdStatusTBrain3 = Bundle.getMessage("NotesStdTBrain3"); 137 protected String stdStatusDash81 = Bundle.getMessage("NotesStdDash81"); 138 protected String stdStatusDash82 = Bundle.getMessage("NotesStdDash82"); 139 protected String stdStatusDash83 = Bundle.getMessage("NotesStdDash83"); 140 protected String stdStatusWatchman1 = Bundle.getMessage("NotesStdWatchman1"); 141 protected String stdStatusWatchman2 = Bundle.getMessage("NotesStdWatchman2"); 142 protected String stdStatusWatchman3 = Bundle.getMessage("NotesStdWatchman3"); 143 protected String stdStatusSignalman1 = Bundle.getMessage("NotesStdSignalman1"); 144 protected String stdStatusSignalman2 = Bundle.getMessage("NotesStdSignalman2"); 145 protected String stdStatusSignalman3 = Bundle.getMessage("NotesStdSignalman3"); 146 protected String stdStatusSwitchman1 = Bundle.getMessage("NotesStdSwitchman1"); 147 protected String stdStatusSwitchman2 = Bundle.getMessage("NotesStdSwitchman2"); 148 protected String stdStatusSwitchman3 = Bundle.getMessage("NotesStdSwitchman3"); 149 protected String stdStatusYardMaster1 = Bundle.getMessage("NotesStdYardMaster1"); 150 protected String stdStatusYardMaster2 = Bundle.getMessage("NotesStdYardMaster2"); 151 protected String stdStatusYardMaster3 = Bundle.getMessage("NotesStdYardMaster3"); 152 protected String stdStatusSentry1 = Bundle.getMessage("NotesStdSentry1"); 153 protected String stdStatusSentry2 = Bundle.getMessage("NotesStdSentry2"); 154 protected String stdStatusSentry3 = Bundle.getMessage("NotesStdSentry3"); 155 protected String editStatus1 = Bundle.getMessage("NotesEdit1"); 156 protected String editStatus2 = Bundle.getMessage("NotesEdit2"); 157 protected String editStatus3 = Bundle.getMessage("NotesEdit3"); 158 protected String infoStatus1 = Bundle.getMessage("NotesStd1"); 159 protected String infoStatus2 = Bundle.getMessage("NotesStd2"); 160 protected String infoStatus3 = Bundle.getMessage("NotesStd3"); 161 162 protected javax.swing.JTextField receiveDelayField = new javax.swing.JTextField(3); 163 164 /** 165 * Constructor method. 166 * @param memo system connection. 167 */ 168 public NodeConfigFrame(AcelaSystemConnectionMemo memo) { 169 super(); 170 _memo = memo; 171 } 172 173 /** 174 * Initialize the config window 175 */ 176 @Override 177 public void initComponents() { 178 setTitle(Bundle.getMessage("ConfigNodesTitle")); 179 180 contentPane = getContentPane(); 181 contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); 182 183 // Set up node address and node type 184 JPanel panel1 = new JPanel(); 185 panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); 186 187 // Copy and pasted from the info button 188 StringBuilder nodesstring = new StringBuilder(""); 189 int tempnumnodes = _memo.getTrafficController().getNumNodes(); 190 for (int i = 0; i < tempnumnodes; i++) { 191 AcelaNode tempnode; 192 tempnode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(i); 193 nodesstring.append(" ").append(tempnode.getNodeTypeString()); 194 } 195 thenodesStaticC.setText(nodesstring.toString()); 196 197 // panelthenodes displays the current node configuration and polling result 198 JPanel panelthenodes = new JPanel(); 199 panelthenodes.setLayout(new BoxLayout(panelthenodes, BoxLayout.Y_AXIS)); 200 201 JPanel panelthenodes1 = new JPanel(); 202 panelthenodes1.setLayout(new FlowLayout()); 203 panelthenodes1.add(new JLabel(Bundle.getMessage("NodesLabel") + " ")); 204 panelthenodes1.add(thenodesStaticH); 205 panelthenodes.add(panelthenodes1); 206 207 JPanel panelthenodes2 = new JPanel(); 208 panelthenodes2.setLayout(new FlowLayout()); 209 panelthenodes2.add(new JLabel(Bundle.getMessage("AsConfiguredLabel") + " ")); 210 panelthenodes2.add(thenodesStaticC); 211 panelthenodes.add(panelthenodes2); 212 213 JPanel panelthenodes3 = new JPanel(); 214 panelthenodes3.setLayout(new FlowLayout()); 215 panelthenodes3.add(new JLabel(Bundle.getMessage("AsPolledLabel") + " ")); 216 panelthenodes3.add(thenodesStaticP); 217 panelthenodes.add(panelthenodes3); 218 219 Border panelthenodesBorder = BorderFactory.createEtchedBorder(); 220 Border panelthenodesTitled = BorderFactory.createTitledBorder(panelthenodesBorder, 221 Bundle.getMessage("BoxLabelNodes")); 222 panelthenodes.setBorder(panelthenodesTitled); 223 224 contentPane.add(panelthenodes); 225 226 // panel11 is the node address 227 JPanel panel11 = new JPanel(); 228 panel11.setLayout(new FlowLayout()); 229 230 panel11.add(new JLabel(Bundle.getMessage("LabelNodeAddress") + " ")); 231 nodeAddrBox = new JComboBox<String>(AcelaNode.getNodeNames()); 232 nodeAddrBox.addActionListener(new ActionListener() { 233 @Override 234 public void actionPerformed(ActionEvent event) { 235 infoButtonActionPerformed(); 236 } 237 }); 238 panel11.add(nodeAddrBox); 239 panel11.add(nodeAddrField); 240// nodeAddrField.setToolTipText(Bundle.getMessage("TipNodeAddress")); 241 nodeAddrField.setText("0"); 242 panel11.add(nodeAddrStatic); 243 nodeAddrField.setVisible(false); 244 nodeAddrStatic.setVisible(false); 245 contentPane.add(panel11); 246 247 // panelNodeInfo is the node type 248 JPanel panelNodeInfo = new JPanel(); 249 250 panelNodeInfo.add(new JLabel(" " + Bundle.getMessage("LabelNodeType") + " ")); 251 nodeTypeBox = new JComboBox<String>(AcelaNode.getModuleNames()); 252 nodeTypeBox.addActionListener(new ActionListener() { 253 @Override 254 public void actionPerformed(ActionEvent event) { 255 String s = (String) nodeTypeBox.getSelectedItem(); 256 if (s.equals("Acela")) { 257 panelAcela.setVisible(true); 258 panelTBrain.setVisible(false); 259 panelDash8.setVisible(false); 260 panelWatchman.setVisible(false); 261 panelSignalman.setVisible(false); 262 panelSwitchman.setVisible(false); 263 panelYardMaster.setVisible(false); 264 panelSentry.setVisible(false); 265 } else if (s.equals("TrainBrain")) { 266 panelAcela.setVisible(false); 267 panelTBrain.setVisible(true); 268 panelDash8.setVisible(false); 269 panelWatchman.setVisible(false); 270 panelSignalman.setVisible(false); 271 panelSwitchman.setVisible(false); 272 panelYardMaster.setVisible(false); 273 panelSentry.setVisible(false); 274 } else if (s.equals("Dash-8")) { 275 panelAcela.setVisible(false); 276 panelTBrain.setVisible(false); 277 panelDash8.setVisible(true); 278 panelWatchman.setVisible(false); 279 panelSignalman.setVisible(false); 280 panelSwitchman.setVisible(false); 281 panelYardMaster.setVisible(false); 282 panelSentry.setVisible(false); 283 } else if (s.equals("Watchman")) { 284 panelAcela.setVisible(false); 285 panelTBrain.setVisible(false); 286 panelDash8.setVisible(false); 287 panelWatchman.setVisible(true); 288 panelSignalman.setVisible(false); 289 panelSwitchman.setVisible(false); 290 panelYardMaster.setVisible(false); 291 panelSentry.setVisible(false); 292 } else if (s.equals("SignalMan")) { 293 panelAcela.setVisible(false); 294 panelTBrain.setVisible(false); 295 panelDash8.setVisible(false); 296 panelWatchman.setVisible(false); 297 panelSignalman.setVisible(true); 298 panelSwitchman.setVisible(false); 299 panelYardMaster.setVisible(false); 300 panelSentry.setVisible(false); 301 } else if (s.equals("SwitchMan")) { 302 panelAcela.setVisible(false); 303 panelTBrain.setVisible(false); 304 panelDash8.setVisible(false); 305 panelWatchman.setVisible(false); 306 panelSignalman.setVisible(false); 307 panelSwitchman.setVisible(true); 308 panelYardMaster.setVisible(false); 309 panelSentry.setVisible(false); 310 } else if (s.equals("YardMaster")) { 311 panelAcela.setVisible(false); 312 panelTBrain.setVisible(false); 313 panelDash8.setVisible(false); 314 panelWatchman.setVisible(false); 315 panelSignalman.setVisible(false); 316 panelSwitchman.setVisible(false); 317 panelYardMaster.setVisible(true); 318 panelSentry.setVisible(false); 319 } else if (s.equals("Sentry")) { 320 panelAcela.setVisible(false); 321 panelTBrain.setVisible(false); 322 panelDash8.setVisible(false); 323 panelWatchman.setVisible(false); 324 panelSignalman.setVisible(false); 325 panelSwitchman.setVisible(false); 326 panelYardMaster.setVisible(false); 327 panelSentry.setVisible(true); 328 } // Add code here for other types of nodes 329 else { 330 panelAcela.setVisible(false); 331 panelTBrain.setVisible(false); 332 panelDash8.setVisible(false); 333 panelWatchman.setVisible(false); 334 panelSignalman.setVisible(false); 335 panelSwitchman.setVisible(false); 336 panelYardMaster.setVisible(false); 337 panelSentry.setVisible(false); 338 } 339 } 340 }); 341 panelNodeInfo.add(nodeTypeBox); 342 nodeTypeBox.setToolTipText(Bundle.getMessage("TipNodeType")); 343 panelNodeInfo.add(nodeTypeStatic); 344 nodeTypeBox.setVisible(false); 345 nodeTypeStatic.setVisible(true); 346 contentPane.add(panelNodeInfo); 347 348 // Set up the Acela nodes 349 panelAcela.setLayout(new BoxLayout(panelAcela, BoxLayout.Y_AXIS)); 350 JPanel panelAcela1 = new JPanel(); 351 panelAcela1.setLayout(new FlowLayout()); 352 statusTextAcela1.setText(stdStatusAcela1); 353 statusTextAcela1.setVisible(true); 354 panelAcela1.add(statusTextAcela1); 355 panelAcela.add(panelAcela1); 356 JPanel panelAcela2 = new JPanel(); 357 panelAcela2.setLayout(new FlowLayout()); 358 statusTextAcela2.setText(stdStatusAcela2); 359 statusTextAcela2.setVisible(true); 360 panelAcela2.add(statusTextAcela2); 361 panelAcela.add(panelAcela2); 362 JPanel panelAcela3 = new JPanel(); 363 panelAcela3.setLayout(new FlowLayout()); 364 statusTextAcela3.setText(stdStatusAcela3); 365 statusTextAcela3.setVisible(true); 366 panelAcela3.add(statusTextAcela3); 367 panelAcela.add(panelAcela3); 368 JPanel panelAcela4 = new JPanel(); 369 panelAcela4.setLayout(new FlowLayout()); 370 statusTextAcela4.setText(stdStatusAcela4); 371 statusTextAcela4.setVisible(true); 372 panelAcela4.add(statusTextAcela4); 373 panelAcela.add(panelAcela4); 374 JPanel panelAcela5 = new JPanel(); 375 panelAcela5.setLayout(new FlowLayout()); 376 statusTextAcela5.setText(stdStatusAcela5); 377 statusTextAcela5.setVisible(true); 378 panelAcela5.add(statusTextAcela5); 379 panelAcela.add(panelAcela5); 380 JPanel panelAcela6 = new JPanel(); 381 panelAcela6.setLayout(new FlowLayout()); 382 statusTextAcela6.setText(stdStatusAcela6); 383 statusTextAcela6.setVisible(true); 384 panelAcela6.add(statusTextAcela6); 385 panelAcela.add(panelAcela6); 386 JPanel panelAcela7 = new JPanel(); 387 panelAcela7.setLayout(new FlowLayout()); 388 statusTextAcela7.setText(stdStatusAcela7); 389 statusTextAcela7.setVisible(true); 390 panelAcela7.add(statusTextAcela7); 391 panelAcela.add(panelAcela7); 392 JPanel panelAcela8 = new JPanel(); 393 panelAcela8.setLayout(new FlowLayout()); 394 statusTextAcela8.setText(stdStatusAcela8); 395 statusTextAcela8.setVisible(true); 396 panelAcela8.add(statusTextAcela8); 397 panelAcela.add(panelAcela8); 398 JPanel panelAcela9 = new JPanel(); 399 panelAcela9.setLayout(new FlowLayout()); 400 statusTextAcela9.setText(stdStatusAcela9); 401 statusTextAcela9.setVisible(true); 402 panelAcela9.add(statusTextAcela9); 403 panelAcela.add(panelAcela9); 404 JPanel panelAcela10 = new JPanel(); 405 panelAcela10.setLayout(new FlowLayout()); 406 statusTextAcela10.setText(stdStatusAcela10); 407 statusTextAcela10.setVisible(true); 408 panelAcela10.add(statusTextAcela10); 409 panelAcela.add(panelAcela10); 410 JPanel panelAcela11 = new JPanel(); 411 panelAcela11.setLayout(new FlowLayout()); 412 statusTextAcela11.setText(stdStatusAcela11); 413 statusTextAcela11.setVisible(true); 414 panelAcela11.add(statusTextAcela11); 415 panelAcela.add(panelAcela11); 416 417 Border panelAcelaBorder = BorderFactory.createEtchedBorder(); 418 Border panelAcelaTitled = BorderFactory.createTitledBorder(panelAcelaBorder, 419 Bundle.getMessage("BoxLabelNodeSpecific")); 420 panelAcela.setBorder(panelAcelaTitled); 421 422 contentPane.add(panelAcela); 423 424 // Set up the Dash8 nodes 425 panelDash8.setLayout(new BoxLayout(panelDash8, BoxLayout.Y_AXIS)); 426 JPanel panelDash81 = new JPanel(); 427 panelDash81.setLayout(new FlowLayout()); 428 statusTextDash81.setText(stdStatusDash81); 429 statusTextDash81.setVisible(true); 430 panelDash81.add(statusTextDash81); 431 panelDash8.add(panelDash81); 432 433 JPanel panelDash82 = new JPanel(); 434 panelDash82.setLayout(new FlowLayout()); 435 statusTextDash82.setText(stdStatusDash82); 436 statusTextDash82.setVisible(true); 437 panelDash82.add(statusTextDash82); 438 panelDash8.add(panelDash82); 439 440 JPanel panelDash83 = new JPanel(); 441 panelDash83.setLayout(new FlowLayout()); 442 statusTextDash83.setText(stdStatusDash83); 443 statusTextDash83.setVisible(true); 444 panelDash83.add(statusTextDash83); 445 panelDash8.add(panelDash83); 446 447 // Output circuit configuration 448 d8outputConfigModel = new OutputConfigModel(); 449 d8outputConfigModel.setNumRows(8); 450 d8outputConfigModel.setEditMode(false); 451 JTable d8outputConfigTable = new JTable(d8outputConfigModel); 452 d8outputConfigTable.setRowSelectionAllowed(false); 453 d8outputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125)); 454 455 JComboBox<String> d8outputWiredCombo = new JComboBox<String>(); 456 d8outputWiredCombo.addItem(Bundle.getMessage("OutputWiredNC")); 457 d8outputWiredCombo.addItem(Bundle.getMessage("OutputWiredNO")); 458 459 JComboBox<String> d8initialStateCombo = new JComboBox<String>(); 460 d8initialStateCombo.addItem(Bundle.getMessage("InitialStateOn")); 461 d8initialStateCombo.addItem(Bundle.getMessage("InitialStateOff")); 462 463 JComboBox<String> d8outputTypeCombo = new JComboBox<String>(); 464 d8outputTypeCombo.addItem(Bundle.getMessage("OutputTypeONOFF")); 465 d8outputTypeCombo.addItem(Bundle.getMessage("OutputTypePULSE")); 466 d8outputTypeCombo.addItem(Bundle.getMessage("OutputTypeBLINK")); 467 468 JComboBox<String> d8outputLengthCombo = new JComboBox<String>(); 469 for (int t = 0; t < 255; t++) { 470 d8outputLengthCombo.addItem(String.valueOf(t)); 471 } 472 473 TableColumnModel d8outputColumnModel = d8outputConfigTable.getColumnModel(); 474 TableColumn d8outputCircuitAddressColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN); 475 d8outputCircuitAddressColumn.setMinWidth(70); 476 d8outputCircuitAddressColumn.setMaxWidth(80); 477 TableColumn d8outputWiredColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN); 478 d8outputWiredColumn.setCellEditor(new DefaultCellEditor(d8outputWiredCombo)); 479 d8outputWiredColumn.setResizable(false); 480 d8outputWiredColumn.setMinWidth(90); 481 d8outputWiredColumn.setMaxWidth(100); 482 TableColumn d8initialStateColumn = d8outputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN); 483 d8initialStateColumn.setCellEditor(new DefaultCellEditor(d8initialStateCombo)); 484 d8initialStateColumn.setResizable(false); 485 d8initialStateColumn.setMinWidth(90); 486 d8initialStateColumn.setMaxWidth(100); 487 TableColumn d8outputTypeColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN); 488 d8outputTypeColumn.setCellEditor(new DefaultCellEditor(d8outputTypeCombo)); 489 d8outputTypeColumn.setResizable(false); 490 d8outputTypeColumn.setMinWidth(90); 491 d8outputTypeColumn.setMaxWidth(100); 492 TableColumn d8outputLengthColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN); 493 d8outputLengthColumn.setCellEditor(new DefaultCellEditor(d8outputLengthCombo)); 494 d8outputLengthColumn.setResizable(false); 495 d8outputLengthColumn.setMinWidth(90); 496 d8outputLengthColumn.setMaxWidth(100); 497 TableColumn d8outputaddressColumn = d8outputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN); 498 d8outputaddressColumn.setMinWidth(110); 499 d8outputaddressColumn.setMaxWidth(120); 500 501 // Finish Set up the Dash8 nodes 502 JScrollPane d8outputScrollPane = new JScrollPane(d8outputConfigTable); 503 504 JPanel panelDash8Table = new JPanel(); 505 panelDash8Table.setLayout(new BoxLayout(panelDash8Table, BoxLayout.Y_AXIS)); 506 507 panelDash8Table.add(d8outputScrollPane, BorderLayout.CENTER); 508 panelDash8.add(panelDash8Table, BoxLayout.Y_AXIS); 509 510 Border panelDash8Border = BorderFactory.createEtchedBorder(); 511 Border panelDash8Titled = BorderFactory.createTitledBorder(panelDash8Border, 512 Bundle.getMessage("BoxLabelNodeSpecific")); 513 panelDash8.setBorder(panelDash8Titled); 514 515 panelDash8.setVisible(false); 516 contentPane.add(panelDash8); 517 518 // Set up the TBrain nodes 519 panelTBrain.setLayout(new BoxLayout(panelTBrain, BoxLayout.Y_AXIS)); 520 JPanel panelTBrain1 = new JPanel(); 521 statusTextTBrain1.setText(stdStatusTBrain1); 522 statusTextTBrain1.setVisible(true); 523 panelTBrain1.add(statusTextTBrain1); 524 panelTBrain.add(panelTBrain1); 525 526 JPanel panelTBrain2 = new JPanel(); 527 statusTextTBrain2.setText(stdStatusTBrain2); 528 statusTextTBrain2.setVisible(true); 529 panelTBrain2.add(statusTextTBrain2); 530 panelTBrain.add(panelTBrain2); 531 532 JPanel panelTBrain3 = new JPanel(); 533 statusTextTBrain3.setText(stdStatusTBrain3); 534 statusTextTBrain3.setVisible(true); 535 panelTBrain3.add(statusTextTBrain3); 536 panelTBrain.add(panelTBrain3); 537 538 TBoutputConfigModel = new OutputConfigModel(); 539 TBoutputConfigModel.setNumRows(4); 540 TBoutputConfigModel.setEditMode(false); 541 JTable TBoutputConfigTable = new JTable(TBoutputConfigModel); 542 TBoutputConfigTable.setRowSelectionAllowed(false); 543 TBoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 62)); 544 545 JComboBox<String> TBoutputWiredCombo = new JComboBox<String>(); 546 TBoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNC")); 547 TBoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNO")); 548 549 JComboBox<String> TBoutputTypeCombo = new JComboBox<String>(); 550 TBoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeONOFF")); 551 TBoutputTypeCombo.addItem(Bundle.getMessage("OutputTypePULSE")); 552 TBoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeBLINK")); 553 554 JComboBox<String> TBinitialStateCombo = new JComboBox<String>(); 555 TBinitialStateCombo.addItem(Bundle.getMessage("InitialStateOn")); 556 TBinitialStateCombo.addItem(Bundle.getMessage("InitialStateOff")); 557 558 JComboBox<String> TBoutputLengthCombo = new JComboBox<String>(); 559 for (int t = 0; t < 255; t++) { 560 TBoutputLengthCombo.addItem(String.valueOf(t)); 561 } 562 563 TableColumnModel TBoutputColumnModel = TBoutputConfigTable.getColumnModel(); 564 TableColumn TBoutputCircuitAddressColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN); 565 TBoutputCircuitAddressColumn.setMinWidth(70); 566 TBoutputCircuitAddressColumn.setMaxWidth(80); 567 TableColumn TBoutputWiredColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN); 568 TBoutputWiredColumn.setCellEditor(new DefaultCellEditor(TBoutputWiredCombo)); 569 TBoutputWiredColumn.setResizable(false); 570 TBoutputWiredColumn.setMinWidth(90); 571 TBoutputWiredColumn.setMaxWidth(100); 572 TableColumn TBinitialStateColumn = TBoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN); 573 TBinitialStateColumn.setCellEditor(new DefaultCellEditor(TBinitialStateCombo)); 574 TBinitialStateColumn.setResizable(false); 575 TBinitialStateColumn.setMinWidth(90); 576 TBinitialStateColumn.setMaxWidth(100); 577 TableColumn TBoutputTypeColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN); 578 TBoutputTypeColumn.setCellEditor(new DefaultCellEditor(TBoutputTypeCombo)); 579 TBoutputTypeColumn.setResizable(false); 580 TBoutputTypeColumn.setMinWidth(90); 581 TBoutputTypeColumn.setMaxWidth(100); 582 TableColumn TBoutputLengthColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN); 583 TBoutputLengthColumn.setCellEditor(new DefaultCellEditor(TBoutputLengthCombo)); 584 TBoutputLengthColumn.setResizable(false); 585 TBoutputLengthColumn.setMinWidth(90); 586 TBoutputLengthColumn.setMaxWidth(100); 587 TableColumn TBoutputaddressColumn = TBoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN); 588 TBoutputaddressColumn.setMinWidth(110); 589 TBoutputaddressColumn.setMaxWidth(120); 590 591 JScrollPane TBoutputScrollPane = new JScrollPane(TBoutputConfigTable); 592 593 JPanel panelTrainBrainTable = new JPanel(); 594 panelTrainBrainTable.setLayout(new BoxLayout(panelTrainBrainTable, BoxLayout.Y_AXIS)); 595 596 panelTrainBrainTable.add(TBoutputScrollPane, BorderLayout.CENTER); 597 panelTBrain.add(panelTrainBrainTable, BoxLayout.Y_AXIS); 598 599 TBsensorConfigModel = new SensorConfigModel(); 600 TBsensorConfigModel.setNumRows(4); 601 TBsensorConfigModel.setEditMode(false); 602 603 JTable TBsensorConfigTable = new JTable(TBsensorConfigModel); 604 TBsensorConfigTable.setRowSelectionAllowed(false); 605 TBsensorConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 62)); 606 607 JComboBox<String> TBfilterTypeCombo = new JComboBox<String>(); 608 TBfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeNoise")); 609 TBfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeDebounce")); 610 TBfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeCarGap")); 611 TBfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeDirtyTrack")); 612 613 JComboBox<String> TBfilterPolarityCombo = new JComboBox<String>(); 614 TBfilterPolarityCombo.addItem(Bundle.getMessage("FilterNormalPolarity")); 615 TBfilterPolarityCombo.addItem(Bundle.getMessage("FilterInversePolarity")); 616 617 JComboBox<String> TBfilterThresholdCombo = new JComboBox<String>(); 618 for (int t = 0; t < 32; t++) { 619 TBfilterThresholdCombo.addItem(String.valueOf(t)); 620 } 621 622 TableColumnModel TBtypeColumnModel = TBsensorConfigTable.getColumnModel(); 623 TableColumn TBcircuitAddressColumn = TBtypeColumnModel.getColumn(SensorConfigModel.SENSORCIRCUITADDRESS_COLUMN); 624 TBcircuitAddressColumn.setMinWidth(70); 625 TBcircuitAddressColumn.setMaxWidth(80); 626 TableColumn TBcardTypeColumn = TBtypeColumnModel.getColumn(SensorConfigModel.TYPE_COLUMN); 627 TBcardTypeColumn.setCellEditor(new DefaultCellEditor(TBfilterTypeCombo)); 628 TBcardTypeColumn.setResizable(false); 629 TBcardTypeColumn.setMinWidth(90); 630 TBcardTypeColumn.setMaxWidth(100); 631 TableColumn TBcardPolarityColumn = TBtypeColumnModel.getColumn(SensorConfigModel.POLARITY_COLUMN); 632 TBcardPolarityColumn.setCellEditor(new DefaultCellEditor(TBfilterPolarityCombo)); 633 TBcardPolarityColumn.setResizable(false); 634 TBcardPolarityColumn.setMinWidth(90); 635 TBcardPolarityColumn.setMaxWidth(100); 636 TableColumn TBcardThresholdColumn = TBtypeColumnModel.getColumn(SensorConfigModel.THRESHOLD_COLUMN); 637 TBcardThresholdColumn.setCellEditor(new DefaultCellEditor(TBfilterThresholdCombo)); 638 TBcardThresholdColumn.setResizable(false); 639 TBcardThresholdColumn.setMinWidth(90); 640 TBcardThresholdColumn.setMaxWidth(100); 641 TableColumn TBsensorAddressColumn = TBtypeColumnModel.getColumn(SensorConfigModel.SENSORADDRESS_COLUMN); 642 TBsensorAddressColumn.setMinWidth(110); 643 TBsensorAddressColumn.setMaxWidth(1200); 644 645 JScrollPane TBsensorScrollPane = new JScrollPane(TBsensorConfigTable); 646 647 JPanel panelTBsensortable = new JPanel(); 648 panelTBsensortable.setLayout(new BoxLayout(panelTBsensortable, BoxLayout.Y_AXIS)); 649 650 panelTBsensortable.add(TBsensorScrollPane, BorderLayout.CENTER); 651 panelTBrain.add(panelTBsensortable, BoxLayout.Y_AXIS); 652 653 // Finish Set up the TrainBrain nodes 654 Border panelTBrainBorder = BorderFactory.createEtchedBorder(); 655 Border panelTBrainTitled = BorderFactory.createTitledBorder(panelTBrainBorder, 656 Bundle.getMessage("BoxLabelNodeSpecific")); 657 panelTBrain.setBorder(panelTBrainTitled); 658 659 contentPane.add(panelTBrain); 660 panelTBrain.setVisible(false); 661 662 // Set up the Watchman nodes 663 panelWatchman.setLayout(new BoxLayout(panelWatchman, BoxLayout.Y_AXIS)); 664 JPanel panelWatchman1 = new JPanel(); 665 panelWatchman1.setLayout(new FlowLayout()); 666 statusTextWatchman1.setText(stdStatusWatchman1); 667 statusTextWatchman1.setVisible(true); 668 panelWatchman1.add(statusTextWatchman1); 669 panelWatchman.add(panelWatchman1); 670 671 JPanel panelWatchman2 = new JPanel(); 672 panelWatchman2.setLayout(new FlowLayout()); 673 statusTextWatchman2.setText(stdStatusWatchman2); 674 statusTextWatchman2.setVisible(true); 675 panelWatchman2.add(statusTextWatchman2); 676 panelWatchman.add(panelWatchman2); 677 678 JPanel panelWatchman3 = new JPanel(); 679 panelWatchman3.setLayout(new FlowLayout()); 680 statusTextWatchman3.setText(stdStatusWatchman3); 681 statusTextWatchman3.setVisible(true); 682 panelWatchman3.add(statusTextWatchman3); 683 panelWatchman.add(panelWatchman3); 684 685 wmsensorConfigModel = new SensorConfigModel(); 686 wmsensorConfigModel.setNumRows(8); 687 wmsensorConfigModel.setEditMode(false); 688 689 JTable wmsensorConfigTable = new JTable(wmsensorConfigModel); 690 wmsensorConfigTable.setRowSelectionAllowed(false); 691 wmsensorConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125)); 692 693 JComboBox<String> wmfilterTypeCombo = new JComboBox<String>(); 694 wmfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeNoise")); 695 wmfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeDebounce")); 696 wmfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeCarGap")); 697 wmfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeDirtyTrack")); 698 699 JComboBox<String> wmfilterPolarityCombo = new JComboBox<String>(); 700 wmfilterPolarityCombo.addItem(Bundle.getMessage("FilterNormalPolarity")); 701 wmfilterPolarityCombo.addItem(Bundle.getMessage("FilterInversePolarity")); 702 703 JComboBox<String> wmfilterThresholdCombo = new JComboBox<String>(); 704 for (int t = 0; t < 32; t++) { 705 wmfilterThresholdCombo.addItem(String.valueOf(t)); 706 } 707 TableColumnModel wmtypeColumnModel = wmsensorConfigTable.getColumnModel(); 708 TableColumn wmcircuitAddressColumn = wmtypeColumnModel.getColumn(SensorConfigModel.SENSORCIRCUITADDRESS_COLUMN); 709 wmcircuitAddressColumn.setMinWidth(70); 710 wmcircuitAddressColumn.setMaxWidth(80); 711 TableColumn wmcardTypeColumn = wmtypeColumnModel.getColumn(SensorConfigModel.TYPE_COLUMN); 712 wmcardTypeColumn.setCellEditor(new DefaultCellEditor(wmfilterTypeCombo)); 713 wmcardTypeColumn.setResizable(false); 714 wmcardTypeColumn.setMinWidth(90); 715 wmcardTypeColumn.setMaxWidth(100); 716 TableColumn wmcardPolarityColumn = wmtypeColumnModel.getColumn(SensorConfigModel.POLARITY_COLUMN); 717 wmcardPolarityColumn.setCellEditor(new DefaultCellEditor(wmfilterPolarityCombo)); 718 wmcardPolarityColumn.setResizable(false); 719 wmcardPolarityColumn.setMinWidth(90); 720 wmcardPolarityColumn.setMaxWidth(100); 721 TableColumn wmcardThresholdColumn = wmtypeColumnModel.getColumn(SensorConfigModel.THRESHOLD_COLUMN); 722 wmcardThresholdColumn.setCellEditor(new DefaultCellEditor(wmfilterThresholdCombo)); 723 wmcardThresholdColumn.setResizable(false); 724 wmcardThresholdColumn.setMinWidth(90); 725 wmcardThresholdColumn.setMaxWidth(100); 726 TableColumn wmsensorAddressColumn = wmtypeColumnModel.getColumn(SensorConfigModel.SENSORADDRESS_COLUMN); 727 wmsensorAddressColumn.setMinWidth(110); 728 wmsensorAddressColumn.setMaxWidth(1200); 729 730 // Finish Set up the Watchman nodes 731 JScrollPane wmsensorScrollPane = new JScrollPane(wmsensorConfigTable); 732 733 JPanel panelWatchmantable = new JPanel(); 734 panelWatchmantable.setLayout(new BoxLayout(panelWatchmantable, BoxLayout.Y_AXIS)); 735 736 panelWatchmantable.add(wmsensorScrollPane, BorderLayout.CENTER); 737 panelWatchman.add(panelWatchmantable, BoxLayout.Y_AXIS); 738 739 Border panelWatchmanBorder = BorderFactory.createEtchedBorder(); 740 Border panelWatchmanTitled = BorderFactory.createTitledBorder(panelWatchmanBorder, 741 Bundle.getMessage("BoxLabelNodeSpecific")); 742 panelWatchman.setBorder(panelWatchmanTitled); 743 744 contentPane.add(panelWatchman); 745 panelWatchman.setVisible(false); 746 747 // Set up the Signalman nodes 748 panelSignalman.setLayout(new BoxLayout(panelSignalman, BoxLayout.Y_AXIS)); 749 JPanel panelSignalman1 = new JPanel(); 750 panelSignalman1.setLayout(new FlowLayout()); 751 statusTextSignalman1.setText(stdStatusSignalman1); 752 statusTextSignalman1.setVisible(true); 753 panelSignalman1.add(statusTextSignalman1); 754 panelSignalman.add(panelSignalman1); 755 756 JPanel panelSignalman2 = new JPanel(); 757 panelSignalman2.setLayout(new FlowLayout()); 758 statusTextSignalman2.setText(stdStatusSignalman2); 759 statusTextSignalman2.setVisible(true); 760 panelSignalman2.add(statusTextSignalman2); 761 panelSignalman.add(panelSignalman2); 762 763 JPanel panelSignalman3 = new JPanel(); 764 panelSignalman3.setLayout(new FlowLayout()); 765 statusTextSignalman3.setText(stdStatusSignalman3); 766 statusTextSignalman3.setVisible(true); 767 panelSignalman3.add(statusTextSignalman3); 768 panelSignalman.add(panelSignalman3); 769 770 // Output circuit configuration 771 smoutputConfigModel = new OutputConfigModel(); 772 smoutputConfigModel.setNumRows(16); 773 smoutputConfigModel.setEditMode(false); 774 JTable smoutputConfigTable = new JTable(smoutputConfigModel); 775 smoutputConfigTable.setRowSelectionAllowed(false); 776 smoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125)); 777 778 JComboBox<String> smoutputWiredCombo = new JComboBox<String>(); 779 smoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNC")); 780 smoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNO")); 781 782 JComboBox<String> sminitialStateCombo = new JComboBox<String>(); 783 sminitialStateCombo.addItem(Bundle.getMessage("InitialStateOn")); 784 sminitialStateCombo.addItem(Bundle.getMessage("InitialStateOff")); 785 786 JComboBox<String> smoutputTypeCombo = new JComboBox<String>(); 787 smoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeONOFF")); 788 smoutputTypeCombo.addItem(Bundle.getMessage("OutputTypePULSE")); 789 smoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeBLINK")); 790 791 JComboBox<String> smoutputLengthCombo = new JComboBox<String>(); 792 for (int t = 0; t < 255; t++) { 793 smoutputLengthCombo.addItem(String.valueOf(t)); 794 } 795 796 TableColumnModel smoutputColumnModel = smoutputConfigTable.getColumnModel(); 797 TableColumn smoutputCircuitAddressColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN); 798 smoutputCircuitAddressColumn.setMinWidth(70); 799 smoutputCircuitAddressColumn.setMaxWidth(80); 800 TableColumn smoutputWiredColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN); 801 smoutputWiredColumn.setCellEditor(new DefaultCellEditor(smoutputWiredCombo)); 802 smoutputWiredColumn.setResizable(false); 803 smoutputWiredColumn.setMinWidth(90); 804 smoutputWiredColumn.setMaxWidth(100); 805 TableColumn sminitialStateColumn = smoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN); 806 sminitialStateColumn.setCellEditor(new DefaultCellEditor(sminitialStateCombo)); 807 sminitialStateColumn.setResizable(false); 808 sminitialStateColumn.setMinWidth(90); 809 sminitialStateColumn.setMaxWidth(100); 810 TableColumn smoutputTypeColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN); 811 smoutputTypeColumn.setCellEditor(new DefaultCellEditor(smoutputTypeCombo)); 812 smoutputTypeColumn.setResizable(false); 813 smoutputTypeColumn.setMinWidth(90); 814 smoutputTypeColumn.setMaxWidth(100); 815 TableColumn smoutputLengthColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN); 816 smoutputLengthColumn.setCellEditor(new DefaultCellEditor(smoutputLengthCombo)); 817 smoutputLengthColumn.setResizable(false); 818 smoutputLengthColumn.setMinWidth(90); 819 smoutputLengthColumn.setMaxWidth(100); 820 TableColumn smoutputaddressColumn = smoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN); 821 smoutputaddressColumn.setMinWidth(110); 822 smoutputaddressColumn.setMaxWidth(120); 823 824 // Finish Set up the Signalman nodes 825 JScrollPane smoutputScrollPane = new JScrollPane(smoutputConfigTable); 826 827 JPanel panelSignalmanTable = new JPanel(); 828 panelSignalmanTable.setLayout(new BoxLayout(panelSignalmanTable, BoxLayout.Y_AXIS)); 829 830 panelSignalmanTable.add(smoutputScrollPane, BorderLayout.CENTER); 831 panelSignalman.add(panelSignalmanTable, BoxLayout.Y_AXIS); 832 833 Border panelSignalmanBorder = BorderFactory.createEtchedBorder(); 834 Border panelSignalmanTitled = BorderFactory.createTitledBorder(panelSignalmanBorder, 835 Bundle.getMessage("BoxLabelNodeSpecific")); 836 panelSignalman.setBorder(panelSignalmanTitled); 837 838 panelSignalman.setVisible(false); 839 contentPane.add(panelSignalman); 840 841 // Set up the YardMaster nodes 842 panelYardMaster.setLayout(new BoxLayout(panelYardMaster, BoxLayout.Y_AXIS)); 843 JPanel panelYardMaster1 = new JPanel(); 844 panelYardMaster1.setLayout(new FlowLayout()); 845 statusTextYardMaster1.setText(stdStatusYardMaster1); 846 statusTextYardMaster1.setVisible(true); 847 panelYardMaster1.add(statusTextYardMaster1); 848 panelYardMaster.add(panelYardMaster1); 849 850 JPanel panelYardMaster2 = new JPanel(); 851 panelYardMaster2.setLayout(new FlowLayout()); 852 statusTextYardMaster2.setText(stdStatusYardMaster2); 853 statusTextYardMaster2.setVisible(true); 854 panelYardMaster2.add(statusTextYardMaster2); 855 panelYardMaster.add(panelYardMaster2); 856 857 JPanel panelYardMaster3 = new JPanel(); 858 panelYardMaster3.setLayout(new FlowLayout()); 859 statusTextYardMaster3.setText(stdStatusYardMaster3); 860 statusTextYardMaster3.setVisible(true); 861 panelYardMaster3.add(statusTextYardMaster3); 862 panelYardMaster.add(panelYardMaster3); 863 864 // Output circuit configuration 865 ymoutputConfigModel = new OutputConfigModel(); 866 ymoutputConfigModel.setNumRows(16); 867 ymoutputConfigModel.setEditMode(false); 868 JTable ymoutputConfigTable = new JTable(ymoutputConfigModel); 869 ymoutputConfigTable.setRowSelectionAllowed(false); 870 ymoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125)); 871 872 JComboBox<String> ymoutputWiredCombo = new JComboBox<String>(); 873 ymoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNC")); 874 ymoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNO")); 875 876 JComboBox<String> yminitialStateCombo = new JComboBox<String>(); 877 yminitialStateCombo.addItem(Bundle.getMessage("InitialStateOn")); 878 yminitialStateCombo.addItem(Bundle.getMessage("InitialStateOff")); 879 880 JComboBox<String> ymoutputTypeCombo = new JComboBox<String>(); 881 ymoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeONOFF")); 882 ymoutputTypeCombo.addItem(Bundle.getMessage("OutputTypePULSE")); 883 ymoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeBLINK")); 884 885 JComboBox<String> ymoutputLengthCombo = new JComboBox<String>(); 886 for (int t = 0; t < 255; t++) { 887 ymoutputLengthCombo.addItem(String.valueOf(t)); 888 } 889 890 TableColumnModel ymoutputColumnModel = ymoutputConfigTable.getColumnModel(); 891 TableColumn ymoutputCircuitAddressColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN); 892 ymoutputCircuitAddressColumn.setMinWidth(70); 893 ymoutputCircuitAddressColumn.setMaxWidth(80); 894 TableColumn ymoutputWiredColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN); 895 ymoutputWiredColumn.setCellEditor(new DefaultCellEditor(ymoutputWiredCombo)); 896 ymoutputWiredColumn.setResizable(false); 897 ymoutputWiredColumn.setMinWidth(90); 898 ymoutputWiredColumn.setMaxWidth(100); 899 TableColumn yminitialStateColumn = ymoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN); 900 yminitialStateColumn.setCellEditor(new DefaultCellEditor(yminitialStateCombo)); 901 yminitialStateColumn.setResizable(false); 902 yminitialStateColumn.setMinWidth(90); 903 yminitialStateColumn.setMaxWidth(100); 904 TableColumn ymoutputTypeColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN); 905 ymoutputTypeColumn.setCellEditor(new DefaultCellEditor(ymoutputTypeCombo)); 906 ymoutputTypeColumn.setResizable(false); 907 ymoutputTypeColumn.setMinWidth(90); 908 ymoutputTypeColumn.setMaxWidth(100); 909 TableColumn ymoutputLengthColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN); 910 ymoutputLengthColumn.setCellEditor(new DefaultCellEditor(ymoutputLengthCombo)); 911 ymoutputLengthColumn.setResizable(false); 912 ymoutputLengthColumn.setMinWidth(90); 913 ymoutputLengthColumn.setMaxWidth(100); 914 TableColumn ymoutputaddressColumn = ymoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN); 915 ymoutputaddressColumn.setMinWidth(110); 916 ymoutputaddressColumn.setMaxWidth(120); 917 918 // Finish Set up the YardMaster nodes 919 JScrollPane ymoutputScrollPane = new JScrollPane(ymoutputConfigTable); 920 921 JPanel panelYardMasterTable = new JPanel(); 922 panelYardMasterTable.setLayout(new BoxLayout(panelYardMasterTable, BoxLayout.Y_AXIS)); 923 924 panelYardMasterTable.add(ymoutputScrollPane, BorderLayout.CENTER); 925 panelYardMaster.add(panelYardMasterTable, BoxLayout.Y_AXIS); 926 927 Border panelYardMasterBorder = BorderFactory.createEtchedBorder(); 928 Border panelYardMasterTitled = BorderFactory.createTitledBorder(panelYardMasterBorder, 929 Bundle.getMessage("BoxLabelNodeSpecific")); 930 panelYardMaster.setBorder(panelYardMasterTitled); 931 932 panelYardMaster.setVisible(false); 933 contentPane.add(panelYardMaster); 934 935 // Set up the SwitchMan nodes 936 panelSwitchman.setLayout(new BoxLayout(panelSwitchman, BoxLayout.Y_AXIS)); 937 JPanel panelSwitchman1 = new JPanel(); 938 panelSwitchman1.setLayout(new FlowLayout()); 939 statusTextSwitchman1.setText(stdStatusSwitchman1); 940 statusTextSwitchman1.setVisible(true); 941 panelSwitchman1.add(statusTextSwitchman1); 942 panelSwitchman.add(panelSwitchman1); 943 944 JPanel panelSwitchman2 = new JPanel(); 945 panelSwitchman2.setLayout(new FlowLayout()); 946 statusTextSwitchman2.setText(stdStatusSwitchman2); 947 statusTextSwitchman2.setVisible(true); 948 panelSwitchman2.add(statusTextSwitchman2); 949 panelSwitchman.add(panelSwitchman2); 950 951 JPanel panelSwitchman3 = new JPanel(); 952 panelSwitchman3.setLayout(new FlowLayout()); 953 statusTextSwitchman3.setText(stdStatusSwitchman3); 954 statusTextSwitchman3.setVisible(true); 955 panelSwitchman3.add(statusTextSwitchman3); 956 panelSwitchman.add(panelSwitchman3); 957 958 // Output circuit configuration 959 swoutputConfigModel = new OutputConfigModel(); 960 swoutputConfigModel.setNumRows(16); 961 swoutputConfigModel.setEditMode(false); 962 JTable swoutputConfigTable = new JTable(swoutputConfigModel); 963 swoutputConfigTable.setRowSelectionAllowed(false); 964 swoutputConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125)); 965 966 JComboBox<String> swoutputWiredCombo = new JComboBox<String>(); 967 swoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNC")); 968 swoutputWiredCombo.addItem(Bundle.getMessage("OutputWiredNO")); 969 970 JComboBox<String> swinitialStateCombo = new JComboBox<String>(); 971 swinitialStateCombo.addItem(Bundle.getMessage("InitialStateOn")); 972 swinitialStateCombo.addItem(Bundle.getMessage("InitialStateOff")); 973 974 JComboBox<String> swoutputTypeCombo = new JComboBox<String>(); 975 swoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeONOFF")); 976 swoutputTypeCombo.addItem(Bundle.getMessage("OutputTypePULSE")); 977 swoutputTypeCombo.addItem(Bundle.getMessage("OutputTypeBLINK")); 978 979 JComboBox<String> swoutputLengthCombo = new JComboBox<String>(); 980 for (int t = 0; t < 255; t++) { 981 swoutputLengthCombo.addItem(String.valueOf(t)); 982 } 983 984 TableColumnModel swoutputColumnModel = swoutputConfigTable.getColumnModel(); 985 TableColumn swoutputCircuitAddressColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTCIRCUITADDRESS_COLUMN); 986 swoutputCircuitAddressColumn.setMinWidth(70); 987 swoutputCircuitAddressColumn.setMaxWidth(80); 988 TableColumn swoutputWiredColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTWIRED_COLUMN); 989 swoutputWiredColumn.setCellEditor(new DefaultCellEditor(swoutputWiredCombo)); 990 swoutputWiredColumn.setResizable(false); 991 swoutputWiredColumn.setMinWidth(90); 992 swoutputWiredColumn.setMaxWidth(100); 993 TableColumn swinitialStateColumn = swoutputColumnModel.getColumn(OutputConfigModel.INITIALSTATE_COLUMN); 994 swinitialStateColumn.setCellEditor(new DefaultCellEditor(swinitialStateCombo)); 995 swinitialStateColumn.setResizable(false); 996 swinitialStateColumn.setMinWidth(90); 997 swinitialStateColumn.setMaxWidth(100); 998 TableColumn swoutputTypeColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTTYPE_COLUMN); 999 swoutputTypeColumn.setCellEditor(new DefaultCellEditor(swoutputTypeCombo)); 1000 swoutputTypeColumn.setResizable(false); 1001 swoutputTypeColumn.setMinWidth(90); 1002 swoutputTypeColumn.setMaxWidth(100); 1003 TableColumn swoutputLengthColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTLENGTH_COLUMN); 1004 swoutputLengthColumn.setCellEditor(new DefaultCellEditor(swoutputLengthCombo)); 1005 swoutputLengthColumn.setResizable(false); 1006 swoutputLengthColumn.setMinWidth(90); 1007 swoutputLengthColumn.setMaxWidth(100); 1008 TableColumn swoutputaddressColumn = swoutputColumnModel.getColumn(OutputConfigModel.OUTPUTADDRESS_COLUMN); 1009 swoutputaddressColumn.setMinWidth(110); 1010 swoutputaddressColumn.setMaxWidth(120); 1011 1012 // Finish Set up the Switchman nodes 1013 JScrollPane swoutputScrollPane = new JScrollPane(swoutputConfigTable); 1014 1015 JPanel panelSwitchmanTable = new JPanel(); 1016 panelSwitchmanTable.setLayout(new BoxLayout(panelSwitchmanTable, BoxLayout.Y_AXIS)); 1017 1018 panelSwitchmanTable.add(swoutputScrollPane, BorderLayout.CENTER); 1019 panelSwitchman.add(panelSwitchmanTable, BoxLayout.Y_AXIS); 1020 1021 Border panelSwitchmanBorder = BorderFactory.createEtchedBorder(); 1022 Border panelSwitchmanTitled = BorderFactory.createTitledBorder(panelSwitchmanBorder, 1023 Bundle.getMessage("BoxLabelNodeSpecific")); 1024 panelSwitchman.setBorder(panelSwitchmanTitled); 1025 1026 panelSwitchman.setVisible(false); 1027 contentPane.add(panelSwitchman); 1028 1029 // Set up the Sentry nodes 1030 panelSentry.setLayout(new BoxLayout(panelSentry, BoxLayout.Y_AXIS)); 1031 JPanel panelSentry1 = new JPanel(); 1032 panelSentry1.setLayout(new FlowLayout()); 1033 statusTextSentry1.setText(stdStatusSentry1); 1034 statusTextSentry1.setVisible(true); 1035 panelSentry1.add(statusTextSentry1); 1036 panelSentry.add(panelSentry1); 1037 1038 JPanel panelSentry2 = new JPanel(); 1039 panelSentry2.setLayout(new FlowLayout()); 1040 statusTextSentry2.setText(stdStatusSentry2); 1041 statusTextSentry2.setVisible(true); 1042 panelSentry2.add(statusTextSentry2); 1043 panelSentry.add(panelSentry2); 1044 1045 JPanel panelSentry3 = new JPanel(); 1046 panelSentry3.setLayout(new FlowLayout()); 1047 statusTextSentry3.setText(stdStatusSentry3); 1048 statusTextSentry3.setVisible(true); 1049 panelSentry3.add(statusTextSentry3); 1050 panelSentry.add(panelSentry3); 1051 1052 sysensorConfigModel = new SensorConfigModel(); 1053 sysensorConfigModel.setNumRows(16); 1054 sysensorConfigModel.setEditMode(false); 1055 1056 JTable sysensorConfigTable = new JTable(sysensorConfigModel); 1057 sysensorConfigTable.setRowSelectionAllowed(false); 1058 sysensorConfigTable.setPreferredScrollableViewportSize(new java.awt.Dimension(180, 125)); 1059 1060 JComboBox<String> syfilterTypeCombo = new JComboBox<String>(); 1061 syfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeNoise")); 1062 syfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeDebounce")); 1063 syfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeCarGap")); 1064 syfilterTypeCombo.addItem(Bundle.getMessage("FilterTypeDirtyTrack")); 1065 1066 JComboBox<String> syfilterPolarityCombo = new JComboBox<String>(); 1067 syfilterPolarityCombo.addItem(Bundle.getMessage("FilterNormalPolarity")); 1068 syfilterPolarityCombo.addItem(Bundle.getMessage("FilterInversePolarity")); 1069 1070 JComboBox<String> syfilterThresholdCombo = new JComboBox<String>(); 1071 for (int t = 0; t < 32; t++) { 1072 syfilterThresholdCombo.addItem(String.valueOf(t)); 1073 } 1074 TableColumnModel sytypeColumnModel = sysensorConfigTable.getColumnModel(); 1075 TableColumn sycircuitAddressColumn = sytypeColumnModel.getColumn(SensorConfigModel.SENSORCIRCUITADDRESS_COLUMN); 1076 sycircuitAddressColumn.setMinWidth(70); 1077 sycircuitAddressColumn.setMaxWidth(80); 1078 TableColumn sycardTypeColumn = sytypeColumnModel.getColumn(SensorConfigModel.TYPE_COLUMN); 1079 sycardTypeColumn.setCellEditor(new DefaultCellEditor(syfilterTypeCombo)); 1080 sycardTypeColumn.setResizable(false); 1081 sycardTypeColumn.setMinWidth(90); 1082 sycardTypeColumn.setMaxWidth(100); 1083 TableColumn sycardPolarityColumn = sytypeColumnModel.getColumn(SensorConfigModel.POLARITY_COLUMN); 1084 sycardPolarityColumn.setCellEditor(new DefaultCellEditor(syfilterPolarityCombo)); 1085 sycardPolarityColumn.setResizable(false); 1086 sycardPolarityColumn.setMinWidth(90); 1087 sycardPolarityColumn.setMaxWidth(100); 1088 TableColumn sycardThresholdColumn = sytypeColumnModel.getColumn(SensorConfigModel.THRESHOLD_COLUMN); 1089 sycardThresholdColumn.setCellEditor(new DefaultCellEditor(syfilterThresholdCombo)); 1090 sycardThresholdColumn.setResizable(false); 1091 sycardThresholdColumn.setMinWidth(90); 1092 sycardThresholdColumn.setMaxWidth(100); 1093 TableColumn sysensorAddressColumn = sytypeColumnModel.getColumn(SensorConfigModel.SENSORADDRESS_COLUMN); 1094 sysensorAddressColumn.setMinWidth(110); 1095 sysensorAddressColumn.setMaxWidth(1200); 1096 1097 // Finish Set up the Sentry nodes 1098 JScrollPane sysensorScrollPane = new JScrollPane(sysensorConfigTable); 1099 1100 JPanel panelSentrytable = new JPanel(); 1101 panelSentrytable.setLayout(new BoxLayout(panelSentrytable, BoxLayout.Y_AXIS)); 1102 1103 panelSentrytable.add(sysensorScrollPane, BorderLayout.CENTER); 1104 panelSentry.add(panelSentrytable, BoxLayout.Y_AXIS); 1105 1106 Border panelSentryBorder = BorderFactory.createEtchedBorder(); 1107 Border panelSentryTitled = BorderFactory.createTitledBorder(panelSentryBorder, 1108 Bundle.getMessage("BoxLabelNodeSpecific")); 1109 panelSentry.setBorder(panelSentryTitled); 1110 1111 contentPane.add(panelSentry); 1112 panelSentry.setVisible(false); 1113 1114 // Set up the notes panel 1115 JPanel panel3 = new JPanel(); 1116 panel3.setLayout(new BoxLayout(panel3, BoxLayout.Y_AXIS)); 1117 JPanel panel31 = new JPanel(); 1118 panel31.setLayout(new FlowLayout()); 1119 statusText1.setText(stdStatus1); 1120 statusText1.setVisible(true); 1121 panel31.add(statusText1); 1122 JPanel panel32 = new JPanel(); 1123 panel32.setLayout(new FlowLayout()); 1124 statusText2.setText(stdStatus2); 1125 statusText2.setVisible(true); 1126 panel32.add(statusText2); 1127 JPanel panel33 = new JPanel(); 1128 panel33.setLayout(new FlowLayout()); 1129 statusText3.setText(stdStatus3); 1130 statusText3.setVisible(true); 1131 panel33.add(statusText3); 1132 panel3.add(panel31); 1133 panel3.add(panel32); 1134 panel3.add(panel33); 1135 Border panel3Border = BorderFactory.createEtchedBorder(); 1136 Border panel3Titled = BorderFactory.createTitledBorder(panel3Border, 1137 Bundle.getMessage("BoxLabelNotes")); 1138 panel3.setBorder(panel3Titled); 1139 contentPane.add(panel3); 1140 1141 // Set up buttons 1142 JPanel panel4 = new JPanel(); 1143 panel4.setLayout(new FlowLayout()); 1144 addButton.setText(Bundle.getMessage("ButtonAdd")); 1145 addButton.setVisible(true); 1146 addButton.setToolTipText(Bundle.getMessage("TipAddButton")); 1147 addButton.addActionListener(new ActionListener() { 1148 @Override 1149 public void actionPerformed(ActionEvent e) { 1150 addButtonActionPerformed(); 1151 } 1152 }); 1153 panel4.add(addButton); 1154 editButton.setText(Bundle.getMessage("ButtonEdit")); 1155 editButton.setVisible(true); 1156 editButton.setToolTipText(Bundle.getMessage("TipEditButton")); 1157 panel4.add(editButton); 1158 editButton.addActionListener(new ActionListener() { 1159 @Override 1160 public void actionPerformed(ActionEvent e) { 1161 editButtonActionPerformed(); 1162 } 1163 }); 1164 panel4.add(deleteButton); 1165 deleteButton.setText(Bundle.getMessage("ButtonDelete")); 1166 deleteButton.setVisible(true); 1167 deleteButton.setToolTipText(Bundle.getMessage("TipDeleteButton")); 1168 panel4.add(deleteButton); 1169 deleteButton.addActionListener(new ActionListener() { 1170 @Override 1171 public void actionPerformed(ActionEvent e) { 1172 deleteButtonActionPerformed(); 1173 } 1174 }); 1175 panel4.add(doneButton); 1176 doneButton.setText(Bundle.getMessage("ButtonDone")); 1177 doneButton.setVisible(true); 1178 doneButton.setToolTipText(Bundle.getMessage("TipDoneButton")); 1179 panel4.add(doneButton); 1180 doneButton.addActionListener(new ActionListener() { 1181 @Override 1182 public void actionPerformed(ActionEvent e) { 1183 doneButtonActionPerformed(); 1184 } 1185 }); 1186 panel4.add(updateButton); 1187 updateButton.setText(Bundle.getMessage("ButtonUpdate")); 1188 updateButton.setVisible(true); 1189 updateButton.setToolTipText(Bundle.getMessage("TipUpdateButton")); 1190 panel4.add(updateButton); 1191 updateButton.addActionListener(new ActionListener() { 1192 @Override 1193 public void actionPerformed(ActionEvent e) { 1194 updateButtonActionPerformed(); 1195 } 1196 }); 1197 updateButton.setVisible(false); 1198 panel4.add(cancelButton); 1199 cancelButton.setText(Bundle.getMessage("ButtonCancel")); 1200 cancelButton.setVisible(true); 1201 cancelButton.setToolTipText(Bundle.getMessage("TipCancelButton")); 1202 panel4.add(cancelButton); 1203 cancelButton.addActionListener(new ActionListener() { 1204 @Override 1205 public void actionPerformed(ActionEvent e) { 1206 cancelButtonActionPerformed(); 1207 } 1208 }); 1209 cancelButton.setVisible(false); 1210 1211 contentPane.add(panel4); 1212 1213 // add help menu to window 1214 addHelpMenu("package.jmri.jmrix.acela.nodeconfig.NodeConfigFrame", true); 1215 1216 // pack for display 1217 pack(); 1218 } 1219 1220 /** 1221 * Method to handle add button 1222 */ 1223 public void addButtonActionPerformed() { 1224 JmriJOptionPane.showMessageDialog(this, 1225 Bundle.getMessage("NotSupported1") + "\n" + Bundle.getMessage("NotSupported2"), 1226 Bundle.getMessage("NotSupportedTitle"), 1227 JmriJOptionPane.INFORMATION_MESSAGE); 1228 resetNotes(); 1229 } 1230 1231 /** 1232 * Method to handle info state 1233 */ 1234 public void infoButtonActionPerformed() { 1235 1236 // lookup the nodes 1237 StringBuilder nodesstring = new StringBuilder(""); 1238 int tempnumnodes = _memo.getTrafficController().getNumNodes(); 1239 for (int i = 0; i < tempnumnodes; i++) { 1240 AcelaNode tempnode; 1241 tempnode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(i); 1242 nodesstring.append(" ").append(tempnode.getNodeTypeString()); 1243 } 1244 thenodesStaticC.setText(nodesstring.toString()); 1245 1246 // Find Acela Node address 1247 nodeAddress = readNodeAddress(); 1248 if (nodeAddress < 0) { 1249 return; 1250 } 1251 // get the AcelaNode corresponding to this node address 1252 curNode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress); 1253 if (curNode == null) { 1254 statusText1.setText(Bundle.getMessage("Error4")); 1255 statusText1.setVisible(true); 1256 errorInStatus1 = true; 1257 resetNotes2(); 1258 return; 1259 } 1260 // Set up static node address 1261 nodeAddrStatic.setText(Integer.toString(nodeAddress)); 1262 nodeAddrBox.setVisible(true); 1263 nodeAddrField.setVisible(false); 1264 nodeAddrStatic.setVisible(false); 1265 // get information for this node and set up combo box 1266 nodeType = curNode.getNodeType(); 1267 nodeTypeBox.setSelectedIndex(nodeType); 1268 nodeTypeBox.setVisible(false); 1269 nodeTypeStatic.setText(AcelaNode.getModuleNames()[nodeType]); 1270 nodeTypeStatic.setVisible(true); 1271 1272 // get information for this node if it is an output node 1273 int numoutputbits = curNode.getNumOutputBitsPerCard(); 1274 if (numoutputbits > 0) { 1275 // set up output types 1276 for (int o = 0; o < numoutputbits; o++) { 1277 if (curNode.getOutputInit(o) == 0) { 1278 initialState[o] = Bundle.getMessage("InitialStateOff"); 1279 } else { // if (curNode.getOutputInit(o) == 1) { 1280 initialState[o] = Bundle.getMessage("InitialStateOn"); 1281 } 1282 if (curNode.getOutputWired(o) == 0) { 1283 outputWired[o] = Bundle.getMessage("OutputWiredNO"); 1284 } else { // if (curNode.getOutputWired(o) == 1) { 1285 outputWired[o] = Bundle.getMessage("OutputWiredNC"); 1286 } 1287 1288 if (curNode.getOutputType(o) == 0) { 1289 outputType[o] = Bundle.getMessage("OutputTypeONOFF"); 1290 } else { 1291 if (curNode.getOutputType(o) == 1) { 1292 outputType[o] = Bundle.getMessage("OutputTypePULSE"); 1293 } else { // if (curNode.getOutputType(o) == 2) { 1294 outputType[o] = Bundle.getMessage("OutputTypeBLINK"); 1295 } 1296 } 1297 1298 outputLength[o] = String.valueOf(curNode.getOutputLength(o)); 1299 } 1300 } 1301 1302 // get information for this node if it is a sensor node 1303 int numsensorbits = curNode.getNumSensorBitsPerCard(); 1304 if (numsensorbits > 0) { 1305 // set up sensor types 1306 for (int i = 0; i < numsensorbits; i++) { 1307 if (curNode.getSensorType(i) == 0) { 1308 filterType[i] = Bundle.getMessage("FilterTypeNoise"); 1309 } else if (curNode.getSensorType(i) == 1) { 1310 filterType[i] = Bundle.getMessage("FilterTypeDebounce"); 1311 } else if (curNode.getSensorType(i) == 2) { 1312 filterType[i] = Bundle.getMessage("FilterTypeCarGap"); 1313 } else { 1314 filterType[i] = Bundle.getMessage("FilterTypeDirtyTrack"); 1315 } 1316 1317 if (curNode.getSensorPolarity(i) == 0) { 1318 filterPolarity[i] = Bundle.getMessage("FilterNormalPolarity"); 1319 } else { 1320 filterPolarity[i] = Bundle.getMessage("FilterInversePolarity"); 1321 } 1322 1323 filterThreshold[i] = String.valueOf(curNode.getSensorThreshold(i)); 1324 } 1325 } 1326 1327 // Switch buttons 1328 editMode = false; 1329 addButton.setVisible(true); 1330 editButton.setVisible(true); 1331 deleteButton.setVisible(true); 1332 doneButton.setVisible(true); 1333 updateButton.setVisible(false); 1334 cancelButton.setVisible(false); 1335 // Switch to edit notes 1336 statusText1.setText(infoStatus1); 1337 statusText2.setText(infoStatus2); 1338 statusText3.setText(infoStatus3); 1339 1340 d8outputConfigModel.setEditMode(false); 1341 swoutputConfigModel.setEditMode(false); 1342 ymoutputConfigModel.setEditMode(false); 1343 TBoutputConfigModel.setEditMode(false); 1344 TBsensorConfigModel.setEditMode(false); 1345 smoutputConfigModel.setEditMode(false); 1346 wmsensorConfigModel.setEditMode(false); 1347 sysensorConfigModel.setEditMode(false); 1348 contentPane.repaint(); 1349 } 1350 1351 /** 1352 * Method to handle edit button 1353 */ 1354 public void editButtonActionPerformed() { 1355 // Find Acela Node address 1356 nodeAddress = readNodeAddress(); 1357 if (nodeAddress < 0) { 1358 return; 1359 } 1360 // get the AcelaNode corresponding to this node address 1361 curNode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress); 1362 if (curNode == null) { 1363 statusText1.setText(Bundle.getMessage("Error4")); 1364 statusText1.setVisible(true); 1365 errorInStatus1 = true; 1366 resetNotes2(); 1367 return; 1368 } 1369 // Set up static node address 1370 nodeAddrStatic.setText(Integer.toString(nodeAddress)); 1371 nodeAddrBox.setVisible(false); 1372 nodeAddrField.setVisible(false); 1373 nodeAddrStatic.setVisible(true); 1374 // get information for this node and set up combo box 1375 nodeType = curNode.getNodeType(); 1376 nodeTypeBox.setSelectedIndex(nodeType); 1377 nodeTypeBox.setVisible(true); 1378 nodeTypeStatic.setText(AcelaNode.getModuleNames()[nodeType]); 1379 nodeTypeStatic.setVisible(false); 1380 1381 // get information for this node if it is an output node 1382 int numoutputbits = curNode.getNumOutputBitsPerCard(); 1383 if (numoutputbits > 0) { 1384 // set up output types 1385 for (int o = 0; o < numoutputbits; o++) { 1386 if (curNode.getOutputInit(o) == 0) { 1387 initialState[o] = Bundle.getMessage("InitialStateOff"); 1388 } else { // if (curNode.getOutputInit(o) == 1) { 1389 initialState[o] = Bundle.getMessage("InitialStateOn"); 1390 } 1391 if (curNode.getOutputWired(o) == 0) { 1392 outputWired[o] = Bundle.getMessage("OutputWiredNO"); 1393 } else { // if (curNode.getOutputWired(o) == 1) { 1394 outputWired[o] = Bundle.getMessage("OutputWiredNC"); 1395 } 1396 1397 if (curNode.getOutputType(o) == 0) { 1398 outputType[o] = Bundle.getMessage("OutputTypeONOFF"); 1399 } else { 1400 if (curNode.getOutputType(o) == 1) { 1401 outputType[o] = Bundle.getMessage("OutputTypePULSE"); 1402 } else { // if (curNode.getOutputType(o) == 2) { 1403 outputType[o] = Bundle.getMessage("OutputTypeBLINK"); 1404 } 1405 } 1406 1407 outputLength[o] = String.valueOf(curNode.getOutputLength(o)); 1408 } 1409 } 1410 1411 // get information for this node if it is a sensor node 1412 int numsensorbits = curNode.getNumSensorBitsPerCard(); 1413 if (numsensorbits > 0) { 1414 // set up sensor types 1415 for (int i = 0; i < numsensorbits; i++) { 1416 if (curNode.getSensorType(i) == 0) { 1417 filterType[i] = Bundle.getMessage("FilterTypeNoise"); 1418 } else if (curNode.getSensorType(i) == 1) { 1419 filterType[i] = Bundle.getMessage("FilterTypeDebounce"); 1420 } else if (curNode.getSensorType(i) == 2) { 1421 filterType[i] = Bundle.getMessage("FilterTypeCarGap"); 1422 } else { 1423 filterType[i] = Bundle.getMessage("FilterTypeDirtyTrack"); 1424 } 1425 1426 if (curNode.getSensorPolarity(i) == 0) { 1427 filterPolarity[i] = Bundle.getMessage("FilterNormalPolarity"); 1428 } else { 1429 filterPolarity[i] = Bundle.getMessage("FilterInversePolarity"); 1430 } 1431 1432 filterThreshold[i] = String.valueOf(curNode.getSensorThreshold(i)); 1433 } 1434 } 1435 1436 // Switch buttons 1437 editMode = true; 1438 addButton.setVisible(false); 1439 editButton.setVisible(false); 1440 deleteButton.setVisible(false); 1441 doneButton.setVisible(false); 1442 updateButton.setVisible(true); 1443 cancelButton.setVisible(true); 1444 // Switch to edit notes 1445 statusText1.setText(editStatus1); 1446 statusText2.setText(editStatus2); 1447 statusText3.setText(editStatus3); 1448 1449 d8outputConfigModel.setEditMode(true); 1450 swoutputConfigModel.setEditMode(true); 1451 ymoutputConfigModel.setEditMode(true); 1452 TBoutputConfigModel.setEditMode(true); 1453 TBsensorConfigModel.setEditMode(true); 1454 smoutputConfigModel.setEditMode(true); 1455 wmsensorConfigModel.setEditMode(true); 1456 sysensorConfigModel.setEditMode(true); 1457 contentPane.repaint(); 1458 1459 } 1460 1461 /** 1462 * Method to handle delete button 1463 */ 1464 public void deleteButtonActionPerformed() { 1465 1466 JmriJOptionPane.showMessageDialog(this, 1467 Bundle.getMessage("NotSupported1") + "\n" + Bundle.getMessage("NotSupported2"), 1468 Bundle.getMessage("NotSupportedTitle"), 1469 JmriJOptionPane.INFORMATION_MESSAGE); 1470 resetNotes(); 1471 } 1472 1473 /** 1474 * Method to handle done button 1475 */ 1476 public void doneButtonActionPerformed() { 1477 if (editMode) { 1478 // Reset 1479 editMode = false; 1480 curNode = null; 1481 // Switch buttons 1482 addButton.setVisible(true); 1483 editButton.setVisible(true); 1484 deleteButton.setVisible(true); 1485 doneButton.setVisible(true); 1486 updateButton.setVisible(false); 1487 cancelButton.setVisible(false); 1488 nodeAddrBox.setVisible(true); 1489// nodeAddrField.setVisible(true); 1490 nodeAddrStatic.setVisible(false); 1491 nodeTypeStatic.setVisible(true); 1492 nodeTypeBox.setVisible(false); 1493 } 1494 if (changedNode && !checkEnabled) { 1495 // Remind user to Save new configuration 1496 JmriJOptionPane.showMessageDialog(this, 1497 Bundle.getMessage("ReminderNode1") + "\n" + Bundle.getMessage("Reminder2"), 1498 Bundle.getMessage("ReminderTitle"), 1499 JmriJOptionPane.INFORMATION_MESSAGE); 1500 } 1501 setVisible(false); 1502 dispose(); 1503 } 1504 1505 /** 1506 * Method to handle update button 1507 */ 1508 public void updateButtonActionPerformed() { 1509 // update node information 1510 nodeType = nodeTypeBox.getSelectedIndex(); 1511 log.debug("update performed: was {} request {}", curNode.getNodeType(), nodeType); 1512 if (curNode.getNodeType() != nodeType) { 1513 // node type has changed 1514 curNode.setNodeType(nodeType); 1515 } 1516 setNodeParameters(); 1517 changedNode = true; 1518 // Reset Edit Mode 1519 editMode = false; 1520 curNode = null; 1521 // Switch buttons 1522 addButton.setVisible(true); 1523 editButton.setVisible(true); 1524 deleteButton.setVisible(true); 1525 doneButton.setVisible(true); 1526 updateButton.setVisible(false); 1527 cancelButton.setVisible(false); 1528 // make node address editable again 1529 nodeAddrBox.setVisible(true); 1530// nodeAddrField.setVisible(true); 1531 nodeAddrStatic.setVisible(false); 1532 nodeTypeBox.setVisible(false); 1533 nodeTypeStatic.setVisible(true); 1534 // refresh notes panel 1535 statusText2.setText(stdStatus2); 1536 statusText3.setText(stdStatus3); 1537 // provide user feedback 1538 statusText1.setText(Bundle.getMessage("FeedBackUpdate") + " " 1539 + Integer.toString(nodeAddress)); 1540 errorInStatus1 = true; 1541 1542 d8outputConfigModel.setEditMode(false); 1543 swoutputConfigModel.setEditMode(false); 1544 ymoutputConfigModel.setEditMode(false); 1545 TBoutputConfigModel.setEditMode(false); 1546 TBsensorConfigModel.setEditMode(false); 1547 smoutputConfigModel.setEditMode(false); 1548 wmsensorConfigModel.setEditMode(false); 1549 sysensorConfigModel.setEditMode(false); 1550 1551 contentPane.repaint(); 1552 1553 } 1554 1555 /** 1556 * Method to handle cancel button 1557 */ 1558 public void cancelButtonActionPerformed() { 1559 // Reset 1560 editMode = false; 1561 curNode = null; 1562 1563 // lookup the nodes 1564 StringBuilder nodesstring = new StringBuilder(""); 1565 int tempnumnodes = _memo.getTrafficController().getNumNodes(); 1566 for (int i = 0; i < tempnumnodes; i++) { 1567 AcelaNode tempnode; 1568 tempnode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(i); 1569 nodesstring.append(" ").append(tempnode.getNodeTypeString()); 1570 } 1571 thenodesStaticC.setText(nodesstring.toString()); 1572 1573 // Find Acela Node address 1574 nodeAddress = readNodeAddress(); 1575 if (nodeAddress < 0) { 1576 return; 1577 } 1578 // get the AcelaNode corresponding to this node address 1579 curNode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress); 1580 if (curNode == null) { 1581 statusText1.setText(Bundle.getMessage("Error4")); 1582 statusText1.setVisible(true); 1583 errorInStatus1 = true; 1584 resetNotes2(); 1585 return; 1586 } 1587 // Set up static node address 1588 nodeAddrStatic.setText(Integer.toString(nodeAddress)); 1589 nodeAddrBox.setVisible(true); 1590 nodeAddrField.setVisible(false); 1591 nodeAddrStatic.setVisible(false); 1592 // get information for this node and set up combo box 1593 nodeType = curNode.getNodeType(); 1594 nodeTypeBox.setSelectedIndex(nodeType); 1595 nodeTypeBox.setVisible(false); 1596 nodeTypeStatic.setText(AcelaNode.getModuleNames()[nodeType]); 1597 nodeTypeStatic.setVisible(true); 1598 1599 // get information for this node if it is an output node 1600 int numoutputbits = curNode.getNumOutputBitsPerCard(); 1601 if (numoutputbits > 0) { 1602 // set up output types 1603 for (int o = 0; o < numoutputbits; o++) { 1604 if (curNode.getOutputInit(o) == 0) { 1605 initialState[o] = Bundle.getMessage("InitialStateOff"); 1606 } else { // if (curNode.getOutputInit(o) == 1) { 1607 initialState[o] = Bundle.getMessage("InitialStateOn"); 1608 } 1609 if (curNode.getOutputWired(o) == 0) { 1610 outputWired[o] = Bundle.getMessage("OutputWiredNO"); 1611 } else { // if (curNode.getOutputWired(o) == 1) { 1612 outputWired[o] = Bundle.getMessage("OutputWiredNC"); 1613 } 1614 1615 if (curNode.getOutputType(o) == 0) { 1616 outputType[o] = Bundle.getMessage("OutputTypeONOFF"); 1617 } else { 1618 if (curNode.getOutputType(o) == 1) { 1619 outputType[o] = Bundle.getMessage("OutputTypePULSE"); 1620 } else { // if (curNode.getOutputType(o) == 2) { 1621 outputType[o] = Bundle.getMessage("OutputTypeBLINK"); 1622 } 1623 } 1624 1625 outputLength[o] = String.valueOf(curNode.getOutputLength(o)); 1626 } 1627 } 1628 1629 // get information for this node if it is a sensor node 1630 int numsensorbits = curNode.getNumSensorBitsPerCard(); 1631 if (numsensorbits > 0) { 1632 // set up sensor types 1633 for (int i = 0; i < numsensorbits; i++) { 1634 if (curNode.getSensorType(i) == 0) { 1635 filterType[i] = Bundle.getMessage("FilterTypeNoise"); 1636 } else if (curNode.getSensorType(i) == 1) { 1637 filterType[i] = Bundle.getMessage("FilterTypeDebounce"); 1638 } else if (curNode.getSensorType(i) == 2) { 1639 filterType[i] = Bundle.getMessage("FilterTypeCarGap"); 1640 } else { 1641 filterType[i] = Bundle.getMessage("FilterTypeDirtyTrack"); 1642 } 1643 1644 if (curNode.getSensorPolarity(i) == 0) { 1645 filterPolarity[i] = Bundle.getMessage("FilterNormalPolarity"); 1646 } else { 1647 filterPolarity[i] = Bundle.getMessage("FilterInversePolarity"); 1648 } 1649 1650 filterThreshold[i] = String.valueOf(curNode.getSensorThreshold(i)); 1651 } 1652 } 1653 1654 // Switch buttons 1655 editMode = false; 1656 addButton.setVisible(true); 1657 editButton.setVisible(true); 1658 deleteButton.setVisible(true); 1659 doneButton.setVisible(true); 1660 updateButton.setVisible(false); 1661 cancelButton.setVisible(false); 1662 // Switch to edit notes 1663 statusText1.setText(infoStatus1); 1664 statusText2.setText(infoStatus2); 1665 statusText3.setText(infoStatus3); 1666 1667 d8outputConfigModel.setEditMode(false); 1668 swoutputConfigModel.setEditMode(false); 1669 ymoutputConfigModel.setEditMode(false); 1670 TBoutputConfigModel.setEditMode(false); 1671 TBsensorConfigModel.setEditMode(false); 1672 smoutputConfigModel.setEditMode(false); 1673 wmsensorConfigModel.setEditMode(false); 1674 sysensorConfigModel.setEditMode(false); 1675 1676 contentPane.repaint(); 1677 } 1678 1679 /** 1680 * Do the done action if the window is closed early. 1681 */ 1682 @SuppressFBWarnings(value = "OVERRIDING_METHODS_MUST_INVOKE_SUPER", 1683 justification = "This calls doneButtonActionPerformed which handles window closing") 1684 @Override 1685 public void windowClosing(java.awt.event.WindowEvent e) { 1686 doneButtonActionPerformed(); 1687 } 1688 1689 /** 1690 * Method to set node parameters The node must exist, and be in 'curNode' 1691 * Also, the node type must be set and in 'nodeType' 1692 */ 1693 void setNodeParameters() { 1694 // set curNode type 1695 curNode.setNodeType(nodeType); 1696 1697 // get information for this node if it is an output node 1698 int numoutputbits = curNode.getNumOutputBitsPerCard(); 1699 if (numoutputbits > 0) { 1700 // set up output types 1701 for (int o = 0; o < numoutputbits; o++) { 1702 if (initialState[o].contentEquals(Bundle.getMessage("InitialStateOff"))) { 1703 curNode.setOutputInit(o, 0); 1704 } else { // if (initialState[o].contentEquals(Bundle.getMessage("InitialStateOn"))) { 1705 curNode.setOutputInit(o, 1); 1706 } 1707 1708 if (outputWired[o].contentEquals(Bundle.getMessage("OutputWiredNO"))) { 1709 curNode.setOutputWired(o, 0); 1710 } else { // if (outputWired[o].contentEquals(Bundle.getMessage("OutputWiredNC"))) { 1711 curNode.setOutputWired(o, 1); 1712 } 1713 1714 if (outputType[o].contentEquals(Bundle.getMessage("OutputTypeONOFF"))) { 1715 curNode.setOutputType(o, 0); 1716 } else { 1717 if (outputType[o].contentEquals(Bundle.getMessage("OutputTypePULSE"))) { 1718 curNode.setOutputType(o, 1); 1719 } else { // if (outputType[o].contentEquals(Bundle.getMessage("OutputTypeBLINK"))) { 1720 curNode.setOutputType(o, 2); 1721 } 1722 } 1723 1724 curNode.setOutputLength(o, Integer.parseInt(outputLength[o])); 1725 } 1726 } 1727 1728 // get information for this node if it is a sensor node 1729 int numsensorbits = curNode.getNumSensorBitsPerCard(); 1730 if (numsensorbits > 0) { 1731 1732 // set up sensor types 1733 for (int i = 0; i < numsensorbits; i++) { 1734 if (filterType[i].contentEquals(Bundle.getMessage("FilterTypeNoise"))) { 1735 curNode.setSensorType(i, 0); 1736 } else if (filterType[i].contentEquals(Bundle.getMessage("FilterTypeDebounce"))) { 1737 curNode.setSensorType(i, 1); 1738 } else if (filterType[i].contentEquals(Bundle.getMessage("FilterTypeCarGap"))) { 1739 curNode.setSensorType(i, 2); 1740 } else { // filterType[i].contentEquals(Bundle.getMessage("FilterTypeDirtyTrack")) 1741 curNode.setSensorType(i, 3); 1742 } 1743 1744 if (filterPolarity[i].contentEquals(Bundle.getMessage("FilterNormalPolarity"))) { 1745 curNode.setSensorPolarity(i, 0); 1746 } else { // filterPolarity[i].contentEquals(Bundle.getMessage("FilterInversePolarity")) 1747 curNode.setSensorPolarity(i, 1); 1748 } 1749 1750 curNode.setSensorThreshold(i, Integer.parseInt(filterThreshold[i])); 1751 } 1752 } 1753 1754 // Cause reinitialization of this Node to reflect these parameters 1755 _memo.getTrafficController().initializeAcelaNode(curNode); 1756 } 1757 1758 /** 1759 * Method to reset the notes error after error display 1760 */ 1761 private void resetNotes() { 1762 if (errorInStatus1) { 1763 if (editMode) { 1764 statusText1.setText(editStatus1); 1765 } else { 1766 statusText1.setText(stdStatus1); 1767 } 1768 errorInStatus1 = false; 1769 } 1770 resetNotes2(); 1771 } 1772 1773 /** 1774 * Reset the second line of Notes area 1775 */ 1776 private void resetNotes2() { 1777 if (errorInStatus2) { 1778 if (editMode) { 1779 statusText1.setText(editStatus2); 1780 } else { 1781 statusText2.setText(stdStatus2); 1782 } 1783 errorInStatus2 = false; 1784 } 1785 } 1786 1787 /** 1788 * Read node address and check for legal range If successful, a node address 1789 * in the range 0-255 is returned. If not successful, -1 is returned and an 1790 * appropriate error message is placed in statusText1. 1791 */ 1792 private int readNodeAddress() { 1793 int addr = -1; 1794 try { 1795 addr = nodeAddrBox.getSelectedIndex(); 1796// addr = Integer.parseInt(nodeAddrField.getText()); 1797 } catch (Exception e) { 1798 statusText1.setText(Bundle.getMessage("Error5")); 1799 statusText1.setVisible(true); 1800 errorInStatus1 = true; 1801 resetNotes2(); 1802 return -1; 1803 } 1804 if ((addr < 0) || (addr > 255)) { 1805 statusText1.setText(Bundle.getMessage("Error6")); 1806 statusText1.setVisible(true); 1807 errorInStatus1 = true; 1808 resetNotes2(); 1809 return -1; 1810 } 1811 return (addr); 1812 } 1813 1814 /** 1815 * Set up table for selecting sensor default parameters for Sentry or TBrain 1816 * nodes 1817 */ 1818// public class SensorConfigModel extends AbstractTableModel 1819 public class SensorConfigModel extends NodeConfigModel { 1820 1821 @Override 1822 public String getColumnName(int c) { 1823 return sensorConfigColumnNames[c]; 1824 } 1825 1826 @Override 1827 public Class<?> getColumnClass(int c) { 1828 return String.class; 1829 } 1830 1831 @Override 1832 public int getColumnCount() { 1833 return 5; 1834 } 1835 1836 @Override 1837 public int getRowCount() { 1838 return numrows; 1839 } 1840 1841 @Override 1842 public void setNumRows(int r) { 1843 numrows = r; 1844 } 1845 1846 @Override 1847 public void setEditMode(boolean b) { 1848 editmode = b; 1849 } 1850 1851 @Override 1852 public boolean getEditMode() { 1853 return editmode; 1854 } 1855 1856 @Override 1857 public Object getValueAt(int r, int c) { 1858 if (c == 0) { 1859 return Integer.toString(r); 1860 } else if (c == 1) { 1861 return filterType[r]; 1862 } else if (c == 2) { 1863 return filterPolarity[r]; 1864 } else if (c == 3) { 1865 return filterThreshold[r]; 1866 } else if (c == 4) { 1867 // Find Acela Node address 1868 nodeAddress = readNodeAddress(); 1869 if (nodeAddress < 0) { 1870 return Integer.toString(0); 1871 } 1872 // get the AcelaNode corresponding to this node address 1873 curNode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress); 1874 if (curNode == null) { 1875 statusText1.setText(Bundle.getMessage("Error4")); 1876 statusText1.setVisible(true); 1877 errorInStatus1 = true; 1878 resetNotes2(); 1879 return Integer.toString(0); 1880 } 1881 return Integer.toString(curNode.getStartingSensorAddress() + r); 1882 } 1883 return ""; 1884 } 1885 1886 @Override 1887 public void setValueAt(Object type, int r, int c) { 1888 if (c == 1) { 1889 filterType[r] = (String) type; 1890 } 1891 if (c == 2) { 1892 filterPolarity[r] = (String) type; 1893 } 1894 if (c == 3) { 1895 filterThreshold[r] = (String) type; 1896 } 1897 } 1898 1899 @Override 1900 public boolean isCellEditable(int r, int c) { 1901 if ((c == 1) && editmode) { 1902 return (true); 1903 } 1904 if ((c == 2) && editmode) { 1905 return (true); 1906 } 1907 if ((c == 3) && editmode) { 1908 return (true); 1909 } 1910 return (false); 1911 } 1912 1913 public static final int SENSORCIRCUITADDRESS_COLUMN = 0; 1914 public static final int TYPE_COLUMN = 1; 1915 public static final int POLARITY_COLUMN = 2; 1916 public static final int THRESHOLD_COLUMN = 3; 1917 public static final int SENSORADDRESS_COLUMN = 0; 1918 } 1919 private String[] sensorConfigColumnNames = {Bundle.getMessage("HeadingSensorCircuitAddress"), 1920 Bundle.getMessage("HeadingFilterType"), 1921 Bundle.getMessage("HeadingFilterPolarity"), 1922 Bundle.getMessage("HeadingFilterThreshold"), 1923 Bundle.getMessage("HeadingSensorAddress")}; 1924 private String[] filterType = new String[16]; 1925 private String[] filterPolarity = new String[16]; 1926 private String[] filterThreshold = new String[16]; 1927 1928 /** 1929 * Set up table for selecting output default parameters for Dash-8 or TBrain 1930 * nodes 1931 */ 1932 public class OutputConfigModel extends NodeConfigModel { 1933 1934 @Override 1935 public String getColumnName(int c) { 1936 return outputConfigColumnNames[c]; 1937 } 1938 1939 @Override 1940 public Class<?> getColumnClass(int c) { 1941 return String.class; 1942 } 1943 1944 @Override 1945 public int getColumnCount() { 1946 return 6; 1947 } 1948 1949 @Override 1950 public int getRowCount() { 1951 return numrows; 1952 } 1953 1954 @Override 1955 public void setNumRows(int r) { 1956 numrows = r; 1957 } 1958 1959 @Override 1960 public void setEditMode(boolean b) { 1961 editmode = b; 1962 } 1963 1964 @Override 1965 public boolean getEditMode() { 1966 return editmode; 1967 } 1968 1969 @Override 1970 public Object getValueAt(int r, int c) { 1971 if (c == 0) { 1972 return Integer.toString(r); 1973 } else if (c == 1) { 1974 return outputWired[r]; 1975 } else if (c == 2) { 1976 return initialState[r]; 1977 } else if (c == 3) { 1978 return outputType[r]; 1979 } else if (c == 4) { 1980 return outputLength[r]; 1981 } else if (c == 5) { 1982 // Find Acela Node address 1983 nodeAddress = readNodeAddress(); 1984 if (nodeAddress < 0) { 1985 return Integer.toString(0); 1986 } 1987 // get the AcelaNode corresponding to this node address 1988 curNode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress); 1989 if (curNode == null) { 1990 statusText1.setText(Bundle.getMessage("Error4")); 1991 statusText1.setVisible(true); 1992 errorInStatus1 = true; 1993 resetNotes2(); 1994 return Integer.toString(0); 1995 } 1996 return Integer.toString(curNode.getStartingOutputAddress() + r); 1997 } 1998 return ""; 1999 } 2000 2001 @Override 2002 public void setValueAt(Object type, int r, int c) { 2003 if (c == 1) { 2004 outputWired[r] = (String) type; 2005 } 2006 if (c == 2) { 2007 initialState[r] = (String) type; 2008 } 2009 if (c == 3) { 2010 outputType[r] = (String) type; 2011 } 2012 if (c == 4) { 2013 outputLength[r] = (String) type; 2014 } 2015 } 2016 2017 @Override 2018 public boolean isCellEditable(int r, int c) { 2019 if ((c == 1) && editmode) { 2020 return (true); 2021 } 2022 if ((c == 2) && editmode) { 2023 return (true); 2024 } 2025 if ((c == 3) && editmode) { 2026 return (true); 2027 } 2028 if ((c == 4) && editmode) { 2029 return (true); 2030 } 2031 return (false); 2032 } 2033 2034 public static final int OUTPUTCIRCUITADDRESS_COLUMN = 0; 2035 public static final int OUTPUTWIRED_COLUMN = 1; 2036 public static final int INITIALSTATE_COLUMN = 2; 2037 public static final int OUTPUTTYPE_COLUMN = 3; 2038 public static final int OUTPUTLENGTH_COLUMN = 4; 2039 public static final int OUTPUTADDRESS_COLUMN = 5; 2040 } 2041 private String[] outputConfigColumnNames = {Bundle.getMessage("HeadingOutputCircuitAddress"), 2042 Bundle.getMessage("HeadingOutputWired"), 2043 Bundle.getMessage("HeadingInitialState"), 2044 Bundle.getMessage("HeadingOutputType"), 2045 Bundle.getMessage("HeadingOutputLength"), 2046 Bundle.getMessage("HeadingOutputAddress")}; 2047 private String[] outputWired = new String[16]; 2048 private String[] initialState = new String[16]; 2049 private String[] outputType = new String[16]; 2050 private String[] outputLength = new String[16]; 2051 2052 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(NodeConfigFrame.class); 2053 2054}