use of jmri.managers.ManagerDefaultSelector in project JMRI by JMRI.
the class ManagerDefaultsConfigPane method reloadConnections.
void reloadConnections(List<SystemConnectionMemo> connList) {
log.debug(" reloadConnections");
ManagerDefaultSelector manager = InstanceManager.getDefault(ManagerDefaultSelector.class);
matrix.setLayout(new GridLayout2(connList.size() + 1, manager.knownManagers.length + 1));
matrix.add(new JLabel(""));
for (ManagerDefaultSelector.Item item : manager.knownManagers) {
matrix.add(new JLabel(item.typeName));
}
groups = new ButtonGroup[manager.knownManagers.length];
for (int i = 0; i < manager.knownManagers.length; i++) {
groups[i] = new ButtonGroup();
}
boolean[] selected = new boolean[manager.knownManagers.length];
for (int x = 0; x < connList.size(); x++) {
// up to down
jmri.jmrix.SystemConnectionMemo memo = connList.get(x);
String name = memo.getUserName();
matrix.add(new JLabel(name));
int i = 0;
for (ManagerDefaultSelector.Item item : manager.knownManagers) {
// left to right
if (memo.provides(item.managerClass)) {
JRadioButton r = new SelectionButton(name, item.managerClass, this);
matrix.add(r);
groups[i].add(r);
if (!selected[i] && manager.getDefault(item.managerClass) == null) {
r.setSelected(true);
selected[i] = true;
}
} else {
// leave a blank
JRadioButton r = new JRadioButton();
r.setEnabled(false);
matrix.add(r);
}
//we need to increment 'i' as we are going onto the next group even if we added a blank button
i++;
}
}
revalidate();
}
Aggregations