use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class CombinedLocoSelListPane method setDecoderSelectionFromLoco.
/**
* Set the decoder selection to a specific decoder from a selected Loco
*/
@Override
void setDecoderSelectionFromLoco(String loco) {
// if there's a valid loco entry...
RosterEntry locoEntry = Roster.getDefault().entryFromTitle(loco);
if (locoEntry == null) {
return;
}
// get the decoder type, it has to be there (assumption!),
String modelString = locoEntry.getDecoderModel();
// find the decoder mfg
String mfgString = DecoderIndexFile.instance().fileFromTitle(modelString).getMfg();
// then select it
updateMfgListWithoutTrigger(mfgString);
// decoder has to be there (assumption!)
// so load it into the list directly
String[] tempArray = new String[1];
tempArray[0] = modelString;
mDecoderList.setListData(tempArray);
// select the entry you just put in, but don't trigger anything!
mDecoderList.removeListSelectionListener(mDecoderListener);
mDecoderList.setSelectedIndex(0);
mDecoderList.addListSelectionListener(mDecoderListener);
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class KnownLocoSelPane method selectLoco.
protected void selectLoco(int dccAddress) {
// locate that loco
List<RosterEntry> l = Roster.getDefault().matchingList(null, null, Integer.toString(dccAddress), null, null, null, null);
if (log.isDebugEnabled()) {
log.debug("selectLoco found " + l.size() + " matches");
}
if (l.size() > 0) {
RosterEntry r = l.get(0);
String id = r.getId();
if (log.isDebugEnabled()) {
log.debug("Loco id is " + id);
}
String group = locoBox.getSelectedRosterGroup();
if (group != null && !group.equals(Roster.ALLENTRIES)) {
List<RosterEntry> entries = Roster.getDefault().getEntriesWithAttributeKeyValue(Roster.getRosterGroupProperty(group), "yes");
if (entries.contains(r)) {
locoBox.setSelectedRosterEntry(r);
} else {
locoBox.setSelectedRosterEntryAndGroup(r, Roster.ALLENTRIES);
}
} else {
locoBox.setSelectedRosterEntry(r);
}
} else {
log.warn("Read address " + dccAddress + ", but no such loco in roster");
}
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class PaneEditAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (log.isDebugEnabled()) {
log.debug("Pane programmer requested");
}
// create the initial frame that steers
final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameEditEntrySetup"));
f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
// add the Roster menu
JMenuBar menuBar = new JMenuBar();
// menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
f.setJMenuBar(menuBar);
// known entry, no programmer
JPanel pane1 = new // not programming
KnownLocoSelPane(// not programming
false) {
@Override
protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
String title = SymbolicProgBundle.getMessage("FrameEditEntryTitle");
JFrame p = new PaneProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", null, false) {
@Override
protected JPanel getModePane() {
return null;
}
};
p.pack();
p.setVisible(true);
}
};
// load primary frame
pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(pane1);
f.pack();
if (log.isDebugEnabled()) {
log.debug("Tab-Programmer setup created");
}
f.setVisible(true);
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class VSDConfigDialog method rosterSaveButtonAction.
/**
* rosterSaveButtonAction()
*
* ActionEventListener method for rosterSaveButton Writes VSDecoder info to
* the RosterEntry.
*/
private void rosterSaveButtonAction(ActionEvent e) {
log.debug("rosterSaveButton pressed");
if (rosterSelector.getSelectedRosterEntries().length != 0) {
RosterEntry r = rosterSelector.getSelectedRosterEntries()[0];
String profile = profileComboBox.getSelectedItem().toString();
String path = VSDecoderManager.instance().getProfilePath(profile);
if ((path == null) || (profile == null)) {
log.debug("Path and/or Profile not selected. Ignore Save button press.");
return;
} else {
r.setOpen(true);
r.putAttribute("VSDecoder_Path", path);
r.putAttribute("VSDecoder_Profile", profile);
int value = JOptionPane.showConfirmDialog(null, MessageFormat.format(Bundle.getMessage("UpdateRoster"), new Object[] { r.titleString() }), Bundle.getMessage("SaveRoster?"), JOptionPane.YES_NO_OPTION);
if (value == JOptionPane.YES_OPTION) {
storeFile(r);
}
r.setOpen(false);
}
// Need to write RosterEntry to file.
}
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class VSDConfigDialog method updateProfileList.
/**
* Update the profile combo box
*/
private void updateProfileList(ArrayList<String> s) {
if (s == null) {
return;
}
// This is a bit tedious...
// Pull all of the existing names from the Profile ComboBox
ArrayList<String> ce_list = new ArrayList<>();
for (int i = 0; i < profileComboBox.getItemCount(); i++) {
ce_list.add(profileComboBox.getItemAt(i).toString());
}
// Cycle through the list provided as "s" and add only
// those profiles that aren't already there.
Iterator<String> itr = s.iterator();
while (itr.hasNext()) {
String st = itr.next();
if (!ce_list.contains(st)) {
log.debug("added item " + st);
profileComboBox.addItem(st);
}
}
// Roster Save button.
if (profileComboBox.getItemCount() > 0) {
profileComboBox.setEnabled(true);
// Enable the roster save button if roster items are available.
if (rosterSelector.getSelectedRosterEntries().length > 0) {
RosterEntry r = rosterSelector.getSelectedRosterEntries()[0];
String profile = r.getAttribute("VSDecoder_Profile");
log.debug("Trying to set the ProfileComboBox to this Profile: " + profile);
if (profile != null) {
profileComboBox.setSelectedItem(profile);
}
rosterSaveButton.setEnabled(true);
}
}
}
Aggregations