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);
}
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("");
}
}
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();
}
}
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());
}
}
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();
}
}
Aggregations