use of org.phoenicis.engines.EngineSetting in project POL-POM-5 by PlayOnLinux.
the class ContainerEngineSettingsPanelSkin method updateEngineSettingsGrid.
/**
* Updates the engine settings in the given {@link GridPane engineSettingsGrid}
*
* @param engineSettingsGrid The GridPane containing the shown engine settings
*/
private void updateEngineSettingsGrid(final GridPane engineSettingsGrid) {
engineSettingsGrid.getChildren().clear();
final ContainerDTO container = getControl().getContainer();
for (EngineSetting engineSetting : getControl().getEngineSettings()) {
final int row = engineSettingsGrid.getRowCount();
final Text engineSettingDescription = new Text(engineSetting.getText());
engineSettingDescription.getStyleClass().add("captionTitle");
final ObservableList<String> items = FXCollections.observableArrayList(engineSetting.getOptions());
final ComboBox<String> engineSettingComboBox = new ComboBox<>(items);
engineSettingComboBox.getStyleClass().add("engine-setting-combo-box");
engineSettingComboBox.disableProperty().bind(getControl().lockEngineSettingsProperty());
// if the container is not specified set no default values
if (container != null) {
try {
engineSettingComboBox.setValue(engineSetting.getCurrentOption(container.getName()));
} catch (Exception e) {
engineSettingComboBox.getSelectionModel().select(0);
LOGGER.warn(String.format("Could not fetch current option for engine setting \"%s\", will use default.", engineSetting.getText()));
LOGGER.debug("Caused by: ", e);
}
engineSettingComboBox.valueProperty().addListener((Observable invalidation) -> Platform.runLater(() -> {
getControl().setLockEngineSettings(true);
engineSetting.setOption(container.getName(), items.indexOf(engineSettingComboBox.getValue()));
getControl().setLockEngineSettings(false);
}));
}
engineSettingsGrid.addRow(row, engineSettingDescription, engineSettingComboBox);
}
}
Aggregations