Skip to content

JWebMP/Toastr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

130 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JWebMP Toastr

Maven Central License

Java 25+ Modular Angular JWebMP

toastr is a Javascript library for Gnome / Growl type non-blocking notifications. The goal is to create a simple core library that can be customized and extended. This plugin provides JWebMP integration with type-safe Java APIs and Angular asset management.

Built on Toastr · JWebMP Core · JPMS module com.jwebmp.plugins.toastr · Java 25+

Installation

<dependency>
  <groupId>com.jwebmp.plugins</groupId>
  <artifactId>toastr</artifactId>
  <version>2.0.3-SNAPSHOT</version>
</dependency>
Gradle (Kotlin DSL)
implementation("com.jwebmp.plugins:toastr:2.0.0-SNAPSHOT")

NPM Dependencies

Automatically included via @TsDependency:

{
  "dependencies": {
    "toastr": "^2.1.4"
  }
}

Quick Start

Prerequisites

  • Java 25 LTS (required)
  • Maven 3.8+
  • Node.js 18+ (for frontend builds)
  • Angular 21+ (auto-integrated via JWebMP)

Basic Usage

import com.jwebmp.plugins.toastr.ToastrFeature;
import com.jwebmp.plugins.toastr.ToastrType;

// Show a simple info toast
addFeature(new ToastrFeature<>("Hello World"));

// Show a toast with title and type
addFeature(new ToastrFeature<>(ToastrType.Success, "Done!", "Your changes have been saved."));

Customizing Options

import com.jwebmp.plugins.toastr.ToastrFeature;
import com.jwebmp.plugins.toastr.ToastrType;
import com.jwebmp.plugins.toastr.ToastrPosition;

ToastrFeature<?> toast = new ToastrFeature<>(ToastrType.Warning, "Alert", "Something needs attention");
toast.getOptions()
     .setPositionClass(ToastrPosition.Toast_Top_Center)
     .setCloseButton(true)
     .setProgressBar(true)
     .setTimeOut(3000)
     .setNewestOnTop(true)
     .setPreventDuplicates(true);

addFeature(toast);

Toast Types

ToastrType.Info      // Information toast (default)
ToastrType.Success   // Success toast
ToastrType.Warning   // Warning toast
ToastrType.Error     // Error toast

Toast Positions

ToastrPosition.Toast_Top_Right       // Top right (default)
ToastrPosition.Toast_Top_Left        // Top left
ToastrPosition.Toast_Top_Center      // Top center
ToastrPosition.Toast_Top_Full_Width  // Top full width
ToastrPosition.Toast_Bottom_Right    // Bottom right
ToastrPosition.Toast_Bottom_Left     // Bottom left
ToastrPosition.Toast_Bottom_Center   // Bottom center
ToastrPosition.Toast_Bottom_Full_Width // Bottom full width

Features

  • Non-Blocking Notifications — Lightweight toast messages that don't interrupt user flow
  • Multiple Toast Types — Info, Success, Warning, and Error styles
  • Configurable Positioning — 8 screen positions to choose from
  • Animation Effects — Easing effects for show/hide transitions via JQ Easing Effects
  • Progress Bar — Optional countdown progress bar
  • Close Button — Optional close button on toasts
  • Duplicate Prevention — Prevent duplicate toast messages
  • CRTP Fluent API — Method chaining for toast configuration
  • Zero Configuration — Auto-registered via ServiceLoader SPI
  • Angular Integration — Assets loaded via @TsDependency, @NgScript, and @NgStyleSheet

Configuration

The plugin is automatically configured when present on the classpath. No manual registration needed.

@TsDependency(value = "toastr", version = "^2.1.4")
@NgScript(name = "Toastr", value = "node_modules/toastr/toastr.js")
@NgStyleSheet(name = "Toastr", value = "node_modules/toastr/build/toastr.min.css")
public class ToastrPageConfigurator implements IPageConfigurator<ToastrPageConfigurator> {
    // Auto-loaded via ServiceLoader SPI
}

Module Structure

src/main/java/com/jwebmp/plugins/toastr/
├── ToastrFeature.java              # Main toast feature component
├── ToastrOptions.java              # Toast configuration options (CRTP)
├── ToastrType.java                 # Toast type enum (Info, Success, Warning, Error)
├── ToastrPosition.java             # Toast position enum (8 positions)
├── ToastrPageConfigurator.java     # Auto-configuration with npm/Angular
├── ToastrReferencePool.java        # Legacy reference pool
└── implementations/
    └── ToastrInclusionsModule.java  # GuicedEE module inclusion

Testing

mvn clean test

Links

License

Licensed under the Apache License 2.0.


Made with JWebMP

About

The JWebSwing Implementation for Toastr JS

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages