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
FieldsModifier and TypeFieldDescriptionjavafx.scene.control.Buttonjavafx.scene.control.ComboBox<Unit>javafx.scene.control.Spinner<Integer>javafx.scene.control.Labeljavafx.scene.control.ListView<Unit>javafx.scene.control.ListView<String>javafx.scene.control.Buttonjavafx.scene.control.Buttonjavafx.scene.control.Labeljavafx.scene.control.TextFieldjavafx.scene.layout.HBoxprivate javafx.collections.ObservableList<String>javafx.scene.control.Spinner<Integer>javafx.scene.control.TextFieldjavafx.scene.control.ComboBox<String> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds event listeners to some fields to set buttons to disabled if input is invalid.voidaddUnits()Called for adding new units.voidCancel all changes and changes scene to the main page.voidCalled for deleting a unit.voiddisplaySuccessfulPopupMessage(String successMessage) Display successful popup message.voidCalled for updating the army's name.voidinitialize(URL url, ResourceBundle resourceBundle) Run when the fxml file is first loaded.voidUpdate army and go back.voidUpdate all fields and labels with updated information.voidWrites 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:
initializein interfacejavafx.fxml.Initializable- Parameters:
url- URL - a Uniform Resource LoaderresourceBundle- ResourceBundle
-