Changeset 13:b15d81be8af3
- Timestamp:
- 11/29/11 17:16:47 (13 years ago)
- Branch:
- default
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
.hgignore
r2 r13 6 6 java/SuperPostak/build/* 7 7 java/SuperPostak/nbproject/private/* 8 9 grafika/logo.png -
java/Postak/nbproject/build-impl.xml
r8 r13 56 56 <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init"> 57 57 <available file="${manifest.file}" property="manifest.available"/> 58 <available file="${application.splash}" property="splashscreen.available"/> 58 <condition property="splashscreen.available"> 59 <and> 60 <not> 61 <equals arg1="${application.splash}" arg2="" trim="true"/> 62 </not> 63 <available file="${application.splash}"/> 64 </and> 65 </condition> 59 66 <condition property="main.class.available"> 60 67 <and> … … 71 78 </and> 72 79 </condition> 80 <condition property="do.archive"> 81 <not> 82 <istrue value="${jar.archive.disabled}"/> 83 </not> 84 </condition> 73 85 <condition property="do.mkdist"> 74 86 <and> 87 <isset property="do.archive"/> 75 88 <isset property="libs.CopyLibs.classpath"/> 76 89 <not> … … 85 98 </and> 86 99 </condition> 87 <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">88 <and>89 <istrue value="${manifest.available+main.class+mkdist.available}"/>90 <istrue value="${splashscreen.available}"/>91 </and>92 </condition>93 <condition property="do.archive">94 <not>95 <istrue value="${jar.archive.disabled}"/>96 </not>97 </condition>98 100 <condition property="do.archive+manifest.available"> 99 101 <and> … … 102 104 </and> 103 105 </condition> 106 <condition property="do.archive+main.class.available"> 107 <and> 108 <isset property="main.class.available"/> 109 <istrue value="${do.archive}"/> 110 </and> 111 </condition> 112 <condition property="do.archive+splashscreen.available"> 113 <and> 114 <isset property="splashscreen.available"/> 115 <istrue value="${do.archive}"/> 116 </and> 117 </condition> 104 118 <condition property="do.archive+manifest.available+main.class"> 105 119 <and> … … 108 122 </and> 109 123 </condition> 110 <condition property=" do.archive+manifest.available+main.class+mkdist.available">111 < and>112 <istrue value="${manifest.available +main.class+mkdist.available}"/>113 <is true value="${do.archive}"/>114 </ and>115 </condition> 116 <condition property=" do.archive+manifest.available+main.class+mkdist.available+splashscreen.available">117 < and>118 <istrue value="${manifest.available+main.class +mkdist.available+splashscreen.available}"/>119 <is true value="${do.archive}"/>120 </ and>124 <condition property="manifest.available-mkdist.available"> 125 <or> 126 <istrue value="${manifest.available}"/> 127 <isset property="do.mkdist"/> 128 </or> 129 </condition> 130 <condition property="manifest.available+main.class-mkdist.available"> 131 <or> 132 <istrue value="${manifest.available+main.class}"/> 133 <isset property="do.mkdist"/> 134 </or> 121 135 </condition> 122 136 <condition property="have.tests"> … … 174 188 <length length="0" string="${endorsed.classpath}" when="greater"/> 175 189 </condition> 176 <property name="javac.fork" value="false"/> 190 <condition else="false" property="jdkBug6558476"> 191 <and> 192 <matches pattern="1\.[56]" string="${java.specification.version}"/> 193 <not> 194 <os family="unix"/> 195 </not> 196 </and> 197 </condition> 198 <property name="javac.fork" value="${jdkBug6558476}"/> 177 199 <property name="jar.index" value="false"/> 200 <property name="jar.index.metainf" value="${jar.index}"/> 178 201 <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/> 179 202 </target> … … 303 326 <files includesfile="${javac.includesfile.binary}"/> 304 327 </delete> 305 <delete file="${javac.includesfile.binary}"/> 328 <delete> 329 <fileset file="${javac.includesfile.binary}"/> 330 </delete> 306 331 </sequential> 307 332 </macrodef> … … 313 338 <attribute default="**" name="testincludes"/> 314 339 <sequential> 315 <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}"> 340 <property name="junit.forkmode" value="perTest"/> 341 <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> 316 342 <batchtest todir="${build.test.results.dir}"> 317 343 <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> … … 329 355 <formatter type="xml"/> 330 356 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> 357 <jvmarg value="-ea"/> 331 358 <jvmarg line="${run.jvmargs}"/> 332 359 </junit> 333 360 </sequential> 334 361 </macrodef> 362 </target> 363 <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/> 364 <target name="-profile-pre-init"> 365 <!-- Empty placeholder for easier customization. --> 366 <!-- You can override this target in the ../build.xml file. --> 367 </target> 368 <target name="-profile-post-init"> 369 <!-- Empty placeholder for easier customization. --> 370 <!-- You can override this target in the ../build.xml file. --> 371 </target> 372 <target name="-profile-init-macrodef-profile"> 373 <macrodef name="resolve"> 374 <attribute name="name"/> 375 <attribute name="value"/> 376 <sequential> 377 <property name="@{name}" value="${env.@{value}}"/> 378 </sequential> 379 </macrodef> 380 <macrodef name="profile"> 381 <attribute default="${main.class}" name="classname"/> 382 <element name="customize" optional="true"/> 383 <sequential> 384 <property environment="env"/> 385 <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/> 386 <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}"> 387 <jvmarg value="${profiler.info.jvmargs.agent}"/> 388 <jvmarg line="${profiler.info.jvmargs}"/> 389 <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> 390 <arg line="${application.args}"/> 391 <classpath> 392 <path path="${run.classpath}"/> 393 </classpath> 394 <syspropertyset> 395 <propertyref prefix="run-sys-prop."/> 396 <mapper from="run-sys-prop.*" to="*" type="glob"/> 397 </syspropertyset> 398 <customize/> 399 </java> 400 </sequential> 401 </macrodef> 402 </target> 403 <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check"> 404 <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail> 405 <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail> 335 406 </target> 336 407 <target depends="-init-debug-args" name="-init-macrodef-nbjpda"> … … 428 499 <target name="-init-macrodef-copylibs"> 429 500 <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3"> 501 <attribute default="${manifest.file}" name="manifest"/> 430 502 <element name="customize" optional="true"/> 431 503 <sequential> … … 443 515 </pathconvert> 444 516 <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/> 445 <copylibs compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">517 <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}"> 446 518 <fileset dir="${build.classes.dir}"/> 447 519 <manifest> … … 572 644 <!-- You can override this target in the ../build.xml file. --> 573 645 </target> 574 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available ">646 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available"> 575 647 <j2seproject1:jar/> 576 648 </target> 577 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class ">649 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available"> 578 650 <j2seproject1:jar manifest="${manifest.file}"/> 579 651 </target> … … 584 656 </j2seproject1:manifest> 585 657 </j2seproject1:jar> 586 <echo >To run this application from the command line without Ant, try:</echo>658 <echo level="info">To run this application from the command line without Ant, try:</echo> 587 659 <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> 588 660 <property location="${dist.jar}" name="dist.jar.resolved"/> … … 591 663 <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> 592 664 </pathconvert> 593 <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo> 594 </target> 595 <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen"> 665 <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo> 666 </target> 667 <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available"> 668 <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> 669 <touch file="${tmp.manifest.file}" verbose="false"/> 670 </target> 671 <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest"> 672 <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> 673 <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/> 674 </target> 675 <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main"> 676 <manifest file="${tmp.manifest.file}" mode="update"> 677 <attribute name="Main-Class" value="${main.class}"/> 678 </manifest> 679 </target> 680 <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen"> 596 681 <basename file="${application.splash}" property="splashscreen.basename"/> 597 682 <mkdir dir="${build.classes.dir}/META-INF"/> 598 683 <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/> 599 < j2seproject3:copylibs>600 < customize>601 <attribute name="Main-Class" value="${main.class}"/>602 <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>603 </customize>604 < /j2seproject3:copylibs>605 <echo >To run this application from the command line without Ant, try:</echo>684 <manifest file="${tmp.manifest.file}" mode="update"> 685 <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/> 686 </manifest> 687 </target> 688 <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack"> 689 <j2seproject3:copylibs manifest="${tmp.manifest.file}"/> 690 <echo level="info">To run this application from the command line without Ant, try:</echo> 606 691 <property location="${dist.jar}" name="dist.jar.resolved"/> 607 <echo>java -jar "${dist.jar.resolved}"</echo> 608 </target> 609 <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available"> 610 <j2seproject3:copylibs> 611 <customize> 612 <attribute name="Main-Class" value="${main.class}"/> 613 </customize> 614 </j2seproject3:copylibs> 615 <echo>To run this application from the command line without Ant, try:</echo> 616 <property location="${dist.jar}" name="dist.jar.resolved"/> 617 <echo>java -jar "${dist.jar.resolved}"</echo> 618 </target> 692 <echo level="info">java -jar "${dist.jar.resolved}"</echo> 693 </target> 694 <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest"> 695 <delete> 696 <fileset file="${tmp.manifest.file}"/> 697 </delete> 698 </target> 699 <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/> 619 700 <target name="-post-jar"> 620 701 <!-- Empty placeholder for easier customization. --> 621 702 <!-- You can override this target in the ../build.xml file. --> 622 703 </target> 623 <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries -and-splashscreen,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>704 <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/> 624 705 <!-- 625 706 ================= … … 687 768 <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/> 688 769 <!-- 770 ================= 771 PROFILING SECTION 772 ================= 773 --> 774 <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile"> 775 <nbprofiledirect> 776 <classpath> 777 <path path="${run.classpath}"/> 778 </classpath> 779 </nbprofiledirect> 780 <profile/> 781 </target> 782 <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single"> 783 <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail> 784 <nbprofiledirect> 785 <classpath> 786 <path path="${run.classpath}"/> 787 </classpath> 788 </nbprofiledirect> 789 <profile classname="${profile.class}"/> 790 </target> 791 <!-- 792 ========================= 793 APPLET PROFILING SECTION 794 ========================= 795 --> 796 <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet"> 797 <nbprofiledirect> 798 <classpath> 799 <path path="${run.classpath}"/> 800 </classpath> 801 </nbprofiledirect> 802 <profile classname="sun.applet.AppletViewer"> 803 <customize> 804 <arg value="${applet.url}"/> 805 </customize> 806 </profile> 807 </target> 808 <!-- 809 ========================= 810 TESTS PROFILING SECTION 811 ========================= 812 --> 813 <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single"> 814 <nbprofiledirect> 815 <classpath> 816 <path path="${run.test.classpath}"/> 817 </classpath> 818 </nbprofiledirect> 819 <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true"> 820 <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> 821 <jvmarg value="${profiler.info.jvmargs.agent}"/> 822 <jvmarg line="${profiler.info.jvmargs}"/> 823 <test name="${profile.class}"/> 824 <classpath> 825 <path path="${run.test.classpath}"/> 826 </classpath> 827 <syspropertyset> 828 <propertyref prefix="test-sys-prop."/> 829 <mapper from="test-sys-prop.*" to="*" type="glob"/> 830 </syspropertyset> 831 <formatter type="brief" usefile="false"/> 832 <formatter type="xml"/> 833 </junit> 834 </target> 835 <!-- 689 836 =============== 690 837 JAVADOC SECTION … … 697 844 <path path="${javac.classpath}"/> 698 845 </classpath> 699 <fileset dir="${src.dir}" excludes=" ${excludes}" includes="${includes}">846 <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}"> 700 847 <filename name="**/*.java"/> 701 848 </fileset> 702 849 <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> 703 850 <include name="**/*.java"/> 851 <exclude name="*.java"/> 704 852 </fileset> 705 853 </javadoc> … … 732 880 <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/> 733 881 </target> 734 <target depends="init, compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">882 <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test"> 735 883 <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/> 736 884 <copy todir="${build.test.classes.dir}"> … … 747 895 <!-- You can override this target in the ../build.xml file. --> 748 896 </target> 749 <target depends="init, compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">897 <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single"> 750 898 <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> 751 899 <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/> -
java/Postak/nbproject/genfiles.properties
r8 r13 5 5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 6 nbproject/build-impl.xml.data.CRC32=ecce8ba0 7 nbproject/build-impl.xml.script.CRC32= bcebfc1f8 nbproject/build-impl.xml.stylesheet.CRC32= 229523de@1.38.3.457 nbproject/build-impl.xml.script.CRC32=c4083fc9 8 nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45 -
java/Postak/src/cz/frantovo/postak/HromadnaZprava.java
r0 r13 14 14 public class HromadnaZprava implements Cloneable { 15 15 16 private static Logger log = Logger.getLogger(HromadnaZprava.class.getName());16 private static final Logger log = Logger.getLogger(HromadnaZprava.class.getName()); 17 17 /** Předmět zprávy */ 18 18 private String predmet; … … 66 66 public void pridejPrijemce(Collection<InternetAddressKomu> prijemci) { 67 67 if (prijemci == null) { 68 log.log(Level.FINER, "Prázdná množina příjemců -nic nepřidáme");68 log.log(Level.FINER, "Prázdná množina příjemců – nic nepřidáme"); 69 69 } else { 70 70 this.prijemci.addAll(prijemci); -
java/SuperPostak/nbproject/build-impl.xml
r7 r13 57 57 <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init"> 58 58 <available file="${manifest.file}" property="manifest.available"/> 59 <available file="${application.splash}" property="splashscreen.available"/> 59 <condition property="splashscreen.available"> 60 <and> 61 <not> 62 <equals arg1="${application.splash}" arg2="" trim="true"/> 63 </not> 64 <available file="${application.splash}"/> 65 </and> 66 </condition> 60 67 <condition property="main.class.available"> 61 68 <and> … … 72 79 </and> 73 80 </condition> 81 <condition property="do.archive"> 82 <not> 83 <istrue value="${jar.archive.disabled}"/> 84 </not> 85 </condition> 74 86 <condition property="do.mkdist"> 75 87 <and> 88 <isset property="do.archive"/> 76 89 <isset property="libs.CopyLibs.classpath"/> 77 90 <not> … … 86 99 </and> 87 100 </condition> 88 <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">89 <and>90 <istrue value="${manifest.available+main.class+mkdist.available}"/>91 <istrue value="${splashscreen.available}"/>92 </and>93 </condition>94 <condition property="do.archive">95 <not>96 <istrue value="${jar.archive.disabled}"/>97 </not>98 </condition>99 101 <condition property="do.archive+manifest.available"> 100 102 <and> … … 103 105 </and> 104 106 </condition> 107 <condition property="do.archive+main.class.available"> 108 <and> 109 <isset property="main.class.available"/> 110 <istrue value="${do.archive}"/> 111 </and> 112 </condition> 113 <condition property="do.archive+splashscreen.available"> 114 <and> 115 <isset property="splashscreen.available"/> 116 <istrue value="${do.archive}"/> 117 </and> 118 </condition> 105 119 <condition property="do.archive+manifest.available+main.class"> 106 120 <and> … … 109 123 </and> 110 124 </condition> 111 <condition property=" do.archive+manifest.available+main.class+mkdist.available">112 < and>113 <istrue value="${manifest.available +main.class+mkdist.available}"/>114 <is true value="${do.archive}"/>115 </ and>116 </condition> 117 <condition property=" do.archive+manifest.available+main.class+mkdist.available+splashscreen.available">118 < and>119 <istrue value="${manifest.available+main.class +mkdist.available+splashscreen.available}"/>120 <is true value="${do.archive}"/>121 </ and>125 <condition property="manifest.available-mkdist.available"> 126 <or> 127 <istrue value="${manifest.available}"/> 128 <isset property="do.mkdist"/> 129 </or> 130 </condition> 131 <condition property="manifest.available+main.class-mkdist.available"> 132 <or> 133 <istrue value="${manifest.available+main.class}"/> 134 <isset property="do.mkdist"/> 135 </or> 122 136 </condition> 123 137 <condition property="have.tests"> … … 175 189 <length length="0" string="${endorsed.classpath}" when="greater"/> 176 190 </condition> 177 <property name="javac.fork" value="false"/> 191 <condition else="false" property="jdkBug6558476"> 192 <and> 193 <matches pattern="1\.[56]" string="${java.specification.version}"/> 194 <not> 195 <os family="unix"/> 196 </not> 197 </and> 198 </condition> 199 <property name="javac.fork" value="${jdkBug6558476}"/> 178 200 <property name="jar.index" value="false"/> 201 <property name="jar.index.metainf" value="${jar.index}"/> 179 202 <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/> 180 203 </target> … … 304 327 <files includesfile="${javac.includesfile.binary}"/> 305 328 </delete> 306 <delete file="${javac.includesfile.binary}"/> 329 <delete> 330 <fileset file="${javac.includesfile.binary}"/> 331 </delete> 307 332 </sequential> 308 333 </macrodef> … … 314 339 <attribute default="**" name="testincludes"/> 315 340 <sequential> 316 <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}"> 341 <property name="junit.forkmode" value="perTest"/> 342 <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> 317 343 <batchtest todir="${build.test.results.dir}"> 318 344 <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> … … 330 356 <formatter type="xml"/> 331 357 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> 358 <jvmarg value="-ea"/> 332 359 <jvmarg line="${run.jvmargs}"/> 333 360 </junit> 334 361 </sequential> 335 362 </macrodef> 363 </target> 364 <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/> 365 <target name="-profile-pre-init"> 366 <!-- Empty placeholder for easier customization. --> 367 <!-- You can override this target in the ../build.xml file. --> 368 </target> 369 <target name="-profile-post-init"> 370 <!-- Empty placeholder for easier customization. --> 371 <!-- You can override this target in the ../build.xml file. --> 372 </target> 373 <target name="-profile-init-macrodef-profile"> 374 <macrodef name="resolve"> 375 <attribute name="name"/> 376 <attribute name="value"/> 377 <sequential> 378 <property name="@{name}" value="${env.@{value}}"/> 379 </sequential> 380 </macrodef> 381 <macrodef name="profile"> 382 <attribute default="${main.class}" name="classname"/> 383 <element name="customize" optional="true"/> 384 <sequential> 385 <property environment="env"/> 386 <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/> 387 <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}"> 388 <jvmarg value="${profiler.info.jvmargs.agent}"/> 389 <jvmarg line="${profiler.info.jvmargs}"/> 390 <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> 391 <arg line="${application.args}"/> 392 <classpath> 393 <path path="${run.classpath}"/> 394 </classpath> 395 <syspropertyset> 396 <propertyref prefix="run-sys-prop."/> 397 <mapper from="run-sys-prop.*" to="*" type="glob"/> 398 </syspropertyset> 399 <customize/> 400 </java> 401 </sequential> 402 </macrodef> 403 </target> 404 <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check"> 405 <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail> 406 <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail> 336 407 </target> 337 408 <target depends="-init-debug-args" name="-init-macrodef-nbjpda"> … … 429 500 <target name="-init-macrodef-copylibs"> 430 501 <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3"> 502 <attribute default="${manifest.file}" name="manifest"/> 431 503 <element name="customize" optional="true"/> 432 504 <sequential> … … 444 516 </pathconvert> 445 517 <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/> 446 <copylibs compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">518 <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}"> 447 519 <fileset dir="${build.classes.dir}"/> 448 520 <manifest> … … 587 659 <!-- You can override this target in the ../build.xml file. --> 588 660 </target> 589 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available ">661 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available"> 590 662 <j2seproject1:jar/> 591 663 </target> 592 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class ">664 <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available"> 593 665 <j2seproject1:jar manifest="${manifest.file}"/> 594 666 </target> … … 599 671 </j2seproject1:manifest> 600 672 </j2seproject1:jar> 601 <echo >To run this application from the command line without Ant, try:</echo>673 <echo level="info">To run this application from the command line without Ant, try:</echo> 602 674 <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> 603 675 <property location="${dist.jar}" name="dist.jar.resolved"/> … … 606 678 <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> 607 679 </pathconvert> 608 <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo> 609 </target> 610 <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen"> 680 <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo> 681 </target> 682 <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available"> 683 <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> 684 <touch file="${tmp.manifest.file}" verbose="false"/> 685 </target> 686 <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest"> 687 <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> 688 <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/> 689 </target> 690 <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main"> 691 <manifest file="${tmp.manifest.file}" mode="update"> 692 <attribute name="Main-Class" value="${main.class}"/> 693 </manifest> 694 </target> 695 <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen"> 611 696 <basename file="${application.splash}" property="splashscreen.basename"/> 612 697 <mkdir dir="${build.classes.dir}/META-INF"/> 613 698 <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/> 614 < j2seproject3:copylibs>615 < customize>616 <attribute name="Main-Class" value="${main.class}"/>617 <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>618 </customize>619 < /j2seproject3:copylibs>620 <echo >To run this application from the command line without Ant, try:</echo>699 <manifest file="${tmp.manifest.file}" mode="update"> 700 <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/> 701 </manifest> 702 </target> 703 <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack"> 704 <j2seproject3:copylibs manifest="${tmp.manifest.file}"/> 705 <echo level="info">To run this application from the command line without Ant, try:</echo> 621 706 <property location="${dist.jar}" name="dist.jar.resolved"/> 622 <echo>java -jar "${dist.jar.resolved}"</echo> 623 </target> 624 <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available"> 625 <j2seproject3:copylibs> 626 <customize> 627 <attribute name="Main-Class" value="${main.class}"/> 628 </customize> 629 </j2seproject3:copylibs> 630 <echo>To run this application from the command line without Ant, try:</echo> 631 <property location="${dist.jar}" name="dist.jar.resolved"/> 632 <echo>java -jar "${dist.jar.resolved}"</echo> 633 </target> 707 <echo level="info">java -jar "${dist.jar.resolved}"</echo> 708 </target> 709 <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest"> 710 <delete> 711 <fileset file="${tmp.manifest.file}"/> 712 </delete> 713 </target> 714 <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/> 634 715 <target name="-post-jar"> 635 716 <!-- Empty placeholder for easier customization. --> 636 717 <!-- You can override this target in the ../build.xml file. --> 637 718 </target> 638 <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries -and-splashscreen,-do-jar-with-libraries,-post-jar,jnlp" description="Build JAR." name="jar"/>719 <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar,jnlp" description="Build JAR." name="jar"/> 639 720 <!-- 640 721 ================= … … 702 783 <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/> 703 784 <!-- 785 ================= 786 PROFILING SECTION 787 ================= 788 --> 789 <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile"> 790 <nbprofiledirect> 791 <classpath> 792 <path path="${run.classpath}"/> 793 </classpath> 794 </nbprofiledirect> 795 <profile/> 796 </target> 797 <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single"> 798 <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail> 799 <nbprofiledirect> 800 <classpath> 801 <path path="${run.classpath}"/> 802 </classpath> 803 </nbprofiledirect> 804 <profile classname="${profile.class}"/> 805 </target> 806 <!-- 807 ========================= 808 APPLET PROFILING SECTION 809 ========================= 810 --> 811 <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet"> 812 <nbprofiledirect> 813 <classpath> 814 <path path="${run.classpath}"/> 815 </classpath> 816 </nbprofiledirect> 817 <profile classname="sun.applet.AppletViewer"> 818 <customize> 819 <arg value="${applet.url}"/> 820 </customize> 821 </profile> 822 </target> 823 <!-- 824 ========================= 825 TESTS PROFILING SECTION 826 ========================= 827 --> 828 <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single"> 829 <nbprofiledirect> 830 <classpath> 831 <path path="${run.test.classpath}"/> 832 </classpath> 833 </nbprofiledirect> 834 <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true"> 835 <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> 836 <jvmarg value="${profiler.info.jvmargs.agent}"/> 837 <jvmarg line="${profiler.info.jvmargs}"/> 838 <test name="${profile.class}"/> 839 <classpath> 840 <path path="${run.test.classpath}"/> 841 </classpath> 842 <syspropertyset> 843 <propertyref prefix="test-sys-prop."/> 844 <mapper from="test-sys-prop.*" to="*" type="glob"/> 845 </syspropertyset> 846 <formatter type="brief" usefile="false"/> 847 <formatter type="xml"/> 848 </junit> 849 </target> 850 <!-- 704 851 =============== 705 852 JAVADOC SECTION … … 712 859 <path path="${javac.classpath}"/> 713 860 </classpath> 714 <fileset dir="${src.dir}" excludes=" ${excludes}" includes="${includes}">861 <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}"> 715 862 <filename name="**/*.java"/> 716 863 </fileset> 717 864 <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> 718 865 <include name="**/*.java"/> 866 <exclude name="*.java"/> 719 867 </fileset> 720 868 </javadoc> … … 747 895 <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/> 748 896 </target> 749 <target depends="init, compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">897 <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test"> 750 898 <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/> 751 899 <copy todir="${build.test.classes.dir}"> … … 762 910 <!-- You can override this target in the ../build.xml file. --> 763 911 </target> 764 <target depends="init, compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">912 <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single"> 765 913 <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> 766 914 <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/> -
java/SuperPostak/nbproject/genfiles.properties
r7 r13 5 5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 6 nbproject/build-impl.xml.data.CRC32=d917048a 7 nbproject/build-impl.xml.script.CRC32= 232b6b6d8 nbproject/build-impl.xml.stylesheet.CRC32= 229523de@1.38.3.457 nbproject/build-impl.xml.script.CRC32=ccb272cf 8 nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45 -
java/SuperPostak/src/cz/frantovo/superPostak/Data.java
r3 r13 16 16 public class Data { 17 17 18 private static Logger log = Logger.getLogger(Data.class.getName());18 private static final Logger log = Logger.getLogger(Data.class.getName()); 19 19 private static Connection spojeni; 20 20 private static byte[] hash; … … 49 49 hash = hashuj(url, jmeno, heslo); 50 50 spojeni = DriverManager.getConnection(url, jmeno, String.valueOf(heslo)); 51 log.log(Level.INFO, "Otevřeno nové spoejní spojení k databázi: " +url);51 log.log(Level.INFO, "Otevřeno nové spoejní spojení k databázi: {0}", url); 52 52 return spojeni; 53 53 } -
java/SuperPostak/src/cz/frantovo/superPostak/DataSQL.java
r3 r13 18 18 public class DataSQL { 19 19 20 private static Logger log = Logger.getLogger(DataSQL.class.getName());20 private static final Logger log = Logger.getLogger(DataSQL.class.getName()); 21 21 private Connection spojeni; 22 22 -
java/SuperPostak/src/cz/frantovo/superPostak/SuperPostak.java
r7 r13 45 45 public class SuperPostak extends javax.swing.JFrame { 46 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 * @param exit při zavření okna ukončí program 61 62 63 64 65 66 67 68 69 70 71 72 73 47 /** Soubor, kde je uložené nastavení */ 48 private static final String NASTAVENI_SOUBOR = "Nastaveni.xml.gz"; 49 private static final String CERTIFIKATY_SOUBOR = "DuveryhodneCertifikaty.keystore"; 50 private static final String NASTAVENI_SLOZKA = ".SuperPostak"; 51 private static final String DOMACI_ADRESAR = System.getProperty("user.home"); 52 private static final Logger log = Logger.getLogger(SuperPostak.class.getName()); 53 private static final long serialVersionUID = -7026850569575604048L; 54 private Nastaveni nastaveni = new Nastaveni(); 55 private Postak postak = new Postak(nastaveni); 56 57 /** 58 * Creates new form SuperPostak 59 * @param ladit předvyplní testovací hodnoty - zprávu 60 * @param exit při zavření okna ukončí program 61 */ 62 public SuperPostak(boolean ladit, boolean exit) { 63 log.log(Level.WARNING, "Program byl spuštěn."); 64 nactiOvladaceJDBC(); 65 vytvorSlozkuProgramu(); 66 initComponents(); 67 68 nactiNastaveni(); 69 ulozNastaveni(); 70 nastaveni.setCestaKCertifikatum(getCestaKCertifikatum()); 71 72 inicializujCardLayout(); 73 setLocationRelativeTo(null); 74 74 75 75 /** Kvůli souborovým dialogům – aby se otvírali ve stejné složce jako minule. */ … … 78 78 prijemciZkusebni.setNastaveni(nastaveni); 79 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 * @param jmeno název databáze 149 150 151 152 153 log.log(Level.INFO, "JDBC ovladač pro " + jmeno + " byl úspěšně načten.");154 155 log.log(Level.INFO, "JDBC ovladač pro " + jmeno + " se nepodařilo načíst.");156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 log.log(Level.INFO, "Složka pro nastavení programu byla vytvořena: " +getCestaKeSlozceProgramu());202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 log.log(Level.INFO, nadpis + ": " + text);264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 80 /** Vyřešíme problém TAB vs. Focus */ 81 vyresitTabFocusProblem(vstupSQL); 82 vyresitTabFocusProblem(vstupZprava); 83 84 /** Ladicí hodnoty */ 85 if (ladit) { 86 nastavLadiciHodnoty(); 87 } 88 89 if (exit) { 90 setDefaultCloseOperation(EXIT_ON_CLOSE); 91 } 92 93 94 } 95 96 private void inicializujCardLayout() { 97 panelDatabaze.setName("panelDatabaze"); 98 panelOdeslat.setName("panelOdeslat"); 99 panelPrijemci.setName("panelPrijemci"); 100 panelServer.setName("panelServer"); 101 panelVychoziPrijemci.setName("panelVychoziPrijemci"); 102 panelZprava.setName("panelZprava"); 103 104 panel.add(panelDatabaze, panelDatabaze.getName()); 105 panel.add(panelOdeslat, panelOdeslat.getName()); 106 panel.add(panelPrijemci, panelPrijemci.getName()); 107 panel.add(panelServer, panelServer.getName()); 108 panel.add(panelVychoziPrijemci, panelVychoziPrijemci.getName()); 109 panel.add(panelZprava, panelZprava.getName()); 110 111 setPanel(panelZprava); 112 pack(); 113 } 114 115 /** 116 * Vyplní formuláře (odesílatel, předmět, zpráva, příjemci...) výchozími hodnotami, 117 * aby se dal program testovat jedním kliknutím. 118 */ 119 private void nastavLadiciHodnoty() { 120 try { 121 vstupAdresaOdesilatele.setText("SuperPostak@frantovo.cz"); 122 vstupJmenoOdesilatele.setText("SuperPošťák"); 123 vstupPredmet.setText("Zkušební zpráva od SuperPošťáka"); 124 vstupZprava.setText("Toto je obyčejná zkušební zpráva v češtině :-)"); 125 ArrayList<InternetAddressKomu> adresy = new ArrayList<InternetAddressKomu>(); 126 adresy.add(new InternetAddressKomu("SuperPostak@frantovo.cz", "SuperPošťák")); 127 prijemciZkusebni.setAdresy(adresy); 128 } catch (UnsupportedEncodingException e) { 129 log.log(Level.SEVERE, null, e); 130 } 131 } 132 133 /** 134 * Pokusíme se načíst ovladače pro různé DB a výsledek zapíšeme do logu. 135 * Další ovladače je možné přidat pomocí manifestu v příslušných knihovnách. 136 * viz http://www.sweb.cz/pichlik/archive/2006_08_06_archive.html#115502885631518161 137 */ 138 private void nactiOvladaceJDBC() { 139 nactiOvladacJDBC("org.postgresql.Driver", "PostgreSQL"); 140 nactiOvladacJDBC("com.mysql.jdbc.Driver", "MySQL"); 141 nactiOvladacJDBC("net.sourceforge.jtds.jdbc.Driver", "jTDS Sybase a MS SQL"); 142 nactiOvladacJDBC("com.sybase.jdbc2.jdbc.SybDriver", "Sybase.com"); 143 nactiOvladacJDBC("oracle.jdbc.OracleDriver", "Oracle"); 144 } 145 146 /** 147 * @param trida ovladač databáze, který se má načíst 148 * @param jmeno název databáze 149 */ 150 private void nactiOvladacJDBC(String trida, String jmeno) { 151 try { 152 Class.forName(trida); 153 log.log(Level.INFO, "JDBC ovladač pro {0} byl úspěšně načten.", jmeno); 154 } catch (ClassNotFoundException e) { 155 log.log(Level.INFO, "JDBC ovladač pro {0} se nepodařilo načíst.", jmeno); 156 } 157 } 158 159 /** Vrací plnou cestu k souboru s nastavením */ 160 protected static String getCestaKCertifikatum() { 161 return getCestaKeSlozceProgramu() + CERTIFIKATY_SOUBOR; 162 } 163 164 /** Vrací plnou cestu k souboru s nastavením */ 165 protected static String getCestaKNastaveni() { 166 return getCestaKeSlozceProgramu() + NASTAVENI_SOUBOR; 167 } 168 169 /** Vrací plnou cestu ke složce programu (nastavení, certifikáty a logy) */ 170 protected static String getCestaKeSlozceProgramu() { 171 return DOMACI_ADRESAR + File.separator + NASTAVENI_SLOZKA + File.separator; 172 } 173 174 /** Načte nastavení ze souboru */ 175 private void nactiNastaveni() { 176 try { 177 XMLDecoder d = new XMLDecoder(new BufferedInputStream(new GZIPInputStream(new FileInputStream(getCestaKNastaveni())))); 178 Object xmlObjekt = d.readObject(); 179 d.close(); 180 181 if (xmlObjekt instanceof Nastaveni) { 182 nastaveni = (Nastaveni) xmlObjekt; 183 } else { 184 nastaveni = new Nastaveni(); 185 log.log(Level.SEVERE, "Nepodařilo se načíst nastavení: není instancí"); 186 } 187 188 nactiNastaveniGUI(); 189 190 log.log(Level.INFO, "Nastavení bylo načteno."); 191 } catch (FileNotFoundException ex) { 192 log.log(Level.SEVERE, "Nepodařilo se načíst nastavení: soubor nenalezen", ex); 193 } catch (IOException ex) { 194 log.log(Level.SEVERE, "Nastavení se nepodařilo načíst: I/O.", ex); 195 } 196 } 197 198 /** Vytvoří (pokud neexistuje) v domovském adresáři složku, kam se ukládá nastavení a případně logy */ 199 private static boolean vytvorSlozkuProgramu() { 200 if (new File(getCestaKeSlozceProgramu()).mkdirs()) { 201 log.log(Level.INFO, "Složka pro nastavení programu byla vytvořena: {0}", getCestaKeSlozceProgramu()); 202 return true; 203 } else { 204 return false; 205 } 206 } 207 208 /** Uloží nastavení do souboru */ 209 private void ulozNastaveni() { 210 try { 211 ulozNastaveniGUI(); 212 213 vytvorSlozkuProgramu(); 214 215 XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(getCestaKNastaveni())))); 216 e.writeObject(nastaveni); 217 e.close(); 218 log.log(Level.INFO, "Nastavení bylo uloženo."); 219 } catch (FileNotFoundException ex) { 220 log.log(Level.SEVERE, "Nastavení se nepodařilo uložit: soubor nenalezen.", ex); 221 } catch (IOException ex) { 222 log.log(Level.SEVERE, "Nastavení se nepodařilo uložit: I/O.", ex); 223 } 224 } 225 226 /** Posbírá zadané hodnoty z GUI a uloží je do objektu nastaveni */ 227 private void ulozNastaveniGUI() { 228 nastaveni.setDatabaze(vstupDatabaze.getText()); 229 nastaveni.setDbHeslo(vstupDBheslo.getPassword()); 230 nastaveni.setDbJmeno(vstupDBjmeno.getText()); 231 nastaveni.setLimitZprav((Integer) vstupSMTPlimitPrijemcu.getValue()); 232 nastaveni.setPostovniHeslo(vstupSMTPheslo.getPassword()); 233 nastaveni.setPostovniJmeno(vstupSMTPjmeno.getText()); 234 nastaveni.setPostovniPort((Integer) vstupSMTPport.getValue()); 235 nastaveni.setPostovniServer(vstupSMTPserver.getText()); 236 nastaveni.setVychoziPrijemci(prijemciVychozi.getAdresy()); 237 } 238 239 /** Aktualizuje GUI formuláře hodnotami z objektu nastaveni */ 240 private void nactiNastaveniGUI() { 241 vstupDatabaze.setText(nastaveni.getDatabaze()); 242 if (nastaveni.getDbHeslo() != null) { 243 vstupDBheslo.setText(String.valueOf(nastaveni.getDbHeslo())); 244 } 245 vstupDBjmeno.setText(nastaveni.getDbJmeno()); 246 vstupSMTPlimitPrijemcu.setValue(nastaveni.getLimitZprav()); 247 if (nastaveni.getPostovniHeslo() != null) { 248 vstupSMTPheslo.setText(String.valueOf(nastaveni.getPostovniHeslo())); 249 } 250 vstupSMTPjmeno.setText(nastaveni.getPostovniJmeno()); 251 vstupSMTPport.setValue(nastaveni.getPostovniPort()); 252 vstupSMTPserver.setText(nastaveni.getPostovniServer()); 253 prijemciVychozi.setAdresy(nastaveni.getVychoziPrijemci()); 254 } 255 256 protected static void zobrazChybovyDialog(Component vlastnik, String strucnaZprava, Throwable vyjimka, Level zavaznost, boolean logovat) { 257 zobrazChybovyDialog(vlastnik, "Chyba", strucnaZprava, null, vyjimka, zavaznost, logovat); 258 } 259 260 protected static void zobrazInformacniDialog(Component vlastnik, String nadpis, String text, boolean loguj) { 261 JOptionPane.showMessageDialog(vlastnik, text, nadpis, JOptionPane.INFORMATION_MESSAGE); 262 if (loguj) { 263 log.log(Level.INFO, "{0}: {1}", new Object[]{nadpis, text}); 264 } 265 } 266 267 protected static void zobrazChybovyDialog(Component vlastnik, String nadpis, String strucnaZprava, String podrobnaZprava, Throwable vyjimka, Level zavaznost, boolean logovat) { 268 if (logovat) { 269 log.log(zavaznost, strucnaZprava, vyjimka); 270 } 271 272 JXErrorPane chybovyPanel = new JXErrorPane(); 273 ErrorInfo chybovaInformace = new ErrorInfo(nadpis, strucnaZprava, podrobnaZprava, null, vyjimka, zavaznost, null); 274 chybovyPanel.setErrorInfo(chybovaInformace); 275 JDialog dialog = JXErrorPane.createDialog(vlastnik, chybovyPanel); 276 dialog.setVisible(true); 277 } 278 279 private void zobrazChybovyDialog(String strucnaZprava, Throwable vyjimka, Level zavaznost, boolean logovat) { 280 zobrazChybovyDialog(this, strucnaZprava, vyjimka, zavaznost, logovat); 281 } 282 283 private void zobrazInformacniDialog(String nadpis, String text, boolean loguj) { 284 zobrazInformacniDialog(this, nadpis, text, loguj); 285 } 286 287 private void zobrazChybovyDialog(String nadpis, String strucnaZprava, String podrobnaZprava, Throwable vyjimka, Level zavaznost, boolean logovat) { 288 zobrazChybovyDialog(this, nadpis, strucnaZprava, podrobnaZprava, vyjimka, zavaznost, logovat); 289 } 290 291 /** This method is called from within the constructor to 292 * initialize the form. 293 * WARNING: Do NOT modify this code. The content of this method is 294 * always regenerated by the Form Editor. 295 */ 296 296 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 297 297 private void initComponents() { … … 927 927 928 928 private void lnTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lnTextActionPerformed 929 929 setPanel(panelZprava); 930 930 }//GEN-LAST:event_lnTextActionPerformed 931 931 932 932 private void lnPrijemciActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lnPrijemciActionPerformed 933 933 setPanel(panelPrijemci); 934 934 }//GEN-LAST:event_lnPrijemciActionPerformed 935 935 936 936 private void lnOdeslatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lnOdeslatActionPerformed 937 937 setPanel(panelOdeslat); 938 938 }//GEN-LAST:event_lnOdeslatActionPerformed 939 939 940 940 private void lnServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lnServerActionPerformed 941 941 setPanel(panelServer); 942 942 }//GEN-LAST:event_lnServerActionPerformed 943 943 944 944 private void lnDatabazeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lnDatabazeActionPerformed 945 945 setPanel(panelDatabaze); 946 946 }//GEN-LAST:event_lnDatabazeActionPerformed 947 947 948 948 private void lnVychoziPrijemciActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lnVychoziPrijemciActionPerformed 949 949 setPanel(panelVychoziPrijemci); 950 950 }//GEN-LAST:event_lnVychoziPrijemciActionPerformed 951 951 952 952 private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing 953 954 953 ulozNastaveni(); 954 log.log(Level.WARNING, "Ukončuji program."); 955 955 }//GEN-LAST:event_formWindowClosing 956 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 957 /** 958 * Sestaví zprávu na základě GUI vstupů. Všechno kromě příjemců, 959 * ti se přidají až dodatečně, podle toho, 960 * jestli jde o zkušební nebo skutečné rozesílání. 961 */ 962 private HromadnaZprava getZprava() throws UnsupportedEncodingException { 963 HromadnaZprava zprava = new HromadnaZprava(); 964 zprava.setOdesilatel(new InternetAddress(vstupAdresaOdesilatele.getText(), vstupJmenoOdesilatele.getText())); 965 zprava.setPredmet(vstupPredmet.getText()); 966 zprava.setText(vstupZprava.getText()); 967 zprava.setFormatHTML(vstupFormatHTML.isSelected()); 968 969 if (Postak.zkontrolujAdresu(odpovedetKomuAdresa.getText())) { 970 InternetAddress komu = new InternetAddress(); 971 komu.setPersonal(odpovedetKomuJmeno.getText()); 972 komu.setAddress(odpovedetKomuAdresa.getText()); 973 zprava.setOdpovedetKomu(komu); 974 } 975 976 return zprava; 977 } 978 979 /** Všichni příjemci, kterým bude odeslána ostrá zpráva. */ 980 private ArrayList<InternetAddressKomu> getPrijemciVsichni() throws SQLException, UnsupportedEncodingException { 981 ArrayList<InternetAddressKomu> vsichni = new ArrayList<InternetAddressKomu>(); 982 Collection<InternetAddressKomu> adresyVychozi = nastaveni.getVychoziPrijemci(); 983 Collection<InternetAddressKomu> adresySQL = getPrijemciSQL(); 984 Collection<InternetAddressKomu> adresyDodatecne = prijemciDodatecni.getAdresy(); 985 986 if (adresyVychozi != null) { 987 vsichni.addAll(adresyVychozi); 988 } 989 if (adresySQL != null) { 990 vsichni.addAll(adresySQL); 991 } 992 if (adresyDodatecne != null) { 993 vsichni.addAll(adresyDodatecne); 994 } 995 return vsichni; 996 } 997 997 998 998 private void rozeslatHromadnouZpravuTlacitkoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rozeslatHromadnouZpravuTlacitkoActionPerformed 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 999 try { 1000 ulozNastaveniGUI(); 1001 HromadnaZprava zprava = getZprava(); 1002 zprava.setPrijemci(getPrijemciVsichni()); 1003 1004 int volba = JOptionPane.showOptionDialog(this, "Počet příjemců hromadné zprávy: " + zprava.getPrijemci().size() + "\nPřejete si zprávu odeslat?", "Potvrdit odeslání", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); 1005 if (volba == JOptionPane.YES_OPTION) { 1006 odesli(zprava); 1007 Postak.vypisPrijemce(zprava.getPrijemci()); 1008 zobrazInformacniDialog("Odesláno", "Zpráva byla odeslána.\nPočet příjemců: " + zprava.getPrijemci().size(), true); 1009 } 1010 } catch (Exception e) { 1011 zobrazChybovyDialog("Zprávu se nepodařilo odeslat", e, Level.SEVERE, true); 1012 } 1013 1013 }//GEN-LAST:event_rozeslatHromadnouZpravuTlacitkoActionPerformed 1014 1014 1015 1015 private void rozeslatZkusebniTlacitkoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rozeslatZkusebniTlacitkoActionPerformed 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1016 try { 1017 ulozNastaveniGUI(); 1018 HromadnaZprava zprava = getZprava(); 1019 zprava.setPrijemci(prijemciZkusebni.getAdresy()); 1020 1021 odesli(zprava); 1022 1023 zobrazInformacniDialog("Odesláno", "Zkušební zpráva byla odeslána.\nPočet adresátů: " + zprava.getPrijemci().size(), true); 1024 } catch (Exception e) { 1025 zobrazChybovyDialog("Zkušební zprávu se nepodařilo odeslat", e, Level.SEVERE, true); 1026 } 1027 1027 }//GEN-LAST:event_rozeslatZkusebniTlacitkoActionPerformed 1028 1028 1029 1029 private void vyzkousetPripojeniTlacitkoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vyzkousetPripojeniTlacitkoActionPerformed 1030 1030 try { 1031 1031 getSpojeni();//GEN-LAST:event_vyzkousetPripojeniTlacitkoActionPerformed 1032 1033 1034 1035 1036 1032 zobrazInformacniDialog("Připojeno k DB", "Připojení k DB proběhlo úspěšně", false); 1033 } catch (SQLException e) { 1034 zobrazChybovyDialog("Spojení s DB", "Připojení k databázi selhalo", null, e, Level.SEVERE, true); 1035 } 1036 } 1037 1037 1038 1038 private void vyzkousetSQLTlacitkoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vyzkousetSQLTlacitkoActionPerformed 1039 1039 try { 1040 1040 Collection<InternetAddressKomu> adresy = getPrijemciSQL();//GEN-LAST:event_vyzkousetSQLTlacitkoActionPerformed 1041 1042 1043 1044 1045 1046 1047 1048 1049 1041 if (adresy == null) { 1042 zobrazInformacniDialog("SQL dotaz", "Dotaz do databáze neproběhl.\nSQL dotaz je prázdný.", false); 1043 } else { 1044 zobrazInformacniDialog("SQL dotaz", "Dotaz do databáze byl úspěšný.\nPočet získaných záznamů: " + adresy.size(), false); 1045 } 1046 } catch (Exception e) { 1047 zobrazChybovyDialog("SQL dotaz", "Provedení SQL příkazu selhalo selhalo", null, e, Level.SEVERE, true); 1048 } 1049 } 1050 1050 1051 1051 private void zobrazitSQLPrijemceTlacitkoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zobrazitSQLPrijemceTlacitkoActionPerformed 1052 1053 1054 1055 1052 try { 1053 Collection<InternetAddressKomu> adresy = getPrijemciSQL(); 1054 1055 ZobrazovacAdres zobrazovac = new ZobrazovacAdres(this, false); 1056 1056 zobrazovac.setNastaveni(nastaveni); 1057 1058 1059 1060 1061 1062 1063 1057 zobrazovac.setAdresy(adresy); 1058 zobrazovac.setLocationRelativeTo(this); 1059 zobrazovac.setVisible(true); 1060 1061 } catch (Exception e) { 1062 zobrazChybovyDialog("SQL dotaz", "Provedení SQL příkazu selhalo selhalo", null, e, Level.SEVERE, true); 1063 } 1064 1064 }//GEN-LAST:event_zobrazitSQLPrijemceTlacitkoActionPerformed 1065 1065 1066 1066 private void zobrazitVsechnyPrijemceTlacitkoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zobrazitVsechnyPrijemceTlacitkoActionPerformed 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1067 try { 1068 Collection<InternetAddressKomu> adresy = getPrijemciVsichni(); 1069 1070 ZobrazovacAdres zobrazovac = new ZobrazovacAdres(this, false); 1071 zobrazovac.setAdresy(adresy); 1072 zobrazovac.setLocationRelativeTo(this); 1073 zobrazovac.setVisible(true); 1074 1075 } catch (Exception e) { 1076 zobrazChybovyDialog("SQL dotaz", "Provedení SQL příkazu selhalo selhalo", null, e, Level.SEVERE, true); 1077 } 1078 1078 }//GEN-LAST:event_zobrazitVsechnyPrijemceTlacitkoActionPerformed 1079 1079 1080 1080 private void odpovedetKomuOdkazActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_odpovedetKomuOdkazActionPerformed 1081 1082 1083 1084 1085 1081 odpovedetKomuDialog.pack(); 1082 odpovedetKomuDialog.setLocationRelativeTo(this); 1083 odpovedetKomuDialog.setModalityType(ModalityType.APPLICATION_MODAL); 1084 odpovedetKomuDialog.getRootPane().setDefaultButton(odpovedetKomuHotovo); 1085 odpovedetKomuDialog.setVisible(true); 1086 1086 }//GEN-LAST:event_odpovedetKomuOdkazActionPerformed 1087 1087 1088 1088 private void odpovedetKomuHotovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_odpovedetKomuHotovoActionPerformed 1089 1089 odpovedetKomuDialog.setVisible(false); 1090 1090 }//GEN-LAST:event_odpovedetKomuHotovoActionPerformed 1091 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1092 /** Provede uživatelem zadaný SQL dotaz a vrátí získané příjemce */ 1093 private Collection<InternetAddressKomu> getPrijemciSQL() throws SQLException, UnsupportedEncodingException { 1094 if ("".equals(vstupSQL.getText())) { 1095 return null; 1096 } else { 1097 return getSpojeni().getAdresy(vstupSQL.getText()); 1098 } 1099 } 1100 1101 private DataSQL getSpojeni() throws SQLException { 1102 return Data.getSpojeniSQL(vstupDatabaze.getText(), vstupDBjmeno.getText(), vstupDBheslo.getPassword()); 1103 } 1104 1105 /** Obalovací třída, která v průběhu odesílání zobrazuje kurzor s hodinami. */ 1106 private void odesli(HromadnaZprava zprava) throws MessagingException { 1107 setCursor(new Cursor(Cursor.WAIT_CURSOR)); 1108 try { 1109 postak.setNastaveni(nastaveni); 1110 postak.odesli(zprava); 1111 1112 } catch (MessagingException e) { 1113 throw e; 1114 } finally { 1115 setCursor(Cursor.getDefaultCursor()); 1116 } 1117 } 1118 1119 private void setPanel(JComponent komponenta) { 1120 1121 if (panel.getLayout() instanceof CardLayout) { 1122 CardLayout l = (CardLayout) panel.getLayout(); 1123 l.show(panel, komponenta.getName()); 1124 } else { 1125 log.log(Level.WARNING, "Neplatí: panel.getLayout() instanceof CardLayout"); 1126 } 1127 1128 } 1129 1130 /** Změní chování tabulátoru v textovém poli - aby se pomocí TABu dalo skočit na další komponentu */ 1131 private void vyresitTabFocusProblem(JTextArea textArea) { 1132 textArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null); 1133 textArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null); 1134 } 1135 1136 public JXTaskPaneContainer getTaskPanel() { 1137 return taskPanel; 1138 } 1139 1140 /** 1141 * @param args the command line arguments 1142 */ 1143 public static void main(String args[]) { 1144 final boolean ladit = (args != null && args.length > 0 && args[0].equals("ladit")); 1145 1146 try { 1147 //LookAndFeel laf = UIManager.getLookAndFeel(); 1148 1149 //laf = new SubstanceLookAndFeel(); 1150 //laf = new SubstanceBusinessLookAndFeel(); 1151 //laf = new SubstanceBusinessBlueSteelLookAndFeel(); 1152 //laf = new SubstanceBusinessBlackSteelLookAndFeel(); 1153 1154 UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel"); 1155 } catch (ClassNotFoundException ex) { 1156 log.log(Level.SEVERE, null, ex); 1157 } catch (InstantiationException ex) { 1158 log.log(Level.SEVERE, null, ex); 1159 } catch (IllegalAccessException ex) { 1160 log.log(Level.SEVERE, null, ex); 1161 } catch (UnsupportedLookAndFeelException ex) { 1162 log.log(Level.SEVERE, null, ex); 1163 } 1164 1165 java.awt.EventQueue.invokeLater(new Runnable() { 1166 1167 public void run() { 1168 new SuperPostak(ladit, true).setVisible(true); 1169 } 1170 }); 1171 } 1172 1172 // Variables declaration - do not modify//GEN-BEGIN:variables 1173 1173 private javax.swing.JLabel jLabel1;