diff --git a/java/labs/j130-lab1.pdf b/java/labs/done/j130-lab1.pdf similarity index 100% rename from java/labs/j130-lab1.pdf rename to java/labs/done/j130-lab1.pdf diff --git a/java/samples/fxml/Lab140_2FXML/build.xml b/java/samples/fxml/Lab140_2FXML/build.xml new file mode 100644 index 0000000..2c9ba3e --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/build.xml @@ -0,0 +1,53 @@ + + Builds, tests, and runs the project Lab140_2FXML. + + + diff --git a/java/samples/fxml/Lab140_2FXML/build/built-jar.properties b/java/samples/fxml/Lab140_2FXML/build/built-jar.properties new file mode 100644 index 0000000..3d398e1 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/build/built-jar.properties @@ -0,0 +1,4 @@ +#Tue, 21 Feb 2023 20:58:22 +0300 + + +C\:\\Users\\denis.LAPTOP-4LI8UQ4O\\OneDrive\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b\\NetBeansProjects\\JavaFXTableExample_dist\\Lab140_2FXML= diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/controller/PersonDto.class b/java/samples/fxml/Lab140_2FXML/build/classes/controller/PersonDto.class new file mode 100644 index 0000000..15f4aec Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/controller/PersonDto.class differ diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/EducationStage.class b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/EducationStage.class new file mode 100644 index 0000000..3914a3d Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/EducationStage.class differ diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLDocument.fxml b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLDocument.fxml new file mode 100644 index 0000000..a961539 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLDocument.fxml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLDocumentController.class b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLDocumentController.class new file mode 100644 index 0000000..0d5324a Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLDocumentController.class differ diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLEducation.fxml b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLEducation.fxml new file mode 100644 index 0000000..8371e6b --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLEducation.fxml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLEducationController.class b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLEducationController.class new file mode 100644 index 0000000..af89eec Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/FXMLEducationController.class differ diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/Lab140_2FXML.class b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/Lab140_2FXML.class new file mode 100644 index 0000000..d32f1cc Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/lab140_2fxml/Lab140_2FXML.class differ diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/model/Education.class b/java/samples/fxml/Lab140_2FXML/build/classes/model/Education.class new file mode 100644 index 0000000..31b5ca1 Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/model/Education.class differ diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/model/Person.class b/java/samples/fxml/Lab140_2FXML/build/classes/model/Person.class new file mode 100644 index 0000000..e16b14e Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/model/Person.class differ diff --git a/java/samples/fxml/Lab140_2FXML/build/classes/repo/Repository.class b/java/samples/fxml/Lab140_2FXML/build/classes/repo/Repository.class new file mode 100644 index 0000000..da52ee4 Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/build/classes/repo/Repository.class differ diff --git a/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.html b/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.html new file mode 100644 index 0000000..45a9507 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.html @@ -0,0 +1,45 @@ + + + + + + + +

Test page for Lab140_2FXML

+ Webstart: click to launch this app as webstart


+ + +
+ diff --git a/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.jar b/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.jar new file mode 100644 index 0000000..cc629be Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.jar differ diff --git a/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.jnlp b/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.jnlp new file mode 100644 index 0000000..d825599 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/dist/Lab140_2FXML.jnlp @@ -0,0 +1,21 @@ + + + + Lab140_2FXML + denis + null + + + + + + + + + + + + + + + diff --git a/java/samples/fxml/Lab140_2FXML/dist/lib/derby.jar b/java/samples/fxml/Lab140_2FXML/dist/lib/derby.jar new file mode 100644 index 0000000..1c50529 Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/dist/lib/derby.jar differ diff --git a/java/samples/fxml/Lab140_2FXML/dist/lib/derbyclient.jar b/java/samples/fxml/Lab140_2FXML/dist/lib/derbyclient.jar new file mode 100644 index 0000000..dde69cd Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/dist/lib/derbyclient.jar differ diff --git a/java/samples/fxml/Lab140_2FXML/dist/lib/derbynet.jar b/java/samples/fxml/Lab140_2FXML/dist/lib/derbynet.jar new file mode 100644 index 0000000..c51fb78 Binary files /dev/null and b/java/samples/fxml/Lab140_2FXML/dist/lib/derbynet.jar differ diff --git a/java/samples/fxml/Lab140_2FXML/dist/web-files/dtjava.js b/java/samples/fxml/Lab140_2FXML/dist/web-files/dtjava.js new file mode 100644 index 0000000..b77ecd7 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/dist/web-files/dtjava.js @@ -0,0 +1,3958 @@ +/* + * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/** + The Java Deployment Toolkit is a utility to deploy Java content in + the browser as applets or applications using the right version of Java. + If needed it can initiate an upgrade of user's system to install required + components of Java platform. +

+ Note that some of the Deployment Toolkit methods may not be fully operational if + used before web page body is loaded (because DT native plugins could not be instantiated). + If you intend to use it before web page DOM tree is ready then dtjava.js + needs to be loaded inside the body element of the page and before use of other DT APIs. + + @module java/deployment_toolkit +*/ +var dtjava = function() { + function notNull(o) { + return (o != undefined && o != null); + } + + function isDef(fn) { + return (fn != null && typeof fn != "undefined"); + } + + //return true if any of patterns from query list is found in the given string + function containsAny(lst, str) { + for (var q = 0; q < lst.length; q++) { + if (str.indexOf(lst[q]) != -1) { + return true; + } + } + return false; + } + + /* Location of static web content - images, javascript files. */ + var jscodebase = (function () { + // + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/fxml/Lab140_2FXML/nbproject/private/configs/______________WebStart.properties b/java/samples/fxml/Lab140_2FXML/nbproject/private/configs/______________WebStart.properties new file mode 100644 index 0000000..7a1d99d --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/nbproject/private/configs/______________WebStart.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=webstart diff --git a/java/samples/fxml/Lab140_2FXML/nbproject/private/configs/____________________.properties b/java/samples/fxml/Lab140_2FXML/nbproject/private/configs/____________________.properties new file mode 100644 index 0000000..7a7b6e4 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/nbproject/private/configs/____________________.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=embedded diff --git a/java/samples/fxml/Lab140_2FXML/nbproject/private/private.properties b/java/samples/fxml/Lab140_2FXML/nbproject/private/private.properties new file mode 100644 index 0000000..2221527 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/nbproject/private/private.properties @@ -0,0 +1,4 @@ +auxiliary.org-netbeans-modules-projectapi.issue214819_5f_fx_5f_enabled=true +# \u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0437\u0430\u0434\u0430\u0447\u0438 JavaFX Ant +endorsed.javafx.ant.classpath=. +user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/java/samples/fxml/Lab140_2FXML/nbproject/project.properties b/java/samples/fxml/Lab140_2FXML/nbproject/project.properties new file mode 100644 index 0000000..9d08d90 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/nbproject/project.properties @@ -0,0 +1,114 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=Lab140_2FXML +application.vendor=denis +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +compile.on.save=true +compile.on.save.unsupported.javafx=true +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Lab140_2FXML.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects +jar.archive.disabled=true +jar.compress=false +javac.classpath=\ + ${javafx.classpath.extension}:\ + ${libs.JAVADB_DRIVER_LABEL.classpath} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +javafx.application.implementation.version=1.0 +javafx.binarycss=false +javafx.classpath.extension=\ + ${java.home}/lib/javaws.jar:\ + ${java.home}/lib/deploy.jar:\ + ${java.home}/lib/plugin.jar +javafx.deploy.allowoffline=true +# If true, application update mode is set to 'background', if false, update mode is set to 'eager' +javafx.deploy.backgroundupdate=false +javafx.deploy.embedJNLP=true +javafx.deploy.includeDT=true +# \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 'true' \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043f\u0438\u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u043e\u0432 \u0434\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 (\u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0438) +javafx.disable.concurrent.runs=false +# \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 'true' \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Run-in-Browser \u0438\u043b\u0438 WebStart +javafx.enable.concurrent.external.runs=false +# This is a JavaFX project +javafx.enabled=true +javafx.fallback.class=com.javafx.main.NoJavaFXFallback +# Main class for JavaFX +javafx.main.class=lab140_2fxml.Lab140_2FXML +javafx.preloader.class= +# This project does not use Preloader +javafx.preloader.enabled=false +javafx.preloader.jar.filename= +javafx.preloader.jar.path= +javafx.preloader.project.path= +javafx.preloader.type=none +# Set true for GlassFish only. Rebases manifest classpaths of JARs in lib dir. Not usable with signed JARs. +javafx.rebase.libs=false +javafx.run.height=600 +javafx.run.width=800 +# Pre-JavaFX 2.0 WebStart is deactivated in JavaFX 2.0+ projects +jnlp.enabled=false +# Main class for Java launcher +main.class=com.javafx.main.Main +# \u0414\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0447\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 Codebase \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f RIA +manifest.custom.codebase=* +# \u0423\u043a\u0430\u0436\u0438\u0442\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 Permissions \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b: sandbox, all-permissions) +manifest.custom.permissions= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${dist.jar}:\ + ${javac.classpath}:\ + ${build.classes.dir} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/java/samples/fxml/Lab140_2FXML/nbproject/project.xml b/java/samples/fxml/Lab140_2FXML/nbproject/project.xml new file mode 100644 index 0000000..85bbdc8 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/nbproject/project.xml @@ -0,0 +1,25 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + + + + + + + + Lab140_2FXML + + + + + + + + + diff --git a/java/samples/fxml/Lab140_2FXML/src/controller/PersonDto.java b/java/samples/fxml/Lab140_2FXML/src/controller/PersonDto.java new file mode 100644 index 0000000..cfdae50 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/controller/PersonDto.java @@ -0,0 +1,100 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package controller; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; +import model.Education; +import model.Person; + +/** + * + * @author denis + */ +public class PersonDto { + private int id; + private String firstname; + private String lastname; + private String gender; + private int educationCount; + private Set educations; + + public PersonDto(Person person) { + this.id = person.getId(); + this.firstname = person.getFirstname(); + this.lastname = person.getLastname(); + this.gender = person.getGender(); + educationCount = person.getEducations().size(); + educations = person.getEducations(); + } + + public int getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } + + public String getGender() { + return gender; + } + + public Set getEducations() { + return educations; + } + + public int getEducationCount() { + return educations.size(); + } + + @Override + public int hashCode() { + int hash = 5; + hash = 23 * hash + this.id; + hash = 23 * hash + Objects.hashCode(this.firstname); + hash = 23 * hash + Objects.hashCode(this.lastname); + hash = 23 * hash + Objects.hashCode(this.gender); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersonDto other = (PersonDto) obj; + if (this.id != other.id) { + return false; + } + if (!Objects.equals(this.firstname, other.firstname)) { + return false; + } + if (!Objects.equals(this.lastname, other.lastname)) { + return false; + } + if (!Objects.equals(this.gender, other.gender)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Person{" + "id=" + id + ", firstname=" + firstname + ", lastname=" + lastname + ", gender=" + gender + '}'; + } +} diff --git a/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/EducationStage.java b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/EducationStage.java new file mode 100644 index 0000000..bc82e4e --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/EducationStage.java @@ -0,0 +1,45 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package lab140_2fxml; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Modality; +import javafx.stage.Stage; + +/** + * + * @author denis + */ +public class EducationStage extends Stage{ + public static int PERSONID; + + public EducationStage(int id) { + PERSONID = id; + } + + public void init(){ + Parent root = null; + try { + root = FXMLLoader.load(getClass().getResource("FXMLEducation.fxml")); + + Scene scene = new Scene(root); + setScene(scene); + initModality(Modality.APPLICATION_MODAL); + showAndWait(); + } catch (IOException ex) { + Logger.getLogger(EducationStage.class.getName()).log(Level.SEVERE, null, ex); + } + + + + + } +} diff --git a/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLDocument.fxml b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLDocument.fxml new file mode 100644 index 0000000..a961539 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLDocument.fxml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLDocumentController.java b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLDocumentController.java new file mode 100644 index 0000000..d532a8f --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLDocumentController.java @@ -0,0 +1,104 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package lab140_2fxml; + +import controller.PersonDto; +import java.net.URL; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Label; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.MouseEvent; +import model.Person; +import repo.Repository; + +/** + * + * @author denis + */ +public class FXMLDocumentController implements Initializable { + + @FXML + private TableView table; +// @FXML +// private TableColumn idColumn; +// @FXML +// private TableColumn firstnameColumn; +// @FXML +// private TableColumn lastnameColumn; +// @FXML +// private TableColumn genderColumn; +// @FXML +// private TableColumn countColumn; + + @FXML + private void handlerMouseClicked(MouseEvent event) { + if(event.getClickCount()==2){ + PersonDto dto = table.getSelectionModel().getSelectedItem(); + System.out.println(dto); + int id = dto.getId(); + new EducationStage(id).init(); + } + } + + @FXML + private void handlerKeyPressed(KeyEvent event) { + if(event.getCode()==KeyCode.ENTER){ + PersonDto dto = table.getSelectionModel().getSelectedItem(); + System.out.println(dto); + int id = dto.getId(); + new EducationStage(id).init(); + } + } + + @Override + public void initialize(URL url, ResourceBundle rb) { + Repository repository = new Repository(); + //получаем коллекцию персон из репозитория + Set persons = repository.getAllPerson(); + //преобразовываем коллекцию персон в коллекцию personDto + Set personDto = persons.stream().map(person -> new PersonDto(person)).collect(Collectors.toSet()); + //создаем ObservableList на основе коллекции personDto + ObservableList obsPersons = FXCollections.observableArrayList(personDto); + table.getColumns().forEach(column -> { + String title = column.getText(); + switch(title){ + case "ИД": + column.setCellValueFactory(new PropertyValueFactory<>("id")); + break; + case "Имя": + column.setCellValueFactory(new PropertyValueFactory<>("firstname")); + break; + case "Фамилия": + column.setCellValueFactory(new PropertyValueFactory<>("lastname")); + break; + case "кол-во": + column.setCellValueFactory(new PropertyValueFactory<>("educationCount")); + break; + case "пол": + column.setCellValueFactory(new PropertyValueFactory<>("gender")); + break; + } + }); +// table.getColumns().get(0).setCellValueFactory(new PropertyValueFactory<>("id")); +// table.getColumns().get(1).setCellValueFactory(new PropertyValueFactory<>("firstname")); +// table.getColumns().get(2).setCellValueFactory(new PropertyValueFactory<>("lastname")); +// table.getColumns().get(3).setCellValueFactory(new PropertyValueFactory<>("gender")); +// table.getColumns().get(4).setCellValueFactory(new PropertyValueFactory<>("educationCount")); + table.setItems(obsPersons); + } + +} diff --git a/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLEducation.fxml b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLEducation.fxml new file mode 100644 index 0000000..8371e6b --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLEducation.fxml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLEducationController.java b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLEducationController.java new file mode 100644 index 0000000..03b974a --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/FXMLEducationController.java @@ -0,0 +1,55 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package lab140_2fxml; + +import java.net.URL; +import java.sql.Date; +import java.util.ResourceBundle; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import model.Education; +import model.Person; +import repo.Repository; + +/** + * FXML Controller class + * + * @author denis + */ +public class FXMLEducationController implements Initializable { + + @FXML + private TableView table; + @FXML + private TableColumn idColumn; + @FXML + private TableColumn universitynameColumn; + @FXML + private TableColumn datefinishColumn; + @FXML + private TableColumn cityColumn; + + /** + * Initializes the controller class. + */ + @Override + public void initialize(URL url, ResourceBundle rb) { + Repository repo = new Repository(); + Person person = repo.findPersonById(EducationStage.PERSONID); + ObservableList list = FXCollections.observableArrayList(person.getEducations()); + idColumn.setCellValueFactory(new PropertyValueFactory<>("id")); + universitynameColumn.setCellValueFactory(new PropertyValueFactory<>("universityname")); + datefinishColumn.setCellValueFactory(new PropertyValueFactory<>("datefinish")); + cityColumn.setCellValueFactory(new PropertyValueFactory<>("city")); + table.setItems(list); + } + +} diff --git a/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/Lab140_2FXML.java b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/Lab140_2FXML.java new file mode 100644 index 0000000..dc066c5 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/lab140_2fxml/Lab140_2FXML.java @@ -0,0 +1,37 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package lab140_2fxml; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +/** + * + * @author denis + */ +public class Lab140_2FXML extends Application { + + @Override + public void start(Stage stage) throws Exception { + Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); + + Scene scene = new Scene(root); + + stage.setScene(scene); + stage.show(); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + launch(args); + } + +} diff --git a/java/samples/fxml/Lab140_2FXML/src/model/Education.java b/java/samples/fxml/Lab140_2FXML/src/model/Education.java new file mode 100644 index 0000000..e72708f --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/model/Education.java @@ -0,0 +1,112 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package model; + +import java.sql.Date; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** + * + * @author denis + */ +public class Education { + private int id; + private String universityname; + private Date datefinish; + private String city; + private Set persons = new HashSet<>(); + + public Education(int id, String universityname, Date datefinish, String city) { + this.id = id; + this.universityname = universityname; + this.datefinish = datefinish; + this.city = city; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getUniversityname() { + return universityname; + } + + public void setUniversityname(String universityname) { + this.universityname = universityname; + } + + public Date getDatefinish() { + return datefinish; + } + + public void setDatefinish(Date datefinish) { + this.datefinish = datefinish; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public Set getPersons() { + return persons; + } + + public void setPersons(Set persons) { + this.persons = persons; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 89 * hash + this.id; + hash = 89 * hash + Objects.hashCode(this.universityname); + hash = 89 * hash + Objects.hashCode(this.datefinish); + hash = 89 * hash + Objects.hashCode(this.city); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Education other = (Education) obj; + if (this.id != other.id) { + return false; + } + if (!Objects.equals(this.universityname, other.universityname)) { + return false; + } + if (!Objects.equals(this.city, other.city)) { + return false; + } + if (!Objects.equals(this.datefinish, other.datefinish)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Education{" + "id=" + id + ", universityname=" + universityname + ", datefinish=" + datefinish + ", City=" + city + '}'; + } +} diff --git a/java/samples/fxml/Lab140_2FXML/src/model/Person.java b/java/samples/fxml/Lab140_2FXML/src/model/Person.java new file mode 100644 index 0000000..9886923 --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/model/Person.java @@ -0,0 +1,119 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package model; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** + * + * @author denis + */ +public class Person { + private int id; + private String firstname; + private String lastname;; + private String gender; + private Set educations = new HashSet<>(); + + public Person(int id, String firstname, String lastname, String gender) { + this.id = id; + this.firstname = firstname; + this.lastname = lastname; + this.gender = gender; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public Set getEducations() { + return educations; + } + + public void setEducations(Set educations) { + this.educations = educations; + } + + public void addEducation(Education education){ + educations.add(education); + education.getPersons().add(this); + } + + @Override + public int hashCode() { + int hash = 5; + hash = 59 * hash + this.id; + hash = 59 * hash + Objects.hashCode(this.firstname); + hash = 59 * hash + Objects.hashCode(this.lastname); + hash = 59 * hash + Objects.hashCode(this.gender); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Person other = (Person) obj; + if (this.id != other.id) { + return false; + } + if (!Objects.equals(this.firstname, other.firstname)) { + return false; + } + if (!Objects.equals(this.lastname, other.lastname)) { + return false; + } + if (!Objects.equals(this.gender, other.gender)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Person{" + "id=" + id + ", firstname=" + firstname + ", lastname=" + lastname + ", gender=" + gender + '}'; + } + + + +} diff --git a/java/samples/fxml/Lab140_2FXML/src/repo/Repository.java b/java/samples/fxml/Lab140_2FXML/src/repo/Repository.java new file mode 100644 index 0000000..01517df --- /dev/null +++ b/java/samples/fxml/Lab140_2FXML/src/repo/Repository.java @@ -0,0 +1,100 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package repo; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import model.Education; +import model.Person; + +/** + * + * @author denis + */ +public class Repository { + + public Set getAllPerson(){ + Set persons = new HashSet<>(); + + try (Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/TrainingDatabase", "root", "root"); + Statement stm = con.createStatement()) { + String sql = "SELECT * FROM PERSON LEFT JOIN EDUCATION ON PERSON.ID = EDUCATION.PERSONID"; + try (ResultSet rs = stm.executeQuery(sql)){ + while(rs.next()){ + Person person; + { + int id = rs.getInt(1); + person = persons.stream().filter(p -> p.getId()==id).findFirst().orElse(null); + if(person==null){ + String firstname = rs.getString(2); + String lastname = rs.getString(3); + String gender = rs.getString(4); + person = new Person(id, firstname, lastname, gender); + persons.add(person); + } + } + { + int id = rs.getInt(5); + String universityname = rs.getString(6); + Date datefinish = rs.getDate(7); + String City = rs.getString(8); + if(universityname!=null || datefinish!=null || City!=null){ + Education education = new Education(id, universityname, datefinish, City); + person.addEducation(education); + } + } + } + } + } catch (SQLException ex) { + Logger.getLogger(Repository.class.getName()).log(Level.SEVERE, null, ex); + } + + return persons; + } + + public Person findPersonById(int personid){ + Person person = null; + try (Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/TrainingDatabase", "root", "root"); + Statement stm = con.createStatement()) { + String sql = "SELECT * FROM PERSON LEFT JOIN EDUCATION ON PERSON.ID = EDUCATION.PERSONID WHERE PERSON.ID=" + personid; + try (ResultSet rs = stm.executeQuery(sql)){ + while(rs.next()){ + { + int id = rs.getInt(1); + + String firstname = rs.getString(2); + String lastname = rs.getString(3); + String gender = rs.getString(4); + if(person==null && (firstname!=null || lastname!=null || gender!=null)){ + person = new Person(id, firstname, lastname, gender); + } + } + { + int id = rs.getInt(5); + String universityname = rs.getString(6); + Date datefinish = rs.getDate(7); + String City = rs.getString(8); + if(universityname!=null || datefinish!=null || City!=null){ + Education education = new Education(id, universityname, datefinish, City); + person.addEducation(education); + } + } + } + } + } catch (SQLException ex) { + Logger.getLogger(Repository.class.getName()).log(Level.SEVERE, null, ex); + } + return person; + } +}