Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from bluishmatt/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
bluishmatt authored Sep 4, 2021
2 parents 40b17f7 + b22e824 commit a38eb13
Show file tree
Hide file tree
Showing 5 changed files with 2,153 additions and 48 deletions.
Binary file modified PastPaperPro.jar
Binary file not shown.
122 changes: 100 additions & 22 deletions src/main/java/co/uk/mattelliot/PrimaryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
Expand Down Expand Up @@ -125,6 +126,8 @@ public void setImage(String paper, String markscheme){
imageViewMS.setFitWidth(markschemeImage.getWidth());
}

int clickedTopicsListview = 0;

public void initialize() throws IOException {
initializeTopBar();
//a list of Paper names for the paper choicebox.
Expand Down Expand Up @@ -235,11 +238,15 @@ public void initialize() throws IOException {
//a flag to stop the mtopicsChoiceBox action triggering and loading a new paper when you click on a question in the currently loaded Paper paper

QuestionTopicsChoiceBox.setItems(questionsTopicsList);
mtopicsChoiceBox.setItems(topics);
mpaperChoiceBox.setItems(PaperNames);
mtopicSelectListView.setItems(listViewTopicQ);
mpaperSelectListView.setItems(listViewPaperQ);

QuestionTopicsChoiceBox.setOnAction(event -> {
QuestionTopicsChoiceBox.getSelectionModel().selectFirst();
});

mtopicsChoiceBox.setItems(topics);
mtopicsChoiceBox.setOnAction(event -> {
if(selectAndChangePaper.get() == true ) {
try {
Expand All @@ -259,7 +266,7 @@ public void initialize() throws IOException {
}
});

mpaperChoiceBox.setItems(PaperNames);

mpaperChoiceBox.setOnAction(event -> {
try {
File paperFile = new File( System.getProperty("user.dir") + "/Papers/" + mpaperChoiceBox.getValue().toString());
Expand All @@ -281,19 +288,31 @@ public void initialize() throws IOException {
sp = mpaperSelectListView.getItems().get(0).toString().indexOf(" ")-1;
questionN = mpaperSelectListView.getItems().get(0).toString().substring(0,sp);
}

outerloop:
for (Topic t : topics) {
for (Question q : t.getQuestions()) {
if (q.getPaper().equals(paper) && q.getQuestionNumber().equals(questionN)) {
/// if (q.equals(lastQuestionClicked)) { //found the topic for last question clicked...
setTopicQuestionsList(topics.indexOf(t));
scrollTo(scrollPane, q.getScrollLocation());
scrollTo(scrollPaneMS, q.getScrollLocationMS());
selectAndChangePaper.set(false);
mtopicsChoiceBox.getSelectionModel().select(t);
selectAndChangePaper.set(true);
mpaperSelectListView.getSelectionModel().selectFirst();
setQuestionsTopicsChoiceBox();
if(mtopicsChoiceBox.getItems() == t) {
setTopicQuestionsList(topics.indexOf(t));
scrollTo(scrollPane, q.getScrollLocation());
scrollTo(scrollPaneMS, q.getScrollLocationMS());
selectAndChangePaper.set(false);
mtopicsChoiceBox.getSelectionModel().select(t);
selectAndChangePaper.set(true);
mpaperSelectListView.getSelectionModel().selectFirst();
setQuestionsTopicsChoiceBox();
//break outerloop;
}else if(clickedTopicsListview ==0){
setTopicQuestionsList(topics.indexOf(t));
scrollTo(scrollPane, q.getScrollLocation());
scrollTo(scrollPaneMS, q.getScrollLocationMS());
selectAndChangePaper.set(false);
mtopicsChoiceBox.getSelectionModel().select(t);
selectAndChangePaper.set(true);
mpaperSelectListView.getSelectionModel().selectFirst();
setQuestionsTopicsChoiceBox();
}
}
}
}
Expand Down Expand Up @@ -324,7 +343,10 @@ public void initialize() throws IOException {
}
});



mtopicSelectListView.setOnMouseClicked(event -> {
clickedTopicsListview = 1;
lastSelectedList = mtopicSelectListView;
setQuestionsTopicsChoiceBox();
Question lastQuestionClicked = getQuestionByLastClicked();
Expand All @@ -339,9 +361,8 @@ public void initialize() throws IOException {
scrollTo(scrollPaneMS, lastQuestionClicked.getScrollLocationMS());
}
});
clickedTopicsListview = 0;

mtopicSelectListView.setItems(listViewTopicQ);
mpaperSelectListView.setItems(listViewPaperQ);
}

public Question getQuestionByLastClicked(){
Expand Down Expand Up @@ -491,7 +512,7 @@ public void getPaperTopicsList(){
for (Topic t:topics) {
for (Question q: t.getQuestions()) {
if (q.getPaper().equals(mpaperChoiceBox.getSelectionModel().getSelectedItem().toString())){
topicsListArray.add(t.toString());
topicsListArray.add(q.getQuestionNumber() + " -- " + t.toString());
}
}
}
Expand Down Expand Up @@ -645,14 +666,14 @@ public void questionDialog(String QuestionS,ArrayList<Integer> topicIndex){
selectAndChangePaper.set(false);
mtopicsChoiceBox.getSelectionModel().select(t);
selectAndChangePaper.set(true);
try {
saveJson(new ActionEvent());
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
try {
saveJson(new ActionEvent());
} catch (IOException e) {
e.printStackTrace();
}
}else{
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Incorrect input");
Expand Down Expand Up @@ -799,10 +820,67 @@ public void about(ActionEvent actionEvent) {
name.setStyle("-fx-font-weight: bold");
contents.getChildren().add(name);
contents.getChildren().add(new Text("as a means to organize past Papers and help improve student learning. \n\r"));
contents.getChildren().add(new Text("If this program was useful please send me a line, I would love to hear how/where this is being used. \n\r"));
contents.getChildren().add(new Text("If this program was useful please send me a line (bluishmatt@gmail.com), I would love to hear how/where this is being used. \n\r"));
contents.getChildren().add(new Text("If it is super useful, you can also show your appreciation via paypal: "));
contents.getChildren().add(new Hyperlink("Paypal (to be added) bluishmatt@gmail.com"));
contents.getChildren().add(new Text("\n\rPlease report any issues or feature requests on github."));

Hyperlink paypalLink = new Hyperlink("paypal.me/MattElliot86");
paypalLink.setOnMouseClicked(event -> {
try {
Desktop desk=Desktop.getDesktop();
desk.browse(new URI("https://www.paypal.me/MattElliot86"));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});
contents.getChildren().add(paypalLink);
contents.getChildren().add(new Text("\n\r"));


Button donateToPaypal = new Button();
donateToPaypal.setStyle("-fx-graphic: url('images/PayPal.png')");
donateToPaypal.setOnMouseClicked(event -> {
try {
Desktop desk=Desktop.getDesktop();
desk.browse(new URI("https://www.paypal.me/MattElliot86"));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});
contents.getChildren().add(donateToPaypal);

contents.getChildren().add(new Text("\n\r"));

contents.getChildren().add(new Text("or donate pizza! "));
Hyperlink coffeeLink = new Hyperlink("buymeacoffee.com/MattElliot");
coffeeLink.setOnMouseClicked(event -> {
try {
Desktop desk=Desktop.getDesktop();
desk.browse(new URI("https://www.buymeacoffee.com/MattElliot"));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});
contents.getChildren().add(coffeeLink);
contents.getChildren().add(new Text("\n\r"));

Button buyMeAPizza = new Button(" (no signup required)");
buyMeAPizza.setStyle("-fx-font-weight: bold");
buyMeAPizza.setStyle("-fx-graphic: url('images/Pizza.png')");
buyMeAPizza.setOnMouseClicked(event -> {
try {
Desktop desk=Desktop.getDesktop();
desk.browse(new URI("https://www.buymeacoffee.com/MattElliot"));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});
contents.getChildren().add(buyMeAPizza);

contents.getChildren().add(new Text("\n\r"));

contents.getChildren().add(new Text("Please report any issues or feature requests on github."));



alert.getDialogPane().setContent(contents);
alert.showAndWait();
Expand Down
Binary file added src/main/resources/images/PayPal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/Pizza.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a38eb13

Please sign in to comment.