Removed prints used for testing and changed addword.fxml to remove version error

Edited the Saved success pop up to show the entry that has been added to the dictionary. Also removed the print statements that were used for initial testing and also changed the version in addword.fxml to remove the version error that came up every time.
This commit is contained in:
Henry Dugmore 2020-04-28 15:38:02 +01:00
parent bb41340481
commit 7564bf1649
6 changed files with 160 additions and 77 deletions

View file

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View file

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="junit">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.12.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="junit-4.12">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.12.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -0,0 +1,17 @@
<component name="libraryTable">
<library name="org.junit.jupiter:junit-jupiter:5.5.2" type="repository">
<properties maven-id="org.junit.jupiter:junit-jupiter:5.5.2" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.5.2/junit-jupiter-5.5.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.5.2/junit-jupiter-api-5.5.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.5.2/junit-platform-commons-1.5.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.5.2/junit-jupiter-params-5.5.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.5.2/junit-jupiter-engine-5.5.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.5.2/junit-platform-engine-1.5.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -17,9 +17,12 @@ import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
public class AddWordController {
@FXML private TextField welsh;
@FXML private TextField english;
@FXML private ComboBox<String> wordType;
@FXML
private TextField welsh;
@FXML
private TextField english;
@FXML
private ComboBox<String> wordType;
public TextField getWelsh() {
return welsh;
@ -30,32 +33,30 @@ public class AddWordController {
}
@FXML
private void initialize(){
private void initialize() {
wordType.getItems().addAll("Masculine noun", "Feminine noun", "Verb", "Other");
System.out.println("Test");
wordType.setValue("Type");
}
@FXML protected void addButtonClick (ActionEvent actionEvent){
@FXML
protected void addButtonClick(ActionEvent actionEvent) {
boolean entryFound = false;
// one or more blank fields
if (english.getText() == null || welsh.getText() == null|| wordType.getValue().equals("Type")){
if (english.getText() == null || welsh.getText() == null || wordType.getValue().equals("Type")) {
Alert error = new Alert(Alert.AlertType.ERROR);
error.setTitle("Error");
error.setHeaderText("Entry Not Saved");
error.setContentText("One or more fields are blank");
error.showAndWait();
}
else {
for (DictionaryEntry entry : Application.dictionary){
} else {
for (DictionaryEntry entry : Application.dictionary) {
entryFound = false;
DictionaryEntry newEntry = new DictionaryEntry(english.getText(),welsh.getText(),wordType.getValue());
if(entry.equals(newEntry)){
DictionaryEntry newEntry = new DictionaryEntry(english.getText(), welsh.getText(), wordType.getValue());
if (entry.equals(newEntry)) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Entry Not Saved");
@ -64,16 +65,15 @@ public class AddWordController {
alert.showAndWait();
entryFound = true;
break;
}
else{
} else {
continue;
}
}
if(!entryFound){
if (!entryFound) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Success");
alert.setHeaderText("Entry Saved");
alert.setContentText("Entry Added");
alert.setContentText("Entry Added - English: " + english.getText() + " Welsh: " + welsh.getText() + " Type: " + wordType.getValue());
alert.showAndWait();
DictionaryEntry dictionaryEntry = new DictionaryEntry(english.getText(), welsh.getText(), wordType.getValue());
@ -81,9 +81,9 @@ public class AddWordController {
Application.dictionary.add(dictionaryEntry);
// output of what was saved for testing
System.out.print(english.getText());
System.out.print(welsh.getText());
System.out.println(wordType.getValue());
// System.out.print(english.getText());
// System.out.print(welsh.getText());
// System.out.println(wordType.getValue());
// Resets values to blank for next word to be entered
english.clear();
@ -108,14 +108,38 @@ public class AddWordController {
private void switchToPrimary() throws IOException {
Application.setRoot("Primary");
}
// add character methods for characters ch, dd, ff, ng, ll, ph, rh, th
public void addCharch(ActionEvent actionEvent) { welsh.appendText("ch"); }
public void addChardd(ActionEvent actionEvent) { welsh.appendText("dd"); }
public void addCharff(ActionEvent actionEvent) { welsh.appendText("ff"); }
public void addCharng(ActionEvent actionEvent) { welsh.appendText("ng"); }
public void addCharll(ActionEvent actionEvent) { welsh.appendText("ll"); }
public void addCharph(ActionEvent actionEvent) { welsh.appendText("ph"); }
public void addCharrh(ActionEvent actionEvent) { welsh.appendText("rh"); }
public void addCharth(ActionEvent actionEvent) { welsh.appendText("th"); }
// add character methods for characters ch, dd, ff, ng, ll, ph, rh, th
public void addCharch(ActionEvent actionEvent) {
welsh.appendText("ch");
}
public void addChardd(ActionEvent actionEvent) {
welsh.appendText("dd");
}
public void addCharff(ActionEvent actionEvent) {
welsh.appendText("ff");
}
public void addCharng(ActionEvent actionEvent) {
welsh.appendText("ng");
}
public void addCharll(ActionEvent actionEvent) {
welsh.appendText("ll");
}
public void addCharph(ActionEvent actionEvent) {
welsh.appendText("ph");
}
public void addCharrh(ActionEvent actionEvent) {
welsh.appendText("rh");
}
public void addCharth(ActionEvent actionEvent) {
welsh.appendText("th");
}
}

View file

@ -8,57 +8,75 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="506.0" prefWidth="702.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="uk.ac.aber.cs22120.group20.javafx.AddWordController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="84.33331298828125" minWidth="10.0" prefWidth="10.666646321614593" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="273.3333536783854" minWidth="10.0" prefWidth="273.3333536783854" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="87.3333740234375" minWidth="7.6666259765625" prefWidth="7.6666259765625" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="50.66668701171875" minHeight="10.0" prefHeight="50.66668701171875" vgrow="SOMETIMES" />
<RowConstraints maxHeight="46.33333333333332" minHeight="10.0" prefHeight="46.33333333333332" vgrow="SOMETIMES" />
<RowConstraints maxHeight="37.666646321614564" minHeight="10.0" prefHeight="37.666646321614564" vgrow="SOMETIMES" />
<RowConstraints maxHeight="34.3333740234375" minHeight="10.0" prefHeight="34.3333740234375" vgrow="SOMETIMES" />
<RowConstraints maxHeight="123.99998474121094" minHeight="10.0" prefHeight="76.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="110.0" minHeight="10.0" prefHeight="31.66668701171872" vgrow="SOMETIMES" />
<RowConstraints maxHeight="133.0" minHeight="10.0" prefHeight="28.999979654947936" vgrow="SOMETIMES" />
<RowConstraints maxHeight="129.33331298828125" minHeight="10.0" prefHeight="129.33331298828125" vgrow="SOMETIMES" />
</rowConstraints>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="506.0"
prefWidth="702.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="uk.ac.aber.cs22120.group20.javafx.AddWordController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="84.33331298828125" minWidth="10.0" prefWidth="10.666646321614593"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="273.3333536783854" minWidth="10.0" prefWidth="273.3333536783854"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="87.3333740234375" minWidth="7.6666259765625"
prefWidth="7.6666259765625"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="50.66668701171875" minHeight="10.0" prefHeight="50.66668701171875" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="46.33333333333332" minHeight="10.0" prefHeight="46.33333333333332" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="37.666646321614564" minHeight="10.0" prefHeight="37.666646321614564"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="34.3333740234375" minHeight="10.0" prefHeight="34.3333740234375" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="123.99998474121094" minHeight="10.0" prefHeight="76.0" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="110.0" minHeight="10.0" prefHeight="31.66668701171872" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="133.0" minHeight="10.0" prefHeight="28.999979654947936" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="129.33331298828125" minHeight="10.0" prefHeight="129.33331298828125"
vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Label alignment="CENTER" prefHeight="17.0" prefWidth="105.0" text="English" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label alignment="CENTER" prefHeight="17.0" prefWidth="105.0" text="Welsh" GridPane.columnIndex="5" GridPane.rowIndex="2" />
<ComboBox fx:id="wordType" prefHeight="25.0" prefWidth="275.0" promptText="Type" GridPane.columnIndex="3" GridPane.rowIndex="3" />
<Button mnemonicParsing="false" onAction="#addButtonClick" prefHeight="25.0" prefWidth="274.0" text="Add Word" GridPane.columnIndex="3" GridPane.rowIndex="4" />
<TextField fx:id="english" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<TextField fx:id="welsh" GridPane.columnIndex="5" GridPane.rowIndex="3" />
<Button mnemonicParsing="false" onAction="#switchToPrimary" prefHeight="25.0" prefWidth="107.0" text="Switch Scene" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Label alignment="CENTER" prefHeight="17.0" prefWidth="105.0" text="English" GridPane.columnIndex="1"
GridPane.rowIndex="2"/>
<Label alignment="CENTER" prefHeight="17.0" prefWidth="105.0" text="Welsh" GridPane.columnIndex="5"
GridPane.rowIndex="2"/>
<ComboBox fx:id="wordType" prefHeight="25.0" prefWidth="275.0" promptText="Type" GridPane.columnIndex="3"
GridPane.rowIndex="3"/>
<Button mnemonicParsing="false" onAction="#addButtonClick" prefHeight="25.0" prefWidth="274.0" text="Add Word"
GridPane.columnIndex="3" GridPane.rowIndex="4"/>
<TextField fx:id="english" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<TextField fx:id="welsh" GridPane.columnIndex="5" GridPane.rowIndex="3"/>
<Button mnemonicParsing="false" onAction="#switchToPrimary" prefHeight="25.0" prefWidth="107.0"
text="Switch Scene" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
<GridPane prefHeight="55.0" prefWidth="258.0" GridPane.columnIndex="3" GridPane.rowIndex="5">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharch" prefHeight="25.0" prefWidth="35.0" text="ch" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addChardd" prefHeight="25.0" prefWidth="34.0" text="dd" GridPane.columnIndex="1" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharff" prefHeight="25.0" prefWidth="34.0" text="ff" GridPane.columnIndex="2" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharng" prefHeight="25.0" prefWidth="34.0" text="ng" GridPane.columnIndex="3" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharll" prefHeight="25.0" prefWidth="34.0" text="ll" GridPane.columnIndex="4" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharph" prefHeight="25.0" prefWidth="34.0" text="ph" GridPane.columnIndex="5" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharrh" prefHeight="25.0" prefWidth="34.0" text="rh" GridPane.columnIndex="6" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharth" prefHeight="25.0" prefWidth="34.0" text="th" GridPane.columnIndex="7" />
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharch"
prefHeight="25.0" prefWidth="35.0" text="ch"/>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addChardd"
prefHeight="25.0" prefWidth="34.0" text="dd" GridPane.columnIndex="1"/>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharff"
prefHeight="25.0" prefWidth="34.0" text="ff" GridPane.columnIndex="2"/>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharng"
prefHeight="25.0" prefWidth="34.0" text="ng" GridPane.columnIndex="3"/>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharll"
prefHeight="25.0" prefWidth="34.0" text="ll" GridPane.columnIndex="4"/>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharph"
prefHeight="25.0" prefWidth="34.0" text="ph" GridPane.columnIndex="5"/>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharrh"
prefHeight="25.0" prefWidth="34.0" text="rh" GridPane.columnIndex="6"/>
<Button minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#addCharth"
prefHeight="25.0" prefWidth="34.0" text="th" GridPane.columnIndex="7"/>
</children>
</GridPane>
</children>