Flgc / javafx-jdbc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Projeto JavaFX com JDBC

Programação Orientada a Objetos com Java


Java MySQL Linux Windows

NPM

Sobre   |   Demonstração   |   Como instalar e executar o projeto   |   Contato   |  



📃 Sobre o projeto

https://github.com/Flgc/javafx-jdbc

O projeto foi desenvolvido durante o curso de Java COMPLETO - Programação Orientada a Objetos + Projetos.

Objetivo geral: Desenvolvimento de aplicações JavaFX com JDBC e o aprofundamento dos fundamentos e a utilização das ferramentas. O principal requisito para esse projeto é que o estudante já tenha conhecimento em OO, Lambda, JDBC e JavaFx com SceneBuilder.

✨ Features

✔ Local project

  • Checklist:

    User libraries: JavaFX, MySQLConnector Run configurarions -> VM arguments: --module-path [path]\java-libs\javafx-sdk\lib --add-modules=javafx.fxml,javafx.controls

✔ 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) 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 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

  • Prerequisites: MySQL server installed and running Database created and instantiated Data access layer implemented (DAO pattern)

  • 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

✔ 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

✔ Saving Seller

  • Checklist: Clone SellerService

    • Replace: Department -> Seller

    Clone SellerListController

    • Replace: Department -> Seller
    • Comment createDialogForm

    Clone SellerList.fxml

    • Replace: Department -> Seller

    Update MainViewController.onMenuItemSellerAction

✔ Seller TableView

✔ SellerForm

  • Checklist:

    Clone SellerFormController

    • Replace: Department -> Seller

    Clone SellerForm view

    • Replace: Department -> Seller

    SellerListController

    • Uncomment createDialogForm

✔ TextField & DatePicker

  • References: https://stackoverflow.com/questions/26831978/javafx-datepicker-getvalue-in-a-specific-format

  • 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

🌎 Demonstração Web

🚀 Tecnologias utilizadas

  • Java
  • JavaFX
  • MySQL
  • SeneBuilder
  • JDBC
  • Eclipse 4.9 2018-09

🔧 Como instalar e executar o projeto

Pré-requisitos: npm / yarn

# clonar repositório
git clone https://github.com/Flgc/javafx-jdbc


# instalar dependências
Java 11
Javafx
mysql-connector-java-8.0.26
Instalar o plug-in E(fx)clipse (>= 3.4.1 version)

📲 Contato

Fabio Luis Guia da Conceição

LinkedIn


©2021/09 - Fábio Luís

About

License:MIT License


Languages

Language:Java 99.8%Language:CSS 0.2%