Versão com comentarios aqui
Objetivo geral:
Introduzir o aluno ao desenvolvimento de aplicações JavaFX com JDBC
Permitir que o aluno conheça os fundamentos e a utilização das ferramentas, de modo que ele possa
depois prosseguir estudando, de forma confortável, as especificidades que desejar
Checklist:
Create FXML "MainView" (package "gui")
Load FXML in Main
Update Main.java
Checklist:
Design MainView.fxml
Customize menu items
Update Main.java
Checklist:
Create controller
In view, associate controller, ids, events
Checklist:
Include util classes to the project (Alerts.java, Constraints.java)
https://github.com/acenelio/javafx5/blob/master/src/gui/util/Alerts.java
https://github.com/acenelio/javafx5/blob/master/src/gui/util/Constraints.java
Create About.fxml (VBox)
In Main.java, expose mainScene reference
In MainViewController.java, create loadView method
Checklist:
Create DepartmentList.fxml (VBox)
In MainViewController.java, load DepartmentList
Checklist:
Create model.entities.Department.java
https://github.com/acenelio/demo-dao-jdbc/blob/master/src/model/entities/Department.java
Create DepartmentListController.java
In view, associate controller, ids, events
Checklist:
Create model.services.DepartmentService.java with findAll method
In DepartmentListController:
Create DepartmentService dependency with set method
Create ObservableList
Create updateTableViewData method
Checklist:
Add a Consumer parameter to loadView method
After loading view, call accept from the Consumer
Add a consumer instance on loadView calls
Checklist:
add model.entities.Seller.java
Add db.properties do project
Add data access packages to project:
db
model.dao
model.dao.impl
In DepartmentService, add DepartmentDao dependency with Factory call
Checklist:
Create gui.util.Utils.java with currentStage method
Create DepartmentForm.fxml (AnchorPane)
GridPane 3x3 (anchors: 20 top, 20 left)
Id text box: not editable
Label error: red
HBox (spacing: 5)
In DepartmentListController, create createDialogForm method
Call createDialogForm on "new" button action
Checklist:
Create DepartmentFormController.java
In view, associate controller, ids, events
Checklist:
In DepartmentFormController
Create a Department dependency with set method
Create updateFormData method
In DepartmentListController
Update onBtNewAction method
Update createDialogForm method
Checklist:
In Utils, implement tryParseToInt method
In DepartmentService, create saveOrUpdate method
In DepartmentFormController
Create a DepartmentService dependency with set method
Implement onBtSaveAction
Implement onBtCancelAction
In DepartmentListController, inject DepartmentService instance
Checklist:
Create interface gui.listeners.DataChangeListener
In DepartmentFormController (subject)
Create List dependency with subscribe method
Notify subscribers when needed
In DepartmentListController (observer)
Implement DataChangeListener interface
Subscribe for DepartmentFormController
Checklist:
Create model.exceptions.ValidationException
In DepartmentFormController
In getFormData method, implement verifications and throw ValidationException
Implement setErrorMessages method
In onBtSaveAction, catch ValidationException
Checklist:
In DepartmentListController
Create new attribute: TableColumn<Department, Department> tableColumnEDIT;
Create initEditButtons method
In updateTableViewData, call initEditButtons
In DepartmentList.fxml
Include new table column
Associate id
Checklist:
In Alerts, create showConfirmation method
In DepartmentService, create remove method
In DepartmentListController
Create new attribute: TableColumn<Department, Department> tableColumnREMOVE;
Create initRemoveButtons method
Catch DbIntegrityException
In updateTableViewData, call initRemoveButtons
In DepartmentList.fxml
Include new table column
Associate id
Checklist:
.gitignore: .settings/
Delete .settings/ folder
Checklist:
Clone SellerService
Replace: Department -> Seller
Clone SellerListController
Replace: Department -> Seller
Comment createDialogForm
Clone SellerList.fxml
Replace: Department -> Seller
Update MainViewController.onMenuItemSellerAction
Checklist:
gui.utils.Util.java
formatTableColumnDate method
formatTableColumnDouble method
SellerListController
TableColumn attributes (Email, BirthDate, BaseSalary)
Update initializeNodes
SellerListView
TableColumn (Email, BirthDate, BaseSalary)
Associate fx:id
Checklist:
Clone SellerFormController
Replace: Department -> Seller
Clone SellerForm view
Replace: Department -> Seller
SellerListController
Uncomment createDialogForm
Checklist:
gui.utils.Util.java
formatDatePicker method
TextField & DatePicker attributes (Email, BirthDate, BaseSalary)
Label error attributes (Email, BirthDate, BaseSalary)
Edit SellerFormView
Bugfix: SellerDaoJDBC.instantiateSeller
obj.setBirthDate(new java.util.Date(rs.getTimestamp("BirthDate").getTime()));
Update: initializeNodes
Update: updateFormData
Checklist:
Update controller:
DepartmentService dependency
attribute
set method
ComboBox comboBoxDepartment
ObservableList obsList
loadAssociatedObjects
initializeComboBoxDepartment
updateFormData
Update view:
ComboBox
fx:id
Checklist:
Update: getFormData
Update: setErrorMessages