Search in sources :

Example 6 with Rules

use of eu.tn.model.Rules in project TNCY-English-Project by mrngg.

the class AnswerSheetController method initialize.

@FXML
public void initialize() {
    actualRules = actualTest.randomRules().getName();
    for (Rules r : actualTest.getRules()) {
        if (r.getName().equals(actualRules)) {
            r.setVisited(true);
            actualSentences = r.randomSentences().getName();
            for (Sentences s : r.getSentences()) {
                if (s.getName().equals(actualSentences)) {
                    s.setVisited(true);
                }
            }
        }
    }
    sentences.setText(actualSentences);
}
Also used : Sentences(eu.tn.model.Sentences) Rules(eu.tn.model.Rules) FXML(javafx.fxml.FXML)

Example 7 with Rules

use of eu.tn.model.Rules in project TNCY-English-Project by mrngg.

the class DbRulesController method ruleChoosen.

public void ruleChoosen() {
    if (availableRules.getSelectionModel().getSelectedItem() != null) {
        int j = 0;
        for (Rules r : rules) {
            if (r.getName().equals(availableRules.getSelectionModel().getSelectedItem().toString())) {
                j = rules.indexOf(r);
            }
        }
        ObservableList<String> items = FXCollections.observableArrayList();
        for (int i = 0; i < rules.get(j).getSentences().size(); i++) {
            items.add(rules.get(j).getSentences().get(i).getName());
        }
        rulesSentences.setItems(items);
        rulesName.setText(rules.get(j).getName());
        rulesHint.setText(rules.get(j).getHint());
        sentencesName.setText("");
        sentencesAnswer.setText("");
    }
}
Also used : Rules(eu.tn.model.Rules)

Example 8 with Rules

use of eu.tn.model.Rules in project TNCY-English-Project by mrngg.

the class DbRulesController method removeSentences.

public void removeSentences() throws IOException {
    if (availableRules.getSelectionModel().getSelectedItem() != null && rulesSentences.getSelectionModel().getSelectedItem() != null) {
        int j = 0;
        int i = 0;
        for (Rules r : rules) {
            if (r.getName().equals(availableRules.getSelectionModel().getSelectedItem().toString())) {
                j = rules.indexOf(r);
                for (Sentences s : r.getSentences()) {
                    if (s.getName().equals(rulesSentences.getSelectionModel().getSelectedItem().toString())) {
                        i = r.getSentences().indexOf(s);
                    }
                }
            }
        }
        rules.get(j).getSentences().remove(i);
        ObservableList<String> items = FXCollections.observableArrayList();
        for (i = 0; i < rules.size(); i++) {
            items.add(rules.get(i).getName());
        }
        availableRules.setItems(items);
        ObservableList<String> itemS = FXCollections.observableArrayList();
        for (i = 0; i < rules.get(j).getSentences().size(); i++) {
            itemS.add(rules.get(j).getSentences().get(i).getName());
        }
        rulesSentences.setItems(itemS);
        sentencesName.setText("");
        sentencesAnswer.setText("");
        new Database().save();
    }
}
Also used : Database(eu.tn.model.Database) Sentences(eu.tn.model.Sentences) Rules(eu.tn.model.Rules)

Example 9 with Rules

use of eu.tn.model.Rules in project TNCY-English-Project by mrngg.

the class DbRulesController method sentenceChoosen.

public void sentenceChoosen() {
    if (availableRules.getSelectionModel().getSelectedItem() != null && rulesSentences.getSelectionModel().getSelectedItem() != null) {
        int j = 0;
        int i = 0;
        for (Rules r : rules) {
            if (r.getName().equals(availableRules.getSelectionModel().getSelectedItem().toString())) {
                j = rules.indexOf(r);
                for (Sentences s : r.getSentences()) {
                    if (s.getName().equals(rulesSentences.getSelectionModel().getSelectedItem().toString())) {
                        i = r.getSentences().indexOf(s);
                    }
                }
            }
        }
        sentencesName.setText(rules.get(j).getSentences().get(i).getName());
        sentencesAnswer.setText(rules.get(j).getSentences().get(i).getAnswer());
    }
}
Also used : Sentences(eu.tn.model.Sentences) Rules(eu.tn.model.Rules)

Example 10 with Rules

use of eu.tn.model.Rules in project TNCY-English-Project by mrngg.

the class DbRulesController method removeRules.

public void removeRules() throws IOException {
    int j = 0;
    if (availableRules.getSelectionModel().getSelectedItem() != null) {
        for (Rules r : rules) {
            if (r.getName().equals(availableRules.getSelectionModel().getSelectedItem().toString())) {
                j = rules.indexOf(r);
            }
        }
        rules.remove(j);
        ObservableList<String> items = FXCollections.observableArrayList();
        for (int i = 0; i < rules.size(); i++) {
            items.add(rules.get(i).getName());
        }
        availableRules.setItems(items);
        ObservableList<String> itemS = FXCollections.observableArrayList();
        rulesSentences.setItems(itemS);
        rulesName.setText("");
        rulesHint.setText("");
        sentencesName.setText("");
        sentencesAnswer.setText("");
        new Database().save();
    }
}
Also used : Database(eu.tn.model.Database) Rules(eu.tn.model.Rules)

Aggregations

Rules (eu.tn.model.Rules)14 Database (eu.tn.model.Database)8 Sentences (eu.tn.model.Sentences)8 IOException (java.io.IOException)6 Scene (javafx.scene.Scene)5 Button (javafx.scene.control.Button)5 Label (javafx.scene.control.Label)5 TextField (javafx.scene.control.TextField)5 Stage (javafx.stage.Stage)5 Insets (javafx.geometry.Insets)4 GridPane (javafx.scene.layout.GridPane)4 Tests (eu.tn.model.Tests)3 FXML (javafx.fxml.FXML)2 Platform (javafx.application.Platform)1 FXMLLoader (javafx.fxml.FXMLLoader)1 BorderPane (javafx.scene.layout.BorderPane)1