Skip to content

Repositorio referente as aulas da sessão 23(Projeto: Aplicação desktop com JavaFX e banco de dados MySQL com JDBC) do curso: Java COMPLETO 2022 Programacao Orientada a Objetos - professor Nelio Alves.

Notifications You must be signed in to change notification settings

rodrigojfagundes/workshop-javafx-jdbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

workshop-javafx-jdbc

Curso: Java COMPLETO 2022 Programação Orientada a Objetos + Projetos | Udemy

Prof. Dr. Nelio Alves

Capítulo: Projeto: Aplicação desktop com JavaF e anco de dados MySQL com JDBC

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

Tela inicial do sistema

Tela de vendedores cadastrados

Tela de cadastro de vendedores

Tela de departamentos cadastrados

Tela para cadastrar um novo departamento

Main view

Checklist:
Create FXML "MainView" (package "gui")
Load FXML in Main
Update Main.java

Main view design

Checklist:
Design MainView.fxml
Customize menu items
Update Main.java

Main view controller

Checklist:
Create controller
In view, associate controller, ids, events

About view

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

DepartmentList view design

Checklist:
Create DepartmentList.fxml (VBox)
In MainViewController.java, load DepartmentList

DepartmentList controller

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

DepartmentService

Checklist:
Create model.services.DepartmentService.java with findAll method
In DepartmentListController:
Create DepartmentService dependency with set method
Create ObservableList
Create updateTableViewData method

Initializing action as parameter

Checklist:
Add a Consumer parameter to loadView method
After loading view, call accept from the Consumer
Add a consumer instance on loadView calls

Adding database access

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

DepartmentForm (dialog) design

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

DepartmentFormController

Checklist:
Create DepartmentFormController.java
In view, associate controller, ids, events

Passing a Department object to DepartmentForm view

Checklist:
In DepartmentFormController
Create a Department dependency with set method
Create updateFormData method
In DepartmentListController
Update onBtNewAction method
Update createDialogForm method

Saving a new Department

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

Observer design pattern to update tableview

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

Validation exception

Checklist:
Create model.exceptions.ValidationException
In DepartmentFormController
In getFormData method, implement verifications and throw ValidationException
Implement setErrorMessages method
In onBtSaveAction, catch ValidationException

Update department

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

Remove department

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

Deleting .settings folder

Checklist:
.gitignore: .settings/
Delete .settings/ folder

SellerList

Checklist:
Clone SellerService
Replace: Department -> Seller
Clone SellerListController
Replace: Department -> Seller
Comment createDialogForm
Clone SellerList.fxml
Replace: Department -> Seller
Update MainViewController.onMenuItemSellerAction

Seller TableView

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

SellerForm

Checklist:
Clone SellerFormController
Replace: Department -> Seller
Clone SellerForm view
Replace: Department -> Seller
SellerListController
Uncomment createDialogForm

TextField & DatePicker

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

Department ComboBox

Checklist:
Update controller:
DepartmentService dependency
attribute
set method
ComboBox comboBoxDepartment
ObservableList obsList
loadAssociatedObjects
initializeComboBoxDepartment
updateFormData
Update view:
ComboBox
fx:id

Saving Seller

Checklist:
Update: getFormData
Update: setErrorMessages

About

Repositorio referente as aulas da sessão 23(Projeto: Aplicação desktop com JavaFX e banco de dados MySQL com JDBC) do curso: Java COMPLETO 2022 Programacao Orientada a Objetos - professor Nelio Alves.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published