Notice user to add authentication server

This commit is contained in:
huangyuhui 2018-09-01 23:38:05 +08:00
parent 64e7cc74b2
commit f2f0c96e62
2 changed files with 20 additions and 0 deletions

View File

@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui.account;
import com.jfoenix.concurrency.JFXUtilities; import com.jfoenix.concurrency.JFXUtilities;
import com.jfoenix.controls.*; import com.jfoenix.controls.*;
import javafx.beans.InvalidationListener;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -90,6 +91,9 @@ public class AddAccountPane extends StackPane {
cboType.setConverter(stringConverter(Accounts::getAccountTypeName)); cboType.setConverter(stringConverter(Accounts::getAccountTypeName));
cboType.getSelectionModel().select(0); cboType.getSelectionModel().select(0);
cboServers.getItems().addListener(onInvalidating(this::checkIfNoServer));
checkIfNoServer();
ReadOnlyObjectProperty<AccountFactory<?>> loginType = cboType.getSelectionModel().selectedItemProperty(); ReadOnlyObjectProperty<AccountFactory<?>> loginType = cboType.getSelectionModel().selectedItemProperty();
txtPassword.visibleProperty().bind(loginType.isNotEqualTo(Accounts.FACTORY_OFFLINE)); txtPassword.visibleProperty().bind(loginType.isNotEqualTo(Accounts.FACTORY_OFFLINE));
@ -122,6 +126,13 @@ public class AddAccountPane extends StackPane {
} }
} }
private void checkIfNoServer() {
if (cboServers.getItems().isEmpty())
cboServers.getStyleClass().setAll("jfx-combo-box-warning");
else
cboServers.getStyleClass().setAll("jfx-combo-box");
}
/** /**
* Gets the additional data that needs to be passed into {@link AccountFactory#create(CharacterSelector, String, String, Object)}. * Gets the additional data that needs to be passed into {@link AccountFactory#create(CharacterSelector, String, String, Object)}.
*/ */

View File

@ -1007,6 +1007,15 @@
-jfx-focus-color: -fx-base-check-color; -jfx-focus-color: -fx-base-check-color;
} }
.jfx-combo-box-warning {
-jfx-focus-color: #D34336;
-jfx-unfocus-color: #D34336;
}
.jfx-combo-box-warning .text {
-fx-fill: #D34336;
}
.combo-box-popup .list-view .jfx-list-cell .label, .combo-box-popup .list-view .jfx-list-cell .label,
.combo-box-popup .list-view .jfx-list-cell:filled:hover .label { .combo-box-popup .list-view .jfx-list-cell:filled:hover .label {
-fx-text-fill: BLACK; -fx-text-fill: BLACK;