Class EditArmyController
java.lang.Object
edu.ntnu.idatt2001.carljgu.client.controllers.EditArmyController
- All Implemented Interfaces:
javafx.fxml.Initializable
A controller class which
handles events in the fxml file edit-army.fxml.
This includes requesting to import
armies and simulate the battle
- Version:
- 1.9 14.05.2022
- Author:
- Carl Gützkow
-
Field Summary
Modifier and TypeFieldDescriptionjavafx.scene.control.Button
javafx.scene.control.ComboBox<Unit>
javafx.scene.control.Spinner<Integer>
javafx.scene.control.Label
javafx.scene.control.ListView<Unit>
javafx.scene.control.ListView<String>
javafx.scene.control.Button
javafx.scene.control.Button
javafx.scene.control.Label
javafx.scene.control.TextField
javafx.scene.layout.HBox
private javafx.collections.ObservableList<String>
javafx.scene.control.Spinner<Integer>
javafx.scene.control.TextField
javafx.scene.control.ComboBox<String>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds event listeners to some fields to set buttons to disabled if input is invalid.void
addUnits()
Called for adding new units.void
Cancel all changes and changes scene to the main page.void
Called for deleting a unit.void
displaySuccessfulPopupMessage
(String successMessage) Display successful popup message.void
Called for updating the army's name.void
initialize
(URL url, ResourceBundle resourceBundle) Run when the fxml file is first loaded.void
Update army and go back.void
Update all fields and labels with updated information.void
Writes the changed army to a csv file.
-
Field Details
-
editArmyTitle
public javafx.scene.control.Label editArmyTitle -
armyToString
public javafx.scene.control.Label armyToString -
editNameField
public javafx.scene.control.TextField editNameField -
editArmyNameButton
public javafx.scene.control.Button editArmyNameButton -
addUnitsButton
public javafx.scene.control.Button addUnitsButton -
deleteUnitsButton
public javafx.scene.control.Button deleteUnitsButton -
unitsTypeComboBox
-
amountOfUnitsSpinner
-
unitsHealthSpinner
-
unitsNameField
public javafx.scene.control.TextField unitsNameField -
allUnitsComboBox
-
armyUnitsListView
-
changelogListView
-
hboxRoot
public javafx.scene.layout.HBox hboxRoot -
observableChangelog
-
-
Constructor Details
-
EditArmyController
public EditArmyController()
-
-
Method Details
-
editArmyName
public void editArmyName()Called for updating the army's name. -
addUnits
public void addUnits()Called for adding new units. Adds units with information about amount of units, their name, their health, and their unit type. -
deleteUnit
public void deleteUnit()Called for deleting a unit. -
cancelAllChanges
public void cancelAllChanges()Cancel all changes and changes scene to the main page. As the changes are stored in a deep copy, the scene change disregards these changes. -
writeToCSV
public void writeToCSV()Writes the changed army to a csv file. -
updateArmyAndGoBack
public void updateArmyAndGoBack()Update army and go back. Sets the original army to the deep copied army. -
displaySuccessfulPopupMessage
Display successful popup message. Creates a new stage which is removed after a click. Adds a blur effect behind the popup message that is removed after it is hidden.- Parameters:
successMessage
- the success message
-
updateComponentsWithInformation
public void updateComponentsWithInformation()Update all fields and labels with updated information. -
addEventListenersToFieldsAndLists
public void addEventListenersToFieldsAndLists()Adds event listeners to some fields to set buttons to disabled if input is invalid. -
initialize
Run when the fxml file is first loaded. Fills in the combo boxes and spinners- Specified by:
initialize
in interfacejavafx.fxml.Initializable
- Parameters:
url
- URL - a Uniform Resource LoaderresourceBundle
- ResourceBundle
-