001package jmri.jmrix.ecos.swing.preferences; 002 003//import jmri.InstanceManager; 004import java.awt.Component; 005import java.awt.event.ActionEvent; 006import java.awt.event.ActionListener; 007import java.beans.PropertyChangeListener; 008import javax.swing.BoxLayout; 009import javax.swing.ButtonGroup; 010import javax.swing.JButton; 011import javax.swing.JCheckBox; 012import javax.swing.JComboBox; 013import javax.swing.JComponent; 014import javax.swing.JLabel; 015import javax.swing.JPanel; 016import javax.swing.JRadioButton; 017import javax.swing.JSeparator; 018import javax.swing.JTabbedPane; 019import javax.swing.JTextField; 020import javax.swing.SwingConstants; 021import jmri.ConfigureManager; 022import jmri.jmrix.ecos.EcosPreferences; 023import jmri.swing.PreferencesPanel; 024 025/** 026 * Pane to show ECoS preferences 027 * 028 * @author Kevin Dickerson Copyright (C) 2009 029 */ 030public class PreferencesPane extends javax.swing.JPanel implements PropertyChangeListener, PreferencesPanel { 031 032 JPanel throttletabpanel = new JPanel(); 033 JPanel rostertabpanel = new JPanel(); 034 JPanel turnouttabpanel = new JPanel(); 035 JComboBox<String> _addTurnoutsEcos; 036 JComboBox<String> _removeTurnoutsEcos; 037 JComboBox<String> _addTurnoutsJmri; 038 JComboBox<String> _removeTurnoutsJmri; 039 JComboBox<String> _masterControl; 040 JComboBox<String> _addLocoEcos; 041 JComboBox<String> _removeLocosEcos; 042 JComboBox<String> _addLocoJmri; 043 JComboBox<String> _removeLocosJmri; 044 JTextField _ecosAttSufText; 045 JTextField _ecosDescription; 046 JRadioButton _adhocLocoEcosAsk; 047 JRadioButton _adhocLocoEcosLeave; 048 JRadioButton _adhocLocoEcosRemove; 049 JRadioButton _forceControlLocoEcosAsk; 050 JRadioButton _forceControlLocoEcosNever; 051 JRadioButton _forceControlLocoEcosAlways; 052 JRadioButton _locoControlNormal; 053 JRadioButton _locoControlForce; 054 ButtonGroup _adhocLocoEcos; 055 ButtonGroup _locoEcosControl; 056 ButtonGroup _locoControl; 057 JCheckBox _rememberAdhocLocosEcos; 058 //JComboBox<String> _defaultProtocol; 059 EcosPreferences ep; 060 boolean updateButtonPressed = false; 061 062 public PreferencesPane(EcosPreferences epref) { 063 super(); 064 ep = epref; 065 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 066 JPanel buttonPanel = new JPanel(); 067 JButton updateButton = new JButton(Bundle.getMessage("ButtonUpdate")); 068 069 updateButton.addActionListener(new ActionListener() { 070 @Override 071 public void actionPerformed(ActionEvent e) { 072 updateButtonPressed(); 073 } 074 }); 075 updateButton.setToolTipText(Bundle.getMessage("UpdateEcosPrefsToolTip")); 076 buttonPanel.add(updateButton); 077 078 //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 079 JTabbedPane tab = new JTabbedPane(); 080 tab.add(rosterTab(), Bundle.getMessage("RosterTitle")); 081 tab.add(throttleTab(), Bundle.getMessage("ThrottleTitle")); 082 tab.add(turnoutTab(), Bundle.getMessage("Turnouts")); 083 084 add(tab); 085 add(buttonPanel); 086 087 ep.addPropertyChangeListener(this); 088 089 } 090 091 @Override 092 public void propertyChange(java.beans.PropertyChangeEvent e) { 093 if (updateButtonPressed) { 094 return; 095 } 096 if (e.getPropertyName().equals("update")) { 097 updateValues(); 098 } 099 } 100 101 void updateValues() { 102 setChoiceType(_removeTurnoutsEcos, ep.getRemoveTurnoutsFromEcos()); 103 setChoiceType(_addTurnoutsJmri, ep.getAddTurnoutsToJMRI()); 104 setChoiceType(_removeTurnoutsJmri, ep.getRemoveTurnoutsFromJMRI()); 105 setChoiceType(_addLocoEcos, ep.getAddLocoToEcos()); 106 setChoiceType(_removeLocosEcos, ep.getRemoveLocoFromEcos()); 107 setChoiceType(_addLocoJmri, ep.getAddLocoToJMRI()); 108 setChoiceType(_removeLocosJmri, ep.getRemoveLocoFromJMRI()); 109 switch (ep.getAdhocLocoFromEcos()) { 110 case 1: 111 _adhocLocoEcosLeave.setSelected(true); 112 break; 113 case 2: 114 _adhocLocoEcosRemove.setSelected(true); 115 break; 116 case 0: 117 default: 118 _adhocLocoEcosAsk.setSelected(true); 119 break; 120 } 121 122 _ecosAttSufText.setText(ep.getRosterAttributeSuffix()); 123 _ecosDescription.setText(ep.getEcosLocoDescription()); 124 125 switch (ep.getForceControlFromEcos()) { 126 case 0x01: 127 _forceControlLocoEcosNever.setSelected(true); 128 break; 129 case 0x02: 130 _forceControlLocoEcosAlways.setSelected(true); 131 break; 132 case 0x00: 133 default: 134 _forceControlLocoEcosAsk.setSelected(true); 135 break; 136 } 137 138 if (ep.getLocoControl()) { 139 _locoControlForce.setSelected(true); 140 } else { 141 _locoControlNormal.setSelected(true); 142 } 143 //setEcosProtocolType(_defaultProtocol, ep.getDefaultEcosProtocol()); 144 } 145 146 private JPanel turnoutTab() { 147 turnouttabpanel.setLayout(new BoxLayout(turnouttabpanel, BoxLayout.Y_AXIS)); 148 149 JPanel _removeTurnoutsEcosPanel = new JPanel(); 150 JLabel _removeTurnoutsEcosLabel = new JLabel(Bundle.getMessage("RemoveTurnoutsEPref")); 151 _removeTurnoutsEcos = new JComboBox<String>(); 152 _removeTurnoutsEcosPanel.add(_removeTurnoutsEcosLabel); 153 initializeChoiceCombo(_removeTurnoutsEcos); 154 if (ep.getRemoveTurnoutsFromEcos() != 0x00) { 155 setChoiceType(_removeTurnoutsEcos, ep.getRemoveTurnoutsFromEcos()); 156 } 157 _removeTurnoutsEcosPanel.add(_removeTurnoutsEcos); 158 turnouttabpanel.add(_removeTurnoutsEcosPanel); 159 160 JPanel _addTurnoutsJMRIPanel = new JPanel(); 161 JLabel _addTurnoutsJMRILabel = new JLabel(Bundle.getMessage("AddTurnoutsJPref")); 162 _addTurnoutsJmri = new JComboBox<String>(); 163 _addTurnoutsJMRIPanel.add(_addTurnoutsJMRILabel); 164 initializeChoiceCombo(_addTurnoutsJmri); 165 if (ep.getAddTurnoutsToJMRI() != 0x00) { 166 setChoiceType(_addTurnoutsJmri, ep.getAddTurnoutsToJMRI()); 167 } 168 _addTurnoutsJMRIPanel.add(_addTurnoutsJmri); 169 turnouttabpanel.add(_addTurnoutsJMRIPanel); 170 171 JPanel _removeTurnoutsJMRIPanel = new JPanel(); 172 JLabel _removeTurnoutsJMRILabel = new JLabel(Bundle.getMessage("RemoveTurnoutsJPref")); 173 _removeTurnoutsJmri = new JComboBox<String>(); 174 _removeTurnoutsJMRIPanel.add(_removeTurnoutsJMRILabel); 175 initializeChoiceCombo(_removeTurnoutsJmri); 176 if (ep.getRemoveTurnoutsFromJMRI() != 0x00) { 177 setChoiceType(_removeTurnoutsJmri, ep.getRemoveTurnoutsFromJMRI()); 178 } 179 _removeTurnoutsJMRIPanel.add(_removeTurnoutsJmri); 180 turnouttabpanel.add(_removeTurnoutsJMRIPanel); 181 182 return turnouttabpanel; 183 } 184 185 private JPanel rosterTab() { 186 187 rostertabpanel.setLayout(new BoxLayout(rostertabpanel, BoxLayout.Y_AXIS)); 188 189 JLabel _rosterLabel = new JLabel(Bundle.getMessage("RosterPrefToolTip")); 190 _rosterLabel.setAlignmentX(Component.CENTER_ALIGNMENT); 191 rostertabpanel.add(_rosterLabel); 192 193 JPanel _locomaster = new JPanel(); 194 JLabel _masterLocoLabel = new JLabel(Bundle.getMessage("RosterPrefLabel")); 195 _masterLocoLabel.setAlignmentX(Component.CENTER_ALIGNMENT); 196 _locomaster.add(_masterLocoLabel); 197 _masterControl = new JComboBox<String>(); 198 initializeMasterControlCombo(_masterControl); 199 if (ep.getLocoMaster() != 0x00) { 200 setMasterControlType(_masterControl, ep.getLocoMaster()); 201 } 202 //_masterControl.setEnabled(false); 203 _locomaster.add(_masterControl); 204 rostertabpanel.add(_locomaster); 205 206 JPanel _addlocoecospanel = new JPanel(); 207 JLabel _addLocosEcosLabel = new JLabel(Bundle.getMessage("AddLocosEPref")); 208 _addLocoEcos = new JComboBox<String>(); 209 _addlocoecospanel.add(_addLocosEcosLabel); 210 initializeChoiceCombo(_addLocoEcos); 211 if (ep.getAddLocoToEcos() != 0x00) { 212 setChoiceType(_addLocoEcos, ep.getAddLocoToEcos()); 213 } 214 _addlocoecospanel.add(_addLocoEcos); 215 rostertabpanel.add(_addlocoecospanel); 216 //_addLocosEcos = new JCheckBox("Add Locos to the ECoS"); 217 //_addLocosEcos.setSelected(ep.getAddLocoToEcos()); 218 //_addLocosEcos.setEnabled(false); 219 //rostertabpanel.add(_addLocosEcos); 220 221 /*_removeLocosEcos = new JCheckBox("Remove Locos from the ECoS"); 222 _removeLocosEcos.setSelected(ep.getRemoveLocoFromEcos()); 223 //_removeLocosEcos.setEnabled(false); 224 rostertabpanel.add(_removeLocosEcos);*/ 225 JPanel _removelocosecospanel = new JPanel(); 226 JLabel _removeLocosEcosLabel = new JLabel(Bundle.getMessage("RemoveLocosEPref")); 227 _removeLocosEcos = new JComboBox<String>(); 228 _removelocosecospanel.add(_removeLocosEcosLabel); 229 initializeChoiceCombo(_removeLocosEcos); 230 if (ep.getRemoveLocoFromEcos() != 0x00) { 231 setChoiceType(_removeLocosEcos, ep.getRemoveLocoFromEcos()); 232 } 233 _removelocosecospanel.add(_removeLocosEcos); 234 rostertabpanel.add(_removelocosecospanel); 235 236 /*_addLocosJmri = new JCheckBox("Add Locos to JMRI Roster"); 237 _addLocosJmri.setSelected(ep.getAddLocoToJMRI()); 238 //_addLocosJmri.setEnabled(false); 239 rostertabpanel.add(_addLocosJmri);*/ 240 JPanel _addlocosjmripanel = new JPanel(); 241 JLabel _addLocoJmriLabel = new JLabel(Bundle.getMessage("AddLocosJPref")); 242 _addLocoJmri = new JComboBox<String>(); 243 _addlocosjmripanel.add(_addLocoJmriLabel); 244 initializeChoiceCombo(_addLocoJmri); 245 if (ep.getAddLocoToJMRI() != 0x00) { 246 setChoiceType(_addLocoJmri, ep.getAddLocoToJMRI()); 247 } 248 _addlocosjmripanel.add(_addLocoJmri); 249 rostertabpanel.add(_addlocosjmripanel); 250 251 /*_removeLocosJmri = new JCheckBox("Remove Locos from JMRI Roster"); 252 _removeLocosJmri.setSelected(ep.getRemoveLocoFromJMRI()); 253 _removeLocosJmri.setEnabled(false); 254 rostertabpanel.add(_removeLocosJmri);*/ 255 JPanel _removelocosjmripanel = new JPanel(); 256 JLabel _removeLocosJmriLabel = new JLabel(Bundle.getMessage("RemoveLocosJPref")); 257 _removeLocosJmri = new JComboBox<String>(); 258 _removelocosjmripanel.add(_removeLocosJmriLabel); 259 initializeChoiceCombo(_removeLocosJmri); 260 if (ep.getRemoveLocoFromJMRI() != 0x00) { 261 setChoiceType(_removeLocosJmri, ep.getRemoveLocoFromJMRI()); 262 } 263 _removelocosjmripanel.add(_removeLocosJmri); 264 rostertabpanel.add(_removelocosjmripanel); 265 266 JPanel ecosAttributeSuffix = new JPanel(); 267 JLabel _ecosAttSufLabel = new JLabel(Bundle.getMessage("EcosRosterSuffixLabel")); 268 ecosAttributeSuffix.add(_ecosAttSufLabel); 269 _ecosAttSufText = new JTextField(10); 270 _ecosAttSufText.setToolTipText(Bundle.getMessage("EcosRosterSuffixToolTip")); 271 _ecosAttSufText.setText(ep.getRosterAttributeSuffix()); 272 ecosAttributeSuffix.add(_ecosAttSufText); 273 rostertabpanel.add(ecosAttributeSuffix); 274 275 JPanel ecosDescriptionPanel = new JPanel(); 276 277 JLabel _ecosDesLabel = new JLabel(Bundle.getMessage("EcosLocoDescrLabel")); 278 ecosDescriptionPanel.add(_ecosDesLabel); 279 280 _ecosDescription = new JTextField(20); 281 _ecosDescription.setText(ep.getEcosLocoDescription()); 282 _ecosDescription.setToolTipText(Bundle.getMessage("EcosLocoDescrToolTip")); 283 ecosDescriptionPanel.add(_ecosDescription); 284 285 rostertabpanel.add(ecosDescriptionPanel); 286 287 JLabel _descriptionformat = new JLabel(Bundle.getMessage("EcosTagsHelp1")); 288 rostertabpanel.add(_descriptionformat); 289 JLabel _descriptionformat2 = new JLabel(Bundle.getMessage("EcosTagsHelp2")); 290 rostertabpanel.add(_descriptionformat2); 291 292 return rostertabpanel; 293 } 294 295 private JPanel throttleTab() { 296 297 throttletabpanel.setLayout(new BoxLayout(throttletabpanel, BoxLayout.Y_AXIS)); 298 299 JLabel _throttleLabel = new JLabel(Bundle.getMessage("EcosTempLocoHelp")); 300 _throttleLabel.setAlignmentX(Component.CENTER_ALIGNMENT); 301 throttletabpanel.add(_throttleLabel); 302 /*_throttleLabel = new JLabel("specifically created to enable a throttle to be used"); 303 throttletabpanel.add(_throttleLabel);*/ 304 _throttleLabel.setAlignmentX(Component.CENTER_ALIGNMENT); 305 _adhocLocoEcosAsk = new JRadioButton(Bundle.getMessage("ButtonAlwaysAsk")); 306 _adhocLocoEcosLeave = new JRadioButton(Bundle.getMessage("ButtonAlwaysLeave")); 307 _adhocLocoEcosRemove = new JRadioButton(Bundle.getMessage("ButtonAlwaysRemove")); 308 switch (ep.getAdhocLocoFromEcos()) { 309 case 1: 310 _adhocLocoEcosLeave.setSelected(true); 311 break; 312 case 2: 313 _adhocLocoEcosRemove.setSelected(true); 314 break; 315 case 0: 316 default: 317 _adhocLocoEcosAsk.setSelected(true); 318 break; 319 } 320 _adhocLocoEcos = new ButtonGroup(); 321 _adhocLocoEcos.add(_adhocLocoEcosAsk); 322 _adhocLocoEcos.add(_adhocLocoEcosLeave); 323 _adhocLocoEcos.add(_adhocLocoEcosRemove); 324 325 JPanel adhocEcosGroup = new JPanel(); 326 adhocEcosGroup.setLayout(new BoxLayout(adhocEcosGroup, BoxLayout.Y_AXIS)); 327 adhocEcosGroup.add(_adhocLocoEcosAsk); 328 adhocEcosGroup.add(_adhocLocoEcosLeave); 329 adhocEcosGroup.add(_adhocLocoEcosRemove); 330 adhocEcosGroup.setAlignmentX(Component.CENTER_ALIGNMENT); 331 throttletabpanel.add(adhocEcosGroup); 332 333 /*throttletabpanel.add(_adhocLocoEcosAsk); 334 throttletabpanel.add(_adhocLocoEcosLeave); 335 throttletabpanel.add(_adhocLocoEcosRemove);*/ 336 throttletabpanel.add(new JSeparator(SwingConstants.HORIZONTAL)); 337 _throttleLabel = new JLabel(Bundle.getMessage("EcosControlLocoHelp")); 338 _throttleLabel.setAlignmentX(Component.CENTER_ALIGNMENT); 339 throttletabpanel.add(_throttleLabel); 340 _forceControlLocoEcosAsk = new JRadioButton(Bundle.getMessage("ButtonControlAlwaysAsk")); 341 _forceControlLocoEcosNever = new JRadioButton(Bundle.getMessage("ButtonControlNeverForce")); 342 _forceControlLocoEcosAlways = new JRadioButton(Bundle.getMessage("ButtonControlAlwaysForce")); 343 switch (ep.getForceControlFromEcos()) { 344 case 0x01: 345 _forceControlLocoEcosNever.setSelected(true); 346 break; 347 case 0x02: 348 _forceControlLocoEcosAlways.setSelected(true); 349 break; 350 case 0x00: 351 default: 352 _forceControlLocoEcosAsk.setSelected(true); 353 break; 354 } 355 _locoEcosControl = new ButtonGroup(); 356 _locoEcosControl.add(_forceControlLocoEcosAsk); 357 _locoEcosControl.add(_forceControlLocoEcosNever); 358 _locoEcosControl.add(_forceControlLocoEcosAlways); 359 JPanel locoEcosControlGroup = new JPanel(); 360 locoEcosControlGroup.setLayout(new BoxLayout(locoEcosControlGroup, BoxLayout.Y_AXIS)); 361 locoEcosControlGroup.add(_forceControlLocoEcosAsk); 362 locoEcosControlGroup.add(_forceControlLocoEcosNever); 363 locoEcosControlGroup.add(_forceControlLocoEcosAlways); 364 locoEcosControlGroup.setAlignmentX(Component.CENTER_ALIGNMENT); 365 throttletabpanel.add(locoEcosControlGroup); 366 /*throttletabpanel.add(new JSeparator(SwingConstants.HORIZONTAL)); 367 368 JPanel _defaultprotocolpanel = new JPanel(); 369 370 JLabel _defaultprotocolLabel = new JLabel("Sets the Default protocol to use for an Adhoc Loco"); 371 _defaultprotocolpanel.add(_defaultprotocolLabel); 372 _defaultProtocol = new JComboBox<String>(); 373 initializeEcosProtocolCombo(_defaultProtocol); 374 if (ep.getLocoMaster()!=0x00) 375 setEcosProtocolType(_defaultProtocol, ep.getDefaultEcosProtocol()); 376 defaultprotocolpanel.add(_defaultProtocol); 377 throttletabpanel.add(_defaultprotocolpanel);*/ 378 throttletabpanel.add(new JSeparator(SwingConstants.HORIZONTAL)); 379 _locoControl = new ButtonGroup(); 380 _locoControlNormal = new JRadioButton(Bundle.getMessage("ButtonControlAlwaysGain")); 381 _locoControlForce = new JRadioButton(Bundle.getMessage("ButtonControlAlwaysForce")); 382 _locoControl.add(_locoControlNormal); 383 _locoControl.add(_locoControlForce); 384 if (ep.getLocoControl()) { 385 _locoControlForce.setSelected(true); 386 } else { 387 _locoControlNormal.setSelected(true); 388 } 389 JLabel _locoControlLabel = new JLabel(Bundle.getMessage("EcosTakeControlHelp")); 390 JPanel locoControlGroup = new JPanel(); 391 locoControlGroup.add(_locoControlLabel); 392 locoControlGroup.setLayout(new BoxLayout(locoControlGroup, BoxLayout.Y_AXIS)); 393 locoControlGroup.add(_locoControlNormal); 394 locoControlGroup.add(_locoControlForce); 395 locoControlGroup.setAlignmentX(Component.CENTER_ALIGNMENT); 396 throttletabpanel.add(locoControlGroup); 397 398 return throttletabpanel; 399 } 400 401 private void updateButtonPressed() { 402 //Disable any action on the listener. 403 updateButtonPressed = true; 404 //EcosPreferences ep = adaptermemo.getPreferenceManager(); 405 ep.setRemoveLocoFromJMRI(getChoiceType(_removeLocosJmri)); 406 ep.setAddLocoToJMRI(getChoiceType(_addLocoJmri)); 407 ep.setRemoveLocoFromEcos(getChoiceType(_removeLocosEcos)); 408 ep.setAddLocoToEcos(getChoiceType(_addLocoEcos)); 409 ep.setRemoveTurnoutsFromJMRI(getChoiceType(_removeTurnoutsJmri)); 410 ep.setAddTurnoutsToJMRI(getChoiceType(_addTurnoutsJmri)); 411 ep.setRemoveTurnoutsFromEcos(getChoiceType(_removeTurnoutsEcos)); 412 //ep.setAddTurnoutsToEcos(getChoiceType(_addTurnoutsEcos)); 413 ep.setLocoMaster(getMasterControlType(_masterControl)); 414 //ep.setDefaultEcosProtocol(getEcosProtocol(_defaultProtocol)); 415 ep.setEcosLocoDescription(_ecosDescription.getText()); 416 ep.setRosterAttribute(_ecosAttSufText.getText()); 417 418 if (_adhocLocoEcosAsk.isSelected()) { 419 ep.setAdhocLocoFromEcos(0); 420 } else if (_adhocLocoEcosLeave.isSelected()) { 421 ep.setAdhocLocoFromEcos(1); 422 } else if (_adhocLocoEcosRemove.isSelected()) { 423 ep.setAdhocLocoFromEcos(2); 424 } else { 425 ep.setAdhocLocoFromEcos(0); 426 } 427 428 if (_locoControlForce.isSelected()) { 429 ep.setLocoControl(true); 430 } else { 431 ep.setLocoControl(false); 432 } 433 434 ConfigureManager cm = jmri.InstanceManager.getNullableDefault(jmri.ConfigureManager.class); 435 if (cm != null) { 436 cm.storePrefs(); 437 } 438 updateButtonPressed = false; 439 } 440 441 /** 442 * Options in the ECoS Sync prefs drop down. 443 * <p> 444 * Keep masterControlTypes array identical to {@link jmri.jmrix.ecos.EcosPreferences#setLocoMaster(String)} 445 */ 446 String[] masterControlTypes = {Bundle.getMessage("NOSYNC"), Bundle.getMessage("WARNING"), "JMRI", "ECoS"}; 447 int[] masterControlCode = {0x00, 0x01, 0x02, 0x03}; 448 int numTypes = 4; // number of entries in the above arrays 449 450 private void initializeMasterControlCombo(JComboBox<String> masterCombo) { 451 masterCombo.removeAllItems(); 452 for (int i = 0; i < numTypes; i++) { 453 masterCombo.addItem(masterControlTypes[i]); 454 } 455 } 456 457 private void setMasterControlType(JComboBox<String> masterBox, int master) { 458 for (int i = 0; i < numTypes; i++) { 459 if (master == masterControlCode[i]) { 460 masterBox.setSelectedIndex(i); 461 return; 462 } 463 } 464 } 465 466 private int getMasterControlType(JComboBox<String> masterBox) { 467 return masterControlCode[masterBox.getSelectedIndex()]; 468 } 469 470 String[] choiceTypes = {Bundle.getMessage("DeleteAsk"), 471 Bundle.getMessage("ButtonNo"), 472 Bundle.getMessage("ButtonYes")}; 473 int[] masterChoiceCode = {0x00, 0x01, 0x02}; 474 int numChoiceTypes = 3; // number of entries in the above arrays 475 476 private void initializeChoiceCombo(JComboBox<String> masterCombo) { 477 masterCombo.removeAllItems(); 478 for (int i = 0; i < numChoiceTypes; i++) { 479 masterCombo.addItem(choiceTypes[i]); 480 } 481 } 482 483 private void setChoiceType(JComboBox<String> masterBox, int master) { 484 for (int i = 0; i < numChoiceTypes; i++) { 485 if (master == masterChoiceCode[i]) { 486 masterBox.setSelectedIndex(i); 487 return; 488 } 489 } 490 } 491 492 private int getChoiceType(JComboBox<String> masterBox) { 493 return masterChoiceCode[masterBox.getSelectedIndex()]; 494 } 495 496 // String[] ecosProtocolTypes = {"DCC14","DCC28", "DCC128", "MM14", "MM27", "MM28", "SX32", "MMFKT"}; 497 // int numProtocolTypes = 8; // number of entries in the above arrays 498 499 /*private void initializeEcosProtocolCombo(JComboBox<String> protocolCombo) { 500 protocolCombo.removeAllItems(); 501 for (int i = 0;i<numProtocolTypes;i++) { 502 protocolCombo.addItem(ecosProtocolTypes[i]); 503 } 504 }*/ 505 /*private void setEcosProtocolType(JComboBox<String> masterBox, String protocol){ 506 for (int i = 0;i<numProtocolTypes;i++) { 507 if (protocol.equals(ecosProtocolTypes[i])) { 508 masterBox.setSelectedIndex(i); 509 return; 510 } 511 } 512 }*/ 513 514 /*private String getEcosProtocol(JComboBox<String> masterBox){ 515 return ecosProtocolTypes[masterBox.getSelectedIndex()]; 516 517 }*/ 518 @Override 519 public String getPreferencesItem() { 520 return "ECoS"; // NOI18N 521 } 522 523 @Override 524 public String getPreferencesItemText() { 525 return Bundle.getMessage("MenuItemECoSPrefs"); 526 } 527 528 @Override 529 public String getTabbedPreferencesTitle() { 530 return this.ep.getAdaptermemo().getUserName(); 531 } 532 533 @Override 534 public String getLabelKey() { 535 return null; 536 } 537 538 @Override 539 public JComponent getPreferencesComponent() { 540 return this; 541 } 542 543 @Override 544 public boolean isPersistant() { 545 return false; 546 } 547 548 @Override 549 public String getPreferencesTooltip() { 550 return null; 551 } 552 553 @Override 554 public void savePreferences() { 555 this.updateButtonPressed(); 556 } 557 558 @Override 559 public boolean isDirty() { 560 return this.ep.getChangeMade(); 561 } 562 563 @Override 564 public boolean isRestartRequired() { 565 // is this correct? If not, we would need to set a flag in 566 // updateButtonPressed() to set this true. 567 return false; 568 } 569 570 @Override 571 public boolean isPreferencesValid() { 572 return true; // no validity checking performed 573 } 574} 575