comment desktop models and utils
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Module descriptor for the pet shop desktop application.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
module org.example.petshopdesktop {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Table-friendly wrapper for appointment data using JavaFX properties.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.DTOs;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Table-friendly wrapper for product data using JavaFX properties.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.DTOs;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Table-friendly wrapper for product-supplier data using JavaFX properties.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.DTOs;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Table-friendly wrapper for purchase order data using JavaFX properties.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.DTOs;
|
||||
|
||||
import javafx.beans.property.*;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Table-friendly wrapper for sale data using JavaFX properties.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.DTOs;
|
||||
|
||||
import javafx.beans.property.*;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Table-friendly wrapper for service data using JavaFX properties.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.DTOs;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
@@ -107,4 +113,4 @@ public class ServiceDTO {
|
||||
|
||||
return service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Entry point that starts the JavaFX application.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop;
|
||||
|
||||
import javafx.application.Application;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Main JavaFX application that sets up and launches the window.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop;
|
||||
|
||||
import javafx.application.Application;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Shared input validation methods used across the app.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop;
|
||||
|
||||
public class Validator {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Defines the roles a user can have in the system.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.auth;
|
||||
|
||||
public enum Role {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Stores the currently logged-in user's session details.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.auth;
|
||||
|
||||
public class UserSession {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents an adoption record with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents an appointment with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
@@ -43,4 +49,4 @@ public class Appointment {
|
||||
public SimpleStringProperty appointmentDateProperty() { return appointmentDate; }
|
||||
public SimpleStringProperty appointmentTimeProperty() { return appointmentTime; }
|
||||
public SimpleStringProperty appointmentStatusProperty() { return appointmentStatus; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a product category with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a customer with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents an inventory entry with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a pet with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a product with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a product-supplier relationship with JavaFX properties.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a purchase order with fields for display in tables.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -49,4 +55,4 @@ public class PurchaseOrder {
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a single item added to the sale cart.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
public class SaleCartItem {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Holds the full details of a completed sale for display.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents one line item within a sale.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
public class SaleLineItem {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a service offered by the pet shop.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
@@ -95,4 +101,4 @@ public class Service {
|
||||
public String toString() {
|
||||
return getServiceName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a staff account used for login and permissions.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents a supplier with JavaFX properties for table binding.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Represents the currently logged-in user.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import org.example.petshopdesktop.auth.Role;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Holds sales data for a single day used in charts.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models.analytics;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Holds sales data grouped by employee for charts.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models.analytics;
|
||||
|
||||
public class EmployeeSalesData {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Holds sales data grouped by payment method for charts.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models.analytics;
|
||||
|
||||
public class PaymentMethodData {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Holds sales data grouped by product for charts.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models.analytics;
|
||||
|
||||
public class ProductSalesData {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Holds overall sales totals for the analytics dashboard.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.models.analytics;
|
||||
|
||||
public class SalesSummary {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Custom calendar widget for picking and highlighting dates.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.ui;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
@@ -87,6 +93,10 @@ public class CalendarPane extends VBox {
|
||||
onDateSelected = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the calendar forward or backward by one week or month depending on mode.
|
||||
* @param direction +1 for forward, -1 for backward
|
||||
*/
|
||||
private void navigate(int direction) {
|
||||
if (weekMode) {
|
||||
currentDate = currentDate.plusWeeks(direction);
|
||||
@@ -96,6 +106,11 @@ public class CalendarPane extends VBox {
|
||||
rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the day grid from scratch. In week mode, shows 7 days starting
|
||||
* from Sunday. In month mode, calculates how many rows are needed and offsets
|
||||
* the first day to the correct column based on its day-of-week.
|
||||
*/
|
||||
private void rebuild() {
|
||||
dayGrid.getChildren().clear();
|
||||
dayGrid.getColumnConstraints().clear();
|
||||
@@ -108,6 +123,7 @@ public class CalendarPane extends VBox {
|
||||
}
|
||||
|
||||
if (weekMode) {
|
||||
// getValue() gives Mon=1..Sun=7; mod 7 maps to Sun=0..Sat=6
|
||||
int dow = currentDate.getDayOfWeek().getValue() % 7;
|
||||
LocalDate startOfWeek = currentDate.minusDays(dow);
|
||||
lblHeader.setText("Week of " + startOfWeek.format(DateTimeFormatter.ofPattern("MMM d, yyyy")));
|
||||
@@ -117,6 +133,7 @@ public class CalendarPane extends VBox {
|
||||
} else {
|
||||
YearMonth ym = YearMonth.of(currentDate.getYear(), currentDate.getMonthValue());
|
||||
lblHeader.setText(currentDate.format(DateTimeFormatter.ofPattern("MMMM yyyy")));
|
||||
// Figure out which column the 1st falls on, then how many rows we need
|
||||
int firstDow = ym.atDay(1).getDayOfWeek().getValue() % 7;
|
||||
int daysInMonth = ym.lengthOfMonth();
|
||||
int rows = (int) Math.ceil((firstDow + daysInMonth) / 7.0);
|
||||
@@ -136,6 +153,12 @@ public class CalendarPane extends VBox {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a single day cell with appropriate styling for selected/today/normal states.
|
||||
* Shows a red dot if the date has events. Clicking toggles selection.
|
||||
* @param date the date this cell represents
|
||||
* @return the styled cell
|
||||
*/
|
||||
private StackPane buildDayCell(LocalDate date) {
|
||||
boolean isSelected = date.equals(selectedDate);
|
||||
boolean isToday = date.equals(LocalDate.now());
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Renders SVG files inside a WebView for display in the UI.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.ui;
|
||||
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Writes user actions to a local log file.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Loads and caches images from the server for display.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.util;
|
||||
|
||||
import javafx.application.Platform;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Sends system tray notifications from the desktop app.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.util;
|
||||
|
||||
import javafx.embed.swing.SwingFXUtils;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Opens native file chooser dialogs for selecting files.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.util;
|
||||
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Helper methods for setting up and formatting table views.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.util;
|
||||
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
@@ -20,6 +26,12 @@ public final class TableViewSupport {
|
||||
private TableViewSupport() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps a FilteredList in a SortedList and binds it to the table's sort order.
|
||||
* This way clicking column headers sorts the already-filtered data.
|
||||
* @param tableView the table to bind to
|
||||
* @param filteredItems the filtered data source
|
||||
*/
|
||||
public static <T> void bindSortedItems(TableView<T> tableView, FilteredList<T> filteredItems) {
|
||||
SortedList<T> sortedItems = new SortedList<>(filteredItems);
|
||||
sortedItems.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
@@ -43,6 +55,10 @@ public final class TableViewSupport {
|
||||
delay.playFromStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a numeric column as Canadian currency (e.g. $12.50).
|
||||
* @param column the table column to apply formatting to
|
||||
*/
|
||||
public static <S, T extends Number> void applyCurrencyColumn(TableColumn<S, T> column) {
|
||||
if (column == null) {
|
||||
return;
|
||||
@@ -58,6 +74,11 @@ public final class TableViewSupport {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a double-click handler to table rows that calls the given action with the row item.
|
||||
* @param tableView the table to add the handler to
|
||||
* @param action callback that receives the clicked row's item
|
||||
*/
|
||||
public static <T> void installDoubleClickAction(TableView<T> tableView, Consumer<T> action) {
|
||||
tableView.setRowFactory(tv -> {
|
||||
TableRow<T> row = new TableRow<>();
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Applies input formatting like phone numbers to text fields.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
package org.example.petshopdesktop.util;
|
||||
|
||||
import javafx.application.Platform;
|
||||
|
||||
Reference in New Issue
Block a user