diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 00000000..f6b1c4ce --- /dev/null +++ b/.gitattributes @@ -0,0 +1,34 @@ +# Java sources +*.java text diff=java +*.kt text diff=java +*.groovy text diff=java +*.scala text diff=java +*.gradle text diff=java +*.gradle.kts text diff=java + +# These files are text and should be normalized (Convert crlf => lf) +*.css text diff=css +*.scss text diff=css +*.sass text +*.df text +*.htm text diff=html +*.html text diff=html +*.js text +*.jsp text +*.jspf text +*.jspx text +*.properties text +*.tld text +*.tag text +*.tagx text +*.xml text + +# These files are binary and should be left untouched +# (binary is a macro for -text -diff) +*.class binary +*.dll binary +*.ear binary +*.jar binary +*.so binary +*.war binary +*.jks binary \ No newline at end of file diff --git a/.github/workflows/FUNDING.yml b/.github/workflows/FUNDING.yml new file mode 100644 index 00000000..2a7c2148 --- /dev/null +++ b/.github/workflows/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: palexdev +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 4771c16e..e19d7bd5 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ out/ # Others materialfx/src/test demo/scenicView.properties +scenicView.properties diff --git a/.run/MaterialFX [build].run.xml b/.run/MaterialFX [build].run.xml old mode 100644 new mode 100755 diff --git a/.run/MaterialFX [clean build].run.xml b/.run/MaterialFX [clean build].run.xml new file mode 100644 index 00000000..b2a0a586 --- /dev/null +++ b/.run/MaterialFX [clean build].run.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + + + \ No newline at end of file diff --git a/.run/MaterialFX [clean].run.xml b/.run/MaterialFX [clean].run.xml old mode 100644 new mode 100755 diff --git a/.run/MaterialFX [jlinkZip].run.xml b/.run/MaterialFX [jlinkZip].run.xml old mode 100644 new mode 100755 diff --git a/.run/MaterialFX [materialfx_uploadArchives].run.xml b/.run/MaterialFX [materialfx_uploadArchives].run.xml old mode 100644 new mode 100755 diff --git a/.run/MaterialFX [run].run.xml b/.run/MaterialFX [run].run.xml old mode 100644 new mode 100755 diff --git a/.run/MaterialFX [testrun].run.xml b/.run/MaterialFX [testrun].run.xml old mode 100644 new mode 100755 diff --git a/.run/Run Tests.run.xml b/.run/Run Tests.run.xml deleted file mode 100644 index a834b2fb..00000000 --- a/.run/Run Tests.run.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e2780305 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,67 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +(Date format is dd-MM-yyyy) + +## Type of Changes +- **Added** for new features. +- **Changed** for changes in existing functionality. +- **Deprecated** for soon-to-be removed features. +- **Removed** for now removed features. +- **Fixed** for any bug fixes. + +## [11.13.0] - 22-01-2022 +_This version won't follow the above scheme as the amount of changes and commits is simply too huge and there would be no +way to correctly show all the changes without making mistakes (duplicates, "overlapping" changes...), for this reason +I'll try to sum up only the major changes below._ + +- The demo has been completely remade +- Added new beans and properties +- Added new mechanisms for bindings +- Added new collections, in particular an ObservableList that combines the capabilities of JavaFX's FilteredList and SortedList. +Also those two are read-only, but MaterialFX also offers a version that allows to directly make changes to the source list +- ReactFX, Flowless removed in favor of my own Virtual Flow implementation, VirtualizedFX. As a result all controls having lists have been reworked. +- The table view has been reworked as well to use a Virtual Flow (scrollable) so it's efficiency is now on a whole new level. There's also a paginated +version of the table (like before) but it still uses a Virtual Flow, which of course makes it efficient +- MFXLabels have been deprecated and removed as now MaterialFX follows Material Design's text fields. The new MFXTextFields are the best thing you're gonna see +on JavaFX. They have all the features defined by Material Design principles and also more. They now offer a floating label that can have 4 states: disabled, above, border, inline. +Oh, they can also be set to behave like Labels, no need to have duplicate controls (Label and TextFields), since they offer the same functionalities duh. +- Many controls (such as combo boxes, date pickers) now extends MFXTextField, so they inherit all its features. +- Almost all controls have been reviewed/remade to make them fully functional (there were a lot of issues with CSS not working properly). +- The Filter API has been reviewed and now it's more powerful than ever with the new MFXFilterPane. +- The Validation API has been reviewed as well, it is as powerful as before thanks to JavaFX properties and observables, but it's much more flexible. It's up to the user now +to decide when and how to validate a control. Also an important design choice has been made here. Many validation frameworks for JavaFX also offer a way to decorate a control, +but I decided to not to that as it would violate the Single Responsibility Principle! Validation has nothing to do with UI, plus depending on the fanciness of your App it's up to +you to decide how the validation controls will look like! +- Dialogs and Notifications have been reviewed as well. The dialogs have been simplified, and for notifications there are now two separate systems. +- The date picker is now on a whole new level, it's been remade from scratch and it's simply beautiful, powerful and versatile. +- There are also new components! MFXPopup is a PopupControl that actually works. Ever tried to style a PopupControl but no matter what the CSS would not work? +Do not worry about that never again, just use MFXPopup it's super easy thanks to my custom MFXCSSBridge (check documentation would be too much to write here haha). +MFXPagination has been made for MFXPaginatedTableViews, remade from scratch (meaning that doesn't extend Pagination) with a stunning modern look. +MFXTooltip, an alternative to JavaFX's tooltip, much more versatile! +- MFXRippleGenerator has been deprecated. The ripple generation is organized to be a new API, meaning that there are now interfaces and a base abstract class from which +you can implement new ripple generators. The new default implementation is MFXCircleRippleGenerator. The new API also allows you to create new Ripples by implementing the IRipple interface. +It's a rather advanced API tbh, but hey, it's there, who knows maybe someday I'll need it to be like this. +- MFXHLoader and MFXVLoader are no more. The loading API has been "extracted" to be independent from UI. MFXLoader has the same capabilities as the aforementioned controls +but it's not a Node. It's up to the user to decide how to manage the loaded views, and how to translate the loaded beans to a Node. (see the documentation and the DemoController for an example +on how to easily create a nav-bar even with the new API) +- The Selection API has been reviewed as well. It also supports the "extend selection" behavior when "Shift" is pressed, like you would expect from a file manager. +- There is an insane amount of new utilities, for JavaFX as well as for Java + +Again, let me **apologize** for this messy changelist, but I promise from next version changes will be tracked properly! + + + + + + + + + + + + + + diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 6d8455de..b14c2b2b --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@

- Logo + Logo

@@ -18,7 +18,7 @@

MaterialFX

- MaterialFX is an open source Java library which provides material components for JavaFX + MaterialFX is an open source Java library which provides material design components for JavaFX
Explore the wiki »
@@ -35,12 +35,14 @@ ## Table of Contents * [About the Project and History of JavaFX](#about-the-project-and-history-of-javafx) +* [About the Logo](#about-the-logo) * [Some GIFs](#preview-gifs) * [Getting Started](#getting-started) * [Build](#build) * [Usage](#usage) * [Gradle](#gradle) * [Maven](#maven) +* [Changelog](#changelog) * [Roadmap](#roadmap) * [Contributing](#contributing) * [License](#license) @@ -74,104 +76,102 @@ That's where this project comes in. The aim of my project is to bring components Google's material design guidelines to JavaFX. The second purpose is to provide a successor to the already available [JFoenix](https://github.com/jfoenixadmin/JFoenix) library, which is a bit old and has a lot of issues. -In recent months the project has evolved a lot, to the point that it is no longer a simple substitute. -To date MaterialFX offers not only restyled controls, but also: new and unique controls such as the Stepper, controls completely redone from scratch such as ComboBoxes or TableViews (and many others), and many utilities for JavaFX and Java (NodeUtils, ColorUtils, StringUtils ...). +In recent months the project has evolved a lot, to the point that it is no longer a simple substitute. +To date MaterialFX offers not only restyled controls, but also: new and unique controls such as the Stepper, +controls completely redone from scratch such as ComboBoxes or TableViews (and many others), +and many utilities for JavaFX and Java (NodeUtils, ColorUtils, StringUtils ...). + + + +## About The Logo +MaterialFX v11.13.0 brought a lot of fixes and new features, but it also brought a new logo, something that is more +meaningful for me and that somewhat represents the new version. +The new logo is a Phoenix, the immortal bird from Greek mythology, associated to regeneration/rebirth. +When a Phoenix dies it obtains new life by raising from its ashes. +MaterialFX v11.13.0 fixed many critical bugs and broken features, I like to think that it is reborn from +the previous version, so I thought a new logo would have been a good idea. ## Preview GIFs -#### Imgur Link: [Gallery](https://gifyu.com/album/cU3) +#### Imgur Link: [Gallery](https://imgur.com/a/IrDirnI)

Buttons
-Buttons +Buttons

-CheckBoxes +Check Boxes, Radio Buttons and Toggles
-Checkboxes +Checkboxes

-ComboBoxes +Combo Boxes
-Comboboxes -
-

- -
-DatePickers -
-Datepickers +Comboboxes

Dialogs
-Dialogs +Dialogs
-

-
-Labels -
-Labels -

-
-ListViews +Fields
-Listviews +Fields

-Notifications +Lists
-Notifications +Listviews

-ProgressBars +Notifications
-Progressbars +Notifications

-ProgressSpinners +Pickers
-Progressspinners +Pickers

-RadioButtons +Progress
-Radiobuttons +Progress

-ScrollPanes +Scroll Panes
-Scrollpanes +Scrollpanes

Sliders
-Sliders +Sliders

@@ -179,39 +179,17 @@ To date MaterialFX offers not only restyled controls, but also: new and unique c
Stepper
-Stepper +Stepper

-TableViews +Tables
-Tableviews +Tableviews

-
-TextFields -
-Textfields -
-

- -
-Toggles -
-Toggles -
-

- -
-FontResources -
-Radiobuttons -
-

-
- ## Getting Started @@ -229,7 +207,10 @@ To run the main demo, execute the following command: gradlew run -**NOTE** : MaterialFX requires **Java 11** and above. +**NOTE**: MaterialFX requires **Java 11** and above. + +**NOTE**: Starting from version 11.14.0 (next major version), MaterialFX will transition to +Java 17 and bump version to 17.x.x. What will happen to version 11 is still to be decided ### Usage @@ -241,7 +222,7 @@ repositories { } dependencies { -implementation 'io.github.palexdev:materialfx:11.12.0' +implementation 'io.github.palexdev:materialfx:11.13.0' } ``` @@ -251,15 +232,20 @@ implementation 'io.github.palexdev:materialfx:11.12.0' io.github.palexdev materialfx - 11.12.0 + 11.13.0 ``` +## Changelog +See the [CHANGELOG](https://github.com/palexdev/MaterialFX/blob/main/CHANGELOG.md) file for a list of changes per version. + + + ## Roadmap -See the [open issues](https://github.com/palexdev/MaterialFX/issues) for a list of proposed features (and known issues). +See the [Open Issues](https://github.com/palexdev/MaterialFX/issues) for a list of proposed features (and known issues). See the [ROADMAP](https://github.com/palexdev/MaterialFX/blob/main/ROADMAP.md) for a list of implemented and upcoming features. @@ -294,10 +280,14 @@ Project Link: [https://github.com/palexdev/MaterialFX](https://github.com/palexd #### Donation -Ever since I was a kid I have always liked programming, I find it interesting and often funny too, however it can also -be a difficult and stressful job at times. This is my first public project, and I'm dedicating a lot of time to it. This -is an open source library of course and everyone can use it for free, but if you feel like it you can make a small -donation here. [![Donate](https://img.shields.io/badge/$-support-green.svg?style=flat-square)](https://bit.ly/31XB8zD) +It's been more than a year since I started developing MaterialFX. Implementing cool looking, fully functional controls, +introducing new components and features as well as providing many utilities for JavaFX and Java is really hard, +especially considering that developing for JavaFX also means to deal with its closeness, its bugs, its annoying +design decisions. Many times I've honestly been on the verge of giving up because sometimes it's really too much +stress to handle. +**But**, today MaterialFX is a great library, supported by many people and I'm proud of it. +If you are using MaterialFX in your projects and feel like it, I recently activated [GitHub Sponsors](https://github.com/sponsors/palexdev) so +you can easily donate/sponsor. @@ -308,6 +298,10 @@ donation here. [![Donate](https://img.shields.io/badge/$-support-green.svg?style - Yiding He - Alaa Abu Zidan - Ultraviolet-Ninja -- *Your name can be here by supporting me at this link, [Support](https://bit.ly/31XB8zD)* +- Sourabh Bhat +- Mohammad Chaudhry (thank you very much for the huge donation, YOU are the legend) +- Yahia Rehab +- Mauro de Wit +- *Your name can be here by supporting me at this link, [GitHub Sponsors](https://github.com/sponsors/palexdev)* Thank you very very much to all supporters, to all people who contribute to the project, to all people that thanked me, you really made my day diff --git a/ROADMAP.md b/ROADMAP.md old mode 100644 new mode 100755 index 88977509..cf9c491b --- a/ROADMAP.md +++ b/ROADMAP.md @@ -14,4 +14,5 @@ - [ ] *Scrollable MFXTableView*

- [ ] *MFXToastNotification* -- [ ] *Improve Notification System(?)* \ No newline at end of file +- [ ] *Improve Notification System(?)* +- [ ] *Introduce StringConverters for listviews' cells too?* \ No newline at end of file diff --git a/build.gradle b/build.gradle old mode 100644 new mode 100755 index a682079c..d531ed2b --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,31 @@ +buildscript { + repositories { + gradlePluginPortal() + } + + dependencies { + classpath 'org.javamodularity:moduleplugin:1.8.10' // Workaround for broken javafxplugin + } +} + plugins { id 'java-library' - id 'org.openjfx.javafxplugin' version '0.0.10' apply false + id 'org.openjfx.javafxplugin' version '0.0.11' apply false } group 'io.github.palexdev' -version '11.12.0' +version '11.13.0' repositories { mavenCentral() - jcenter() } subprojects { apply plugin: 'org.openjfx.javafxplugin' javafx { - version = "16" - modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.media', 'javafx.swing', 'javafx.web' ] + version = "17.0.1" + modules = ['javafx.controls', 'javafx.fxml', 'javafx.media', 'javafx.swing', 'javafx.web'] } } diff --git a/demo/build.gradle b/demo/build.gradle old mode 100644 new mode 100755 index 284ea628..c51e3d0d --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,11 +1,10 @@ plugins { id 'application' - id 'org.beryx.jlink' version '2.23.3' + id 'org.beryx.jlink' version '2.24.4' } repositories { mavenCentral() - jcenter() flatDir { dirs "${project(':demo').projectDir}/libs" @@ -14,14 +13,18 @@ repositories { dependencies { testImplementation "org.testfx:testfx-core:4.0.16-alpha" - testImplementation "junit:junit:4.13.1" - testImplementation "org.testfx:testfx-junit:4.0.16-alpha" + testImplementation "org.testfx:testfx-junit5:4.0.16-alpha" + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testImplementation 'org.junit.platform:junit-platform-suite-api:1.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' implementation name: 'scenicview' implementation "fr.brouillard.oss:cssfx:11.4.0" implementation 'org.kordamp.ikonli:ikonli-core:12.2.0' implementation 'org.kordamp.ikonli:ikonli-javafx:12.2.0' implementation 'org.kordamp.ikonli:ikonli-fontawesome5-pack:12.2.0' + implementation 'io.github.palexdev:virtualizedfx:11.2.4' implementation project(':materialfx') } @@ -43,4 +46,8 @@ jlink { jpackage { imageOptions = ['--icon', 'src/main/resources/logo.ico'] } +} + +test { + useJUnitPlatform() } \ No newline at end of file diff --git a/demo/libs/scenicview.jar b/demo/libs/scenicview.jar old mode 100644 new mode 100755 diff --git a/demo/src/main/java/io/github/palexdev/materialfx/demo/Demo.java b/demo/src/main/java/io/github/palexdev/materialfx/demo/Demo.java index de660103..478d86ed 100644 --- a/demo/src/main/java/io/github/palexdev/materialfx/demo/Demo.java +++ b/demo/src/main/java/io/github/palexdev/materialfx/demo/Demo.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Parisi Alessandro + * Copyright (C) 2022 Parisi Alessandro * This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). * * MaterialFX is free software: you can redistribute it and/or modify @@ -22,45 +22,26 @@ import io.github.palexdev.materialfx.demo.controllers.DemoController; import javafx.application.Application; import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.stage.StageStyle; -import java.io.IOException; - public class Demo extends Application { - private double xOffset; - private double yOffset; - - @Override - public void start(Stage primaryStage) throws IOException { - CSSFX.start(); - - FXMLLoader fxmlLoader = new FXMLLoader(MFXDemoResourcesLoader.loadURL("Demo.fxml")); - fxmlLoader.setControllerFactory(controller -> new DemoController(primaryStage, getHostServices())); - StackPane demoPane = fxmlLoader.load(); - - demoPane.setOnMousePressed(event -> { - xOffset = primaryStage.getX() - event.getScreenX(); - yOffset = primaryStage.getY() - event.getScreenY(); - }); - demoPane.setOnMouseDragged(event -> { - primaryStage.setX(event.getScreenX() + xOffset); - primaryStage.setY(event.getScreenY() + yOffset); - }); - - primaryStage.setTitle("MaterialFX Demo - Features Preview"); - primaryStage.initStyle(StageStyle.TRANSPARENT); - Scene scene = new Scene(demoPane); - scene.setFill(Color.TRANSPARENT); - primaryStage.setScene(scene); - primaryStage.show(); - } - - public static void main(String[] args) { - launch(args); - } + @Override + public void start(Stage primaryStage) throws Exception { + CSSFX.start(); + + FXMLLoader loader = new FXMLLoader(MFXDemoResourcesLoader.loadURL("fxml/Demo.fxml")); + loader.setControllerFactory(c -> new DemoController(primaryStage)); + Parent root = loader.load(); + Scene scene = new Scene(root); + scene.setFill(Color.TRANSPARENT); + primaryStage.initStyle(StageStyle.TRANSPARENT); + primaryStage.setScene(scene); + primaryStage.setTitle("MaterialFX Demo"); + primaryStage.show(); + } } diff --git a/demo/src/main/java/io/github/palexdev/materialfx/demo/MFXDemoResourcesLoader.java b/demo/src/main/java/io/github/palexdev/materialfx/demo/MFXDemoResourcesLoader.java old mode 100644 new mode 100755 index a446942b..41dde53e --- a/demo/src/main/java/io/github/palexdev/materialfx/demo/MFXDemoResourcesLoader.java +++ b/demo/src/main/java/io/github/palexdev/materialfx/demo/MFXDemoResourcesLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Parisi Alessandro + * Copyright (C) 2022 Parisi Alessandro * This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). * * MaterialFX is free software: you can redistribute it and/or modify @@ -27,19 +27,19 @@ */ public class MFXDemoResourcesLoader { - private MFXDemoResourcesLoader() { - } + private MFXDemoResourcesLoader() { + } - public static URL loadURL(String path) { - return MFXDemoResourcesLoader.class.getResource(path); - } + public static URL loadURL(String path) { + return MFXDemoResourcesLoader.class.getResource(path); + } - public static String load(String path) { - return loadURL(path).toString(); - } + public static String load(String path) { + return loadURL(path).toString(); + } - public static InputStream loadStream(String name) { - return MFXDemoResourcesLoader.class.getResourceAsStream(name); - } + public static InputStream loadStream(String name) { + return MFXDemoResourcesLoader.class.getResourceAsStream(name); + } } diff --git a/demo/src/main/java/io/github/palexdev/materialfx/demo/TestDemo.java b/demo/src/main/java/io/github/palexdev/materialfx/demo/TestDemo.java deleted file mode 100644 index 5413c49e..00000000 --- a/demo/src/main/java/io/github/palexdev/materialfx/demo/TestDemo.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2021 Parisi Alessandro - * This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). - * - * MaterialFX is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * MaterialFX is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with MaterialFX. If not, see . - */ - -package io.github.palexdev.materialfx.demo; - -import io.github.palexdev.materialfx.controls.MFXButton; -import io.github.palexdev.materialfx.controls.MFXIconWrapper; -import io.github.palexdev.materialfx.controls.MFXRectangleToggleNode; -import io.github.palexdev.materialfx.controls.MFXTableView; -import io.github.palexdev.materialfx.controls.cell.MFXTableColumn; -import io.github.palexdev.materialfx.controls.cell.MFXTableRowCell; -import io.github.palexdev.materialfx.demo.model.FilterablePerson; -import io.github.palexdev.materialfx.font.FontResources; -import io.github.palexdev.materialfx.font.MFXFontIcon; -import io.github.palexdev.materialfx.utils.ColorUtils; -import javafx.application.Application; -import javafx.geometry.Pos; -import javafx.scene.Scene; -import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; -import javafx.stage.Stage; -import org.scenicview.ScenicView; - -import java.util.Random; - -@SuppressWarnings("All") -public class TestDemo extends Application { - private final Random random = new Random(System.currentTimeMillis()); - - @Override - public void start(Stage primaryStage) { - VBox box = new VBox(100); - box.setAlignment(Pos.CENTER); - - HBox bbox = new HBox(20); - bbox.setAlignment(Pos.CENTER); - - MFXButton b1 = new MFXButton("Set Leading"); - MFXButton b2 = new MFXButton("Set Trailing"); - MFXButton b3 = new MFXButton("Set Graphic"); - MFXButton b4 = new MFXButton("Remove Graphic"); - MFXButton b5 = new MFXButton("Remove Label Graphic"); - MFXRectangleToggleNode rtn = new MFXRectangleToggleNode(""); - rtn.setPrefSize(32, 32); - rtn.setAlignment(Pos.CENTER); - - b1.setOnAction(event -> { - rtn.setLabelLeadingIcon(MFXFontIcon.getRandomIcon(12, ColorUtils.getRandomColor())); - }); - b2.setOnAction(event -> { - rtn.setLabelTrailingIcon(MFXFontIcon.getRandomIcon(12, ColorUtils.getRandomColor())); - }); - b3.setOnAction(event -> { - rtn.setGraphic(MFXFontIcon.getRandomIcon(12, ColorUtils.getRandomColor())); - }); - b4.setOnAction(event -> { - rtn.setGraphic(null); - }); - b5.setOnAction(event -> { - rtn.setLabelLeadingIcon(null); - rtn.setLabelTrailingIcon(null); - }); - - bbox.getChildren().addAll(b1, b2, b3, b4, b5); - - box.getChildren().addAll(rtn, bbox); - box.getStylesheets().add(MFXDemoResourcesLoader.load("css/TestDemo.css")); - - Scene scene = new Scene(box, 800, 600); - primaryStage.setScene(scene); - primaryStage.show(); - - ScenicView.show(scene); - } - - public static void main(String[] args) { - launch(args); - } - - private static boolean isInvalidCharacter(char c) { - if (c == 0x7F) return true; - if (c == 0xA) return true; - if (c == 0x9) return true; - return c < 0x20; - } - - public MFXIconWrapper getRandomIcon(double size) { - FontResources[] resources = FontResources.values(); - String desc = resources[random.nextInt(resources.length)].getDescription(); - return new MFXIconWrapper(new MFXFontIcon(desc, size, ColorUtils.getRandomColor()), size * 1.5); - } - - private void setupTable(MFXTableView tableView) { - MFXTableColumn firstName = new MFXTableColumn<>("FName"); - MFXTableColumn lastName = new MFXTableColumn<>("LName"); - MFXTableColumn address = new MFXTableColumn<>("Address"); - MFXTableColumn age = new MFXTableColumn<>("age"); - - firstName.setRowCellFunction(person -> new MFXTableRowCell(person.firstNameProperty())); - lastName.setRowCellFunction(person -> new MFXTableRowCell(person.lastNameProperty())); - address.setRowCellFunction(person -> new MFXTableRowCell(person.addressProperty())); - age.setRowCellFunction(person -> new MFXTableRowCell(person.ageProperty().asString())); - - tableView.getTableColumns().addAll(firstName, lastName, address, age); - //tableView.setItems(people); - } - - public String randStr() { - int leftLimit = 97; // letter 'a' - int rightLimit = 122; // letter 'z' - int targetStringLength = 30; - return random.ints(leftLimit, rightLimit + 1) - .limit(targetStringLength) - .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) - .toString(); - } -} diff --git a/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/TogglesController.java b/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ChecksRadiosToggleController.java similarity index 53% rename from demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/TogglesController.java rename to demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ChecksRadiosToggleController.java index 6088647f..8826ead2 100644 --- a/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/TogglesController.java +++ b/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ChecksRadiosToggleController.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Parisi Alessandro + * Copyright (C) 2022 Parisi Alessandro * This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). * * MaterialFX is free software: you can redistribute it and/or modify @@ -22,34 +22,43 @@ import io.github.palexdev.materialfx.controls.MFXToggleButton; import io.github.palexdev.materialfx.font.MFXFontIcon; import io.github.palexdev.materialfx.utils.ColorUtils; +import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.scene.paint.Color; import java.net.URL; import java.util.ResourceBundle; -public class TogglesController implements Initializable { +public class ChecksRadiosToggleController implements Initializable { - @FXML - private MFXToggleButton toggleButton; + @FXML + private MFXToggleButton customToggle; - @FXML - private MFXRectangleToggleNode rec1; + @FXML + private MFXRectangleToggleNode r1; - @FXML - private MFXRectangleToggleNode rec2; + @FXML + private MFXRectangleToggleNode r2; - @Override - public void initialize(URL location, ResourceBundle resources) { - rec1.setLabelLeadingIcon(MFXFontIcon.getRandomIcon(16, ColorUtils.getRandomColor())); - rec1.setLabelTrailingIcon(MFXFontIcon.getRandomIcon(16, ColorUtils.getRandomColor())); - rec2.setLabelLeadingIcon(MFXFontIcon.getRandomIcon(16, ColorUtils.getRandomColor())); - rec2.setLabelTrailingIcon(MFXFontIcon.getRandomIcon(16, ColorUtils.getRandomColor())); - } + @FXML + private MFXRectangleToggleNode r3; - @FXML - private void handleButtonClick() { - toggleButton.setToggleColor(ColorUtils.getRandomColor()); - toggleButton.setSelected(false); - } + @FXML + private void changeColors(ActionEvent event) { + customToggle.setColors(ColorUtils.getRandomColor(), ColorUtils.getRandomColor()); + customToggle.setSelected(false); + } + + @Override + public void initialize(URL location, ResourceBundle resources) { + r1.setLabelLeadingIcon(MFXFontIcon.getRandomIcon(16, Color.BLACK)); + r1.setLabelTrailingIcon(MFXFontIcon.getRandomIcon(16, Color.BLACK)); + + r2.setLabelLeadingIcon(MFXFontIcon.getRandomIcon(16, Color.BLACK)); + r2.setLabelTrailingIcon(MFXFontIcon.getRandomIcon(16, Color.BLACK)); + + r3.setLabelLeadingIcon(MFXFontIcon.getRandomIcon(16, Color.BLACK)); + r3.setLabelTrailingIcon(MFXFontIcon.getRandomIcon(16, Color.BLACK)); + } } diff --git a/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ComboBoxesController.java b/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ComboBoxesController.java new file mode 100644 index 00000000..21ae3b2b --- /dev/null +++ b/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ComboBoxesController.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2022 Parisi Alessandro + * This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). + * + * MaterialFX is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MaterialFX is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MaterialFX. If not, see . + */ + +package io.github.palexdev.materialfx.demo.controllers; + +import io.github.palexdev.materialfx.controls.MFXComboBox; +import io.github.palexdev.materialfx.controls.MFXFilterComboBox; +import io.github.palexdev.materialfx.controls.MFXTooltip; +import io.github.palexdev.materialfx.controls.legacy.MFXLegacyComboBox; +import io.github.palexdev.materialfx.demo.model.Model; +import io.github.palexdev.materialfx.demo.model.Person; +import io.github.palexdev.materialfx.utils.StringUtils; +import io.github.palexdev.materialfx.utils.others.FunctionalStringConverter; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.util.StringConverter; + +import java.net.URL; +import java.util.ResourceBundle; +import java.util.function.Function; +import java.util.function.Predicate; + +public class ComboBoxesController implements Initializable { + + @FXML + private MFXLegacyComboBox lCombo; + + @FXML + private MFXLegacyComboBox lCustCombo; + + @FXML + private MFXComboBox nBFCombo; + + @FXML + private MFXComboBox nCombo; + + @FXML + private MFXComboBox nCustCombo; + + @FXML + private MFXComboBox nEditCombo; + + @FXML + private MFXComboBox nNFCombo; + + @FXML + private MFXFilterComboBox filterCombo; + + @FXML + private MFXFilterComboBox custFilterCombo; + + @Override + public void initialize(URL location, ResourceBundle resources) { + ObservableList strings = Model.strings; + ObservableList people = Model.people; + + lCombo.setItems(strings); + lCustCombo.setItems(strings); + + nCombo.setItems(strings); + nCustCombo.setItems(strings); + nEditCombo.setItems(strings); + nBFCombo.setItems(strings); + nNFCombo.setItems(strings); + + nEditCombo.setOnCancel(s -> nEditCombo.setText(nEditCombo.getSelectedItem())); + nEditCombo.setOnCommit(s -> { + if (!strings.contains(s)) { + strings.add(s); + } + nEditCombo.selectItem(s); + }); + + MFXTooltip.of( + nEditCombo, + """ + This combo box allows you to add new items to the list (no duplicates allowed) when pressing Enter. + It also allows to restore the previous selected item by pressing Ctrl+Shift+Z. + Both key strokes are default for all MFXComboBoxes but the action to perform must be configured by the user. + This combo box is also set to scroll to the selected item when opening the popup. + """ + ).install(); + + StringConverter converter = FunctionalStringConverter.converter( + s -> { + throw new UnsupportedOperationException(); + }, + person -> person.getName() + " " + person.getSurname() + ); + Function> filterFunction = s -> person -> StringUtils.containsIgnoreCase(converter.toString(person), s); + filterCombo.setItems(people); + filterCombo.setConverter(converter); + filterCombo.setFilterFunction(filterFunction); + custFilterCombo.setItems(people); + custFilterCombo.setConverter(converter); + custFilterCombo.setFilterFunction(filterFunction); + custFilterCombo.setResetOnPopupHidden(false); + } +} diff --git a/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ComboBoxesDemoController.java b/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ComboBoxesDemoController.java deleted file mode 100644 index 86321626..00000000 --- a/demo/src/main/java/io/github/palexdev/materialfx/demo/controllers/ComboBoxesDemoController.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2021 Parisi Alessandro - * This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). - * - * MaterialFX is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * MaterialFX is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with MaterialFX. If not, see . - */ - -package io.github.palexdev.materialfx.demo.controllers; - -import io.github.palexdev.materialfx.controls.MFXCheckbox; -import io.github.palexdev.materialfx.controls.MFXComboBox; -import io.github.palexdev.materialfx.controls.MFXFilterComboBox; -import io.github.palexdev.materialfx.controls.legacy.MFXLegacyComboBox; -import io.github.palexdev.materialfx.demo.model.SimplePerson; -import io.github.palexdev.materialfx.utils.BindingUtils; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.control.Label; -import javafx.scene.paint.Color; -import org.kordamp.ikonli.javafx.FontIcon; - -import java.net.URL; -import java.util.List; -import java.util.ResourceBundle; - -public class ComboBoxesDemoController implements Initializable { - - @FXML - private MFXLegacyComboBox standard; - - @FXML - private MFXLegacyComboBox lineColors; - - @FXML - private MFXLegacyComboBox editable; - - @FXML - private MFXLegacyComboBox