public ConfigurationsDialogBuilder addConfigurations(List<Configuration> configurations) { dialog.setTitle("Choose a configuration to graph"); dialog.configurations = configurations; dialog.borderPanel.setCenter(dialog.scrollPane); ObservableList<Node> children = dialog.configurationsBox.getChildren(); ToggleGroup toggleGroup = new ToggleGroup(); for (Configuration configuration : configurations) { String name = configuration.getName(); RadioButton configurationRadioButton = new RadioButton(name); configurationRadioButton.setToggleGroup(toggleGroup); if (name.equals("compile")) { configurationRadioButton.setSelected(true); // todo select default from prefs } children.add(configurationRadioButton); } return this; }
private Configuration getChosenConfiguration() { ObservableList<Node> children = dialog.configurationsBox.getChildren(); for (Node child : children) { if (child instanceof RadioButton) { RadioButton radioButton = (RadioButton) child; if (radioButton.isSelected()) { String text = radioButton.getText(); List<Configuration> configurations = dialog.configurations; for (Configuration configuration : configurations) { String name = configuration.getName(); if (name.equals(text)) { return configuration; } } } } } return null; }