made some improvements
This commit is contained in:
parent
850381769a
commit
8502728738
@ -66,6 +66,7 @@ public class TestController {
|
||||
questionCountField.disableProperty().bind(isInConfiguringState.not());
|
||||
catalogComboBox.disableProperty().bind(isInConfiguringState.not());
|
||||
startBtn.textProperty().bind(Bindings.when(isInConfiguringState).then("Start").otherwise("Cancle"));
|
||||
startBtn.visibleProperty().bind(isInConfiguringState);
|
||||
nextQuestionBtn.disableProperty().bind(isInConfiguringState);
|
||||
nextQuestionBtn.visibleProperty().bind(isInCorrectionState.not());
|
||||
correctAnswerLable.visibleProperty().bind(isInCorrectionState);
|
||||
|
||||
@ -11,6 +11,7 @@ import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
|
||||
@ -19,6 +20,8 @@ import java.sql.SQLException;
|
||||
import static at.ionas999.questioncatalog.Utils.showConfirmationButton;
|
||||
|
||||
public class ViewController {
|
||||
@FXML
|
||||
private TextField searchField;
|
||||
@FXML
|
||||
private ComboBox<QuestionCatalog> selectBox;
|
||||
@FXML
|
||||
@ -29,7 +32,7 @@ public class ViewController {
|
||||
private ListView<Question> questionListView;
|
||||
|
||||
private ObjectProperty<Question> currentQuestion = new SimpleObjectProperty<>();
|
||||
private ObservableList<Question> questions;
|
||||
private FilteredList<Question> questions;
|
||||
private BooleanProperty isInEditState = new SimpleBooleanProperty(false);
|
||||
|
||||
@FXML
|
||||
@ -44,12 +47,22 @@ public class ViewController {
|
||||
answerField.editableProperty().bind(isInEditState);
|
||||
deleteButton.disableProperty().bind(isInEditState);
|
||||
questionListView.disableProperty().bind(isInEditState);
|
||||
searchField.textProperty().addListener((_,_,newValue) ->{
|
||||
if(newValue == null)
|
||||
newValue = "";
|
||||
String finalNewValue = newValue;
|
||||
questions.setPredicate(x -> x.getQuestion().contains(finalNewValue));
|
||||
});
|
||||
}
|
||||
|
||||
private void loadQuestions(QuestionCatalog catalog) {
|
||||
if (catalog == null) return;
|
||||
try {
|
||||
questions = FXCollections.observableList(QuestionService.GetQuestionsFromCatalog(catalog.getId()));
|
||||
questions = new FilteredList<>(
|
||||
FXCollections.observableList
|
||||
(QuestionService.GetQuestionsFromCatalog(
|
||||
catalog.getId())));
|
||||
|
||||
questionListView.setItems(questions);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@ -16,7 +16,13 @@
|
||||
</top>
|
||||
|
||||
<left>
|
||||
<ListView fx:id="questionListView" prefHeight="364.0" prefWidth="209.0" />
|
||||
<VBox spacing="5.0" prefWidth="209.0">
|
||||
<padding>
|
||||
<Insets top="10.0" left="10.0" right="10.0" bottom="10.0" />
|
||||
</padding>
|
||||
<TextField fx:id="searchField" promptText="Search questions..." />
|
||||
<ListView fx:id="questionListView" prefHeight="364.0" VBox.vgrow="ALWAYS" />
|
||||
</VBox>
|
||||
</left>
|
||||
|
||||
<center>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user