commit f9ec156507d9b18dc3dbbd87e07cfe788f8ab036 Author: Anry Das Date: Sat Mar 15 11:38:15 2025 +0200 Bug fixing: corrected Number Update in List behavior; corrected Number conversion diff --git a/NovaPoshta/.gitignore b/NovaPoshta/.gitignore new file mode 100644 index 0000000..bb9401a --- /dev/null +++ b/NovaPoshta/.gitignore @@ -0,0 +1,45 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### App ### +*.properties +mvnw +mvnw.cmd +*.zip +*.png +/plugins/tt1/ +/plugins/tt2/ +/plugins/DemoPlugin.jar +/plugins/RunTestImpl.jar +/DB/np.db diff --git a/NovaPoshta/DB/np_empty.db b/NovaPoshta/DB/np_empty.db new file mode 100644 index 0000000..8c41d34 Binary files /dev/null and b/NovaPoshta/DB/np_empty.db differ diff --git a/NovaPoshta/Docs/API_request.json b/NovaPoshta/Docs/API_request.json new file mode 100644 index 0000000..d179044 --- /dev/null +++ b/NovaPoshta/Docs/API_request.json @@ -0,0 +1,18 @@ +{ + "apiKey": "[ВАШ КЛЮЧ]", + "modelName": "TrackingDocument", + "calledMethod": "getStatusDocuments", + "methodProperties": { + "Documents" : [ + { + "DocumentNumber":"20400048799000", + "Phone":"380600000000" + } + , + { + "DocumentNumber":"20400048799001", + "Phone":"380600000000" + } + ] + } +} diff --git a/NovaPoshta/Docs/API_responce_descr.xlsx b/NovaPoshta/Docs/API_responce_descr.xlsx new file mode 100644 index 0000000..13ba1da Binary files /dev/null and b/NovaPoshta/Docs/API_responce_descr.xlsx differ diff --git a/NovaPoshta/Docs/API_response.json b/NovaPoshta/Docs/API_response.json new file mode 100644 index 0000000..fae2666 --- /dev/null +++ b/NovaPoshta/Docs/API_response.json @@ -0,0 +1,119 @@ +{ + "success": true, + "data": [{ + "PossibilityCreateReturn" : true, + "PossibilityCreateRefusal" : true, + "PossibilityChangeEW" : true, + "PossibilityCreateRedirecting" : true, + "Number" : "20400048799000", + "Redelivery" : "0", + "RedeliverySum" : "0", + "RedeliveryNum" : "", + "RedeliveryPayer" : "Sender/Recipient", + "OwnerDocumentType" : "", + "LastCreatedOnTheBasisDocumentType" : "", + "LastCreatedOnTheBasisPayerType" : "", + "LastCreatedOnTheBasisDateTime" : "", + "LastTransactionStatusGM" : "", + "LastTransactionDateTimeGM" : "", + "LastAmountTransferGM" : "", + "DateCreated" : "18-11-2021 11:52:42", + "DocumentWeight" : "3", + "FactualWeight" : "3", + "VolumeWeight" : "0.1", + "CheckWeight" : "", + "CheckWeightMethod" : "", + "DocumentCost" : "51", + "CalculatedWeight" : "3", + "SumBeforeCheckWeight" : "", + "PayerType" : "Sender", + "RecipientFullName" : "ПІБ", + "RecipientDateTime" : "21.11.2021 13:53:47", + "ScheduledDeliveryDate" : "19.11.2021 13:53:47", + "PaymentMethod" : "Cash", + "CargoDescriptionString" : "Одяг", + "CargoType" : "Cargo", + "CitySender" : "Київ", + "CityRecipient" : "Київ", + "WarehouseRecipient" : "Відділення №101 (до 15 кг), Міні-відділення: вул. Велика Васильківська, 143/2, (маг. "Фора")", + "CounterpartyType" : "PrivatePerson", + "AfterpaymentOnGoodsCost" : "0", + "ServiceType" : "WarehouseWarehouse", + "UndeliveryReasonsSubtypeDescription" : "", + "WarehouseRecipientNumber" : "101", + "LastCreatedOnTheBasisNumber" : "", + "PhoneRecipient" : "380600000000", + "RecipientFullNameEW" : "", + "WarehouseRecipientInternetAddressRef" : "00000000-0000-0000-0000-000000000000", + "MarketplacePartnerToken" : "", + "ClientBarcode" : "", + "RecipientAddress" : "м. Київ, Відділення №101 (до 15 кг), Міні-відділення, вул. Велика Васильківська, 143/2", + "CounterpartyRecipientDescription" : "Приватна особа", + "DateScan" : "0001-01-01 00:00:00", + "PaymentStatus" : "", + "PaymentStatusDate" : "", + "AmountToPay" : "", + "AmountPaid" : "", + "Status" : "", + "StatusCode" : "", + "RefEW" : "00000000-0000-0000-0000-000000000000", + "BackwardDeliverySubTypesActions" : "", + "BackwardDeliverySubTypesServices" : "", + "UndeliveryReasons" : "", + "DatePayedKeeping" : "", + "InternationalDeliveryType" : "", + "SeatsAmount" : "1", + "CardMaskedNumber" : "", + "ExpressWaybillPaymentStatus" : "PaymentNotAvailable", + "ExpressWaybillAmountToPay" : "", + "PhoneSender" : "", + "TrackingUpdateDate" : "2022-06-07 13:42:56", + "WarehouseSender" : "Отделение №178 (до 30 кг): просп. Оболонский, 35", + "DateReturnCargo" : "", + "DateMoving" : "", + "DateFirstDayStorage" : "", + "RefCityRecipient" : "00000000-0000-0000-0000-000000000000", + "RefCitySender" : "00000000-0000-0000-0000-000000000000", + "RefSettlementRecipient" : "00000000-0000-0000-0000-000000000000", + "RefSettlementSender" : "00000000-0000-0000-0000-000000000000", + "SenderAddress" : "м. Київ, Відділення №178 (до 30 кг): просп. Оболонський, 35", + "SenderFullNameEW" : "Іванов Петро Миколайович", + "AnnouncedPrice" : "50000", + "AdditionalInformationEW" : "", + "ActualDeliveryDate" : "", + "PostomatV3CellReservationNumber" : "00000000-0000-0000-0000-000000000000", + "OwnerDocumentNumber" : "", + "LastAmountReceivedCommissionGM" : "", + "DeliveryTimeframe" : "", + "CreatedOnTheBasis" : "", + "UndeliveryReasonsDate" : "", + "RecipientWarehouseTypeRef" : "00000000-0000-0000-0000-000000000000", + "WarehouseRecipientRef" : "00000000-0000-0000-0000-000000000000", + "CategoryOfWarehouse" : "Branch", + "WarehouseRecipientAddress" : "Киев, Героев Днепра, 53", + "WarehouseSenderInternetAddressRef" : "00000000-0000-0000-0000-000000000000", + "WarehouseSenderAddress" : "Киев, Оболонский, 35", + "CounterpartySenderType" : "PrivatePerson", + "AviaDelivery" : "", + "BarcodeRedBox" : "", + "CargoReturnRefusal" : "false", + "DaysStorageCargo" : "", + "Packaging" : null, + "PartialReturnGoods" : null, + "SecurePayment" : "false", + "PossibilityChangeCash2Card" : true, + "PossibilityChangeDeliveryIntervals" : true, + "PossibilityTermExtensio" : true, + "StorageAmount" : "", + "StoragePrice" : "", + "FreeShipping" : "", + "LoyaltyCardRecipient" : "" + }], + "errors": [], + "warnings": [], + "info": [], + "messageCodes": [], + "errorCodes": [], + "warningCodes": [], + "infoCodes": [] +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloActionGroup.java b/NovaPoshta/Docs/CFX Examples/HelloActionGroup.java new file mode 100644 index 0000000..ca5d526 --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloActionGroup.java @@ -0,0 +1,204 @@ +/** + * Copyright (c) 2013, ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples.actions; + +import javafx.beans.property.BooleanProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Control; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.action.Action; +import org.controlsfx.control.action.ActionCheck; +import org.controlsfx.control.action.ActionGroup; +import org.controlsfx.control.action.ActionUtils; +import org.controlsfx.control.action.ActionUtils.ActionTextBehavior; +import org.controlsfx.samples.Utils; + +import java.util.Arrays; +import java.util.Collection; + +import static org.controlsfx.control.action.ActionUtils.ACTION_SEPARATOR; +import static org.controlsfx.control.action.ActionUtils.ACTION_SPAN; + +public class HelloActionGroup extends ControlsFXSample { + + private static final ImageView image = new ImageView( new Image("/org/controlsfx/samples/security-low.png")); + + private Collection actions = Arrays.asList( + new ActionGroup("Group 1", image, new DummyAction("Action 1.1", image), + new CheckDummyAction("Action 1.2") ), + new ActionGroup("Group 2", image, new DummyAction("Action 2.1"), + ACTION_SEPARATOR, + new ActionGroup("Action 2.2", new DummyAction("Action 2.2.1"), + new CheckDummyAction("Action 2.2.2")), + new DummyAction("Action 2.3") ), + ACTION_SPAN, + ACTION_SEPARATOR, + new CheckDummyAction("Action 3", image), + new ActionGroup("Group 4", image, new DummyAction("Action 4.1", image), + new CheckDummyAction("Action 4.2")) + ); + + private static class DummyAction extends Action { + public DummyAction(String name, Node image) { + super(name); + setGraphic(image); + setEventHandler(ae -> String.format("Action '%s' is executed", getText()) ); + } + + public DummyAction( String name ) { + super(name); + } + + @Override public String toString() { + return getText(); + } + } + + @ActionCheck + private static class CheckDummyAction extends Action { + public CheckDummyAction(String name, Node image) { + super(name); + setGraphic(image); + setEventHandler(ae -> String.format("Action '%s' is executed", getText()) ); + } + + public CheckDummyAction( String name ) { + super(name); + } + + @Override public String toString() { + return getText(); + } + } + + private ObservableList flatten( Collection actions, ObservableList dest ) { + for (Action a : actions) { + if ( a == null || a == ActionUtils.ACTION_SEPARATOR ) continue; + dest.add(a); + if ( a instanceof ActionGroup ) { + flatten( ((ActionGroup)a).getActions(), dest); + } + } + + return dest; + } + + @Override public String getSampleName() { + return "Action Group"; + } + + @Override public String getJavaDocURL() { + return Utils.JAVADOC_BASE + "org/controlsfx/control/action/ActionGroup.html"; + } + + @Override public String getSampleDescription() { + return "MenuBar, ToolBar and ContextMenu presented here are effortlessly built out of the same action tree. " + + "Action properties can be dynamically changed, triggering changes in all related controls"; + } + + @Override public Node getControlPanel() { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + int row = 0; + + // Dynamically enable/disable action + Label lblAddCrumb = new Label("Dynamically enable/disable action: "); + lblAddCrumb.getStyleClass().add("property"); + grid.add(lblAddCrumb, 0, row); + final ComboBox cbActions = new ComboBox<>(flatten( actions, FXCollections.observableArrayList())); + cbActions.getSelectionModel().select(0); + grid.add(cbActions, 1, row); + Action toggleAction = new Action("Enable/Disable") { + { setEventHandler(this::handleAction); } + + private void handleAction(ActionEvent ae) { + Action action = cbActions.getSelectionModel().getSelectedItem(); + if ( action != null ) { + BooleanProperty p = action.disabledProperty(); + p.set(!p.get()); + } + } + }; + grid.add(ActionUtils.createButton(toggleAction), 2, row++); + + return grid; + } + + @Override public Node getPanel(final Stage stage) { + VBox root = new VBox(10); + root.setPadding(new Insets(10, 10, 10, 10)); + root.setMaxHeight(Double.MAX_VALUE); + + Insets topMargin = new Insets(7, 7, 0, 7); + Insets margin = new Insets(0, 7, 7, 7); + + addWithMargin(root, new Label("MenuBar:"), topMargin ).setStyle("-fx-font-weight: bold;"); + addWithMargin(root, ActionUtils.createMenuBar(actions), margin); + + addWithMargin(root,new Label("ToolBar (with text on controls):"), topMargin).setStyle("-fx-font-weight: bold;"); + addWithMargin(root, ActionUtils.createToolBar(actions, ActionTextBehavior.SHOW), margin); + + addWithMargin(root,new Label("ToolBar (no text on controls):"), topMargin).setStyle("-fx-font-weight: bold;"); + addWithMargin(root, ActionUtils.createToolBar(actions, ActionTextBehavior.HIDE), margin); + + addWithMargin(root, new Label("ContextMenu:"), topMargin).setStyle("-fx-font-weight: bold;"); + Label context = new Label("Right-click to see the context menu"); + addWithMargin(root,context, margin); + context.setContextMenu(ActionUtils.createContextMenu(actions)); + context.setStyle("-fx-background-color: #E0E0E0 ;-fx-border-color: black;-fx-border-style: dotted"); + context.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); + VBox.setVgrow(context, Priority.ALWAYS); + VBox.setVgrow(root, Priority.ALWAYS); + + return root; + } + + private Control addWithMargin( VBox parent, Control control, Insets insets) { + parent.getChildren().add(control); + VBox.setMargin(control, insets); + return control; + } + + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloActionProxy.java b/NovaPoshta/Docs/CFX Examples/HelloActionProxy.java new file mode 100644 index 0000000..367f57b --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloActionProxy.java @@ -0,0 +1,224 @@ +/** + * Copyright (c) 2013, ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples.actions; + +import javafx.beans.property.BooleanProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Control; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.action.*; +import org.controlsfx.control.action.ActionUtils.ActionTextBehavior; +import org.controlsfx.samples.Utils; + +import java.util.Arrays; +import java.util.Collection; + +import static org.controlsfx.control.action.ActionMap.action; +import static org.controlsfx.control.action.ActionMap.actions; +import static org.controlsfx.control.action.ActionUtils.ACTION_SEPARATOR; +import static org.controlsfx.control.action.ActionUtils.ACTION_SPAN; + +public class HelloActionProxy extends ControlsFXSample { + + private static final String imagePath = "/org/controlsfx/samples/security-low.png"; + private static final ImageView image = new ImageView(new Image(imagePath)); + + private Collection actions; + + public HelloActionProxy() { + ActionMap.register(this); + actions = Arrays.asList( + new ActionGroup("Group 1", image, actions("action11","action12") ), + new ActionGroup("Group 2", image, actions("action21","---","action22", "action221","action222","action23") ), + ACTION_SPAN, + ACTION_SEPARATOR, + action("action3"), + new ActionGroup("Group 4", image, actions("action41","action42")) + ); + } + + @ActionProxy(text="Action 1.1", graphic=imagePath, accelerator="ctrl+shift+T") + private void action11() { + System.out.println( "Action 1.1 is executed"); + } + + @ActionCheck + @ActionProxy(text="Action 1.2", graphic="http://icons.iconarchive.com/icons/custom-icon-design/mini-3/16/teacher-male-icon.png") + private void action12() { + System.out.println( "Action 1.2 is executed"); + } + + @ActionProxy(text="Action 2.1", graphic=imagePath, factory="org.controlsfx.samples.actions.HelloCustomActionFactory") + private void action21() { + System.out.println( "Action 2.1 is executed (and used a custom action factory)"); + } + + @ActionProxy(text="Action 2.2", graphic=imagePath) + private void action22( ActionEvent evt ) { + System.out.println( "Action 2.2 is executed (and received an ActionEvent)"); + } + + @ActionProxy(text="Action 2.2.1", graphic=imagePath) + private void action221( ActionEvent evt, Action action ) { + System.out.println( "Action 2.2.1 is executed (and received both an ActionEvent and an Action)"); + } + + @ActionProxy(text="Action 2.2.2", graphic=imagePath) + private void action222() { + System.out.println( "Action 2.2.2 is executed"); + } + + @ActionProxy(text="Action 2.3", graphic=imagePath) + private void action23() { + System.out.println( "Action 2.3 is executed"); + } + + @ActionCheck + @ActionProxy(text="Action 3", graphic="font>FontAwesome|STAR") + private void action3() { + System.out.println( "Action 3 is executed"); + } + + @ActionProxy(text="Action 4.1", graphic=imagePath) + private void action41() { + System.out.println( "Action 4.1 is executed"); + } + + @ActionProxy(text="Action 4.2", graphic=imagePath) + private void action42() { + System.out.println( "Action 4.2 is executed"); + } + + private ObservableList flatten( Collection actions, ObservableList dest ) { + + for (Action a : actions) { + if ( a == null || a == ActionUtils.ACTION_SEPARATOR ) continue; + dest.add(a); + if ( a instanceof ActionGroup ) { + flatten( ((ActionGroup)a).getActions(), dest); + } + } + + return dest; + } + + + @Override public String getSampleName() { + return "Action Proxy"; + } + + @Override public String getJavaDocURL() { + return Utils.JAVADOC_BASE + "org/controlsfx/control/action/ActionProxy.html"; + } + + @Override public String getSampleDescription() { + return "MenuBar, ToolBar and ContextMenu presented here are effortlessly built out of the same action tree. " + + "Action properties can be dynamically changed, triggering changes in all related controls"; + } + + @Override public Node getControlPanel() { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + int row = 0; + + // Dynamically enable/disable action + Label lblAddCrumb = new Label("Dynamically enable/disable action: "); + lblAddCrumb.getStyleClass().add("property"); + grid.add(lblAddCrumb, 0, row); + final ComboBox cbActions = new ComboBox<>(flatten( actions, FXCollections.observableArrayList())); + cbActions.getSelectionModel().select(0); + grid.add(cbActions, 1, row); + Action toggleAction = new Action("Enable/Disable") { + { setEventHandler(this::handleAction); } + + private void handleAction(ActionEvent ae) { + Action action = cbActions.getSelectionModel().getSelectedItem(); + if ( action != null ) { + BooleanProperty p = action.disabledProperty(); + p.set(!p.get()); + } + } + }; + grid.add(ActionUtils.createButton(toggleAction), 2, row++); + + return grid; + } + + @Override public Node getPanel(final Stage stage) { + VBox root = new VBox(10); + root.setPadding(new Insets(10, 10, 10, 10)); + root.setMaxHeight(Double.MAX_VALUE); + + Insets topMargin = new Insets(7, 7, 0, 7); + Insets margin = new Insets(0, 7, 7, 7); + + addWithMargin(root, new Label("MenuBar:"), topMargin ).setStyle("-fx-font-weight: bold;"); + addWithMargin(root, ActionUtils.createMenuBar(actions), margin); + + addWithMargin(root,new Label("ToolBar (with text on controls):"), topMargin).setStyle("-fx-font-weight: bold;"); + addWithMargin(root, ActionUtils.createToolBar(actions, ActionTextBehavior.SHOW), margin); + + addWithMargin(root,new Label("ToolBar (no text on controls):"), topMargin).setStyle("-fx-font-weight: bold;"); + addWithMargin(root, ActionUtils.createToolBar(actions, ActionTextBehavior.HIDE), margin); + + addWithMargin(root, new Label("ContextMenu:"), topMargin).setStyle("-fx-font-weight: bold;"); + Label context = new Label("Right-click to see the context menu"); + addWithMargin(root,context, margin); + context.setContextMenu(ActionUtils.createContextMenu(actions)); + context.setStyle("-fx-background-color: #E0E0E0 ;-fx-border-color: black;-fx-border-style: dotted"); + context.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); + VBox.setVgrow(context, Priority.ALWAYS); + VBox.setVgrow(root, Priority.ALWAYS); + + return root; + } + + private Control addWithMargin( VBox parent, Control control, Insets insets) { + parent.getChildren().add(control); + VBox.setMargin(control, insets); + return control; + } + + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloAutoComplete.java b/NovaPoshta/Docs/CFX Examples/HelloAutoComplete.java new file mode 100644 index 0000000..9366d30 --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloAutoComplete.java @@ -0,0 +1,208 @@ +/** + * Copyright (c) 2014, ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples.textfields; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.textfield.AutoCompletionBinding; +import org.controlsfx.control.textfield.TextFields; +import org.controlsfx.samples.Utils; + +import impl.org.controlsfx.skin.AutoCompletePopup; +import impl.org.controlsfx.skin.AutoCompletePopupSkin; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.control.ListCell; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.stage.Stage; + +public class HelloAutoComplete extends ControlsFXSample { + + private AutoCompletionBinding autoCompletionBinding; + private String[] _possibleSuggestions = {"Hey", "Hello", "Hello World", "Apple", "Cool", "Costa", "Cola", "Coca Cola"}; + private Set possibleSuggestions = new HashSet<>(Arrays.asList(_possibleSuggestions)); + private Map colorSuggestions = allColorsWithName(); + + private TextField learningTextField; + + @Override public String getSampleName() { + return "AutoComplete"; + } + + @Override public String getJavaDocURL() { + return Utils.JAVADOC_BASE + "org/controlsfx/control/textfield/TextFields.html"; + } + + @Override public String getSampleDescription() { + return "AutoComplete helps a user with suggestions to type faster, " + + "but does not limit the user from entering alternative text." + + "\n\n" + + "The textfields have been primed with the following words:\n" + + "\"Hey\", \"Hello\", \"Hello World\", \"Apple\", \"Cool\", " + + "\"Costa\", \"Cola\", \"Coca Cola\"" + + "\n\n" + + "The 'Learning TextField' will add whatever words are typed " + + "to the auto-complete popup, as long as you press Enter once " + + "you've finished typing the word." + + "\n\n" + + "The Color TextField will suggest different colors when you type " + + "in their name."; + } + + @Override public Node getPanel(final Stage stage) { + + BorderPane root = new BorderPane(); + + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + // + // TextField with static auto-complete functionality + // + TextField textField = new TextField(); + + TextFields.bindAutoCompletion( + textField, + "Hey", "Hello", "Hello World", "Apple", "Cool", "Costa", "Cola", "Coca Cola"); + + grid.add(new Label("Auto-complete Text"), 0, 0); + grid.add(textField, 1, 0); + GridPane.setHgrow(textField, Priority.ALWAYS); + + + // + // TextField with learning auto-complete functionality + // Learn the word when user presses ENTER + // + learningTextField = new TextField(); + autoCompletionBinding = TextFields.bindAutoCompletion(learningTextField, possibleSuggestions); + learningTextField.setOnKeyPressed(new EventHandler() { + @Override + public void handle(KeyEvent ke) { + switch (ke.getCode()) { + case ENTER: + autoCompletionLearnWord(learningTextField.getText().trim()); + break; + default: + break; + } + } + }); + + grid.add(new Label("Learning TextField"), 0, 1); + grid.add(learningTextField, 1, 1); + GridPane.setHgrow(learningTextField, Priority.ALWAYS); + + // + // TextField with custom cell factory + // Completes color names + // + TextField customTextField = new TextField(); + AutoCompletePopup colorCompletionPopup = TextFields.bindAutoCompletion(customTextField, colorSuggestions.keySet()).getAutoCompletionPopup(); + colorCompletionPopup.setSkin(new AutoCompletePopupSkin(colorCompletionPopup, param -> new ListCell() { + @Override + public void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (empty) { + setText(null); + setGraphic(null); + } else { + setGraphic(new Rectangle(32, 32, colorSuggestions.get(item))); + setText(item); + } + } + })); + + grid.add(new Label("Color TextField with custom CellFactory"), 0, 2); + grid.add(customTextField, 1, 2); + GridPane.setHgrow(customTextField, Priority.ALWAYS); + + root.setTop(grid); + return root; + } + + private void autoCompletionLearnWord(String newWord){ + possibleSuggestions.add(newWord); + + // we dispose the old binding and recreate a new binding + if (autoCompletionBinding != null) { + autoCompletionBinding.dispose(); + } + autoCompletionBinding = TextFields.bindAutoCompletion(learningTextField, possibleSuggestions); + } + + @Override public Node getControlPanel() { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + // TODO Add customization example controls + + + return grid; + } + + /* Modified from https://stackoverflow.com/a/17465261/6094756 */ + private Map allColorsWithName() { + Map map = new HashMap<>(); + try { + for (Field f : Color.class.getFields()) { + Object obj = f.get(null); + if (obj instanceof Color) { + map.put(f.getName(), (Color) obj); + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + map.put("red", Color.RED); + map.put("green", Color.GREEN); + map.put("blue", Color.BLUE); + } + return map; + } + + public static void main(String[] args) { + launch(args); + } + +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloCheckComboBox.java b/NovaPoshta/Docs/CFX Examples/HelloCheckComboBox.java new file mode 100644 index 0000000..25b115e --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloCheckComboBox.java @@ -0,0 +1,241 @@ +/** + * Copyright (c) 2013, 2018 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples.checked; + +import javafx.beans.binding.Bindings; +import javafx.beans.property.ReadOnlyStringProperty; +import javafx.beans.property.ReadOnlyStringWrapper; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.collections.FXCollections; +import javafx.collections.ListChangeListener; +import javafx.collections.ObservableList; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.layout.GridPane; +import javafx.stage.Stage; +import javafx.util.StringConverter; + +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.CheckComboBox; +import org.controlsfx.control.IndexedCheckModel; +import org.controlsfx.samples.Utils; + +public class HelloCheckComboBox extends ControlsFXSample { + + private final Label checkedItemsLabel = new Label(); + private CheckComboBox checkComboBox; + + @Override public String getSampleName() { + return "CheckComboBox"; + } + + @Override public String getJavaDocURL() { + return Utils.JAVADOC_BASE + "org/controlsfx/control/CheckComboBox.html"; + } + + @Override public String getSampleDescription() { + return "A simple UI control that makes it possible to select zero or " + + "more items within a ComboBox without the need to set a custom " + + "cell factory or manually create boolean properties for each " + + "row - simply use the check model property to request the " + + "current selection state."; + } + + @Override public Node getPanel(Stage stage) { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + int row = 0; + + final ObservableList strings = FXCollections.observableArrayList(); + for (int i = 0; i <= 100; i++) { + strings.add("Item " + i); + } + + // normal ComboBox + grid.add(new Label("Normal ComboBox: "), 0, row); + final ComboBox comboBox = new ComboBox<>(strings); + comboBox.focusedProperty().addListener((o, ov, nv) -> { + if(nv) comboBox.show(); else comboBox.hide(); + }); + grid.add(comboBox, 1, row++); + + // CheckComboBox + checkComboBox = new CheckComboBox<>(strings); + checkComboBox.focusedProperty().addListener((o, ov, nv) -> { + if(nv) checkComboBox.show(); else checkComboBox.hide(); + }); + checkComboBox.getCheckModel().getCheckedItems().addListener((ListChangeListener) change -> { + updateText(checkedItemsLabel, change.getList()); + + while (change.next()) { + System.out.println("============================================"); + System.out.println("Change: " + change); + System.out.println("Added sublist " + change.getAddedSubList()); + System.out.println("Removed sublist " + change.getRemoved()); + System.out.println("List " + change.getList()); + System.out.println("Added " + change.wasAdded() + " Permutated " + change.wasPermutated() + " Removed " + change.wasRemoved() + " Replaced " + + change.wasReplaced() + " Updated " + change.wasUpdated()); + System.out.println("============================================"); + } + }); + grid.add(new Label("CheckComboBox: "), 0, row); + grid.add(checkComboBox, 1, row++); + + CheckComboBox checkComboBox2 = new CheckComboBox<>(Person.createDemoList()); + checkComboBox2.setConverter(new StringConverter() { + @Override + public String toString(Person object) { + return object.getFullName(); + } + @Override + public Person fromString(String string) { + return null; + } + }); + checkComboBox2.focusedProperty().addListener((o, ov, nv) -> { + if(nv) checkComboBox2.show(); else checkComboBox2.hide(); + }); + grid.add(new Label("CheckComboBox with data objects: "), 0, row); + grid.add(checkComboBox2, 1, row); + + return grid; + } + + @Override public Node getControlPanel() { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + int row = 0; + + Label label1 = new Label("Checked items: "); + label1.getStyleClass().add("property"); + grid.add(label1, 0, 0); + grid.add(checkedItemsLabel, 1, row++); + updateText(checkedItemsLabel, null); + + Label checkItem2Label = new Label("Check 'Item 2': "); + checkItem2Label.getStyleClass().add("property"); + grid.add(checkItem2Label, 0, row); + final CheckBox checkItem2Btn = new CheckBox(); + checkItem2Btn.setOnAction(e -> { + IndexedCheckModel cm = checkComboBox.getCheckModel(); + if (cm != null) { + cm.toggleCheckState(2); + } + }); + grid.add(checkItem2Btn, 1, row); + + return grid; + } + + protected void updateText(Label label, ObservableList list) { + final StringBuilder sb = new StringBuilder(); + + if (list != null) { + for (int i = 0, max = list.size(); i < max; i++) { + sb.append(list.get(i)); + if (i < max - 1) { + sb.append(", "); + } + } + } + + final String str = sb.toString(); + label.setText(str.isEmpty() ? "" : str); + } + + public static void main(String[] args) { + launch(args); + } + +} + +class Person { + private StringProperty firstName = new SimpleStringProperty(); + private StringProperty lastName = new SimpleStringProperty(); + private ReadOnlyStringWrapper fullName = new ReadOnlyStringWrapper(); + + public Person(String firstName, String lastName) { + this.firstName.set(firstName); + this.lastName.set(lastName); + fullName.bind(Bindings.concat(firstName, " ", lastName)); + } + + public static final ObservableList createDemoList() { + final ObservableList result = FXCollections.observableArrayList(); + result.add(new Person("Paul", "McCartney")); + result.add(new Person("Andrew Lloyd", "Webber")); + result.add(new Person("Herb", "Alpert")); + result.add(new Person("Emilio", "Estefan")); + result.add(new Person("Bernie", "Taupin")); + result.add(new Person("Elton", "John")); + result.add(new Person("Mick", "Jagger")); + result.add(new Person("Keith", "Richerds")); + return result; + } + + public final StringProperty firstNameProperty() { + return this.firstName; + } + + public final java.lang.String getFirstName() { + return this.firstNameProperty().get(); + } + + public final void setFirstName(final String firstName) { + this.firstNameProperty().set(firstName); + } + + public final StringProperty lastNameProperty() { + return this.lastName; + } + + public final String getLastName() { + return this.lastNameProperty().get(); + } + + public final void setLastName(final String lastName) { + this.lastNameProperty().set(lastName); + } + + public final ReadOnlyStringProperty fullNameProperty() { + return this.fullName.getReadOnlyProperty(); + } + + public final String getFullName() { + return this.fullNameProperty().get(); + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloDialogs.java b/NovaPoshta/Docs/CFX Examples/HelloDialogs.java new file mode 100644 index 0000000..d0fb1e6 --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloDialogs.java @@ -0,0 +1,742 @@ +/** + * Copyright (c) 2013, 2015 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples.dialogs; + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import javafx.application.Application; +import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.concurrent.Task; +import javafx.event.ActionEvent; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.Button; +import javafx.scene.control.ButtonBar.ButtonData; +import javafx.scene.control.ButtonType; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ChoiceDialog; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Dialog; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.control.TextInputDialog; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import javafx.scene.text.Font; +import javafx.stage.Modality; +import javafx.stage.Stage; +import javafx.stage.StageStyle; +import javafx.stage.Window; + +import org.controlsfx.ControlsFXSample; +import org.controlsfx.dialog.CommandLinksDialog; +import org.controlsfx.dialog.CommandLinksDialog.CommandLinksButtonType; +import org.controlsfx.dialog.WizardPane; +import org.controlsfx.dialog.ExceptionDialog; +import org.controlsfx.dialog.FontSelectorDialog; +import org.controlsfx.dialog.LoginDialog; +import org.controlsfx.dialog.ProgressDialog; +import org.controlsfx.dialog.Wizard; +import org.controlsfx.dialog.Wizard.LinearFlow; +import org.controlsfx.validation.ValidationSupport; +import org.controlsfx.validation.Validator; + +public class HelloDialogs extends ControlsFXSample { + + @Override + public String getSampleName() { + return "Dialogs"; + } + + @Override + public String getJavaDocURL() { +// return Utils.JAVADOC_BASE + "org/controlsfx/dialog/Dialogs.html"; + return null; + } + + @Override + public String getSampleDescription() { + return ""; + } + + private final ComboBox styleCombobox = new ComboBox<>(); + private final ComboBox modalityCombobox = new ComboBox<>(); + private final CheckBox cbUseBlocking = new CheckBox(); + private final CheckBox cbCloseDialogAutomatically = new CheckBox(); + private final CheckBox cbShowMasthead = new CheckBox(); + private final CheckBox cbSetOwner = new CheckBox(); + private final CheckBox cbCustomGraphic = new CheckBox(); + + private Stage stage; + + @Override + public Node getPanel(Stage stage) { + this.stage = stage; + + GridPane grid = new GridPane(); + grid.setPadding(new Insets(10, 10, 10, 10)); + grid.setHgap(10); + grid.setVgap(10); + + int row = 0; + + Label javafxDialogs = new Label("JavaFX Dialogs:"); + javafxDialogs.setFont(Font.font(25)); + grid.add(javafxDialogs, 0, row++, 2, 1); + + // ******************************************************************* + // Information Dialog + // ******************************************************************* + + grid.add(createLabel("Information Dialog: "), 0, row); + + final Button Hyperlink2 = new Button("Show"); + Hyperlink2.setOnAction( (ActionEvent e) -> { + + Alert dlg = createAlert(AlertType.INFORMATION); + dlg.setTitle("Custom title"); + String optionalMasthead = "Wouldn't this be nice?"; + dlg.getDialogPane().setContentText("A collection of pre-built JavaFX dialogs?\nSeems like a great idea to me..."); + configureSampleDialog(dlg, optionalMasthead); + + // lets get some output when events happen + dlg.setOnShowing(evt -> System.out.println(evt)); + dlg.setOnShown(evt -> System.out.println(evt)); + dlg.setOnHiding(evt -> System.out.println(evt)); + dlg.setOnHidden(evt -> System.out.println(evt)); + +// dlg.setOnCloseRequest(evt -> evt.consume()); + + showDialog(dlg); + }); + + final Button Hyperlink2a = new Button("2 x Buttons (no cancel)"); + Hyperlink2a.setOnAction( (ActionEvent e) -> { + Alert dlg = createAlert(AlertType.INFORMATION); + dlg.setTitle("Custom title"); + String optionalMasthead = "Wouldn't this be nice?"; + dlg.getDialogPane().setContentText("A collection of pre-built JavaFX dialogs?\nSeems like a great idea to me..."); + configureSampleDialog(dlg, optionalMasthead); + dlg.getButtonTypes().add(ButtonType.NEXT); + +// dlg.setOnCloseRequest(evt -> evt.consume()); + + showDialog(dlg); + + }); + + grid.add(new HBox(10, Hyperlink2, Hyperlink2a), 1, row); + + row++; + + // ******************************************************************* + // Confirmation Dialog + // ******************************************************************* + + grid.add(createLabel("Confirmation Dialog: "), 0, row); + + final CheckBox cbShowCancel = new CheckBox("Show Cancel Button"); + cbShowCancel.setSelected(true); + + final Button Hyperlink3 = new Button("Show"); + Hyperlink3.setOnAction(e -> { + Alert dlg = createAlert(AlertType.CONFIRMATION); + dlg.setTitle("You do want dialogs right?"); + String optionalMasthead = "Just Checkin'"; + dlg.getDialogPane().setContentText("I was a bit worried that you might not want them, so I wanted to double check."); + + if (!cbShowCancel.isSelected()) { + dlg.getDialogPane().getButtonTypes().remove(ButtonType.CANCEL); + } + + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + grid.add(new HBox(10, Hyperlink3, cbShowCancel), 1, row); + + row++; + + // ******************************************************************* + // Warning Dialog + // ******************************************************************* + + grid.add(createLabel("Warning Dialog: "), 0, row); + + final Button Hyperlink6a = new Button("Show"); + Hyperlink6a.setOnAction(e -> { + Alert dlg = createAlert(AlertType.WARNING); + dlg.setTitle("I'm warning you!"); + String optionalMasthead = "This is a warning"; + dlg.getDialogPane().setContentText("I'm glad I didn't need to use this..."); + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + grid.add(new HBox(10, Hyperlink6a), 1, row); + + row++; + + // ******************************************************************* + // Error Dialog + // ******************************************************************* + + grid.add(createLabel("Error Dialog: "), 0, row); + + final Button Hyperlink7a = new Button("Show"); + Hyperlink7a.setOnAction(e -> { + Alert dlg = createAlert(AlertType.ERROR); + dlg.setTitle("It looks like you're making a bad decision"); + String optionalMasthead = "Exception Encountered"; + dlg.getDialogPane().setContentText("Better change your mind - this is really your last chance! (Even longer text that should probably wrap)"); + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + grid.add(new HBox(10, Hyperlink7a), 1, row); + + row++; + + + // ******************************************************************* + // Input Dialog (with header) + // ******************************************************************* + + grid.add(createLabel("Input Dialog: "), 0, row); + + final Button Hyperlink8 = new Button("TextField"); + Hyperlink8.setOnAction(e -> { + TextInputDialog dlg = new TextInputDialog(""); + dlg.setTitle("Name Check"); + String optionalMasthead = "Please type in your name"; + dlg.getDialogPane().setContentText("What is your name?"); + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + + final Button Hyperlink9 = new Button("Initial Value Set"); + Hyperlink9.setOnAction(e -> { + TextInputDialog dlg = new TextInputDialog("Jonathan"); + dlg.setTitle("Name Guess"); + String optionalMasthead = "Name Guess"; + dlg.getDialogPane().setContentText("Pick a name?"); + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + + final Button Hyperlink10 = new Button("Set Choices (< 10)"); + Hyperlink10.setOnAction(e -> { + ChoiceDialog dlg = new ChoiceDialog<>("Jonathan", + "Matthew", "Jonathan", "Ian", "Sue", "Hannah"); + dlg.setTitle("Name Guess"); + String optionalMasthead = "Name Guess"; + dlg.getDialogPane().setContentText("Pick a name?"); + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + + final Button Hyperlink11 = new Button("Set Choices (>= 10)"); + Hyperlink11.setOnAction(e -> { + ChoiceDialog dlg = new ChoiceDialog<>("Jonathan", + "Matthew", "Jonathan", "Ian", "Sue", + "Hannah", "Julia", "Denise", "Stephan", + "Sarah", "Ron", "Ingrid"); + dlg.setTitle("Name Guess"); + String optionalMasthead = "Name Guess"; + dlg.getDialogPane().setContentText("Pick a name?"); + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + + grid.add(new HBox(10, Hyperlink8, Hyperlink9, Hyperlink10, Hyperlink11), 1, row); + row++; + + + + + + + // --------- ControlsFX-specific Dialogs + + Label controlsfxDialogs = new Label("ControlsFX Dialogs:"); + controlsfxDialogs.setFont(Font.font(25)); + grid.add(controlsfxDialogs, 0, row++, 2, 1); + + + // ******************************************************************* + // Command links + // ******************************************************************* + + grid.add(createLabel("Pre-built dialogs: "), 0, row); + final Button Hyperlink12 = new Button("Command Links"); + Hyperlink12.setOnAction(e -> { + List links = Arrays + .asList(new CommandLinksButtonType( + "Add a network that is in the range of this computer", + "This shows you a list of networks that are currently available and lets you connect to one.", false), + new CommandLinksButtonType( + "Manually create a network profile", + "This creates a new network profile or locates an existing one and saves it on your computer", + true /*default*/), + new CommandLinksButtonType("Create an ad hoc network", + "This creates a temporary network for sharing files or and Internet connection", false)); + + CommandLinksDialog dlg = new CommandLinksDialog(links); + dlg.setTitle("Manually connect to wireless network"); + String optionalMasthead = "Manually connect to wireless network"; + dlg.getDialogPane().setContentText("How do you want to add a network?"); + configureSampleDialog(dlg, optionalMasthead); + showDialog(dlg); + }); + + final Button Hyperlink12a = new Button("Font Selector"); + Hyperlink12a.setOnAction(e -> { + FontSelectorDialog dlg = new FontSelectorDialog(null); + configureSampleDialog(dlg, "Please select a font!"); + showDialog(dlg); + }); + + final Button Hyperlink12b = new Button("Progress"); + Hyperlink12b.setOnAction((ActionEvent e) -> { + Task worker = new Task() { + @Override + protected Object call() throws Exception { + for (int i = 0; i <= 100; i++) { + updateProgress(i, 99); + updateMessage("progress: " + i); + System.out.println("progress: " + i); + Thread.sleep(100); + } + return null; + } + }; + + ProgressDialog dlg = new ProgressDialog(worker); + configureSampleDialog(dlg, ""); + + Thread th = new Thread(worker); + th.setDaemon(true); + th.start(); + }); + + final Button Hyperlink12c = new Button("Login"); + Hyperlink12c.setOnAction((ActionEvent e) -> { + LoginDialog dlg = new LoginDialog(null, null); + configureSampleDialog(dlg, ""); + showDialog(dlg); + }); + + final Button Hyperlink12d = new Button("Exception"); + Hyperlink12d.setOnAction((ActionEvent e) -> { + ExceptionDialog dlg = new ExceptionDialog(new Exception("ControlsFX is _too_ awesome!")); + configureSampleDialog(dlg, ""); + showDialog(dlg); + }); + + grid.add(new HBox(10, Hyperlink12, Hyperlink12a, Hyperlink12b, Hyperlink12c, Hyperlink12d), 1, row); + row++; + + + // ******************************************************************* + // wizards + // ******************************************************************* + + grid.add(createLabel("Wizard: "), 0, row); + final Button Hyperlink15a = new Button("Linear Wizard"); + Hyperlink15a.setOnAction(e -> showLinearWizard()); + + final Button Hyperlink15b = new Button("Branching Wizard"); + Hyperlink15b.setOnAction(e -> showBranchingWizard()); + + final Button Hyperlink15c = new Button("Validated Linear Wizard"); + Hyperlink15c.setOnAction(e -> showValidatedLinearWizard()); + + grid.add(new HBox(10, Hyperlink15a, Hyperlink15b, Hyperlink15c), 1, row++); + + return grid; + } + + private Alert createAlert(AlertType type) { + Window owner = cbSetOwner.isSelected() ? stage : null; + Alert dlg = new Alert(type, ""); + dlg.initModality(modalityCombobox.getValue()); + dlg.initOwner(owner); + return dlg; + } + + private void configureSampleDialog(Dialog dlg, String header) { + Window owner = cbSetOwner.isSelected() ? stage : null; + if (header != null && cbShowMasthead.isSelected()) { + dlg.getDialogPane().setHeaderText(header); + } + + if (cbCustomGraphic.isSelected()) { + dlg.getDialogPane().setGraphic(new ImageView(new Image(getClass().getResource("/org/controlsfx/samples/controlsfx-logo.png").toExternalForm()))); + } + + dlg.initStyle(styleCombobox.getValue()); + dlg.initOwner(owner); + } + + private void showDialog(Dialog dlg) { + Window owner = cbSetOwner.isSelected() ? stage : null; + if (cbCloseDialogAutomatically.isSelected()) { + new Thread(() -> { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Attempting to close dialog now..."); + Platform.runLater(() -> dlg.close()); + }).start(); + } + dlg.initOwner(owner); + + if (cbUseBlocking.isSelected()) { + dlg.showAndWait().ifPresent(result -> System.out.println("Result is " + result)); + } else { + dlg.show(); + dlg.resultProperty().addListener(o -> System.out.println("Result is: " + dlg.getResult())); + System.out.println("This println is _after_ the show method - we're non-blocking!"); + } + } + + @Override public Node getControlPanel() { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + int row = 0; + + // stage style + grid.add(createLabel("Style: ", "property"), 0, row); + styleCombobox.getItems().setAll(StageStyle.values()); + styleCombobox.setValue(styleCombobox.getItems().get(0)); + grid.add(styleCombobox, 1, row); + row++; + + // modality + grid.add(createLabel("Modality: ", "property"), 0, row); + modalityCombobox.getItems().setAll(Modality.values()); + modalityCombobox.setValue(modalityCombobox.getItems().get(Modality.values().length-1)); + grid.add(modalityCombobox, 1, row); + row++; + + // use blocking + cbUseBlocking.setSelected(true); + grid.add(createLabel("Use blocking: ", "property"), 0, row); + grid.add(cbUseBlocking, 1, row); + row++; + + // close dialog automatically + grid.add(createLabel("Close dialog after 2000ms: ", "property"), 0, row); + grid.add(cbCloseDialogAutomatically, 1, row); + row++; + + // show header + grid.add(createLabel("Show custom header text: ", "property"), 0, row); + grid.add(cbShowMasthead, 1, row); + row++; + + // set owner + grid.add(createLabel("Set dialog owner: ", "property"), 0, row); + grid.add(cbSetOwner, 1, row); + row++; + + // custom graphic + grid.add(createLabel("Use custom graphic: ", "property"), 0, row); + grid.add(cbCustomGraphic, 1, row); + row++; + + return grid; + } + +// private CommandLinksButtonType buildCommandLink( String text, String comment, boolean isDefault ) { +// return new CommandLinksButtonType(text, comment, isDefault); +// } + + + public static void main(String[] args) { + Application.launch(args); + } + + private Node createLabel(String text, String... styleclass) { + Label label = new Label(text); + + if (styleclass == null || styleclass.length == 0) { + label.setFont(Font.font(13)); + } else { + label.getStyleClass().addAll(styleclass); + } + return label; + } + + private void showLinearWizard() { + Window owner = cbSetOwner.isSelected() ? stage : null; + // define pages to show + Wizard wizard = new Wizard(owner); + wizard.setTitle("Linear Wizard"); + + // --- page 1 + int row = 0; + + GridPane page1Grid = new GridPane(); + page1Grid.setVgap(10); + page1Grid.setHgap(10); + + page1Grid.add(new Label("First Name:"), 0, row); + TextField txFirstName = createTextField("firstName"); +// wizard.getValidationSupport().registerValidator(txFirstName, Validator.createEmptyValidator("First Name is mandatory")); + page1Grid.add(txFirstName, 1, row++); + + page1Grid.add(new Label("Last Name:"), 0, row); + TextField txLastName = createTextField("lastName"); +// wizard.getValidationSupport().registerValidator(txLastName, Validator.createEmptyValidator("Last Name is mandatory")); + page1Grid.add(txLastName, 1, row); + + WizardPane page1 = new WizardPane(); + page1.setHeaderText("Please Enter Your Details"); + page1.setContent(page1Grid); + + + // --- page 2 + final WizardPane page2 = new WizardPane() { + @Override public void onEnteringPage(Wizard wizard) { + String firstName = (String) wizard.getSettings().get("firstName"); + String lastName = (String) wizard.getSettings().get("lastName"); + + setContentText("Welcome, " + firstName + " " + lastName + "! Let's add some newlines!\n\n\n\n\n\n\nHello World!"); + } + }; + page2.setHeaderText("Thanks For Your Details!"); + + + // --- page 3 + WizardPane page3 = new WizardPane(); + page3.setHeaderText("Goodbye!"); + page3.setContentText("Page 3, with extra 'help' button!"); + + ButtonType helpDialogButton = new ButtonType("Help", ButtonData.HELP_2); + page3.getButtonTypes().add(helpDialogButton); + Button helpButton = (Button) page3.lookupButton(helpDialogButton); + helpButton.addEventFilter(ActionEvent.ACTION, actionEvent -> { + actionEvent.consume(); // stop hello.dialog from closing + System.out.println("Help clicked!"); + }); + + + + // create wizard + wizard.setFlow(new LinearFlow(page1, page2, page3)); + + System.out.println("page1: " + page1); + System.out.println("page2: " + page2); + System.out.println("page3: " + page3); + + // show wizard and wait for response + wizard.showAndWait().ifPresent(result -> { + if (result == ButtonType.FINISH) { + System.out.println("Wizard finished, settings: " + wizard.getSettings()); + } + }); + } + + private void showBranchingWizard() { + Window owner = cbSetOwner.isSelected() ? stage : null; + // define pages to show. + // Because page1 references page2, we need to declare page2 first. + final WizardPane page2 = new WizardPane(); + page2.setContentText("Page 2"); + + final CheckBox checkBox = new CheckBox("Skip the second page"); + checkBox.setId("skip-page-2"); + VBox vbox = new VBox(10, new Label("Page 1"), checkBox); + final WizardPane page1 = new WizardPane() { + // when we exit page 1, we will check the state of the 'skip page 2' + // checkbox, and if it is true, we will remove page 2 from the pages list + @Override public void onExitingPage(Wizard wizard) { +// List pages = wizard.getPages(); +// if (checkBox.isSelected()) { +// pages.remove(page2); +// } else { +// if (! pages.contains(page2)) { +// pages.add(1, page2); +// } +// } + } + }; + page1.setContent(vbox); + + final WizardPane page3 = new WizardPane(); + page3.setContentText("Page 3"); + + // create wizard + Wizard wizard = new Wizard(owner); + wizard.setTitle("Branching Wizard"); + Wizard.Flow branchingFlow = new Wizard.Flow() { + + @Override + public Optional advance(WizardPane currentPage) { + return Optional.of(getNext(currentPage)); + } + + @Override + public boolean canAdvance(WizardPane currentPage) { + return currentPage != page3; + } + + private WizardPane getNext(WizardPane currentPage) { + if ( currentPage == null ) { + return page1; + } else if ( currentPage == page1) { + return checkBox.isSelected()? page3: page2; + } else { + return page3; + } + } + + }; + + //wizard.setFlow( new LinearWizardFlow( page1, page2, page3)); + wizard.setFlow( branchingFlow); + + // show wizard + wizard.showAndWait().ifPresent(result -> { + if (result == ButtonType.FINISH) { + System.out.println("Wizard finished, settings: " + wizard.getSettings()); + } + }); + } + + private void showValidatedLinearWizard() { + Window owner = cbSetOwner.isSelected() ? stage : null; + Wizard wizard = new Wizard(owner); + wizard.setTitle("Validated Linear Wizard"); + + // Page 1 + WizardPane page1 = new WizardPane() { + ValidationSupport vs = new ValidationSupport(); + { + vs.initInitialDecoration(); + + int row = 0; + + GridPane page1Grid = new GridPane(); + page1Grid.setVgap(10); + page1Grid.setHgap(10); + + page1Grid.add(new Label("Username:"), 0, row); + TextField txUsername = createTextField("username"); + vs.registerValidator(txUsername, Validator.createEmptyValidator("EMPTY!")); + page1Grid.add(txUsername, 1, row++); + + page1Grid.add(new Label("Full Name:"), 0, row); + TextField txFullName = createTextField("fullName"); + page1Grid.add(txFullName, 1, row); + + setContent(page1Grid); + } + + @Override + public void onEnteringPage(Wizard wizard) { + wizard.invalidProperty().unbind(); + wizard.invalidProperty().bind(vs.invalidProperty()); + } + }; + + // Page 2 + + WizardPane page2 = new WizardPane() { + ValidationSupport vs = new ValidationSupport(); + { + vs.initInitialDecoration(); + + int row = 0; + + GridPane page2Grid = new GridPane(); + page2Grid.setVgap(10); + page2Grid.setHgap(10); + + page2Grid.add(new Label("ControlsFX is:"), 0, row); + ComboBox cbControlsFX = createComboBox("controlsfx"); + cbControlsFX.setItems(FXCollections.observableArrayList("Cool", "Great")); + vs.registerValidator(cbControlsFX, Validator.createEmptyValidator("EMPTY!")); + page2Grid.add(cbControlsFX, 1, row++); + + page2Grid.add(new Label("Where have you heard of it?:"), 0, row); + TextField txWhere = createTextField("where"); + vs.registerValidator(txWhere, Validator.createEmptyValidator("EMPTY!")); + page2Grid.add(txWhere, 1, row++); + + page2Grid.add(new Label("Free text:"), 0, row); + TextField txFreeText = createTextField("freetext"); + page2Grid.add(txFreeText, 1, row); + + setContent(page2Grid); + } + + @Override + public void onEnteringPage(Wizard wizard) { + wizard.invalidProperty().unbind(); + wizard.invalidProperty().bind(vs.invalidProperty()); + } + }; + + // create wizard + wizard.setFlow(new LinearFlow(page1, page2)); + + // show wizard and wait for response + wizard.showAndWait().ifPresent(result -> { + if (result == ButtonType.FINISH) { + System.out.println("Wizard finished, settings: " + wizard.getSettings()); + } + }); + } + + private TextField createTextField(String id) { + TextField textField = new TextField(); + textField.setId(id); + GridPane.setHgrow(textField, Priority.ALWAYS); + return textField; + } + + private ComboBox createComboBox(String id) { + ComboBox comboBox = new ComboBox<>(); + comboBox.setId(id); + GridPane.setHgrow(comboBox, Priority.ALWAYS); + return comboBox; + } + +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloGlyphFont.java b/NovaPoshta/Docs/CFX Examples/HelloGlyphFont.java new file mode 100644 index 0000000..cc39bc8 --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloGlyphFont.java @@ -0,0 +1,170 @@ +/** + * Copyright (c) 2013, 2014 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples; + +import javafx.collections.FXCollections; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.ContentDisplay; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Tab; +import javafx.scene.control.TabPane; +import javafx.scene.control.ToolBar; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.stage.Stage; + +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.GridCell; +import org.controlsfx.control.GridView; +import org.controlsfx.glyphfont.FontAwesome; +import org.controlsfx.glyphfont.Glyph; +import org.controlsfx.glyphfont.GlyphFont; +import org.controlsfx.glyphfont.GlyphFontRegistry; + +public class HelloGlyphFont extends ControlsFXSample { + + static { + // Register a custom default font + GlyphFontRegistry.register("icomoon", HelloGlyphFont.class.getResourceAsStream("icomoon.ttf") , 16); + } + + + private GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome"); + private GlyphFont icoMoon = GlyphFontRegistry.font("icomoon"); + + // private static char FAW_TRASH = '\uf014'; + private static char FAW_GEAR = '\uf013'; +// private static char FAW_STAR = '\uf005'; + + private static char IM_BOLD = '\ue027'; + private static char IM_UNDERSCORED = '\ue02b'; + private static char IM_ITALIC = '\ue13e'; + + + + @Override + public String getSampleName() { + return "Glyph Font"; + } + + @Override + public String getJavaDocURL() { + return Utils.JAVADOC_BASE + "org/controlsfx/glyphfont/GlyphFont.html"; + } + + @Override + public Node getPanel(final Stage stage) { + + VBox root = new VBox(10); + + root.setPadding(new Insets(10, 10, 10, 10)); + root.setMaxHeight(Double.MAX_VALUE); + Label title = new Label("Using FontAwesome(CDN)"); + root.getChildren().add(title); + ToolBar toolbar = new ToolBar( + + // There are many ways how you can define a Glyph: + + new Button("", new Glyph("FontAwesome", "TRASH_ALT")), // Use the Glyph-class with a icon name + new Button("", new Glyph("FontAwesome", FontAwesome.Glyph.STAR)), // Use the Glyph-class with a known enum value + new Button("", Glyph.create("FontAwesome|BUG")), // Use the static Glyph-class create protocol + new Button("", fontAwesome.create("REBEL")), // Use the font-instance with a name + new Button("", fontAwesome.create(FontAwesome.Glyph.SMILE_ALT)), // Use the font-instance with a enum + new Button("", fontAwesome.create(FAW_GEAR).color(Color.RED)) // Use the font-instance with a unicode char + ); + root.getChildren().add(toolbar); + title = new Label("Using IcoMoon (Local)"); + root.getChildren().add(title); + + Glyph effectGlyph = icoMoon.create(IM_UNDERSCORED) + .color(Color.BLUE) + .size(48) + .useHoverEffect(); + + Glyph effectGlyph2 = icoMoon.create(IM_UNDERSCORED) + .color(Color.BLUE) + .size(48) + .useGradientEffect().useHoverEffect(); + + toolbar = new ToolBar( + + // Since we have a custom font without named characters, + // we have to use unicode character codes for the icons: + + new Button("", icoMoon.create(IM_BOLD).size(16)), + new Button("", icoMoon.create(IM_UNDERSCORED).color(Color.GREEN).size(32)), + new Button("", icoMoon.create(IM_ITALIC).size(48)), + new Button("", effectGlyph), + new Button("", effectGlyph2)); + root.getChildren().add(toolbar); + + GridPane fontDemo = new GridPane(); + fontDemo.setHgap(5); + fontDemo.setVgap(5); + int maxColumns = 10; + int col = 0; + int row = 0; + + for ( FontAwesome.Glyph glyph: FontAwesome.Glyph.values() ){ + Color randomColor = new Color( Math.random(), Math.random(), Math.random(), 1); + Glyph graphic = Glyph.create( "FontAwesome|" + glyph.name()).sizeFactor(2).color(randomColor).useGradientEffect(); + Button button = new Button(glyph.name(), graphic); + button.setContentDisplay(ContentDisplay.TOP); + button.setMaxWidth(Double.MAX_VALUE); + col = col % maxColumns + 1; + if ( col == 1 ) row++; + fontDemo.add( button, col, row); + GridPane.setFillHeight(button, true); + GridPane.setFillWidth(button, true); + } + + ScrollPane scroller = new ScrollPane(fontDemo); + scroller.setFitToWidth(true); + + TabPane tabs = new TabPane(); + Tab tab = new Tab("FontAwesome Glyph Demo"); + tab.setContent(scroller); + tabs.getTabs().add(tab); + + + root.getChildren().add(tabs); + VBox.setVgrow(tabs, Priority.ALWAYS); + + return root; + + } + + + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloHiddenSidesPane.java b/NovaPoshta/Docs/CFX Examples/HelloHiddenSidesPane.java new file mode 100644 index 0000000..a2c28ae --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloHiddenSidesPane.java @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2014, ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples; + +import javafx.event.EventHandler; +import javafx.geometry.Pos; +import javafx.geometry.Side; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.HiddenSidesPane; + +public class HelloHiddenSidesPane extends ControlsFXSample { + + @Override + public String getSampleName() { + return "Hidden Sides Pane"; + } + + @Override + public String getJavaDocURL() { + return Utils.JAVADOC_BASE + + "org/controlsfx/control/HiddenSidesPane.html"; + } + + @Override + public String getSampleDescription() { + return "Hidden nodes will appear when moving the mouse cursor close to the edge of the content node. " + + "They disappear again when the mouse cursor exits them. In this example a hidden node " + + "can be pinned (and unpinned) by clicking on it so that it stays visible all the time."; + } + + @Override + public Node getPanel(Stage stage) { + StackPane stackPane = new StackPane(); + stackPane.setStyle("-fx-padding: 30"); + + HiddenSidesPane pane = new HiddenSidesPane(); + + Label content = new Label("Content Node"); + content.setStyle("-fx-background-color: white; -fx-border-color: black;"); + content.setAlignment(Pos.CENTER); + content.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); + + pane.setContent(content); + + SideNode top = new SideNode("Top", Side.TOP, pane); + top.setStyle("-fx-background-color: rgba(0,255,0,.25);"); + pane.setTop(top); + + SideNode right = new SideNode("Right", Side.RIGHT, pane); + right.setStyle("-fx-background-color: rgba(0,0, 255,.25);"); + pane.setRight(right); + + SideNode bottom = new SideNode("Bottom", Side.BOTTOM, pane); + bottom.setStyle("-fx-background-color: rgba(255,255,0,.25);"); + pane.setBottom(bottom); + + SideNode left = new SideNode("Left", Side.LEFT, pane); + left.setStyle("-fx-background-color: rgba(255,0,0,.25);"); + pane.setLeft(left); + + stackPane.getChildren().add(pane); + + return stackPane; + } + + class SideNode extends Label { + + public SideNode(final String text, final Side side, + final HiddenSidesPane pane) { + + super(text + " (Click to pin / unpin)"); + + setAlignment(Pos.CENTER); + setPrefSize(200, 200); + + setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent event) { + if (pane.getPinnedSide() != null) { + setText(text + " (unpinned)"); + pane.setPinnedSide(null); + } else { + setText(text + " (pinned)"); + pane.setPinnedSide(side); + } + } + }); + } + } + + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloListActionView.java b/NovaPoshta/Docs/CFX Examples/HelloListActionView.java new file mode 100644 index 0000000..4a7cf98 --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloListActionView.java @@ -0,0 +1,196 @@ +/** + * Copyright (c) 2018 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.geometry.Side; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.VBox; +import javafx.scene.text.Font; +import javafx.scene.text.FontPosture; +import javafx.scene.text.FontWeight; +import javafx.stage.Stage; +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.ListActionView; +import org.controlsfx.control.action.Action; +import org.controlsfx.control.action.ActionUtils; +import org.controlsfx.glyphfont.FontAwesome; + +import java.util.List; + +public class HelloListActionView extends ControlsFXSample { + + private ListActionView view; + + @Override + public String getSampleName() { + return "List Action View"; + } + + @Override + public Node getPanel(Stage stage) { + view = new ListActionView<>(); + view.getItems().addAll("Dirk", "Jonathan", "Eugene","Abhinay", "Samir"); + view.getActions().addAll(createActions()); + + GridPane pane = new GridPane(); + pane.add(view, 0, 0); + pane.setAlignment(Pos.CENTER); + + return pane; + } + + @Override + public Node getControlPanel() { + VBox root = new VBox(20); + root.setPadding(new Insets(30, 30, 30, 30)); + + CheckBox useCellFactory = new CheckBox("Use cell factory"); + useCellFactory.setOnAction(evt -> { + if (useCellFactory.isSelected()) { + view.setCellFactory(listView -> { + ListCell cell = new ListCell() { + @Override + public void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + + if (empty) { + setText(null); + setGraphic(null); + } else { + setText(item == null ? "null" : item); + setGraphic(null); + } + } + }; + cell.setFont(Font.font("Arial", FontWeight.BOLD, + FontPosture.ITALIC, 18)); + return cell; + }); + } else { + view.setCellFactory(null); + } + }); + + CheckBox clearActions = new CheckBox("Clear Actions"); + clearActions.selectedProperty().addListener((observable, oldValue, newValue) -> { + if (newValue) { + view.getActions().clear(); + } else { + view.getActions().addAll(createActions()); + } + }); + + ComboBox sideComboBox = new ComboBox<>(FXCollections.observableArrayList(Side.values())); + sideComboBox.setTooltip(new Tooltip("The side of the ListView on which the actions should be displayed")); + + sideComboBox.getSelectionModel().select(Side.LEFT); + view.sideProperty().bind(sideComboBox.getSelectionModel().selectedItemProperty()); + + root.getChildren().addAll(useCellFactory, clearActions, sideComboBox); + + return root; + } + + @Override + public String getSampleDescription() { + return "A control used to let the user select multiple values from a " + + "list of available values. Selected values are moved into a " + + "second list that is showing the current selection. Items can " + + "be moved by double clicking on them or by first selecting " + + "them and then pressing one of the buttons in the center."; + } + + @Override + public String getJavaDocURL() { + return Utils.JAVADOC_BASE + + "org/controlsfx/control/ListActionView.html"; + } + + public static void main(String[] args) { + launch(args); + } + + private ObservableList createActions() { + ListActionView.ListAction moveUp = new ListActionView.ListAction( + new FontAwesome().create(FontAwesome.Glyph.ANGLE_UP)) { + @Override + public void initialize(ListView listView) { + setEventHandler(e -> moveSelectedItemsUp(listView)); + } + }; + ListActionView.ListAction moveDown = new ListActionView.ListAction(new FontAwesome().create(FontAwesome.Glyph.ANGLE_DOWN)) { + @Override + public void initialize(ListView listView) { + setEventHandler(e -> moveSelectedItemsDown(listView)); + } + }; + return FXCollections.observableArrayList(moveUp, ActionUtils.ACTION_SEPARATOR, moveDown); + } + + private void moveSelectedItemsUp(ListView listView) { + final MultipleSelectionModel selectionModel = listView.getSelectionModel(); + final ObservableList selectedIndices = selectionModel.getSelectedIndices(); + final ObservableList items = listView.getItems(); + for (final Integer selectedIndex : selectedIndices) { + if (selectedIndex > 0) { + if (selectedIndices.contains(selectedIndex - 1)) continue; + final String item = items.get(selectedIndex); + final String itemToBeReplaced = items.get(selectedIndex - 1); + items.set(selectedIndex - 1, item); + items.set(selectedIndex, itemToBeReplaced); + selectionModel.clearSelection(selectedIndex); + selectionModel.select(selectedIndex - 1); + } + } + } + + private void moveSelectedItemsDown(ListView listView) { + final ObservableList items = listView.getItems(); + final MultipleSelectionModel selectionModel = listView.getSelectionModel(); + final List selectedIndices = selectionModel.getSelectedIndices(); + int lastIndex = items.size() - 1; + // Last selected item is to be replaced first + for (int index = selectedIndices.size() - 1; index >= 0; index--) { + final Integer selectedIndex = selectedIndices.get(index); + if (selectedIndex < lastIndex) { + if (selectedIndices.contains(selectedIndex + 1)) continue; + final String item = items.get(selectedIndex); + final String itemToBeReplaced = items.get(selectedIndex + 1); + items.set(selectedIndex + 1, item); + items.set(selectedIndex, itemToBeReplaced); + selectionModel.clearSelection(selectedIndex); + selectionModel.select(selectedIndex + 1); + } + } + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloMasterDetailPane.java b/NovaPoshta/Docs/CFX Examples/HelloMasterDetailPane.java new file mode 100644 index 0000000..4a222fa --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloMasterDetailPane.java @@ -0,0 +1,156 @@ +/** + * Copyright (c) 2014 - 2016 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.geometry.Side; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.layout.GridPane; +import javafx.stage.Stage; +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.MasterDetailPane; + +public class HelloMasterDetailPane extends ControlsFXSample { + + @Override + public String getJavaDocURL() { + return Utils.JAVADOC_BASE + + "org/controlsfx/control/MasterDetailPane.html"; + } + + + @Override + public String getControlStylesheetURL() { + return "/org/controlsfx/control/masterdetailpane.css"; + } + + private MasterDetailPane masterDetailPane; + + @Override + public Node getPanel(Stage stage) { + masterDetailPane = new MasterDetailPane(Side.BOTTOM); + masterDetailPane.setShowDetailNode(true); + + return masterDetailPane; + } + + @Override + public Node getControlPanel() { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + int row = 0; + + // show details + Label lblShowDetail = new Label("Show details: "); + lblShowDetail.getStyleClass().add("property"); + grid.add(lblShowDetail, 0, row); + CheckBox chkShowDetails = new CheckBox(); + grid.add(chkShowDetails, 1, row++); + chkShowDetails.selectedProperty().bindBidirectional(masterDetailPane.showDetailNodeProperty()); + + + // animated + Label lblAnimated = new Label("Animated: "); + lblAnimated.getStyleClass().add("property"); + grid.add(lblAnimated, 0, row); + CheckBox chkAnimated = new CheckBox(); + grid.add(chkAnimated, 1, row++); + chkAnimated.selectedProperty().bindBidirectional(masterDetailPane.animatedProperty()); + + + // side + Label lblSide = new Label("Side: "); + lblSide.getStyleClass().add("property"); + grid.add(lblSide, 0, row); + ComboBox positionBox = new ComboBox<>(); + positionBox.getItems().addAll(Side.values()); + grid.add(positionBox, 1, row++); + positionBox.setValue(masterDetailPane.getDetailSide()); + masterDetailPane.detailSideProperty().bind(positionBox.valueProperty()); + + // detail node + Label lblDetailNode = new Label("Detail Node: "); + lblDetailNode.getStyleClass().add("property"); + grid.add(lblDetailNode, 0, row); + ComboBox detailNodeBox = new ComboBox<>(); + detailNodeBox.getItems().addAll(DetailType.values()); + grid.add(detailNodeBox, 1, row++); + detailNodeBox.valueProperty().addListener(it -> { + switch (detailNodeBox.getValue()) { + case LABEL: + final Label label = new Label("Detail"); + label.setMaxWidth(Double.MAX_VALUE); + label.setAlignment(Pos.CENTER); + label.setStyle("-fx-background-color: lightcoral;"); + masterDetailPane.setDetailNode(label); + break; + case NONE: + masterDetailPane.setDetailNode(null); + break; + case LIST_VIEW: + final ListView listView = new ListView<>(); + listView.getItems().addAll("Katja", "Dirk", "Philip", "Jule", "Armin"); + listView.setPrefSize(150,150); + masterDetailPane.setDetailNode(listView); + break; + } + }); + + // reset position + Button resetButton = new Button("Reset Divider"); + resetButton.setOnAction(evt -> masterDetailPane.resetDividerPosition()); + grid.add(resetButton, 1, row++); + + return grid; + } + + public enum DetailType { + NONE, + LABEL, + LIST_VIEW + } + + @Override + public String getSampleDescription() { + return "A control used to display a master node and a detail node. The detail can be shown / hidden at the top, the bottom, to the left or to the right."; + } + + public static void main(String[] args) { + Application.launch(args); + } + + @Override + public String getSampleName() { + return "Master Detail Pane"; + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloPropertySheet.java b/NovaPoshta/Docs/CFX Examples/HelloPropertySheet.java new file mode 100644 index 0000000..6b0e0db --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloPropertySheet.java @@ -0,0 +1,258 @@ +/** + * Copyright (c) 2014, 2015 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples; + +import java.time.LocalDate; +import java.time.Month; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Optional; +import javafx.beans.value.ObservableValue; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.concurrent.Service; +import javafx.concurrent.Task; +import javafx.concurrent.WorkerStateEvent; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.PropertySheet; +import org.controlsfx.control.PropertySheet.Item; +import org.controlsfx.control.PropertySheet.Mode; +import org.controlsfx.control.SegmentedButton; +import org.controlsfx.control.action.Action; +import org.controlsfx.control.action.ActionUtils; +import org.controlsfx.property.BeanProperty; +import org.controlsfx.property.BeanPropertyUtils; +import org.controlsfx.samples.propertysheet.CustomPropertyDescriptor; +import org.controlsfx.samples.propertysheet.SampleBean; + +public class HelloPropertySheet extends ControlsFXSample { + + private static Map customDataMap = new LinkedHashMap<>(); + + static { + customDataMap.put("1. Name#First Name", "Jonathan"); + customDataMap.put("1. Name#Last Name", "Giles"); + customDataMap.put("1. Name#Birthday", LocalDate.of(1985, Month.JANUARY, 12)); + customDataMap.put("2. Billing Address#Address 1", ""); + customDataMap.put("2. Billing Address#Address 2", ""); + customDataMap.put("2. Billing Address#City", ""); + customDataMap.put("2. Billing Address#State", ""); + customDataMap.put("2. Billing Address#Zip", ""); + customDataMap.put("3. Phone#Home", "123-123-1234"); + customDataMap.put("3. Phone#Mobile", "234-234-2345"); + customDataMap.put("3. Phone#Work", ""); + } + + private PropertySheet propertySheet = new PropertySheet(); + + public static void main(String[] args) { + launch(); + } + + @Override + public String getSampleName() { + return "Property Sheet"; + } + + @Override + public String getSampleDescription() { + return "The PropertySheet control is useful when you want to present a number" + + " of properties to a user for them to edit."; + } + + @Override + public String getJavaDocURL() { + return Utils.JAVADOC_BASE + "org/controlsfx/control/PropertySheet.html"; + } + + + @Override + public String getControlStylesheetURL() { + return "/org/controlsfx/control/propertysheet.css"; + } + + class CustomPropertyItem implements Item { + + private String key; + private String category, name; + + public CustomPropertyItem(String key) { + this.key = key; + String[] skey = key.split("#"); + category = skey[0]; + name = skey[1]; + } + + @Override + public Class getType() { + return customDataMap.get(key).getClass(); + } + + @Override + public String getCategory() { + return category; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public Object getValue() { + return customDataMap.get(key); + } + + @Override + public void setValue(Object value) { + customDataMap.put(key, value); + } + + @Override + public Optional> getObservableValue() { + return Optional.empty(); + } + + } + + class ActionShowInPropertySheet extends Action { + + private Object bean; + + public ActionShowInPropertySheet(String title, Object bean) { + super(title); + setEventHandler(this::handleAction); + this.bean = bean; + } + + private ObservableList getCustomModelProperties() { + ObservableList list = FXCollections.observableArrayList(); + for (String key : customDataMap.keySet()) { + list.add(new CustomPropertyItem(key)); + } + return list; + } + + private void handleAction(ActionEvent ae) { + + // retrieving bean properties may take some time + // so we have to put it on separate thread to keep UI responsive + Service service = new Service>() { + + @Override + protected Task> createTask() { + return new Task>() { + @Override + protected ObservableList call() throws Exception { + return bean == null ? getCustomModelProperties() : BeanPropertyUtils.getProperties(bean); + } + }; + } + + }; + service.setOnSucceeded(new EventHandler() { + + @SuppressWarnings("unchecked") + @Override + public void handle(WorkerStateEvent e) { + if (bean instanceof SampleBean) { + for (Item i : (ObservableList) e.getSource().getValue()) { + if (i instanceof BeanProperty && ((BeanProperty) i).getPropertyDescriptor() instanceof CustomPropertyDescriptor) { + BeanProperty bi = (BeanProperty) i; + bi.setEditable(((CustomPropertyDescriptor) bi.getPropertyDescriptor()).isEditable()); + } + } + } + propertySheet.getItems().setAll((ObservableList) e.getSource().getValue()); + } + }); + service.start(); + } + } + + @Override + public Node getPanel(Stage stage) { + return propertySheet; + } + + @Override + public Node getControlPanel() { + VBox infoPane = new VBox(10); + + Button button = new Button("Title"); + TextField textField = new TextField(); + SampleBean sampleBean = new SampleBean(); + + SegmentedButton segmentedButton = ActionUtils.createSegmentedButton( + new ActionShowInPropertySheet("Bean: Button", button), + new ActionShowInPropertySheet("Bean: TextField", textField), + new ActionShowInPropertySheet("Custom Model", null), + new ActionShowInPropertySheet("Custom BeanInfo", sampleBean) + ); + segmentedButton.getStyleClass().add(SegmentedButton.STYLE_CLASS_DARK); + segmentedButton.getButtons().get(0).fire(); + + CheckBox toolbarModeVisible = new CheckBox("Show Mode Buttons"); + toolbarModeVisible.selectedProperty().bindBidirectional(propertySheet.modeSwitcherVisibleProperty()); + + CheckBox toolbarSearchVisible = new CheckBox("Show Search Field"); + toolbarSearchVisible.selectedProperty().bindBidirectional(propertySheet.searchBoxVisibleProperty()); + + infoPane.getChildren().add(toolbarModeVisible); + infoPane.getChildren().add(toolbarSearchVisible); + infoPane.getChildren().add(segmentedButton); + infoPane.getChildren().add(button); + infoPane.getChildren().add(textField); + + return infoPane; + } + + class ActionModeChange extends Action { + + public ActionModeChange(String title, Mode mode) { + super(title); + setEventHandler(ae -> propertySheet.modeProperty().set(mode)); + } + + } + +} \ No newline at end of file diff --git a/NovaPoshta/Docs/CFX Examples/HelloValidation.java b/NovaPoshta/Docs/CFX Examples/HelloValidation.java new file mode 100644 index 0000000..4294987 --- /dev/null +++ b/NovaPoshta/Docs/CFX Examples/HelloValidation.java @@ -0,0 +1,234 @@ +/** + * Copyright (c) 2014, 2019 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples; + +import java.time.LocalDate; +import java.util.Arrays; + +import javafx.beans.InvalidationListener; +import javafx.beans.Observable; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.ColorPicker; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Control; +import javafx.scene.control.DatePicker; +import javafx.scene.control.Label; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Slider; +import javafx.scene.control.TextField; +import javafx.scene.control.ToggleButton; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.paint.Color; +import javafx.stage.Stage; +import javafx.util.Callback; + +import org.controlsfx.ControlsFXSample; +import org.controlsfx.validation.ValidationResult; +import org.controlsfx.validation.ValidationSupport; +import org.controlsfx.validation.Validator; +import org.controlsfx.validation.decoration.CompoundValidationDecoration; +import org.controlsfx.validation.decoration.GraphicValidationDecoration; +import org.controlsfx.validation.decoration.StyleClassValidationDecoration; +import org.controlsfx.validation.decoration.ValidationDecoration; + +public class HelloValidation extends ControlsFXSample { + + private TextField textField = new TextField(); + private ValidationSupport validationSupport = new ValidationSupport(); + + @Override public String getSampleName() { + return "Component Validation"; + } + + @Override public String getJavaDocURL() { + return Utils.JAVADOC_BASE + "org/controlsfx/validation/ValidationSupport.html"; + } + + @Override public String getSampleDescription() { + return "Component Validation"; + } + + @Override public Node getPanel(final Stage stage) { + GridPane root = new GridPane(); + root.setVgap(10); + root.setHgap(10); + root.setPadding(new Insets(30, 30, 0, 30)); + + root.sceneProperty().addListener(new InvalidationListener() { + @Override public void invalidated(Observable o) { + if (root.getScene() != null) { + root.getScene().getStylesheets().add(HelloDecorator.class.getResource("validation.css").toExternalForm()); + } + } + }); + + int row = 0; + + // text field + validationSupport.registerValidator(textField, Validator.createEmptyValidator("Text is required")); + + root.add(new Label("TextField"), 0, row); + root.add(textField, 1, row); + GridPane.setHgrow(textField, Priority.ALWAYS); + + //combobox + row++; + ComboBox combobox = new ComboBox(); + combobox.getItems().addAll("Item A", "Item B", "Item C"); + validationSupport.registerValidator(combobox, (Control c, String newValue) -> + ValidationResult.fromErrorIf(combobox, "ComboBox Selection required", newValue == null || newValue.isEmpty()) + .addInfoIf(combobox, "Item A is the first item", "Item A".equals(newValue)) + .addInfoIf(combobox, "Item B is the second item", "Item B".equals(newValue)) + .addInfoIf(combobox, "Item C is the third item", "Item C".equals(newValue)) + ); + + root.add(new Label("ComboBox"), 0, row); + root.add(combobox, 1, row); + GridPane.setHgrow(combobox, Priority.ALWAYS); + + //choicebox + row++; + ChoiceBox choiceBox = new ChoiceBox(); + choiceBox.getItems().addAll("Item A", "Item B", "Item C"); + validationSupport.registerValidator(choiceBox, Validator.createEmptyValidator("ChoiceBox Selection required")); + + root.add(new Label("ChoiceBox"), 0, row); + root.add(choiceBox, 1, row); + GridPane.setHgrow(choiceBox, Priority.ALWAYS); + + //checkbox + row++; + CheckBox checkBox = new CheckBox(); + validationSupport.registerValidator(checkBox, (Control c, Boolean newValue) -> + ValidationResult.fromErrorIf(c, "Checkbox should be checked", !newValue)); + + root.add(new Label("CheckBox"), 0, row); + root.add(checkBox, 1, row); + GridPane.setHgrow(checkBox, Priority.ALWAYS); + + //slider + row++; + Slider slider = new Slider(-50d, 50d, -10d); + slider.setShowTickLabels(true); + validationSupport.registerValidator(slider, (Control c, Double newValue) -> + ValidationResult.fromErrorIf(slider, "Slider value should be > 0", newValue <= 0)); + + root.add(new Label("Slider"), 0, row); + root.add(slider, 1, row); + GridPane.setHgrow(slider, Priority.ALWAYS); + + // color picker + row++; + ColorPicker colorPicker = new ColorPicker(Color.RED); + validationSupport.registerValidator(colorPicker, + Validator.createEqualsValidator("Color should be WHITE or BLACK", Arrays.asList(Color.WHITE, Color.BLACK))); + + root.add(new Label("Color Picker"), 0, row); + root.add(colorPicker, 1, row); + GridPane.setHgrow(colorPicker, Priority.ALWAYS); + + // date picker + row++; + DatePicker datePicker = new DatePicker(); + validationSupport.registerValidator(datePicker, false, (Control c, LocalDate newValue) -> + ValidationResult.fromWarningIf(datePicker, "The date should be today", !LocalDate.now().equals(newValue))); + + root.add(new Label("Date Picker"), 0, row); + root.add(datePicker, 1, row); + GridPane.setHgrow(datePicker, Priority.ALWAYS); + + ScrollPane scrollPane = new ScrollPane(root); + return scrollPane; + } + + @Override public Node getControlPanel() { + GridPane grid = new GridPane(); + grid.setVgap(10); + grid.setHgap(10); + grid.setPadding(new Insets(30, 30, 0, 30)); + + ValidationDecoration iconDecorator = new GraphicValidationDecoration(); + ValidationDecoration cssDecorator = new StyleClassValidationDecoration(); + ValidationDecoration compoundDecorator = new CompoundValidationDecoration(cssDecorator, iconDecorator); + + int row = 0; + + // --- validation decorator + Callback, ListCell> cellFactory = listView -> new ListCell() { + @Override protected void updateItem(ValidationDecoration decorator, boolean empty) { + super.updateItem(decorator, empty); + + if (empty) { + setText(""); + } else { + if (decorator instanceof StyleClassValidationDecoration) { + setText("Style Class Validation Decorator"); + } else if (decorator instanceof GraphicValidationDecoration) { + setText("Graphic Validation Decorator"); + } else if (decorator instanceof CompoundValidationDecoration) { + setText("Compound Validation Decorator"); + } else { + setText("Unknown decorator type!"); + } + } + } + }; + ComboBox decoratorBox = new ComboBox<>(); + decoratorBox.getItems().addAll(iconDecorator, cssDecorator, compoundDecorator); + decoratorBox.setCellFactory(cellFactory); + decoratorBox.setButtonCell(cellFactory.call(null)); + decoratorBox.getSelectionModel().selectedItemProperty().addListener((o,old,decorator) -> + validationSupport.setValidationDecorator(decorator)); + decoratorBox.getSelectionModel().select(0); + + Label validationDecoratorLabel = new Label("Validation Decorator: "); + validationDecoratorLabel.getStyleClass().add("property"); + grid.add(validationDecoratorLabel, 0, row); + grid.add(decoratorBox, 1, row); + GridPane.setHgrow(decoratorBox, Priority.ALWAYS); + + row++; + ToggleButton btnToggleRequired = new ToggleButton("Toggle TextField required status"); + btnToggleRequired.setSelected(ValidationSupport.isRequired(textField)); + btnToggleRequired.setOnAction(e -> { + ValidationSupport.setRequired(textField, btnToggleRequired.isSelected()); + }); + grid.add(btnToggleRequired, 1, row, 1, 1); + + return grid; + } + + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file diff --git a/NovaPoshta/Docs/EditPhones.fxml b/NovaPoshta/Docs/EditPhones.fxml new file mode 100644 index 0000000..effebc7 --- /dev/null +++ b/NovaPoshta/Docs/EditPhones.fxml @@ -0,0 +1,15 @@ + + + + + + + +