Skip to content

Commit

Permalink
"None of your repository starts with 'questions.'" Alert
Browse files Browse the repository at this point in the history
  • Loading branch information
gekoramy committed Jul 27, 2018
1 parent 86b0199 commit d96ecf3
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.ListView;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TextField;
import javafx.scene.control.*;
import javafx.stage.Stage;
import me.gekoramy.github.quiz.app.AppDownload;
import me.gekoramy.github.quiz.exception.NotLoggedException;
Expand All @@ -19,7 +16,9 @@

import javax.inject.Inject;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import java.util.stream.Collectors;

/**
* @author Luca Mosetti
Expand Down Expand Up @@ -49,11 +48,17 @@ public void initialize(URL location, ResourceBundle resources) {
}

private void onSucceeded() {
repositories.getValue().stream().filter(r -> r.getName().startsWith(Constants.PREFIX)).forEach(r -> {
Hyperlink link = new Hyperlink(r.getName());
link.setOnAction(e -> onChosen(r));
links.add(link);
});
List<Repository> questionsRepos = repositories.getValue().stream().filter(r -> r.getName().startsWith(Constants.PREFIX)).collect(Collectors.toList());

if (questionsRepos.isEmpty()) {
new Alert(Alert.AlertType.WARNING, "None of your repository starts with 'questions.'").show();
} else {
questionsRepos.forEach(r -> {
Hyperlink link = new Hyperlink(r.getName());
link.setOnAction(e -> onChosen(r));
links.add(link);
});
}
}

private void onChosen(Repository chosen) {
Expand Down

0 comments on commit d96ecf3

Please sign in to comment.