001/* 002For this warning: 003Note: C:\Users\NetBeansJMRI\Documents\NetBeansProjects\CTCTest\src\packageTest\FrmMainForm.java uses unchecked or unsafe operations. 004Note: Recompile with -Xlint:unchecked for details. 005Do this: 006 Project Properties -> Build -> Compiling in "Additional compiler options" at the bottom: 007 put in "-Xlint:unchecked" 008 009https://stackoverflow.com/questions/494869/file-changed-listener-in-java 010https://blogs.oracle.com/thejavatutorials/watching-a-directory-for-changes-mdash-file-change-notification-in-nio2 011 012Set look and feel at design: 013https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 014At runtime (dynamic): 015https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html#dynamic 016*/ 017package jmri.jmrit.ctc.editor.gui; 018 019import jmri.jmrit.ctc.CTCFiles; 020import jmri.jmrit.ctc.configurexml.ImportExternalData; 021import jmri.jmrit.ctc.editor.code.Columns; 022import jmri.jmrit.ctc.editor.code.CodeButtonHandlerDataRoutines; 023import jmri.jmrit.ctc.editor.code.AwtWindowProperties; 024import jmri.jmrit.ctc.editor.code.CheckJMRIObject; 025import jmri.jmrit.ctc.editor.code.CommonSubs; 026import jmri.jmrit.ctc.editor.code.CreateGUIObjectsXMLFile; 027 028import jmri.jmrit.ctc.editor.code.ProgramProperties; 029import java.awt.Toolkit; 030import java.awt.event.KeyEvent; 031import java.awt.event.WindowAdapter; 032import java.awt.event.WindowEvent; 033 034import javax.swing.DefaultListModel; 035import javax.swing.JFrame; 036 037import javax.swing.KeyStroke; 038import jmri.InstanceManager; 039import jmri.jmrit.ctc.CtcManager; 040import jmri.jmrit.ctc.ctcserialdata.CTCSerialData; 041import jmri.jmrit.ctc.ctcserialdata.CodeButtonHandlerData; 042import jmri.jmrit.ctc.ctcserialdata.OtherData; 043import jmri.util.swing.JmriJOptionPane; 044 045/** 046 * 047 * @author Gregory J. Bedlek Copyright (C) 2018, 2019 048 */ 049public class FrmMainForm extends JFrame { 050 051 private static final String FORM_PROPERTIES = "FrmMainForm"; // NOI18N 052 private CTCSerialData _mCTCSerialData; 053 private Columns _mColumns; 054 private DefaultListModel<String> _mDefaultListModel; 055 private ProgramProperties _mProgramProperties; 056 private AwtWindowProperties _mAwtWindowProperties; 057 private CheckJMRIObject _mCheckJMRIObject; 058 059 private boolean _mAnySubFormOpen = false; // For any BUT FrmTRL_Rules 060 boolean _mTRL_RulesFormOpen = false; // for ONLY FrmTRL_Rules 061 062// @SuppressWarnings("LeakingThisInConstructor") // NOI18N Lazy, since this is NOT a multi-threaded program. 063 public FrmMainForm() { 064 super(); 065 InstanceManager.setDefault(jmri.jmrit.ctc.editor.gui.FrmMainForm.class, this); 066 CtcManager ctcManager = InstanceManager.getDefault(CtcManager.class); 067 _mProgramProperties = ctcManager.getProgramProperties(); 068 _mCTCSerialData = ctcManager.getCTCSerialData(); 069 initComponents(); 070 CommonSubs.addHelpMenu(this, "package.jmri.jmrit.ctc.CTC", true); // NOI18N 071 _mAwtWindowProperties = new AwtWindowProperties(this, "AwtWindowProperties.txt", FORM_PROPERTIES); // NOI18N 072 _mCheckJMRIObject = new CheckJMRIObject(); 073 setupEditor(); 074 _mImport.setEnabled(CTCFiles.fileExists("CTCSystem.xml")); // Disable import if there is no file 075 } 076 077 /** 078 * Create a platform specific accelerator key stroke 079 * @param keycode The integer value for the key from KeyEvent 080 * @return The key stroke with the platform's accelerator character 081 */ 082 @SuppressWarnings("deprecation") // getMenuShortcutKeyMask() 083 private KeyStroke getAccelerator(int keycode) { 084 int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(); 085 return KeyStroke.getKeyStroke(keycode, modifier); 086 } 087 088 /** 089 * This method is called from within the constructor to initialize the form. 090 * WARNING: Do NOT modify this code. The content of this method is always 091 * regenerated by the Form Editor. 092 * Note: The form editor will set the method private. It must be public. 093 */ 094 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 095 private void initComponents() { 096 097 jMenuItem1 = new javax.swing.JMenuItem(); 098 jMenu3 = new javax.swing.JMenu(); 099 jLabel1 = new javax.swing.JLabel(); 100 jScrollPane1 = new javax.swing.JScrollPane(); 101 _mPresentlyDefinedColumns = new javax.swing.JList<>(); 102 addButton = new javax.swing.JButton(); 103 deleteButton = new javax.swing.JButton(); 104 _mSIDI_Enabled = new javax.swing.JCheckBox(); 105 _mEdit_SIDI = new javax.swing.JButton(); 106 _mEdit_SIDI_Prompt = new javax.swing.JLabel(); 107 _mEdit_SIDL_Prompt = new javax.swing.JLabel(); 108 _mSIDL_Enabled = new javax.swing.JCheckBox(); 109 _mEdit_SIDL = new javax.swing.JButton(); 110 _mEdit_SWDI_Prompt = new javax.swing.JLabel(); 111 _mSWDI_Enabled = new javax.swing.JCheckBox(); 112 _mEdit_SWDI = new javax.swing.JButton(); 113 _mEdit_SWDL_Prompt = new javax.swing.JLabel(); 114 _mSWDL_Enabled = new javax.swing.JCheckBox(); 115 _mEdit_SWDL = new javax.swing.JButton(); 116 _mEdit_CO_Prompt = new javax.swing.JLabel(); 117 _mCO_Enabled = new javax.swing.JCheckBox(); 118 _mEdit_CO = new javax.swing.JButton(); 119 _mEdit_TUL_Prompt = new javax.swing.JLabel(); 120 _mTUL_Enabled = new javax.swing.JCheckBox(); 121 _mEdit_TUL = new javax.swing.JButton(); 122 _mEdit_IL_Prompt = new javax.swing.JLabel(); 123 _mIL_Enabled = new javax.swing.JCheckBox(); 124 _mEdit_IL = new javax.swing.JButton(); 125 _mEdit_TRL_Prompt = new javax.swing.JLabel(); 126 _mTRL_Enabled = new javax.swing.JCheckBox(); 127 _mEdit_TRL = new javax.swing.JButton(); 128 _mEdit_CB_Prompt = new javax.swing.JLabel(); 129 _mEdit_CB = new javax.swing.JButton(); 130 _mCB_EditAlwaysEnabled = new javax.swing.JLabel(); 131 changeNumbersButton = new javax.swing.JButton(); 132 _mButtonWriteXMLFiles = new javax.swing.JButton(); 133 _mMoveUp = new javax.swing.JButton(); 134 _mMoveDown = new javax.swing.JButton(); 135 jMenuBar1 = new javax.swing.JMenuBar(); 136 _mFile = new javax.swing.JMenu(); 137 _mNew = new javax.swing.JMenuItem(); 138 _mImport = new javax.swing.JMenuItem(); 139 _mEdit = new javax.swing.JMenu(); 140 _mFixErrors = new javax.swing.JMenuItem(); 141 _mConfigure = new javax.swing.JMenu(); 142 _mDebugging = new javax.swing.JMenuItem(); 143 _mDefaults = new javax.swing.JMenuItem(); 144 _mFleeting = new javax.swing.JMenuItem(); 145 _mPatterns = new javax.swing.JMenuItem(); 146 _mGUIDesign = new javax.swing.JMenuItem(); 147 _mHelp = new javax.swing.JMenu(); 148 _mHelpAbout = new javax.swing.JMenuItem(); 149 150 jMenuItem1.setText("jMenuItem1"); 151 152 jMenu3.setText("jMenu3"); 153 154 setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); 155 setLocation(new java.awt.Point(0, 0)); 156 addWindowListener(new java.awt.event.WindowAdapter() { 157 @Override 158 public void windowClosing(java.awt.event.WindowEvent evt) { 159 formWindowClosing(evt); 160 } 161 }); 162 163 jLabel1.setText(Bundle.getMessage("LabelDefined")); 164 165 _mPresentlyDefinedColumns.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); 166 _mPresentlyDefinedColumns.addListSelectionListener(new javax.swing.event.ListSelectionListener() { 167 @Override 168 public void valueChanged(javax.swing.event.ListSelectionEvent evt) { 169 _mPresentlyDefinedColumnsValueChanged(evt); 170 } 171 }); 172 jScrollPane1.setViewportView(_mPresentlyDefinedColumns); 173 174 addButton.setText(Bundle.getMessage("ButtonAdd")); 175 addButton.addActionListener(new java.awt.event.ActionListener() { 176 @Override 177 public void actionPerformed(java.awt.event.ActionEvent evt) { 178 addButtonActionPerformed(evt); 179 } 180 }); 181 182 deleteButton.setText(Bundle.getMessage("ButtonDelete")); 183 deleteButton.addActionListener(new java.awt.event.ActionListener() { 184 @Override 185 public void actionPerformed(java.awt.event.ActionEvent evt) { 186 deleteButtonActionPerformed(evt); 187 } 188 }); 189 190 _mSIDI_Enabled.setText(Bundle.getMessage("LabelEnabled")); 191 _mSIDI_Enabled.addActionListener(new java.awt.event.ActionListener() { 192 @Override 193 public void actionPerformed(java.awt.event.ActionEvent evt) { 194 _mSIDI_EnabledActionPerformed(evt); 195 } 196 }); 197 198 _mEdit_SIDI.setText(Bundle.getMessage("ButtonEdit")); 199 _mEdit_SIDI.addActionListener(new java.awt.event.ActionListener() { 200 @Override 201 public void actionPerformed(java.awt.event.ActionEvent evt) { 202 _mEdit_SIDIActionPerformed(evt); 203 } 204 }); 205 206 _mEdit_SIDI_Prompt.setText(Bundle.getMessage("LabelSignalIndicators")); 207 208 _mEdit_SIDL_Prompt.setText(Bundle.getMessage("LabelSignalLever")); 209 210 _mSIDL_Enabled.setText(Bundle.getMessage("LabelEnabled")); 211 _mSIDL_Enabled.addActionListener(new java.awt.event.ActionListener() { 212 @Override 213 public void actionPerformed(java.awt.event.ActionEvent evt) { 214 _mSIDL_EnabledActionPerformed(evt); 215 } 216 }); 217 218 _mEdit_SIDL.setText(Bundle.getMessage("ButtonEdit")); 219 _mEdit_SIDL.addActionListener(new java.awt.event.ActionListener() { 220 @Override 221 public void actionPerformed(java.awt.event.ActionEvent evt) { 222 _mEdit_SIDLActionPerformed(evt); 223 } 224 }); 225 226 _mEdit_SWDI_Prompt.setText(Bundle.getMessage("LabelSwitchIndicators")); 227 228 _mSWDI_Enabled.setText(Bundle.getMessage("LabelEnabled")); 229 _mSWDI_Enabled.addActionListener(new java.awt.event.ActionListener() { 230 @Override 231 public void actionPerformed(java.awt.event.ActionEvent evt) { 232 _mSWDI_EnabledActionPerformed(evt); 233 } 234 }); 235 236 _mEdit_SWDI.setText(Bundle.getMessage("ButtonEdit")); 237 _mEdit_SWDI.addActionListener(new java.awt.event.ActionListener() { 238 @Override 239 public void actionPerformed(java.awt.event.ActionEvent evt) { 240 _mEdit_SWDIActionPerformed(evt); 241 } 242 }); 243 244 _mEdit_SWDL_Prompt.setText(Bundle.getMessage("LabelSwitchLever")); 245 246 _mSWDL_Enabled.setText(Bundle.getMessage("LabelEnabled")); 247 _mSWDL_Enabled.addActionListener(new java.awt.event.ActionListener() { 248 @Override 249 public void actionPerformed(java.awt.event.ActionEvent evt) { 250 _mSWDL_EnabledActionPerformed(evt); 251 } 252 }); 253 254 _mEdit_SWDL.setText(Bundle.getMessage("ButtonEdit")); 255 _mEdit_SWDL.addActionListener(new java.awt.event.ActionListener() { 256 @Override 257 public void actionPerformed(java.awt.event.ActionEvent evt) { 258 _mEdit_SWDLActionPerformed(evt); 259 } 260 }); 261 262 _mEdit_CO_Prompt.setText(Bundle.getMessage("LabelCallOn")); 263 264 _mCO_Enabled.setText(Bundle.getMessage("LabelEnabled")); 265 _mCO_Enabled.addActionListener(new java.awt.event.ActionListener() { 266 @Override 267 public void actionPerformed(java.awt.event.ActionEvent evt) { 268 _mCO_EnabledActionPerformed(evt); 269 } 270 }); 271 272 _mEdit_CO.setText(Bundle.getMessage("ButtonEdit")); 273 _mEdit_CO.addActionListener(new java.awt.event.ActionListener() { 274 @Override 275 public void actionPerformed(java.awt.event.ActionEvent evt) { 276 _mEdit_COActionPerformed(evt); 277 } 278 }); 279 280 _mEdit_TUL_Prompt.setText(Bundle.getMessage("LabelTurnoutLock")); 281 282 _mTUL_Enabled.setText(Bundle.getMessage("LabelEnabled")); 283 _mTUL_Enabled.addActionListener(new java.awt.event.ActionListener() { 284 @Override 285 public void actionPerformed(java.awt.event.ActionEvent evt) { 286 _mTUL_EnabledActionPerformed(evt); 287 } 288 }); 289 290 _mEdit_TUL.setText(Bundle.getMessage("ButtonEdit")); 291 _mEdit_TUL.addActionListener(new java.awt.event.ActionListener() { 292 @Override 293 public void actionPerformed(java.awt.event.ActionEvent evt) { 294 _mEdit_TULActionPerformed(evt); 295 } 296 }); 297 298 _mEdit_IL_Prompt.setText(Bundle.getMessage("LabelIndicatorLock")); 299 300 _mIL_Enabled.setText(Bundle.getMessage("LabelEnabled")); 301 _mIL_Enabled.addActionListener(new java.awt.event.ActionListener() { 302 @Override 303 public void actionPerformed(java.awt.event.ActionEvent evt) { 304 _mIL_EnabledActionPerformed(evt); 305 } 306 }); 307 308 _mEdit_IL.setText(Bundle.getMessage("ButtonEdit")); 309 _mEdit_IL.addActionListener(new java.awt.event.ActionListener() { 310 @Override 311 public void actionPerformed(java.awt.event.ActionEvent evt) { 312 _mEdit_ILActionPerformed(evt); 313 } 314 }); 315 316 _mEdit_TRL_Prompt.setText(Bundle.getMessage("LabelTrafficLock")); 317 318 _mTRL_Enabled.setText(Bundle.getMessage("LabelEnabled")); 319 _mTRL_Enabled.addActionListener(new java.awt.event.ActionListener() { 320 @Override 321 public void actionPerformed(java.awt.event.ActionEvent evt) { 322 _mTRL_EnabledActionPerformed(evt); 323 } 324 }); 325 326 _mEdit_TRL.setText(Bundle.getMessage("ButtonEdit")); 327 _mEdit_TRL.addActionListener(new java.awt.event.ActionListener() { 328 @Override 329 public void actionPerformed(java.awt.event.ActionEvent evt) { 330 _mEdit_TRLActionPerformed(evt); 331 } 332 }); 333 334 _mEdit_CB_Prompt.setText(Bundle.getMessage("LabelCode")); 335 336 _mEdit_CB.setText(Bundle.getMessage("ButtonEdit")); 337 _mEdit_CB.addActionListener(new java.awt.event.ActionListener() { 338 @Override 339 public void actionPerformed(java.awt.event.ActionEvent evt) { 340 _mEdit_CBActionPerformed(evt); 341 } 342 }); 343 344 _mCB_EditAlwaysEnabled.setText(Bundle.getMessage("InfoEnabled")); 345 346 changeNumbersButton.setText(Bundle.getMessage("ButtonChange")); 347 changeNumbersButton.addActionListener(new java.awt.event.ActionListener() { 348 @Override 349 public void actionPerformed(java.awt.event.ActionEvent evt) { 350 changeNumbersButtonActionPerformed(evt); 351 } 352 }); 353 354 _mButtonWriteXMLFiles.setText(Bundle.getMessage("ButtonXmlFiles")); 355 _mButtonWriteXMLFiles.addActionListener(new java.awt.event.ActionListener() { 356 @Override 357 public void actionPerformed(java.awt.event.ActionEvent evt) { 358 _mButtonWriteXMLFilesActionPerformed(evt); 359 } 360 }); 361 362 _mMoveUp.setText(Bundle.getMessage("ButtonMoveUp")); 363 _mMoveUp.addActionListener(new java.awt.event.ActionListener() { 364 @Override 365 public void actionPerformed(java.awt.event.ActionEvent evt) { 366 _mMoveUpActionPerformed(evt); 367 } 368 }); 369 370 _mMoveDown.setText(Bundle.getMessage("ButtonMoveDown")); 371 _mMoveDown.addActionListener(new java.awt.event.ActionListener() { 372 @Override 373 public void actionPerformed(java.awt.event.ActionEvent evt) { 374 _mMoveDownActionPerformed(evt); 375 } 376 }); 377 378 _mFile.setText(Bundle.getMessage("MenuFile")); 379 380 _mNew.setAccelerator(getAccelerator(KeyEvent.VK_N)); 381 _mNew.setText(Bundle.getMessage("MenuNew")); 382 _mNew.addActionListener(new java.awt.event.ActionListener() { 383 @Override 384 public void actionPerformed(java.awt.event.ActionEvent evt) { 385 _mNewActionPerformed(evt); 386 } 387 }); 388 _mFile.add(_mNew); 389 390 _mImport.setText(Bundle.getMessage("MenuImport")); 391 _mImport.addActionListener(new java.awt.event.ActionListener() { 392 @Override 393 public void actionPerformed(java.awt.event.ActionEvent evt) { 394 _mImportActionPerformed(evt); 395 } 396 }); 397 _mFile.add(_mImport); 398 399 jMenuBar1.add(_mFile); 400 401 _mEdit.setText(Bundle.getMessage("MenuEdit")); 402 403 _mFixErrors.setText(Bundle.getMessage("MenuFix")); 404 _mFixErrors.addActionListener(new java.awt.event.ActionListener() { 405 @Override 406 public void actionPerformed(java.awt.event.ActionEvent evt) { 407 _mFixErrorsActionPerformed(evt); 408 } 409 }); 410 _mEdit.add(_mFixErrors); 411 412 jMenuBar1.add(_mEdit); 413 414 _mConfigure.setText(Bundle.getMessage("MenuConfigure")); 415 416 _mDebugging.setText(Bundle.getMessage("MenuDebugging")); 417 _mDebugging.addActionListener(new java.awt.event.ActionListener() { 418 @Override 419 public void actionPerformed(java.awt.event.ActionEvent evt) { 420 _mDebuggingActionPerformed(evt); 421 } 422 }); 423 _mConfigure.add(_mDebugging); 424 425 _mDefaults.setText(Bundle.getMessage("MenuDefaults")); 426 _mDefaults.addActionListener(new java.awt.event.ActionListener() { 427 @Override 428 public void actionPerformed(java.awt.event.ActionEvent evt) { 429 _mDefaultsActionPerformed(evt); 430 } 431 }); 432 _mConfigure.add(_mDefaults); 433 434 _mFleeting.setText(Bundle.getMessage("MenuFleeting")); 435 _mFleeting.addActionListener(new java.awt.event.ActionListener() { 436 @Override 437 public void actionPerformed(java.awt.event.ActionEvent evt) { 438 _mFleetingActionPerformed(evt); 439 } 440 }); 441 _mConfigure.add(_mFleeting); 442 443 _mPatterns.setText(Bundle.getMessage("MenuPatterns")); 444 _mPatterns.addActionListener(new java.awt.event.ActionListener() { 445 @Override 446 public void actionPerformed(java.awt.event.ActionEvent evt) { 447 _mPatternsActionPerformed(evt); 448 } 449 }); 450 _mConfigure.add(_mPatterns); 451 452 _mGUIDesign.setText(Bundle.getMessage("MenuDesign")); 453 _mGUIDesign.addActionListener(new java.awt.event.ActionListener() { 454 @Override 455 public void actionPerformed(java.awt.event.ActionEvent evt) { 456 _mGUIDesignActionPerformed(evt); 457 } 458 }); 459 _mConfigure.add(_mGUIDesign); 460 461 jMenuBar1.add(_mConfigure); 462 463 _mHelp.setText(Bundle.getMessage("MenuAbout")); 464 465 _mHelpAbout.setText(Bundle.getMessage("MenuAbout")); 466 _mHelpAbout.addActionListener(new java.awt.event.ActionListener() { 467 @Override 468 public void actionPerformed(java.awt.event.ActionEvent evt) { 469 _mHelpAboutActionPerformed(evt); 470 } 471 }); 472 _mHelp.add(_mHelpAbout); 473 474 jMenuBar1.add(_mHelp); 475 476 setJMenuBar(jMenuBar1); 477 478 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 479 getContentPane().setLayout(layout); 480 layout.setHorizontalGroup( 481 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 482 .addGroup(layout.createSequentialGroup() 483 .addContainerGap() 484 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 485 .addGroup(layout.createSequentialGroup() 486 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 487 .addGroup(layout.createSequentialGroup() 488 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 489 .addComponent(_mEdit_CB_Prompt) 490 .addComponent(_mEdit_CB) 491 .addComponent(_mCB_EditAlwaysEnabled)) 492 .addGap(27, 27, 27) 493 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 494 .addComponent(_mEdit_SIDI_Prompt) 495 .addComponent(_mSIDI_Enabled) 496 .addComponent(_mEdit_SIDI))) 497 .addGroup(layout.createSequentialGroup() 498 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 499 .addComponent(_mEdit_CO_Prompt) 500 .addComponent(_mCO_Enabled) 501 .addComponent(_mEdit_CO)) 502 .addGap(43, 43, 43) 503 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 504 .addComponent(_mEdit_TRL) 505 .addComponent(_mTRL_Enabled) 506 .addComponent(_mEdit_TRL_Prompt)))) 507 .addGap(18, 18, 18) 508 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 509 .addComponent(_mEdit_SIDL_Prompt) 510 .addComponent(_mSIDL_Enabled) 511 .addComponent(_mEdit_SIDL) 512 .addComponent(_mEdit_TUL_Prompt) 513 .addComponent(_mTUL_Enabled) 514 .addComponent(_mEdit_TUL)) 515 .addGap(18, 18, 18) 516 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 517 .addComponent(_mEdit_IL) 518 .addComponent(_mIL_Enabled) 519 .addComponent(_mEdit_IL_Prompt) 520 .addGroup(layout.createSequentialGroup() 521 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 522 .addComponent(_mEdit_SWDI_Prompt) 523 .addComponent(_mSWDI_Enabled) 524 .addComponent(_mEdit_SWDI)) 525 .addGap(18, 18, 18) 526 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 527 .addComponent(_mEdit_SWDL) 528 .addComponent(_mSWDL_Enabled) 529 .addComponent(_mEdit_SWDL_Prompt)))) 530 .addGap(0, 228, Short.MAX_VALUE)) 531 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 532 .addComponent(jLabel1) 533 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 534 .addGroup(layout.createSequentialGroup() 535 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 662, javax.swing.GroupLayout.PREFERRED_SIZE) 536 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 537 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 538 .addGroup(layout.createSequentialGroup() 539 .addComponent(_mButtonWriteXMLFiles, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE) 540 .addContainerGap(12, Short.MAX_VALUE)) 541 .addGroup(layout.createSequentialGroup() 542 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 543 .addGroup(layout.createSequentialGroup() 544 .addGap(4, 4, 4) 545 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 546 .addComponent(addButton) 547 .addComponent(deleteButton))) 548 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 549 .addComponent(_mMoveUp, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 550 .addComponent(_mMoveDown, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 551 .addComponent(changeNumbersButton, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)) 552 .addGap(0, 0, Short.MAX_VALUE)))))) 553 ); 554 layout.setVerticalGroup( 555 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 556 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 557 .addContainerGap() 558 .addComponent(jLabel1) 559 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 560 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 561 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE) 562 .addGroup(layout.createSequentialGroup() 563 .addComponent(addButton) 564 .addGap(18, 18, 18) 565 .addComponent(deleteButton) 566 .addGap(18, 18, 18) 567 .addComponent(changeNumbersButton) 568 .addGap(18, 18, 18) 569 .addComponent(_mMoveUp) 570 .addGap(18, 18, 18) 571 .addComponent(_mMoveDown) 572 .addGap(18, 18, 18) 573 .addComponent(_mButtonWriteXMLFiles))) 574 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 575 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 576 .addComponent(_mEdit_CB_Prompt) 577 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 578 .addComponent(_mEdit_SIDI_Prompt) 579 .addComponent(_mEdit_SIDL_Prompt) 580 .addComponent(_mEdit_SWDI_Prompt) 581 .addComponent(_mEdit_SWDL_Prompt))) 582 .addGap(3, 3, 3) 583 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 584 .addComponent(_mSIDI_Enabled) 585 .addComponent(_mSIDL_Enabled) 586 .addComponent(_mSWDI_Enabled) 587 .addComponent(_mSWDL_Enabled) 588 .addComponent(_mCB_EditAlwaysEnabled)) 589 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 590 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 591 .addComponent(_mEdit_SIDI) 592 .addComponent(_mEdit_SIDL) 593 .addComponent(_mEdit_SWDI) 594 .addComponent(_mEdit_SWDL) 595 .addComponent(_mEdit_CB)) 596 .addGap(18, 18, 18) 597 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 598 .addComponent(_mEdit_CO_Prompt) 599 .addComponent(_mEdit_TRL_Prompt) 600 .addComponent(_mEdit_TUL_Prompt) 601 .addComponent(_mEdit_IL_Prompt)) 602 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 603 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 604 .addComponent(_mCO_Enabled) 605 .addComponent(_mTRL_Enabled) 606 .addComponent(_mTUL_Enabled) 607 .addComponent(_mIL_Enabled)) 608 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 609 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 610 .addComponent(_mEdit_CO) 611 .addComponent(_mEdit_TRL) 612 .addComponent(_mEdit_TUL) 613 .addComponent(_mEdit_IL)) 614 .addContainerGap(20, Short.MAX_VALUE)) 615 ); 616 617 pack(); 618 }// </editor-fold>//GEN-END:initComponents 619 620 public void shutdown() { 621 jmri.InstanceManager.reset(jmri.jmrit.ctc.editor.gui.FrmMainForm.class); 622 dispose(); 623 } 624 625 private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed 626 if (_mAnySubFormOpen) return; 627 _mAnySubFormOpen = true; 628// Pre-scan and find the highest switch number used so far, and highest column number: 629 int highestSwitchNumber = _mCTCSerialData.findHighestSwitchNumberUsedSoFar(); 630 int highestColumnNumber = _mCTCSerialData.findHighestColumnNumberUsedSoFar(); 631 FrmAddModifyCTCColumn dialog = new FrmAddModifyCTCColumn(_mAwtWindowProperties, _mColumns, false, highestSwitchNumber + 2, highestColumnNumber + 1, false); 632 dialog.addWindowListener(new WindowAdapter() { 633 @Override 634 public void windowClosed(WindowEvent e) { 635 if (dialog.closedNormally()) { 636 _mCTCSerialData.addCodeButtonHandlerData(CodeButtonHandlerDataRoutines.createNewCodeButtonHandlerData(_mCTCSerialData.getUniqueNumber(), dialog._mNewSwitchNumber, dialog._mNewSignalEtcNumber, dialog._mNewGUIColumnNumber, _mProgramProperties)); 637 _mColumns.updateFrame(); 638 } 639 _mAnySubFormOpen = false; 640 } 641 }); 642 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 643 }//GEN-LAST:event_addButtonActionPerformed 644 645 private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed 646 if ((_mPresentlyDefinedColumns.getSelectedValue()).contains(Columns.REFERENCES_PRESENT_INDICATOR)) { 647 JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("FrmMainFormReferencesExist")); // NOI18N 648 return; // Do nothing! 649 } 650 int selectedIndex = _mPresentlyDefinedColumns.getSelectedIndex(); 651 if (selectedIndex != -1) { // Safety: 652 _mCTCSerialData.removeCodeButtonHandlerData(selectedIndex); 653 _mColumns.updateFrame(); 654 } 655 }//GEN-LAST:event_deleteButtonActionPerformed 656 657 private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing 658 if (!validToExitAtThisTime(Bundle.getMessage("FrmMainFormExitError1"))) return; // NOI18N 659 _mAwtWindowProperties.saveWindowStateAndClose(this, FORM_PROPERTIES); 660 shutdown(); 661 }//GEN-LAST:event_formWindowClosing 662 663 private boolean validToExitAtThisTime(String whatIsTriggeringSave) { 664 if (_mColumns.anyErrorsPresent()) { 665 JmriJOptionPane.showMessageDialog(this, 666 Bundle.getMessage("FrmMainFormValidError1") + whatIsTriggeringSave + Bundle.getMessage("FrmMainFormValidError2"), 667 Bundle.getMessage("FrmMainFormValidError3"), 668 JmriJOptionPane.ERROR_MESSAGE); // NOI18N 669 return false; 670 } 671 return true; 672 } 673 674 private void _mPresentlyDefinedColumnsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event__mPresentlyDefinedColumnsValueChanged 675 if (!evt.getValueIsAdjusting()) { // returns false is FINAL in chain. 676 int selectedIndex = _mPresentlyDefinedColumns.getSelectedIndex(); 677// I guess at some level this makes sense: 678// It seems that "_mDefaultListModel.clear();" and "_mDefaultListModel.addElement..." BOTH 679// causes this routine to be called repeatedly with a -1 each time for selectedIndex. In fact, for EACH 680// "_mDefaultListModel.addElement..." it calls us with -1. Go figure! Why -1 in that case? 681// Isn't one being added that makes sense at a value >= 0? Then why call us at all? Sigh...... 682// I'm used to other languages (C, C++, C#) that don't do this. 683 _mColumns.setEntrySelected(selectedIndex); 684 } 685 }//GEN-LAST:event__mPresentlyDefinedColumnsValueChanged 686 687 private void _mSIDI_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mSIDI_EnabledActionPerformed 688 _mColumns.sidi_EnabledClicked(_mSIDI_Enabled.isSelected()); 689 }//GEN-LAST:event__mSIDI_EnabledActionPerformed 690 691 private void _mSIDL_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mSIDL_EnabledActionPerformed 692 _mColumns.sidl_EnabledClicked(_mSIDL_Enabled.isSelected()); 693 }//GEN-LAST:event__mSIDL_EnabledActionPerformed 694 695 private void _mSWDI_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mSWDI_EnabledActionPerformed 696 _mColumns.swdi_EnabledClicked(_mSWDI_Enabled.isSelected()); 697 }//GEN-LAST:event__mSWDI_EnabledActionPerformed 698 699 private void _mSWDL_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mSWDL_EnabledActionPerformed 700 _mColumns.swdl_EnabledClicked(_mSWDL_Enabled.isSelected()); 701 }//GEN-LAST:event__mSWDL_EnabledActionPerformed 702 703 private void _mCO_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mCO_EnabledActionPerformed 704 _mColumns.co_EnabledClicked(_mCO_Enabled.isSelected()); 705 }//GEN-LAST:event__mCO_EnabledActionPerformed 706 707 private void _mTUL_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mTUL_EnabledActionPerformed 708 _mColumns.tul_EnabledClicked(_mTUL_Enabled.isSelected()); 709 }//GEN-LAST:event__mTUL_EnabledActionPerformed 710 711 private void _mIL_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mIL_EnabledActionPerformed 712 _mColumns.il_EnabledClicked(_mIL_Enabled.isSelected()); 713 }//GEN-LAST:event__mIL_EnabledActionPerformed 714 715 private void _mEdit_SIDIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_SIDIActionPerformed 716 if (_mAnySubFormOpen) return; 717 _mAnySubFormOpen = true; 718 FrmSIDI dialog = new FrmSIDI( _mAwtWindowProperties, _mColumns.getSelectedCodeButtonHandlerData(), _mProgramProperties, _mCheckJMRIObject, 719 _mCTCSerialData.getOtherData()._mSignalSystemType == OtherData.SIGNAL_SYSTEM_TYPE.SIGNALHEAD); 720 dialog.addWindowListener(new WindowAdapter() { 721 @Override 722 public void windowClosed(WindowEvent e) { 723 if (dialog.closedNormally()) { 724 _mColumns.updateFrame(); 725 } 726 _mAnySubFormOpen = false; 727 } 728 }); 729 dialog.setVisible(true); 730 }//GEN-LAST:event__mEdit_SIDIActionPerformed 731 732 private void _mEdit_SIDLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_SIDLActionPerformed 733 if (_mAnySubFormOpen) return; 734 _mAnySubFormOpen = true; 735 FrmSIDL dialog = new FrmSIDL(_mAwtWindowProperties, _mColumns.getSelectedCodeButtonHandlerData(), _mProgramProperties, _mCheckJMRIObject); 736 dialog.addWindowListener(new WindowAdapter() { 737 @Override 738 public void windowClosed(WindowEvent e) { 739 if (dialog.closedNormally()) { 740 _mColumns.updateFrame(); 741 } 742 _mAnySubFormOpen = false; 743 } 744 }); 745 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 746 }//GEN-LAST:event__mEdit_SIDLActionPerformed 747 748 private void _mEdit_SWDIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_SWDIActionPerformed 749 if (_mAnySubFormOpen) return; 750 _mAnySubFormOpen = true; 751 FrmSWDI dialog = new FrmSWDI(_mAwtWindowProperties, _mColumns.getSelectedCodeButtonHandlerData(), _mProgramProperties, _mCheckJMRIObject); 752 dialog.addWindowListener(new WindowAdapter() { 753 @Override 754 public void windowClosed(WindowEvent e) { 755 if (dialog.closedNormally()) { 756 _mColumns.updateFrame(); 757 } 758 _mAnySubFormOpen = false; 759 } 760 }); 761 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 762 }//GEN-LAST:event__mEdit_SWDIActionPerformed 763 764 private void _mEdit_SWDLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_SWDLActionPerformed 765 if (_mAnySubFormOpen) return; 766 _mAnySubFormOpen = true; 767 FrmSWDL dialog = new FrmSWDL(_mAwtWindowProperties, _mColumns.getSelectedCodeButtonHandlerData(), _mProgramProperties, _mCheckJMRIObject); 768 dialog.addWindowListener(new WindowAdapter() { 769 @Override 770 public void windowClosed(WindowEvent e) { 771 if (dialog.closedNormally()) { 772 _mColumns.updateFrame(); 773 } 774 _mAnySubFormOpen = false; 775 } 776 }); 777 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 778 }//GEN-LAST:event__mEdit_SWDLActionPerformed 779 780 private void _mEdit_COActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_COActionPerformed 781 if (_mAnySubFormOpen) return; 782 _mAnySubFormOpen = true; 783 FrmCO dialog = new FrmCO( _mAwtWindowProperties, _mColumns.getSelectedCodeButtonHandlerData(), 784 _mProgramProperties, _mCTCSerialData, _mCheckJMRIObject, 785 _mCTCSerialData.getOtherData()._mSignalSystemType == OtherData.SIGNAL_SYSTEM_TYPE.SIGNALHEAD); 786 dialog.addWindowListener(new WindowAdapter() { 787 @Override 788 public void windowClosed(WindowEvent e) { 789 if (dialog.closedNormally()) { 790 _mColumns.updateFrame(); 791 } 792 _mAnySubFormOpen = false; 793 } 794 }); 795 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 796 }//GEN-LAST:event__mEdit_COActionPerformed 797 798 private void _mEdit_TULActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_TULActionPerformed 799 if (_mAnySubFormOpen) return; 800 _mAnySubFormOpen = true; 801 FrmTUL dialog = new FrmTUL(_mAwtWindowProperties, _mCTCSerialData, _mColumns.getSelectedCodeButtonHandlerData(), _mProgramProperties, _mCheckJMRIObject); 802 dialog.addWindowListener(new WindowAdapter() { 803 @Override 804 public void windowClosed(WindowEvent e) { 805 if (dialog.closedNormally()) { 806 _mColumns.updateFrame(); 807 } 808 _mAnySubFormOpen = false; 809 } 810 }); 811 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 812 }//GEN-LAST:event__mEdit_TULActionPerformed 813 814 private void _mEdit_ILActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_ILActionPerformed 815 if (_mAnySubFormOpen) return; 816 _mAnySubFormOpen = true; 817 FrmIL dialog = new FrmIL( _mAwtWindowProperties, _mColumns.getSelectedCodeButtonHandlerData(), _mCheckJMRIObject, 818 _mCTCSerialData.getOtherData()._mSignalSystemType == OtherData.SIGNAL_SYSTEM_TYPE.SIGNALHEAD, 819 _mCTCSerialData); 820 dialog.addWindowListener(new WindowAdapter() { 821 @Override 822 public void windowClosed(WindowEvent e) { 823 if (dialog.closedNormally()) { 824 _mColumns.updateFrame(); 825 } 826 _mAnySubFormOpen = false; 827 } 828 }); 829 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 830 }//GEN-LAST:event__mEdit_ILActionPerformed 831 832 private void _mTRL_EnabledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mTRL_EnabledActionPerformed 833 _mColumns.trl_EnabledClicked(_mTRL_Enabled.isSelected()); 834 }//GEN-LAST:event__mTRL_EnabledActionPerformed 835 836 private void _mEdit_TRLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_TRLActionPerformed 837 if (_mAnySubFormOpen) return; 838 _mAnySubFormOpen = true; 839 CodeButtonHandlerData codeButtonHandlerDataSelected = _mColumns.getSelectedCodeButtonHandlerData(); 840 FrmTRL dialog = new FrmTRL( _mAwtWindowProperties, codeButtonHandlerDataSelected, 841 _mCTCSerialData, _mCheckJMRIObject); 842 dialog.addWindowListener(new WindowAdapter() { 843 @Override 844 public void windowClosed(WindowEvent e) { 845 if (dialog.closedNormally()) { 846 _mColumns.updateFrame(); 847 } 848 _mAnySubFormOpen = false; 849 } 850 }); 851 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 852 }//GEN-LAST:event__mEdit_TRLActionPerformed 853 854 private void _mEdit_CBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mEdit_CBActionPerformed 855 if (_mAnySubFormOpen) return; 856 _mAnySubFormOpen = true; 857 FrmCB dialog = new FrmCB( _mAwtWindowProperties, _mColumns.getSelectedCodeButtonHandlerData(), 858 _mProgramProperties, _mCTCSerialData, _mCheckJMRIObject); 859 dialog.addWindowListener(new WindowAdapter() { 860 @Override 861 public void windowClosed(WindowEvent e) { 862 if (dialog.closedNormally()) { 863 _mColumns.updateFrame(); 864 } 865 _mAnySubFormOpen = false; 866 } 867 }); 868 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 869 }//GEN-LAST:event__mEdit_CBActionPerformed 870 871 private void changeNumbersButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeNumbersButtonActionPerformed 872 if (_mAnySubFormOpen) return; 873 _mAnySubFormOpen = true; 874 CodeButtonHandlerData temp = _mColumns.getSelectedCodeButtonHandlerData(); 875 FrmAddModifyCTCColumn dialog = new FrmAddModifyCTCColumn(_mAwtWindowProperties, _mColumns, true, temp._mSwitchNumber, temp._mGUIColumnNumber, temp._mGUIGeneratedAtLeastOnceAlready); 876 dialog.addWindowListener(new WindowAdapter() { 877 @Override 878 public void windowClosed(WindowEvent e) { 879 if (dialog.closedNormally()) { 880 _mCTCSerialData.updateSwitchAndSignalEtcNumbersEverywhere(_mColumns.getEntrySelectedIndex(), dialog._mNewSwitchNumber, dialog._mNewSignalEtcNumber, dialog._mNewGUIColumnNumber, dialog._mNewGUIGeneratedAtLeastOnceAlready); 881 882 CodeButtonHandlerData codeButtonHandlerData = _mCTCSerialData.getCodeButtonHandlerData(_mColumns.getEntrySelectedIndex()); 883 CodeButtonHandlerDataRoutines.updateExistingCodeButtonHandlerDataWithSubstitutedData(_mProgramProperties, codeButtonHandlerData); 884 885 _mColumns.updateFrame(); 886 } 887 _mAnySubFormOpen = false; 888 } 889 }); 890 dialog.setVisible(true); // MUST BE AFTER "addWindowListener"! BUG IN AWT/SWING! 891 }//GEN-LAST:event_changeNumbersButtonActionPerformed 892 893 private void _mButtonWriteXMLFilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mButtonWriteXMLFilesActionPerformed 894 CreateGUIObjectsXMLFile.writeGUIObjects(); 895 _mColumns.updateFrame(); 896 }//GEN-LAST:event__mButtonWriteXMLFilesActionPerformed 897 898 private void setupEditor() { 899 setTitle(Bundle.getMessage("TitleMainForm")); // NOI18N 900 _mDefaultListModel = new DefaultListModel<>(); 901 _mPresentlyDefinedColumns.setModel(_mDefaultListModel); 902 _mColumns = new Columns(_mCTCSerialData, _mCheckJMRIObject, _mDefaultListModel, 903 deleteButton, changeNumbersButton, 904 _mMoveUp, _mMoveDown, 905 _mEdit_CB_Prompt, _mCB_EditAlwaysEnabled, _mEdit_CB, 906 _mEdit_SIDI_Prompt, _mSIDI_Enabled, _mEdit_SIDI, 907 _mEdit_SIDL_Prompt, _mSIDL_Enabled, _mEdit_SIDL, 908 _mEdit_SWDI_Prompt, _mSWDI_Enabled, _mEdit_SWDI, 909 _mEdit_SWDL_Prompt, _mSWDL_Enabled, _mEdit_SWDL, 910 _mEdit_CO_Prompt, _mCO_Enabled, _mEdit_CO, 911 _mEdit_TRL_Prompt, _mTRL_Enabled, _mEdit_TRL, 912 _mEdit_TUL_Prompt, _mTUL_Enabled, _mEdit_TUL, 913 _mEdit_IL_Prompt, _mIL_Enabled, _mEdit_IL); 914 } 915 916 private void _mNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mNewActionPerformed 917 int response = JmriJOptionPane.showConfirmDialog(this, 918 Bundle.getMessage("NewConfigWarning"), // config will be removed, continue ? 919 Bundle.getMessage("NewConfigTitle"), 920 JmriJOptionPane.YES_NO_OPTION); 921 if (response != JmriJOptionPane.YES_OPTION ) return; 922 923 CtcManager ctcManager = InstanceManager.getDefault(CtcManager.class); 924 _mProgramProperties = ctcManager.newProgramProperties(); 925 _mCTCSerialData = ctcManager.newCTCSerialData(); 926 setupEditor(); 927 }//GEN-LAST:event__mNewActionPerformed 928 929 private void _mImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mImportActionPerformed 930 int response = JmriJOptionPane.showConfirmDialog(this, 931 Bundle.getMessage("ImportWarning"), // config will be replaced, continue ? 932 Bundle.getMessage("ImportTitle"), 933 JmriJOptionPane.YES_NO_OPTION); 934 if (response != JmriJOptionPane.YES_OPTION ) return; 935 936 CtcManager ctcManager = InstanceManager.getDefault(CtcManager.class); 937 _mProgramProperties = ctcManager.newProgramProperties(); 938 _mCTCSerialData = ctcManager.newCTCSerialData(); 939 ImportExternalData.loadExternalData(); 940 _mImport.setEnabled(CTCFiles.fileExists("CTCSystem.xml")); // Disable import if there is no file 941 setupEditor(); 942 }//GEN-LAST:event__mImportActionPerformed 943 944 private void _mFleetingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mFleetingActionPerformed 945 if (_mAnySubFormOpen) return; 946 _mAnySubFormOpen = true; 947 FrmFleeting dialog = new FrmFleeting(_mAwtWindowProperties, _mCTCSerialData.getOtherData()); 948 dialog.setVisible(true); 949 dialog.addWindowListener(new WindowAdapter() { 950 @Override 951 public void windowClosed(WindowEvent e) { 952 _mAnySubFormOpen = false; 953 } 954 }); 955 }//GEN-LAST:event__mFleetingActionPerformed 956 957 private void _mPatternsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mPatternsActionPerformed 958 if (_mAnySubFormOpen) return; 959 _mAnySubFormOpen = true; 960 FrmPatterns dialog = new FrmPatterns(_mAwtWindowProperties, _mProgramProperties); 961 dialog.setVisible(true); 962 dialog.addWindowListener(new WindowAdapter() { 963 @Override 964 public void windowClosed(WindowEvent e) { 965 _mAnySubFormOpen = false; 966 } 967 }); 968 }//GEN-LAST:event__mPatternsActionPerformed 969 970 private void _mDefaultsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mDefaultsActionPerformed 971 if (_mAnySubFormOpen) return; 972 _mAnySubFormOpen = true; 973 FrmDefaults dialog = new FrmDefaults(_mAwtWindowProperties, _mProgramProperties, _mCTCSerialData.getOtherData()); 974 dialog.setVisible(true); 975 dialog.addWindowListener(new WindowAdapter() { 976 @Override 977 public void windowClosed(WindowEvent e) { 978 _mAnySubFormOpen = false; 979 } 980 }); 981 }//GEN-LAST:event__mDefaultsActionPerformed 982 983 private void _mDebuggingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mDebuggingActionPerformed 984 if (_mAnySubFormOpen) return; 985 _mAnySubFormOpen = true; 986 FrmDebugging dialog = new FrmDebugging(_mAwtWindowProperties, _mCTCSerialData.getOtherData()); 987 dialog.setVisible(true); 988 dialog.addWindowListener(new WindowAdapter() { 989 @Override 990 public void windowClosed(WindowEvent e) { 991 _mAnySubFormOpen = false; 992 } 993 }); 994 }//GEN-LAST:event__mDebuggingActionPerformed 995 996 private void _mGUIDesignActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mGUIDesignActionPerformed 997 if (_mAnySubFormOpen) return; 998 _mAnySubFormOpen = true; 999 FrmGUIDesign dialog = new FrmGUIDesign(_mAwtWindowProperties, _mCTCSerialData.getOtherData()); 1000 dialog.setVisible(true); 1001 dialog.addWindowListener(new WindowAdapter() { 1002 @Override 1003 public void windowClosed(WindowEvent e) { 1004 _mAnySubFormOpen = false; 1005 } 1006 }); 1007 }//GEN-LAST:event__mGUIDesignActionPerformed 1008 1009 private void _mMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mMoveUpActionPerformed 1010 int selectedIndex = _mPresentlyDefinedColumns.getSelectedIndex(); 1011 if (selectedIndex != -1) { // Safety: 1012 _mCTCSerialData.moveUp(selectedIndex); 1013 _mColumns.updateFrame(); 1014 if (selectedIndex > 0) selectedIndex--; 1015 _mPresentlyDefinedColumns.setSelectedIndex(selectedIndex); 1016 } 1017 }//GEN-LAST:event__mMoveUpActionPerformed 1018 1019 private void _mMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mMoveDownActionPerformed 1020 int selectedIndex = _mPresentlyDefinedColumns.getSelectedIndex(); 1021 if (selectedIndex != -1) { // Safety: 1022 _mCTCSerialData.moveDown(selectedIndex); 1023 _mColumns.updateFrame(); 1024 if (selectedIndex != _mCTCSerialData.getCodeButtonHandlerDataSize() - 1) selectedIndex++; 1025 _mPresentlyDefinedColumns.setSelectedIndex(selectedIndex); 1026 } 1027 }//GEN-LAST:event__mMoveDownActionPerformed 1028 1029 private void _mFixErrorsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mFixErrorsActionPerformed 1030 if (_mAnySubFormOpen) return; 1031 _mAnySubFormOpen = true; 1032 FrmFixErrors dialog = new FrmFixErrors(_mAwtWindowProperties, _mColumns); 1033 dialog.setVisible(true); 1034 dialog.addWindowListener(new WindowAdapter() { 1035 @Override 1036 public void windowClosed(WindowEvent e) { 1037 _mAnySubFormOpen = false; 1038 } 1039 }); 1040 }//GEN-LAST:event__mFixErrorsActionPerformed 1041 1042 private void _mHelpAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mHelpAboutActionPerformed 1043 if (_mAnySubFormOpen) return; 1044 _mAnySubFormOpen = true; 1045 FrmAbout dialog = new FrmAbout(_mAwtWindowProperties); 1046 dialog.setVisible(true); 1047 dialog.addWindowListener(new WindowAdapter() { 1048 @Override 1049 public void windowClosed(WindowEvent e) { 1050 _mAnySubFormOpen = false; 1051 } 1052 }); 1053 }//GEN-LAST:event__mHelpAboutActionPerformed 1054 1055 // Variables declaration - do not modify//GEN-BEGIN:variables 1056 private javax.swing.JButton _mButtonWriteXMLFiles; 1057 private javax.swing.JLabel _mCB_EditAlwaysEnabled; 1058 private javax.swing.JCheckBox _mCO_Enabled; 1059 private javax.swing.JMenu _mConfigure; 1060 private javax.swing.JMenuItem _mDebugging; 1061 private javax.swing.JMenuItem _mDefaults; 1062 private javax.swing.JMenu _mEdit; 1063 private javax.swing.JButton _mEdit_CB; 1064 private javax.swing.JLabel _mEdit_CB_Prompt; 1065 private javax.swing.JButton _mEdit_CO; 1066 private javax.swing.JLabel _mEdit_CO_Prompt; 1067 private javax.swing.JButton _mEdit_IL; 1068 private javax.swing.JLabel _mEdit_IL_Prompt; 1069 private javax.swing.JButton _mEdit_SIDI; 1070 private javax.swing.JLabel _mEdit_SIDI_Prompt; 1071 private javax.swing.JButton _mEdit_SIDL; 1072 private javax.swing.JLabel _mEdit_SIDL_Prompt; 1073 private javax.swing.JButton _mEdit_SWDI; 1074 private javax.swing.JLabel _mEdit_SWDI_Prompt; 1075 private javax.swing.JButton _mEdit_SWDL; 1076 private javax.swing.JLabel _mEdit_SWDL_Prompt; 1077 private javax.swing.JButton _mEdit_TRL; 1078 private javax.swing.JLabel _mEdit_TRL_Prompt; 1079 private javax.swing.JButton _mEdit_TUL; 1080 private javax.swing.JLabel _mEdit_TUL_Prompt; 1081 private javax.swing.JMenu _mFile; 1082 private javax.swing.JMenuItem _mFixErrors; 1083 private javax.swing.JMenuItem _mFleeting; 1084 private javax.swing.JMenuItem _mGUIDesign; 1085 private javax.swing.JMenu _mHelp; 1086 private javax.swing.JMenuItem _mHelpAbout; 1087 private javax.swing.JCheckBox _mIL_Enabled; 1088 private javax.swing.JMenuItem _mImport; 1089 private javax.swing.JButton _mMoveDown; 1090 private javax.swing.JButton _mMoveUp; 1091 private javax.swing.JMenuItem _mNew; 1092 private javax.swing.JMenuItem _mPatterns; 1093 private javax.swing.JList<String> _mPresentlyDefinedColumns; 1094 private javax.swing.JCheckBox _mSIDI_Enabled; 1095 private javax.swing.JCheckBox _mSIDL_Enabled; 1096 private javax.swing.JCheckBox _mSWDI_Enabled; 1097 private javax.swing.JCheckBox _mSWDL_Enabled; 1098 private javax.swing.JCheckBox _mTRL_Enabled; 1099 private javax.swing.JCheckBox _mTUL_Enabled; 1100 private javax.swing.JButton addButton; 1101 private javax.swing.JButton changeNumbersButton; 1102 private javax.swing.JButton deleteButton; 1103 private javax.swing.JLabel jLabel1; 1104 private javax.swing.JMenu jMenu3; 1105 private javax.swing.JMenuBar jMenuBar1; 1106 private javax.swing.JMenuItem jMenuItem1; 1107 private javax.swing.JScrollPane jScrollPane1; 1108 // End of variables declaration//GEN-END:variables 1109}