This commit is contained in:
Sebastian Stenzel
2016-05-10 14:31:55 +02:00
parent 6006d65ce0
commit 7b6c5318c5
3 changed files with 9 additions and 5 deletions

View File

@@ -43,6 +43,9 @@ public class SettingsController extends LocalizedFXMLViewController {
@FXML
private TextField portField;
@FXML
private Label useIpv6Label;
@FXML
private CheckBox useIpv6Checkbox;
@@ -55,7 +58,8 @@ public class SettingsController extends LocalizedFXMLViewController {
checkForUpdatesCheckbox.setSelected(settings.isCheckForUpdatesEnabled() && !areUpdatesManagedExternally());
portField.setText(String.valueOf(settings.getPort()));
portField.addEventFilter(KeyEvent.KEY_TYPED, this::filterNumericKeyEvents);
useIpv6Checkbox.setDisable(!SystemUtils.IS_OS_WINDOWS);
useIpv6Label.setVisible(SystemUtils.IS_OS_WINDOWS);
useIpv6Checkbox.setVisible(SystemUtils.IS_OS_WINDOWS);
useIpv6Checkbox.setSelected(SystemUtils.IS_OS_WINDOWS && settings.shouldUseIpv6());
versionLabel.setText(String.format(localization.getString("settings.version.label"), applicationVersion().orElse("SNAPSHOT")));
@@ -81,7 +85,7 @@ public class SettingsController extends LocalizedFXMLViewController {
private void portDidChange(String newValue) {
try {
int port = Integer.parseInt(newValue);
if (port < Settings.MIN_PORT || port > Settings.MAX_PORT) {
if (!settings.isPortValid(port)) {
settings.setPort(Settings.DEFAULT_PORT);
} else {
settings.setPort(port);

View File

@@ -93,8 +93,8 @@ public class Settings implements Serializable {
}
}
private boolean isPortValid(int port) {
return port == DEFAULT_PORT || port >= MIN_PORT && port <= MAX_PORT;
public boolean isPortValid(int port) {
return port == DEFAULT_PORT || port >= MIN_PORT && port <= MAX_PORT || port == 0;
}
public boolean shouldUseIpv6() {

View File

@@ -38,7 +38,7 @@
<TextField GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="portField" cacheShape="true" cache="true" promptText="%settings.port.prompt" />
<!-- Row 2 -->
<Label GridPane.rowIndex="2" GridPane.columnIndex="0" text="%settings.useipv6.label" cacheShape="true" cache="true" />
<Label GridPane.rowIndex="2" GridPane.columnIndex="0" fx:id="useIpv6Label" text="%settings.useipv6.label" cacheShape="true" cache="true" />
<CheckBox GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="useIpv6Checkbox" cacheShape="true" cache="true" />
</children>
</GridPane>