diff --git a/LICENSE b/LICENSE index e95cbb7..c535500 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,3 @@ -<<<<<<< HEAD ============================== Code License ============================== @@ -56,63 +55,4 @@ you permission, that decision is considered final and binding. This software contains third-party components. These components may fall under a different license and have a different copyright holder than the above. -======= -============================== - Code License -============================== - -Copyright (c) 2015, Netsyms Technologies -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors -may be used to endorse or promote products derived from this software without -specific prior written permission. - -4. You adhere to the Media License detailed below. If you do not, this license -is automatically revoked and you must purge all copies of the software you -possess, in source or binary form. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -============================== - Media License -============================== - -All images and other graphical files (the "graphics") included with this -software are copyright (c) 2015 Netsyms Technologies. You may not distribute -the graphics or any program, source code repository, or other digital storage -media containing them without written permission from Netsyms Technologies. -This ban on distribution only applies to publicly available systems. -A password-protected network file share, USB drive, or other storage scheme that -cannot be easily accessed by the public is generally allowed. If in doubt, -contact Netsyms Technologies. If Netsyms Technologies allows or denies -you permission, that decision is considered final and binding. - -============================== - Other Licenses -============================== - -This software contains third-party components. These components may fall under -a different license and have a different copyright holder than the above. ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 Consult their license information or the Manual system for more information. \ No newline at end of file diff --git a/README.md b/README.md index 0c55c53..c920ee6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -<<<<<<< HEAD SyMAT ===== @@ -16,23 +15,4 @@ http://symatapp.com/ Report a Bug ------ -======= -SyMAT -===== - -SyMAT is a computer science and math system written in Java. - -This repository is extremely bleeding-edge, and we won't help you compile it. -We test new features before committing, but there are bugs. -If you want a stable release, download the latest one from our website. - -Get SyMAT ------- - -To get SyMAT for your platform, go to: -http://symatapp.com/ - -Report a Bug ------- ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 To report bugs, go to: https://github.com/Netsyms/SyMAT/issues \ No newline at end of file diff --git a/build.xml b/build.xml index ab32708..d9cb61c 100644 --- a/build.xml +++ b/build.xml @@ -1,4 +1,3 @@ -<<<<<<< HEAD -======= - - - - - - - - - - - Builds, tests, and runs the project SyMAT. - - - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties index cf1dc24..b20c11c 100644 --- a/lib/nblibraries.properties +++ b/lib/nblibraries.properties @@ -1,4 +1,3 @@ -<<<<<<< HEAD # # Copyright (c) 2015, Netsyms Technologies # All rights reserved. @@ -88,68 +87,3 @@ libs.CopyLibs.classpath=\ ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar libs.CopyLibs.displayName=CopyLibs Task libs.CopyLibs.prop-version=2.0 -======= -# -# Copyright (c) 2015, Netsyms Technologies -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation and/or -# other materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors -# may be used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -libs.absolutelayout.classpath=\ - ${base}/absolutelayout/AbsoluteLayout.jar -libs.absolutelayout.displayName=Absolute Layout -# -# Netsyms Technologies -# Open Source License -# -# Source code can be used for any purpose, as long as: -# - Compiled binaries are rebranded and trademarks are not -# visible by the end user at any time, except to give -# credit to Netsyms Technologies, such as by showing -# "Based on by Netsyms Technologies" or a -# similar notice; -# - You do not use the code for evil; -# - Rebranded compiled applications have significant -# differences in functionality; -# - and you provide your modified source code for download, -# under the terms of the GNU LGPL v3 or a comparable -# license. -# -# Compiled binaries cannot be redistributed or mirrored, -# unless: -# - You have written permission from Netsyms Technologies; -# - Downloads are not available from Netsyms Technologies, -# not even behind a paywall or other blocking mechanism; -# - or you have received a multi-computer license, in which -# case you should take measures to prevent unauthorized -# downloads, such as preventing download access from the -# Internet. -# -libs.CopyLibs.classpath=\ - ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar -libs.CopyLibs.displayName=CopyLibs Task -libs.CopyLibs.prop-version=2.0 ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 415be86..c893a4f 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1,4 +1,3 @@ -<<<<<<< HEAD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 62c1f79..0ff40f3 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,4 +1,3 @@ -<<<<<<< HEAD build.xml.data.CRC32=70b2413f build.xml.script.CRC32=cfce77fe build.xml.stylesheet.CRC32=8064a381@1.75.2.48 @@ -7,13 +6,3 @@ build.xml.stylesheet.CRC32=8064a381@1.75.2.48 nbproject/build-impl.xml.data.CRC32=70b2413f nbproject/build-impl.xml.script.CRC32=e6773cad nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 -======= -build.xml.data.CRC32=70b2413f -build.xml.script.CRC32=cfce77fe -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=70b2413f -nbproject/build-impl.xml.script.CRC32=e6773cad -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/nbproject/project.properties b/nbproject/project.properties index 04f02d8..d83890d 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,3 @@ -<<<<<<< HEAD annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= @@ -148,154 +147,3 @@ run.test.classpath=\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=${file.reference.SyMAT-src} -======= -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.desc=Math and Programming for People -application.homepage=https://symatapp.com/ -application.splash=C:\\Users\\Skylar\\Documents\\Apocalypse Labs\\appmedia\\SyMAT\\splashscreen.png -application.title=SyMAT -application.vendor=Netsyms Technologies -auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml -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 -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/SyMAT.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.autocomplete-2.5.4.jar=lib/autocomplete-2.5.4.jar -file.reference.beautyeye_lnf.jar=lib/beautyeye_lnf.jar -file.reference.commons-codec-1.9.jar=lib/commons-codec-1.9.jar -file.reference.commons-logging-1.2.jar=lib/commons-logging-1.2.jar -file.reference.flamingo-6.3.jar=lib/flamingo-6.3.jar -file.reference.htmlcleaner-2.10.jar=lib/htmlcleaner-2.10.jar -file.reference.httpclient-4.5.jar=lib/httpclient-4.5.jar -file.reference.httpclient-cache-4.5.jar=lib/httpclient-cache-4.5.jar -file.reference.httpclient-win-4.5.jar=lib/httpclient-win-4.5.jar -file.reference.httpcore-4.4.1.jar=lib/httpcore-4.4.1.jar -file.reference.httpmime-4.5.jar=lib/httpmime-4.5.jar -file.reference.iText-4.2.0-com.itextpdf.jar=lib/iText-4.2.0-com.itextpdf.jar -file.reference.JavaPrettify-1.2.1.jar=lib\\JavaPrettify-1.2.1.jar -file.reference.jmathplot.jar=lib/jmathplot.jar -file.reference.jna-4.1.0.jar=lib/jna-4.1.0.jar -file.reference.jna-platform-4.1.0.jar=lib/jna-platform-4.1.0.jar -file.reference.js-engine.jar=lib/js-engine.jar -file.reference.js.jar=lib/js.jar -file.reference.json-simple-1.1.1.jar=lib/json-simple-1.1.1.jar -file.reference.jython-standalone-2.7.0.jar=lib/jython-standalone-2.7.0.jar -file.reference.log4j-1.2.11.jar=lib/log4j-1.2.11.jar -file.reference.rsyntaxtextarea-2.5.6.jar=lib/rsyntaxtextarea-2.5.6.jar -file.reference.seaglasslookandfeel-0.2.jar=lib/seaglasslookandfeel-0.2.jar -file.reference.SyMAT-src=src -file.reference.symja-2014-11-01.jar=lib/symja-2014-11-01.jar -file.reference.trident-6.3.jar=lib/trident-6.3.jar -file.reference.ujmp-complete-0.2.5.jar=lib\\ujmp-complete-0.2.5.jar -includes=** -jar.archive.disabled=${jnlp.enabled} -jar.compress=false -jar.index=${jnlp.enabled} -javac.classpath=\ - ${file.reference.autocomplete-2.5.4.jar}:\ - ${file.reference.beautyeye_lnf.jar}:\ - ${file.reference.flamingo-6.3.jar}:\ - ${file.reference.htmlcleaner-2.10.jar}:\ - ${file.reference.iText-4.2.0-com.itextpdf.jar}:\ - ${file.reference.jmathplot.jar}:\ - ${file.reference.js-engine.jar}:\ - ${file.reference.js.jar}:\ - ${file.reference.json-simple-1.1.1.jar}:\ - ${file.reference.log4j-1.2.11.jar}:\ - ${file.reference.rsyntaxtextarea-2.5.6.jar}:\ - ${file.reference.seaglasslookandfeel-0.2.jar}:\ - ${file.reference.symja-2014-11-01.jar}:\ - ${file.reference.trident-6.3.jar}:\ - ${file.reference.JavaPrettify-1.2.1.jar}:\ - ${file.reference.ujmp-complete-0.2.5.jar}:\ - ${file.reference.commons-codec-1.9.jar}:\ - ${file.reference.commons-logging-1.2.jar}:\ - ${file.reference.httpclient-4.5.jar}:\ - ${file.reference.httpclient-cache-4.5.jar}:\ - ${file.reference.httpclient-win-4.5.jar}:\ - ${file.reference.httpcore-4.4.1.jar}:\ - ${file.reference.httpmime-4.5.jar}:\ - ${file.reference.jna-4.1.0.jar}:\ - ${file.reference.jna-platform-4.1.0.jar}:\ - ${file.reference.jython-standalone-2.7.0.jar} -# 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.reference.flamingo-6.3.jar=lib/flamingo-6.3-javadoc.jar -javadoc.reference.ujmp-complete-0.2.5.jar=lib\\ujmp-complete-0.2.5-javadoc.zip!/0.2.5/ujmp-core/apidocs/ -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle=SyMAT Code Docs -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=default -jnlp.offline-allowed=false -jnlp.signed=false -jnlp.signing= -jnlp.signing.alias= -jnlp.signing.keystore= -main.class=net.apocalypselabs.symat.Main -# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed -manifest.custom.codebase= -# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) -manifest.custom.permissions= -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -project.license=aplabs-oss_1 -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=${file.reference.SyMAT-src} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/nbproject/project.xml b/nbproject/project.xml index c926d25..9d062bb 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -1,4 +1,3 @@ -<<<<<<< HEAD org.netbeans.modules.java.j2seproject @@ -15,21 +14,3 @@ -======= - - - org.netbeans.modules.java.j2seproject - - - SyMAT - - - - - - - .\lib\nblibraries.properties - - - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/BadInputException.java b/src/net/apocalypselabs/symat/BadInputException.java index b683d58..bd99889 100644 --- a/src/net/apocalypselabs/symat/BadInputException.java +++ b/src/net/apocalypselabs/symat/BadInputException.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -72,68 +71,3 @@ public class BadInputException extends Exception { super(msg); } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -/** - * - * Bad input exception. Useful for throwing errors in user code. - * - * @author Skylar - */ -public class BadInputException extends Exception { - - public BadInputException() { - super(); - } - - public BadInputException(String msg) { - super(msg); - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/CodeCompleter.java b/src/net/apocalypselabs/symat/CodeCompleter.java index 6225835..997fa5a 100644 --- a/src/net/apocalypselabs/symat/CodeCompleter.java +++ b/src/net/apocalypselabs/symat/CodeCompleter.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -120,116 +119,3 @@ public class CodeCompleter { } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import org.fife.ui.autocomplete.BasicCompletion; -import org.fife.ui.autocomplete.CompletionProvider; -import org.fife.ui.autocomplete.DefaultCompletionProvider; -import org.fife.ui.autocomplete.VariableCompletion; - -/** - * - * @author Skylar - */ -public class CodeCompleter { - - private final CompletionProvider provider; - private final String lang; - - /** - * - * @param language Either js or py. - */ - public CodeCompleter(String language) { - lang = language; - provider = makeCompletions(); - } - - public CompletionProvider getProvider() { - return provider; - } - - private CompletionProvider makeCompletions() { - DefaultCompletionProvider provider = new DefaultCompletionProvider(); - try { - String[] files = {"functions", "constants"}; - for (String fileid : files) { - BufferedReader reader = new BufferedReader( - new InputStreamReader( - CodeCompleter.class.getResourceAsStream("resources/" + (fileid.equals(files[0]) ? "" : lang) + fileid + ".txt"))); - String line; - while ((line = reader.readLine()) != null) { - switch (fileid) { - case "functions": - String[] args = line.split("\\|"); - if (args.length == 2) { - provider.addCompletion(new BasicCompletion(provider, args[0], args[1])); - } else if (args.length == 3) { - provider.addCompletion(new BasicCompletion(provider, args[0], args[1], args[2])); - } else { - provider.addCompletion(new BasicCompletion(provider, args[0])); - } - break; - case "constants": - provider.addCompletion(new VariableCompletion(provider, line, "double")); - break; - } - } - } - } catch (IOException ex) { - Debug.printerr(ex.getMessage()); - } - return provider; - } - -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/CodeExport.java b/src/net/apocalypselabs/symat/CodeExport.java index d8cc83b..eb46054 100644 --- a/src/net/apocalypselabs/symat/CodeExport.java +++ b/src/net/apocalypselabs/symat/CodeExport.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -487,483 +486,3 @@ public class CodeExport extends javax.swing.JInternalFrame { private javax.swing.JTextField titleBox; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import com.itextpdf.text.Document; -import com.itextpdf.text.DocumentException; -import com.itextpdf.text.html.simpleparser.HTMLWorker; -import com.itextpdf.text.html.simpleparser.StyleSheet; -import com.itextpdf.text.pdf.PdfWriter; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.StringReader; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import org.htmlcleaner.CleanerProperties; -import org.htmlcleaner.HtmlCleaner; -import org.htmlcleaner.SimpleHtmlSerializer; -import org.htmlcleaner.TagNode; -import prettify.PrettifyParser; -import syntaxhighlight.ParseResult; - -/** - * - * @author Skylar - */ -public class CodeExport extends javax.swing.JInternalFrame { - - private String codeLang = "js"; - private String html; - private final String origCode; - private String outputTxt = ""; - - /** - * Creates new form CodeExport - * - * @param code The code. - */ - public CodeExport(String code) { - origCode = code; - initComponents(); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - html = genHtml(code); - } - }); - html = genHtml(code); - previewPane.setText(html); - previewPane.setCaretPosition(0); - } - - /** - * Create CodeExport window with a set language for syntax highlighting. - * - * @param code The code. - * @param lang Options are "js" or "python". - */ - public CodeExport(String code, String lang) { - this(code); - codeLang = lang; - } - - public CodeExport(String code, String lang, String out) { - this(code, lang); - outputTxt = out; - } - - private String genHtml(String code) { - String css = ""; - BufferedReader reader = new BufferedReader( - new InputStreamReader( - CodeExport.class - .getResourceAsStream("pretty.css"))); - String line; - try { - while ((line = reader.readLine()) != null) { - css += line; - } - } catch (IOException ex) { - Logger.getLogger(CodeExport.class.getName()).log(Level.SEVERE, null, ex); - } - html = "" - + "" - + "" - + "" - + "" - + "" - + "" - + "

" + titleBox.getText() + "

"; - if (!authBox.getText().equals("")) { - html += "

Author: " + authBox.getText() + "

"; - } - if (!dateBox.getText().equals("")) { - html += "

Date: " + dateBox.getText() + "

"; - } - if (!headerBox.getText().equals("")) { - html += "

" + headerBox.getText() + "

"; - } - if (outputPlaceBox.getSelectedIndex() == 1) { - html += getOutput(); - } - PrettifyParser parser = new PrettifyParser(); - List parseResults = parser.parse(codeLang, code); - html += PrettifyToHtml.toHtml(code, parseResults); - if (outputPlaceBox.getSelectedIndex() == 0) { - html += getOutput(); - } - html += ""; - html = html.replace("\t", "    "); - html = html.replace("\n", "
"); - HtmlCleaner cleaner = new HtmlCleaner(); - CleanerProperties props = cleaner.getProperties(); - TagNode node = cleaner.clean(html); - html = new SimpleHtmlSerializer(props).getAsString(node); - html = html.replace("'", "'"); - html = html.replace("", ""); - Debug.println(html); - return html; - } - - private String getOutput() { - return "

Output:

"
-                + outputTxt.replace("<", "<").
-                replace("&", "&").
-                replace(">", ">").
-                replace("\"", "''")
-                + "\n\n
"; - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jScrollPane1 = new javax.swing.JScrollPane(); - previewPane = new javax.swing.JTextPane(); - jPanel1 = new javax.swing.JPanel(); - titleBox = new javax.swing.JTextField(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - authBox = new javax.swing.JTextField(); - dateBox = new javax.swing.JTextField(); - jLabel3 = new javax.swing.JLabel(); - jScrollPane2 = new javax.swing.JScrollPane(); - headerBox = new javax.swing.JTextArea(); - jLabel4 = new javax.swing.JLabel(); - jButton1 = new javax.swing.JButton(); - jPanel2 = new javax.swing.JPanel(); - exHtml = new javax.swing.JButton(); - exPdf = new javax.swing.JButton(); - outputPlaceBox = new javax.swing.JComboBox(); - jLabel5 = new javax.swing.JLabel(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Export Code"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/export.png"))); // NOI18N - - previewPane.setEditable(false); - previewPane.setContentType("text/html"); // NOI18N - jScrollPane1.setViewportView(previewPane); - - titleBox.setText("SyMAT Project"); - - jLabel1.setText("Title:"); - - jLabel2.setText("Author:"); - - authBox.setText(PrefStorage.getSetting("author", "")); - - jLabel3.setText("Date:"); - - headerBox.setColumns(20); - headerBox.setLineWrap(true); - headerBox.setRows(2); - headerBox.setTabSize(4); - headerBox.setWrapStyleWord(true); - jScrollPane2.setViewportView(headerBox); - - jLabel4.setText("Header:"); - - jButton1.setText("Update Preview"); - jButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton1ActionPerformed(evt); - } - }); - - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Export to:")); - - exHtml.setText("HTML"); - exHtml.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exHtmlActionPerformed(evt); - } - }); - - exPdf.setText("PDF"); - exPdf.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exPdfActionPerformed(evt); - } - }); - - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); - jPanel2.setLayout(jPanel2Layout); - jPanel2Layout.setHorizontalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(exPdf, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(exHtml, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)) - .addContainerGap()) - ); - jPanel2Layout.setVerticalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addGap(18, 18, 18) - .addComponent(exHtml) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(exPdf) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - outputPlaceBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Below code", "Above code", "No" })); - outputPlaceBox.setSelectedIndex(2); - - jLabel5.setText("Include output:"); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel5) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(outputPlaceBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel1) - .addGap(18, 18, 18) - .addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) - .addComponent(jLabel3)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(authBox) - .addComponent(dateBox)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jButton1)) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(5, 5, 5) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1) - .addComponent(jLabel4) - .addComponent(jButton1)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jScrollPane2) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(authBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(dateBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel3)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel5) - .addComponent(outputPlaceBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(0, 0, Short.MAX_VALUE))) - .addGap(0, 0, Short.MAX_VALUE)) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(0, 0, 0)) - ); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 10, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - - pack(); - }// //GEN-END:initComponents - - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed - html = genHtml(origCode); - previewPane.setText(html); - previewPane.setCaretPosition(0); - }//GEN-LAST:event_jButton1ActionPerformed - - private void exHtmlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exHtmlActionPerformed - doSave("html"); - }//GEN-LAST:event_exHtmlActionPerformed - - private void exPdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exPdfActionPerformed - doSave("pdf"); - }//GEN-LAST:event_exPdfActionPerformed - - private void doSave(String format) { - html = genHtml(origCode); - JFileChooser fc = new JFileChooser(); - FileFilter filter; - switch (format) { - case "pdf": - filter = new FileNameExtensionFilter("Portable Document Format (PDF)", "pdf"); - break; - default: - filter = new FileNameExtensionFilter("Web Document (HTML)", "html"); - } - fc.setFileFilter(filter); - fc.addChoosableFileFilter(filter); - int r = fc.showSaveDialog(this); - if (r == JFileChooser.APPROVE_OPTION) { - String file = FileUtils.getFileWithExtension(fc).getAbsolutePath(); - switch (format) { - case "html": - saveFile(html, file); - break; - case "pdf": - savePdfFile(html, file); - break; - } - } - } - - private void savePdfFile(String html, String path) { - try { - String k = html; - try (OutputStream file = new FileOutputStream(new File(path))) { - Document document = new Document(); - PdfWriter.getInstance(document, file); - document.open(); - HTMLWorker htmlWorker = new HTMLWorker(document); - StyleSheet styles = new StyleSheet(); - styles.loadStyle("com", "color", "green"); - styles.loadStyle("kwd", "color", "blue"); - styles.loadStyle("pln", "color", "black"); - styles.loadStyle("lit", "color", "#0099cc"); - styles.loadStyle("pun", "color", "black"); - styles.loadStyle("pun", "font-weight", "bold"); - htmlWorker.setStyleSheet(styles); - htmlWorker.parse(new StringReader(k)); - document.close(); - savedMsg(); - } - } catch (IOException | DocumentException e) { - JOptionPane.showInternalMessageDialog(this, "Error saving: " + e.getMessage()); - } - } - - private void saveFile(String content, String path) { - try { - PrintStream out = new PrintStream(new FileOutputStream(path)); - out.print(content); - savedMsg(); - } catch (Exception ex) { - JOptionPane.showInternalMessageDialog(this, "Error saving: " + ex.getMessage()); - } - } - - private void savedMsg() { - JOptionPane.showInternalMessageDialog(this, "Export complete!"); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextField authBox; - private javax.swing.JTextField dateBox; - private javax.swing.JButton exHtml; - private javax.swing.JButton exPdf; - private javax.swing.JTextArea headerBox; - private javax.swing.JButton jButton1; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JComboBox outputPlaceBox; - private javax.swing.JTextPane previewPane; - private javax.swing.JTextField titleBox; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/CodeRunner.java b/src/net/apocalypselabs/symat/CodeRunner.java index d436f18..87ff6af 100644 --- a/src/net/apocalypselabs/symat/CodeRunner.java +++ b/src/net/apocalypselabs/symat/CodeRunner.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -313,309 +312,3 @@ public class CodeRunner { return text; } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import javax.swing.JOptionPane; - -/** - * - * @author Skylar - */ -public class CodeRunner { - - private ScriptEngine se; - private StringWriter sw = new StringWriter(); - private PrintWriter pw = new PrintWriter(sw); - private String modules = ""; - private String moduleterm = ""; - - // If we need to wrap code around input to make everything nice. - private boolean wrapRequired = false; - // What codez are we speaking? - private String scriptLang = ""; - - public CodeRunner() { - this("javascript"); - } - - public CodeRunner(int lang) { - this(lang == 0 ? "js" : "py"); - } - - public CodeRunner(String lang) { - scriptLang = lang; - switch (lang) { - case "javascript": - case "js": - case "rhino": - scriptLang = "javascript"; - se = new ScriptEngineManager().getEngineByName("rhino"); - wrapRequired = true; - try { - // Add custom functions. - se.eval("importClass(net.apocalypselabs.symat.Functions);" - + "SyMAT_Functions = new net.apocalypselabs.symat.Functions();" - + "SyMAT_Functions.setLang('js');\n" - + getFunctions("js") - + loadToolkits()); - // Allow engine access from scripts. - se.put("engine", se); - attachWriters(); - } catch (Exception ex) { - initError(ex); - } - break; - case "python": - case "jython": - case "py": - scriptLang = "python"; - se = new ScriptEngineManager().getEngineByName("python"); - try { - se.eval("from math import *\n" - + "from net.apocalypselabs.symat import Functions\n" - + "_=Functions()\n" - + "_.setLang('py')\n\n" - + getFunctions("py") - + loadToolkits()); - // Allow engine access from scripts. - se.put("engine", se); - attachWriters(); - } catch (Exception ex) { - initError(ex); - } - break; - default: - throw new UnsupportedOperationException("Script language " + lang + " not supported."); - } - } - - public static List loadResources(final String name, - final ClassLoader classLoader) throws IOException { - final List list = new ArrayList(); - final Enumeration systemResources - = (classLoader == null ? ClassLoader.getSystemClassLoader() : classLoader) - .getResources(name); - while (systemResources.hasMoreElements()) { - list.add(systemResources.nextElement().openStream()); - } - return list; - } - - private String loadToolkits() { - String out = ""; - try { - List il = loadResources("meta.txt", null); - InputStream[] ii = new InputStream[il.size()]; - for (InputStream i : il.toArray(ii)) { - BufferedReader br = new BufferedReader(new InputStreamReader(i)); - while (br.ready()) { - String l = br.readLine(); - if (l.contains("=")) { - String classname = l.split("=")[0]; - String varname = l.split("=")[1]; - if (scriptLang.equals("javascript")) { - out += "importClass(" + classname + ");" - + varname + " = new " + classname + "();"; - } else { - out += "from " - + classname.substring(0, classname.lastIndexOf(".")) - + " import " + classname.substring(classname.lastIndexOf(".") + 1) + "\n" - + varname + " = " + classname.substring(classname.lastIndexOf(".") + 1) + "()\n"; - } - } - } - } - } catch (Exception ex) { - - } - Debug.println(out); - return out; - } - - @Deprecated - public CodeRunner(String lang, boolean shell) { - this(lang); - } - - private void attachWriters() { - se.getContext().setWriter(pw); - se.getContext().setErrorWriter(pw); - Debug.println("Attached writers."); - } - - /** - * Inits the Python engine on application start. - * - * @param fakeInit Set it to true. - */ - public CodeRunner(boolean fakeInit) { - if (fakeInit) { - se = new ScriptEngineManager().getEngineByName("python"); - } - } - - public StringWriter getStringWriter() { - return sw; - } - - public PrintWriter getPrintWriter() { - return pw; - } - - public String getBufferDump() { - String dump = sw.toString(); - sw.getBuffer().setLength(0); - return dump; - } - - private void initError(Exception ex) { - JOptionPane.showMessageDialog(null, "Error: " - + "Could not properly initialize " + scriptLang + " scripting engine." - + "\n\nSome functions may not work.\n\n" - + "(" + ex.getMessage() + ")"); - } - - /** - * Parse a String of code. - * - * @param eval A String of code to evaluate. - * @return the result. - */ - public Object evalString(String eval) { - try { - Object res = se.eval(wrapMath(eval)); - if (res == null) { - res = ""; - } - String result = res + sw.getBuffer().toString().trim(); - sw.getBuffer().setLength(0); - return result; - } catch (ScriptException ex) { - return formatEx(ex); - } - } - - /** - * Parse code and use the default output writers. - * - * @param eval A String of code to evaluate. - */ - public void evalCode(String eval) { - try { - Object res = se.eval(wrapMath(eval)); - if (res == null) { - res = ""; - } - } catch (ScriptException ex) { - sw.append(formatEx(ex)); - } - } - - private String formatEx(ScriptException ex) { - String err = ex.getMessage(); - //err = err.replace("sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: ", ""); - //err = err.replace("", "file"); - //err = err.replace("sun.org.mozilla.javascript.internal.EvaluatorException: ", ""); - return "Error: " + err; - } - - /** - * Allows use of Math.blah() as just blah(). Also gives access to SyMAT Java - * functions. - * - * @param eval input string - * @return wrapped input - */ - private String wrapMath(String eval) { - if (wrapRequired) { - String with = "with(SyMAT_Functions){with(Math){" + eval + "}}"; - Debug.println(with); - return with; - } - return eval; - } - - public void setVar(String var, Object val) { - se.put(var, val); - } - - public Object getVar(String var) { - return se.get(var); - } - - private String getFunctions(String lang) { - String text = ""; - try { - BufferedReader reader = new BufferedReader( - new InputStreamReader( - CodeRunner.class - .getResourceAsStream("functions." + lang))); - String line; - while ((line = reader.readLine()) != null) { - text += line + "\n"; - } - } catch (Exception e) { - } - return text; - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Debug.java b/src/net/apocalypselabs/symat/Debug.java index 38d7adf..ea87e8e 100644 --- a/src/net/apocalypselabs/symat/Debug.java +++ b/src/net/apocalypselabs/symat/Debug.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -118,78 +117,3 @@ public class Debug { } } } -======= -/* - * This class is public domain because it is standalone and - * is potentially useful to other projects. - * - * If this cannot be placed in the public domain, it is licensed under - * the Creative Commons Zero license. - * - * Feel free to use it however you wish! - */ -package net.apocalypselabs.symat; - -/** - * This class handles debug logging, so it's easy to disable. - * - * @author Skylar - */ -public class Debug { - - // If output should be on or off - public static boolean debug = true; - - /** - * Turn debug output on and off. - * - * @param b - */ - public static void setDebug(boolean b) { - debug = b; - } - - /** - * Check if debug output is enabled. - * - * @return true if it is. - */ - public static boolean getDebug() { - return debug; - } - - /** - * Call System.out.println(data) if debug output enabled. - * - * @param data Data to print. - */ - public static void println(Object data) { - if (debug) { - System.out.println(data); - } - } - - /** - * Call System.err.println(data) if debug output enabled. - * - * @param data Data to print. - */ - public static void printerr(Object data) { - if (debug) { - System.err.println(data); - } - } - - /** - * Call e.printStackTrace() if debug output enabled. - * - * @param e an Exception. - */ - @SuppressWarnings(value = {"CallToPrintStackTrace"}) - public static void stacktrace(Exception e) { - if (debug) { - e.printStackTrace(); - } - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Editor.java b/src/net/apocalypselabs/symat/Editor.java index afcd01d..27f2124 100644 --- a/src/net/apocalypselabs/symat/Editor.java +++ b/src/net/apocalypselabs/symat/Editor.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -1053,1049 +1052,3 @@ public class Editor extends javax.swing.JInternalFrame { private javax.swing.JMenuItem undoBtn; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Component; -import java.awt.Font; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import org.fife.ui.autocomplete.AutoCompletion; -import org.fife.ui.autocomplete.CompletionProvider; -import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; -import org.fife.ui.rsyntaxtextarea.SyntaxConstants; -import org.fife.ui.rsyntaxtextarea.Theme; -import org.fife.ui.rtextarea.RTextScrollPane; - -/** - * - * @author Skylar - */ -public class Editor extends javax.swing.JInternalFrame { - - private CodeRunner cr; - private RunThread rt; - private UpdateOutput uo; - - private final JFileChooser fc = new JFileChooser(); - private boolean isSaved = false; - private RSyntaxTextArea codeBox = new RSyntaxTextArea(); - private final RTextScrollPane sp; - private boolean fileChanged = false; - - private CompletionProvider jscomp = new CodeCompleter("js").getProvider(); - private CompletionProvider pycomp = new CodeCompleter("py").getProvider(); - private AutoCompletion jsac = new AutoCompletion(jscomp); - private AutoCompletion pyac = new AutoCompletion(pycomp); - - private File filedata; - - private int font_size = 12; - - /** - * @param python If true sets to Python - */ - public Editor(boolean python) { - initComponents(); - - FileFilter filter = new FileNameExtensionFilter("JavaScript (syjs, js)", "syjs", "js"); - fc.setFileFilter(filter); - fc.addChoosableFileFilter(filter); - fc.addChoosableFileFilter(new FileNameExtensionFilter( - "Python (sypy, py)", "sypy", "py")); - fc.addChoosableFileFilter(new FileNameExtensionFilter( - "Plain Text (txt, text)", "txt", "text")); - - try { - font_size = Integer.valueOf(PrefStorage.getSetting("editfont")); - } catch (Exception ex) { - Debug.printerr("Font size error!"); - } - codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size)); - outputBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size)); - - loadTheme(); - - codeBox.setCodeFoldingEnabled(true); - codeBox.setAntiAliasingEnabled(true); - sp = new RTextScrollPane(codeBox); - sp.setFoldIndicatorEnabled(true); - editPanel.add(sp); - codeBox.addMouseListener(new java.awt.event.MouseAdapter() { - @Override - public void mouseClicked(java.awt.event.MouseEvent evt) { - formMouseClicked(evt); - } - }); - - if (python) { - pyac.install(codeBox); - javascriptOption.setSelected(false); - pythonOption.setSelected(true); - codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON); - } else { - jsac.install(codeBox); - codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); - } - sp.setVisible(true); - codeBox.setVisible(true); - codeBox.requestFocus(); - - codeBox.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void changedUpdate(DocumentEvent e) { - changed(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - changed(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - changed(); - } - - public void changed() { - fileChanged = true; - } - }); - } - - /** - * @param text Text to load. - */ - public Editor(String text) { - this(); - codeBox.setText(text); - } - - /** - * - * @param text Text to load - * @param openSaveDialog If true, prompts for save immediately - */ - public Editor(String text, boolean openSaveDialog) { - this(text); - if (openSaveDialog) { - saveAsMenuActionPerformed(null); - } - } - - public Editor() { - this(false); - } - - /** - * Show open dialog. - * - * @param openfile Nothing to see here, move along. - */ - public Editor(int openfile) { - this(""); - openMenuActionPerformed(null); - } - - private void setEditorTheme(String themeName) { - try { - Theme theme - = Theme.load( - Editor.class. - getResourceAsStream( - "resources/" + themeName + ".xml"), - new Font(Font.MONOSPACED, Font.PLAIN, font_size)); - theme.apply(codeBox); - } catch (Exception e) { - } - } - - private void loadTheme() { - outputBox.setBackground(net.apocalypselabs.symat.Theme.boxColor()); - outputBox.setForeground(net.apocalypselabs.symat.Theme.textColor()); - setBackground(net.apocalypselabs.symat.Theme.windowColor()); - setEditorTheme(net.apocalypselabs.symat.Theme.editorTheme()); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jMenuItem4 = new javax.swing.JMenuItem(); - jMenuBar2 = new javax.swing.JMenuBar(); - jMenu3 = new javax.swing.JMenu(); - jMenu4 = new javax.swing.JMenu(); - langBtnGroup = new javax.swing.ButtonGroup(); - jPanel1 = new javax.swing.JPanel(); - jSplitPane1 = new javax.swing.JSplitPane(); - outputPanel = new javax.swing.JPanel(); - jLabel1 = new javax.swing.JLabel(); - jScrollPane1 = new javax.swing.JScrollPane(); - outputBox = new javax.swing.JTextArea(); - clearBtn = new javax.swing.JButton(); - editPanel = new javax.swing.JPanel(); - jMenuBar1 = new javax.swing.JMenuBar(); - fileMenu = new javax.swing.JMenu(); - openMenu = new javax.swing.JMenuItem(); - openSampleBtn = new javax.swing.JMenu(); - sampleHelloWorld = new javax.swing.JMenuItem(); - sampleGraph = new javax.swing.JMenuItem(); - saveMenu = new javax.swing.JMenuItem(); - saveAsMenu = new javax.swing.JMenuItem(); - jMenu1 = new javax.swing.JMenu(); - exportMenu = new javax.swing.JMenuItem(); - packPluginMenu = new javax.swing.JMenuItem(); - shareMenu = new javax.swing.JMenuItem(); - shareAsMenu = new javax.swing.JMenuItem(); - editMenu = new javax.swing.JMenu(); - undoBtn = new javax.swing.JMenuItem(); - redoBtn = new javax.swing.JMenuItem(); - jSeparator1 = new javax.swing.JPopupMenu.Separator(); - cutBtn = new javax.swing.JMenuItem(); - copyBtn = new javax.swing.JMenuItem(); - pasteBtn = new javax.swing.JMenuItem(); - runMenu = new javax.swing.JMenu(); - runCodeBtn = new javax.swing.JMenuItem(); - killButton = new javax.swing.JMenuItem(); - codeLangMenu = new javax.swing.JMenu(); - javascriptOption = new javax.swing.JRadioButtonMenuItem(); - pythonOption = new javax.swing.JRadioButtonMenuItem(); - - jMenuItem4.setText("jMenuItem4"); - - jMenu3.setText("File"); - jMenuBar2.add(jMenu3); - - jMenu4.setText("Edit"); - jMenuBar2.add(jMenu4); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Editor"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/editor.png"))); // NOI18N - setMinimumSize(new java.awt.Dimension(125, 50)); - setPreferredSize(new java.awt.Dimension(550, 375)); - addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - formMouseClicked(evt); - } - }); - - jSplitPane1.setDividerLocation(200); - jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); - jSplitPane1.setResizeWeight(0.7); - - jLabel1.setText("Output:"); - - outputBox.setEditable(false); - outputBox.setColumns(20); - outputBox.setLineWrap(true); - outputBox.setRows(3); - outputBox.setWrapStyleWord(true); - outputBox.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - outputBoxMouseClicked(evt); - } - }); - jScrollPane1.setViewportView(outputBox); - - clearBtn.setText("Clear"); - clearBtn.setToolTipText(""); - clearBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - clearBtnActionPerformed(evt); - } - }); - - javax.swing.GroupLayout outputPanelLayout = new javax.swing.GroupLayout(outputPanel); - outputPanel.setLayout(outputPanelLayout); - outputPanelLayout.setHorizontalGroup( - outputPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(outputPanelLayout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(clearBtn)) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) - ); - outputPanelLayout.setVerticalGroup( - outputPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(outputPanelLayout.createSequentialGroup() - .addGroup(outputPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1) - .addComponent(clearBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(0, 0, 0) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)) - ); - - jSplitPane1.setRightComponent(outputPanel); - - editPanel.setLayout(new java.awt.BorderLayout()); - jSplitPane1.setLeftComponent(editPanel); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane1) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane1) - ); - - fileMenu.setText("File"); - - openMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); - openMenu.setText("Open..."); - openMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - openMenuActionPerformed(evt); - } - }); - fileMenu.add(openMenu); - - openSampleBtn.setText("Open Code Sample"); - - sampleHelloWorld.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_1, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); - sampleHelloWorld.setText("helloworld"); - sampleHelloWorld.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - sampleHelloWorldActionPerformed(evt); - } - }); - openSampleBtn.add(sampleHelloWorld); - - sampleGraph.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_2, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); - sampleGraph.setText("graph"); - sampleGraph.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - sampleGraphActionPerformed(evt); - } - }); - openSampleBtn.add(sampleGraph); - - fileMenu.add(openSampleBtn); - - saveMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); - saveMenu.setText("Save..."); - saveMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveMenuActionPerformed(evt); - } - }); - fileMenu.add(saveMenu); - - saveAsMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); - saveAsMenu.setText("Save as..."); - saveAsMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveAsMenuActionPerformed(evt); - } - }); - fileMenu.add(saveAsMenu); - - jMenu1.setText("Publish"); - jMenu1.setToolTipText(""); - - exportMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK)); - exportMenu.setText("Export code"); - exportMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exportMenuActionPerformed(evt); - } - }); - jMenu1.add(exportMenu); - - packPluginMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); - packPluginMenu.setText("Package as plugin"); - packPluginMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - packPluginMenuActionPerformed(evt); - } - }); - jMenu1.add(packPluginMenu); - - fileMenu.add(jMenu1); - - shareMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.CTRL_MASK)); - shareMenu.setText("Share..."); - shareMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - shareMenuActionPerformed(evt); - } - }); - fileMenu.add(shareMenu); - - shareAsMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); - shareAsMenu.setText("Share as..."); - shareAsMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - shareAsMenuActionPerformed(evt); - } - }); - fileMenu.add(shareAsMenu); - - jMenuBar1.add(fileMenu); - - editMenu.setText("Edit"); - - undoBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK)); - undoBtn.setText("Undo"); - undoBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - undoBtnActionPerformed(evt); - } - }); - editMenu.add(undoBtn); - - redoBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.CTRL_MASK)); - redoBtn.setText("Redo"); - redoBtn.setToolTipText(""); - redoBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - redoBtnActionPerformed(evt); - } - }); - editMenu.add(redoBtn); - editMenu.add(jSeparator1); - - cutBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); - cutBtn.setText("Cut"); - cutBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cutBtnActionPerformed(evt); - } - }); - editMenu.add(cutBtn); - - copyBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); - copyBtn.setText("Copy"); - copyBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - copyBtnActionPerformed(evt); - } - }); - editMenu.add(copyBtn); - - pasteBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); - pasteBtn.setText("Paste"); - pasteBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - pasteBtnActionPerformed(evt); - } - }); - editMenu.add(pasteBtn); - - jMenuBar1.add(editMenu); - - runMenu.setText("Run"); - - runCodeBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0)); - runCodeBtn.setText("Run code"); - runCodeBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - runCodeBtnActionPerformed(evt); - } - }); - runMenu.add(runCodeBtn); - - killButton.setText("Kill script"); - killButton.setEnabled(false); - killButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - killButtonActionPerformed(evt); - } - }); - runMenu.add(killButton); - - codeLangMenu.setText("Language"); - - javascriptOption.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_J, java.awt.event.InputEvent.CTRL_MASK)); - langBtnGroup.add(javascriptOption); - javascriptOption.setSelected(true); - javascriptOption.setText("Javascript"); - javascriptOption.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - javascriptOptionActionPerformed(evt); - } - }); - codeLangMenu.add(javascriptOption); - - pythonOption.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK)); - langBtnGroup.add(pythonOption); - pythonOption.setText("Python"); - pythonOption.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - pythonOptionActionPerformed(evt); - } - }); - codeLangMenu.add(pythonOption); - - runMenu.add(codeLangMenu); - - jMenuBar1.add(runMenu); - - setJMenuBar(jMenuBar1); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - private void openMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuActionPerformed - int r = fc.showOpenDialog(this); - if (r == JFileChooser.APPROVE_OPTION) { - try { - File f = fc.getSelectedFile(); - codeBox.setText(FileUtils.readFile(f.toString())); - isSaved = true; - filedata = f; - setTitle(f.getName()); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(this, - "Error: Cannot load file: " + ex.getMessage()); - } - } - codeBox.setCaretPosition(0); - }//GEN-LAST:event_openMenuActionPerformed - - /** - * Open a file given its path as a String. - * - * @param file The path to the file. - */ - public void openFileFromName(String file) { - try { - Debug.println(file); - File f = new File(file); - openString(FileUtils.readFile(f.getAbsolutePath()), - f.getAbsolutePath(), true); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Error: Cannot load file: " + ex.getMessage()); - Main.loadRecentFiles(); - } - } - - /** - * Open a file. - * - * @param data The file contents - * @param file Name of the file (ex. "foobar.syjs") - */ - private void openString(String data, String file, boolean saved) { - codeBox.setText(data); - isSaved = saved; - fileChanged = false; - setTitle((new File(file)).getName()); - if (file.matches(".*\\.(js|mls|symt|syjs)")) { - javascriptOption.setSelected(true); - pythonOption.setSelected(false); - codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); - pyac.uninstall(); - jsac.install(codeBox); - } else if (file.matches(".*\\.(sypy|py)")) { - javascriptOption.setSelected(false); - pythonOption.setSelected(true); - codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON); - jsac.uninstall(); - pyac.install(codeBox); - } - filedata = new File(file); - } - - private void saveMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuActionPerformed - if (!isSaved) { - int r = fc.showSaveDialog(this); - if (r == JFileChooser.APPROVE_OPTION) { - try { - filedata = FileUtils.getFileWithExtension(fc); - FileUtils.saveFile(codeBox.getText(), filedata.getAbsolutePath(), true); - isSaved = true; - fileChanged = false; - setTitle(FileUtils.getFileWithExtension(fc).getName()); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(this, - "Error: Cannot save file: " + ex.getMessage()); - } - } - } else { - try { - FileUtils.saveFile(codeBox.getText(), - filedata.getAbsolutePath(), true); - fileChanged = false; - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(this, - "Error: Cannot save file: " + ex.getMessage()); - } - } - try { - Debug.println(filedata.toString()); - Debug.println(filedata.getAbsolutePath()); - } catch (Exception ex) { - - } - }//GEN-LAST:event_saveMenuActionPerformed - - private void saveAsMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuActionPerformed - isSaved = false; // Reset saved status, force dialog - saveMenuActionPerformed(evt); - }//GEN-LAST:event_saveAsMenuActionPerformed - - private void runCodeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runCodeBtnActionPerformed - if (javascriptOption.isSelected()) { - rt = new RunThread("javascript"); - rt.start(); - } else if (pythonOption.isSelected()) { - rt = new RunThread("python"); - rt.start(); - } - }//GEN-LAST:event_runCodeBtnActionPerformed - - /** - * This thread runs the code. - */ - private class RunThread extends Thread { - - String lang = ""; - - public RunThread(String codelang) { - lang = codelang; - } - - @Override - public void run() { - if (filedata == null && codeBox.getText().contains("//include ")) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "You must save this file before using file includes!", - "Save Required", - JOptionPane.WARNING_MESSAGE); - return; - } - setRunning(true); - execCode(lang); - setRunning(false); - } - } - - private void setRunning(boolean isRunning) { - final boolean running = isRunning; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (running) { - runMenu.setText("Running..."); - codeBox.setEditable(false); - for (Component mu : jMenuBar1.getComponents()) { - mu.setEnabled(false); - } - runMenu.setEnabled(true); - runCodeBtn.setEnabled(false); - codeLangMenu.setEnabled(false); - killButton.setEnabled(true); - } else { - runMenu.setText("Run"); - codeBox.setEditable(true); - for (Component mu : jMenuBar1.getComponents()) { - mu.setEnabled(true); - } - runCodeBtn.setEnabled(true); - codeLangMenu.setEnabled(true); - killButton.setEnabled(false); - } - } - }); - } - - private void execCode(String lang) { - if (!checkRequiredVersion(codeBox.getText(), lang)) { - return; - } - cr = new CodeRunner(lang); - uo = new UpdateOutput(cr); - String script = loadExternalScripts(codeBox.getText(), lang); - Debug.println(lang); - Debug.println(script); - uo.start(); - cr.evalCode(script); - uo.kill(); - } - - private class UpdateOutput extends Thread { - - private final CodeRunner cr; - private boolean keepGoing = true; - - public void kill() { - keepGoing = false; - flush(); - } - - @Override - public void run() { - while (keepGoing) { - try { - flush(); - Thread.sleep(100); - } catch (Exception ex) { - - } - } - } - - private void flush() { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - String d = cr.getBufferDump(); - if (!d.equals("")) { - outputBox.append(d); - Debug.println(d); - } - } - }); - } - - public UpdateOutput(CodeRunner c) { - cr = c; - } - } - - private boolean checkRequiredVersion(String script, String lang) { - String prefix = "//"; - if (lang.startsWith("p")) { - prefix = "##"; - } - String line = script.trim().split("\\n", 2)[0]; - if (line.startsWith(prefix + "needs ")) { - String versions = line.substring(8).trim(); - Debug.println(versions); - String min = versions; - String max = "999999999"; - if (versions.contains("-")) { - min = versions.split("-")[0]; - max = versions.split("-")[1]; - } - try { - int minNum = Integer.parseInt(min); - int maxNum = Integer.parseInt(max); - if (!(minNum <= Main.APP_CODE - && maxNum >= Main.APP_CODE)) { - JOptionPane.showInternalMessageDialog(this, "This script " - + "cannot be run on this version of SyMAT."); - return false; - } - return true; - } catch (Exception ex) { - outputBox.append("Error: Bad version selection syntax: " - + ex.getMessage() + "\n"); - } - } else { - return true; - } - return false; - } - - /** - * Load external script files, relative to the current file. - * - * @param script The file to parse for includes. - * @param lang The script language. - * @return The script modified as needed. - */ - private String loadExternalScripts(String script, String lang) { - String[] lines = script.split("\n"); - String temp; - String result = ""; - String pre = "//"; - if (lang.startsWith("p")) { - pre = "##"; - } - for (String line : lines) { - if (line.startsWith(pre + "include ") - && !line.trim().endsWith(pre + "include")) { - temp = line.split(" ", 2)[1]; - try { - line = loadExternalScripts(FileUtils.readFile( - filedata.getParent() - + "./" + temp), lang); - } catch (IOException ex) { - outputBox.append("Error: Cannot read " - + "referenced script file: " + ex.getMessage() - + "\n"); - } - } - result += line + "\n"; - } - return result; - } - - private void exportMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportMenuActionPerformed - String lang = pythonOption.isSelected() ? "python" : "js"; - Main.loadFrame(new CodeExport(codeBox.getText(), lang, outputBox.getText())); - }//GEN-LAST:event_exportMenuActionPerformed - - private void javascriptOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javascriptOptionActionPerformed - codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); - pyac.uninstall(); - jsac.install(codeBox); - }//GEN-LAST:event_javascriptOptionActionPerformed - - private void pythonOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pythonOptionActionPerformed - codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON); - jsac.uninstall(); - pyac.install(codeBox); - }//GEN-LAST:event_pythonOptionActionPerformed - - private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked - loadTheme(); - }//GEN-LAST:event_formMouseClicked - - private void outputBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_outputBoxMouseClicked - formMouseClicked(evt); - }//GEN-LAST:event_outputBoxMouseClicked - - private void sampleHelloWorldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sampleHelloWorldActionPerformed - openSample("helloworld"); - }//GEN-LAST:event_sampleHelloWorldActionPerformed - - private void sampleGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sampleGraphActionPerformed - openSample("graph"); - }//GEN-LAST:event_sampleGraphActionPerformed - - private void pasteBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pasteBtnActionPerformed - codeBox.paste(); - }//GEN-LAST:event_pasteBtnActionPerformed - - private void copyBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyBtnActionPerformed - codeBox.copy(); - }//GEN-LAST:event_copyBtnActionPerformed - - private void cutBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cutBtnActionPerformed - codeBox.cut(); - }//GEN-LAST:event_cutBtnActionPerformed - - private void clearBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearBtnActionPerformed - outputBox.setText(""); - }//GEN-LAST:event_clearBtnActionPerformed - - private void undoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_undoBtnActionPerformed - codeBox.undoLastAction(); - }//GEN-LAST:event_undoBtnActionPerformed - - private void redoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redoBtnActionPerformed - codeBox.redoLastAction(); - }//GEN-LAST:event_redoBtnActionPerformed - - private void shareMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shareMenuActionPerformed - createShared(""); - }//GEN-LAST:event_shareMenuActionPerformed - - private void shareAsMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shareAsMenuActionPerformed - String id = JOptionPane.showInternalInputDialog(this, - "Enter the pad ID to share to. " - + "If the pad exists, it will be overwritten.", - "Share", - JOptionPane.QUESTION_MESSAGE); - if (!(id == null || id.equals(""))) { - createShared(id); - } - }//GEN-LAST:event_shareAsMenuActionPerformed - - private void packPluginMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_packPluginMenuActionPerformed - Main.loadFrame(new PackagePlugin(codeBox.getText(), - javascriptOption.isSelected() ? 0 : 1 - )); - }//GEN-LAST:event_packPluginMenuActionPerformed - - private void killButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_killButtonActionPerformed - uo.kill(); - rt.stop(); - setRunning(false); - outputBox.append("" - + "\n=============" - + "\nScript killed" - + "\n=============\n"); - }//GEN-LAST:event_killButtonActionPerformed - - private void createShared(String id) { - try { - String padid = Pads.genPad(id, codeBox.getText()); - Pads.addPad(padid); - Pads.loadPad(padid); - JOptionPane.showInternalMessageDialog(this, - new SharePad(padid), - "Share Pad", - JOptionPane.PLAIN_MESSAGE); - } catch (Exception ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Could not create new pad: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - } - } - - /** - * Open a sample code file with the given name.

- * Uses the current language. - * - * @param name Name of file in codesamples package without extension - */ - private void openSample(String name) { - String ext = "js"; - if (!javascriptOption.isSelected()) { - ext = "py"; - } - String text = ""; - try { - BufferedReader reader = new BufferedReader( - new InputStreamReader( - Editor.class - .getResourceAsStream("codesamples/" + name + "." + ext))); - String line; - while ((line = reader.readLine()) != null) { - text += line + "\n"; - } - } catch (Exception e) { - text = "Error: Could not open embedded sample file."; - if (ext.equals("js")) { - text = "/* " + text + " */"; - } else { - text = "# " + text; - } - } - openString(text, name + "." + ext, false); - } - - @Override - public void doDefaultCloseAction() { - if (fileChanged == false) { - dispose(); - } else { - int p = JOptionPane.showInternalConfirmDialog(this, - "Do you want to save the file before closing?", - "Unsaved Changes", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (p == JOptionPane.NO_OPTION) { - dispose(); - } else { - saveMenuActionPerformed(null); - } - } - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton clearBtn; - private javax.swing.JMenu codeLangMenu; - private javax.swing.JMenuItem copyBtn; - private javax.swing.JMenuItem cutBtn; - private javax.swing.JMenu editMenu; - private javax.swing.JPanel editPanel; - private javax.swing.JMenuItem exportMenu; - private javax.swing.JMenu fileMenu; - private javax.swing.JLabel jLabel1; - private javax.swing.JMenu jMenu1; - private javax.swing.JMenu jMenu3; - private javax.swing.JMenu jMenu4; - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JMenuBar jMenuBar2; - private javax.swing.JMenuItem jMenuItem4; - private javax.swing.JPanel jPanel1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JPopupMenu.Separator jSeparator1; - private javax.swing.JSplitPane jSplitPane1; - private javax.swing.JRadioButtonMenuItem javascriptOption; - private javax.swing.JMenuItem killButton; - private javax.swing.ButtonGroup langBtnGroup; - private javax.swing.JMenuItem openMenu; - private javax.swing.JMenu openSampleBtn; - private javax.swing.JTextArea outputBox; - private javax.swing.JPanel outputPanel; - private javax.swing.JMenuItem packPluginMenu; - private javax.swing.JMenuItem pasteBtn; - private javax.swing.JRadioButtonMenuItem pythonOption; - private javax.swing.JMenuItem redoBtn; - private javax.swing.JMenuItem runCodeBtn; - private javax.swing.JMenu runMenu; - private javax.swing.JMenuItem sampleGraph; - private javax.swing.JMenuItem sampleHelloWorld; - private javax.swing.JMenuItem saveAsMenu; - private javax.swing.JMenuItem saveMenu; - private javax.swing.JMenuItem shareAsMenu; - private javax.swing.JMenuItem shareMenu; - private javax.swing.JMenuItem undoBtn; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/FileUtils.java b/src/net/apocalypselabs/symat/FileUtils.java index 6cdcda1..4ec2ee2 100644 --- a/src/net/apocalypselabs/symat/FileUtils.java +++ b/src/net/apocalypselabs/symat/FileUtils.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -155,151 +154,3 @@ public class FileUtils { return out; } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Scanner; -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileNameExtensionFilter; - -/** - * File Utilities. - * - * @author Skylar - */ -public class FileUtils { - - /** - * Read a UTF-8 text file. - * - * @param path Where is the file? - * @return The file contents. - * @throws IOException - */ - public static String readFile(String path) - throws IOException { - byte[] encoded = Files.readAllBytes(Paths.get(path)); - return new String(encoded, StandardCharsets.UTF_8); - } - - /** - * Returns the selected file from a JFileChooser, including the extension - * from the file filter. - * - * Credit to http://stackoverflow.com/users/964243/boann - * - * @param c The JFileChooser to extract from. - * @return duh. - */ - public static File getFileWithExtension(JFileChooser c) { - File file = c.getSelectedFile(); - if (c.getFileFilter() instanceof FileNameExtensionFilter) { - String[] exts = ((FileNameExtensionFilter) c.getFileFilter()).getExtensions(); - String nameLower = file.getName().toLowerCase(); - for (String ext : exts) { // check if it already has a valid extension - if (nameLower.endsWith('.' + ext.toLowerCase())) { - return file; // if yes, return as-is - } - } - // if not, append the first extension from the selected filter - file = new File(file.toString() + '.' + exts[0]); - } - return file; - } - - public static void saveFile(String content, String path, boolean addToRecent) - throws IOException { - try (PrintStream out = new PrintStream(new FileOutputStream(path))) { - out.print(content); - } - if (addToRecent) { - Main.addRecentFile((new File(path)).getAbsolutePath()); - } - } - - /** - * Get an MD5 hash. - * - * http://stackoverflow.com/a/6565597/2534036 - * - * @param md5 the text to hash. - * @return - */ - public static String MD5(String md5) { - try { - java.security.MessageDigest md - = java.security.MessageDigest.getInstance("MD5"); - byte[] array = md.digest(md5.getBytes()); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < array.length; ++i) { - sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); - } - return sb.toString(); - } catch (java.security.NoSuchAlgorithmException e) { - } - return null; - } - - public static String getUrl(String url) throws MalformedURLException, IOException { - String out; - try (Scanner sc = new Scanner(new URL(url).openStream(), "UTF-8")) { - out = sc.useDelimiter("\\A").next(); - } - return out; - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/FontOptions.java b/src/net/apocalypselabs/symat/FontOptions.java index 21559d0..b5aeb0b 100644 --- a/src/net/apocalypselabs/symat/FontOptions.java +++ b/src/net/apocalypselabs/symat/FontOptions.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -144,140 +143,3 @@ public class FontOptions extends javax.swing.JPanel { private javax.swing.JSpinner jSpinner1; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -/** - * - * @author Skylar - */ -public class FontOptions extends javax.swing.JPanel { - - private boolean modified = false; - - /** - * Creates new form FontOptions - */ - public FontOptions() { - initComponents(); - } - - public FontOptions(int size) { - this(); - jSpinner1.setValue(size); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jSpinner1 = new javax.swing.JSpinner(); - jLabel1 = new javax.swing.JLabel(); - - setMinimumSize(new java.awt.Dimension(110, 50)); - setPreferredSize(new java.awt.Dimension(110, 50)); - - jSpinner1.setValue(12); - jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - jSpinner1StateChanged(evt); - } - }); - - jLabel1.setText("pt"); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel1) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1)) - .addContainerGap(19, Short.MAX_VALUE)) - ); - }// //GEN-END:initComponents - - private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged - if ((int) jSpinner1.getValue() <= 0) { - jSpinner1.setValue(1); - } else if ((int) jSpinner1.getValue() > 64) { - jSpinner1.setValue(64); - } - modified = true; - }//GEN-LAST:event_jSpinner1StateChanged - - public int getResult() { - return (int) jSpinner1.getValue(); - } - - public boolean isModified() { - return modified; - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel jLabel1; - private javax.swing.JSpinner jSpinner1; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Functions.java b/src/net/apocalypselabs/symat/Functions.java index ffca750..bf7d83f 100644 --- a/src/net/apocalypselabs/symat/Functions.java +++ b/src/net/apocalypselabs/symat/Functions.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -1306,1302 +1305,3 @@ public class Functions { } } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import static java.lang.Math.*; -import java.lang.reflect.Array; -import java.math.BigInteger; -import java.net.URL; -import java.security.SecureRandom; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.prefs.Preferences; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import static net.apocalypselabs.symat.Main.API_URL; -import net.apocalypselabs.symat.components.TextBox; -import org.matheclipse.core.eval.EvalUtilities; -import org.matheclipse.core.interfaces.IExpr; -import org.matheclipse.parser.client.math.MathException; -import org.mozilla.javascript.NativeArray; -import org.python.core.PyList; - -/** - * These functions are accessible from JavaScript. - * - * There are a lot of aliases in here too. - * - * @author Skylar - */ -public class Functions { - - public static final HashMap GLOBALS = new HashMap<>(); - - private final EvalUtilities util = new EvalUtilities(true, true); - Graph graphwin = new Graph(true); - - private String lang = "py"; - - private final SecureRandom rng = new SecureRandom(); - - /* - Useful interactions - */ - /** - * Display a message dialog box. - * - * @param message The message to give. - */ - public void notify(Object message) { - JOptionPane.showInternalMessageDialog(Main.mainPane, message.toString()); - } - - /** - * Display message dialog. - * - * This is an alias to help JavaScript programmers. - * - * @param message The message - */ - public void alert(Object message) { - notify(message); - } - - /** - * Display an input dialog box with a text field. - * - * @param question Text to label dialog - * @return The inputted text - */ - public String ask(String question) { - return JOptionPane.showInternalInputDialog(Main.mainPane, question); - } - - /** - * Pause execution for the specified number of milliseconds. - * - * @param millis - */ - public void pause(long millis) { - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - // Nothing to do. - } - } - - /** - * @see pause() - * @param millis - */ - public void sleep(long millis) { - pause(millis); - } - - /** - * Quit SyMAT. - */ - public void quitApplication() { - System.exit(0); - } - - /* - Math commands - */ - /** - * Find the factorial (n!) of a number. - * - * @param n positive integer - * @return n! as String - * @throws net.apocalypselabs.symat.BadInputException - */ - public String factorial(long n) throws BadInputException { - if (n <= 0) { - throw new BadInputException("Input must be greater than zero!"); - } - - BigInteger inc = new BigInteger("1"); - BigInteger fact = new BigInteger("1"); - - for (long c = 1; c <= n; c++) { - fact = fact.multiply(inc); - inc = inc.add(BigInteger.ONE); - } - return fact.toString(); - } - - /** - * Take (a^b) mod m. If b is -1, finds the modular inverse of a mod m. - * - * @param a Number - * @param b Exponent - * @param m Modulus - * @return pow(a,b)%m. - */ - public double powermod(double a, double b, double m) { - if (b == -1) { - BigInteger in = new BigInteger(String.valueOf((int) a)); - return in.modInverse(new BigInteger(String.valueOf((int) m))).doubleValue(); - } - return (pow(a, b) % m + m) % m; - } - - /** - * Take (a^b) mod m. If b is -1, finds the modular inverse of a mod m. - * - * @param a Number - * @param b Exponent - * @param m Modulus - * @return pow(a,b)%m. - */ - public String powermod(String a, String b, String m) { - BigInteger in = new BigInteger(a); - if (b.equals("-1")) { - return in.modInverse(new BigInteger(m)).toString(); - } - return in.modPow(new BigInteger(b), new BigInteger(m)).toString(); - } - - public long gcd(long a, long b) { - if (b == 0) { - return a; - } - return gcd(b, a % b); - } - - public String gcd(String a, String b) { - return (new BigInteger(a).gcd(new BigInteger(b)).toString()); - } - - /** - * Differentiate the function with respect to idv. - * - * @param function Function - * @param idv independent variable - * @return Differentiated function - */ - public String diff(String function, String idv) { - return util.evaluate("diff(" + function + "," + idv + ")").toString(); - } - - /** - * Differentiate the function with respect to x. - * - * @param function Function - * @return Differentiated function - */ - public String diff(String function) { - // Assume "x" as var - return diff(function, "x"); - } - - @Deprecated - public String D(String function, String idv) { - return diff(function, idv); - } - - public double[] solve(String function, String idv, int eq) { - String res = $("Solve[" + function + "==" + eq + ", " + idv + "]"); - res = res.substring(1, res.length() - 1); - String[] cmp = res.split(","); - for (int i = 0; i < cmp.length; i++) { - cmp[i] = cmp[i].replace("{" + idv + "->", ""); - cmp[i] = cmp[i].replace("}", ""); - } - double[] out = new double[cmp.length]; - for (int i = 0; i < cmp.length; i++) { - try { - if (cmp[i].contains("I")) { - if (cmp[i].contains("-I")) { - out[i] = Double.NEGATIVE_INFINITY; - } else { - out[i] = Double.POSITIVE_INFINITY; - } - } else { - out[i] = Double.parseDouble(cmp[i]); - } - } catch (Exception ex) { - return new double[]{Double.NaN}; - } - } - return out; - } - - public double[] solve(String function, String idv) { - return solve(function, idv, 0); - } - - public double[] solve(String function) { - return solve(function, "x"); - } - - private String printa(double[] o) { - String out = "["; - for (int i = 0; i < o.length; i++) { - out += o[i] + (i == o.length - 1 ? "" : ", "); - } - out += "]"; - return out; - } - - private String printa(int[] o) { - String out = "["; - for (int i = 0; i < o.length; i++) { - out += o[i] + (i == o.length - 1 ? "" : ", "); - } - out += "]"; - return out; - } - - private String printa(boolean[] o) { - String out = "["; - for (int i = 0; i < o.length; i++) { - out += (o[i] ? "true" : "false") + (i == o.length - 1 ? "" : ", "); - } - out += "]"; - return out; - } - - public String printa(Object o) { - String out = "["; - if (o instanceof int[]) { - int[] arr = (int[]) o; - for (int i = 0; i < arr.length; i++) { - out += arr[i] + (i == arr.length - 1 ? "" : ", "); - } - } else if (o instanceof double[]) { - double[] arr = (double[]) o; - for (int i = 0; i < arr.length; i++) { - out += arr[i] + (i == arr.length - 1 ? "" : ", "); - } - } else if (o instanceof boolean[]) { - double[] arr = (double[]) o; - for (int i = 0; i < arr.length; i++) { - out += arr[i] + (i == arr.length - 1 ? "" : ", "); - } - } else if (o instanceof int[][]) { - int[][] arr = (int[][]) o; - for (int i = 0; i < arr.length; i++) { - out += printa(arr[i]) + (i == arr.length - 1 ? "" : ", "); - } - } else if (o instanceof double[][]) { - double[][] arr = (double[][]) o; - for (int i = 0; i < arr.length; i++) { - out += printa(arr[i]) + (i == arr.length - 1 ? "" : ", "); - } - } else if (o instanceof boolean[][]) { - boolean[][] arr = (boolean[][]) o; - for (int i = 0; i < arr.length; i++) { - out += printa(arr[i]) + (i == arr.length - 1 ? "" : ", "); - } - } else if (o instanceof NativeArray) { - NativeArray arr = (NativeArray) o; - for (long i = 0; i < arr.getLength(); i++) { - - out += (arr.get(i) instanceof NativeArray ? printa(arr.get(i)) - : arr.get(i).toString()) - + (i == arr.getLength() - 1 ? "" : ", "); - } - } else if (o instanceof PyList) { - PyList arr = (PyList) o; - Object[] oo = arr.toArray(); - for (int i = 0; i < oo.length; i++) { - out += (oo[i] instanceof Object[] ? printa(oo[i]) : oo[i].toString()) - + (i == oo.length - 1 ? "" : ", "); - } - } else { - Object[] arr = (Object[]) o; - for (int i = 0; i < arr.length; i++) { - out += (arr[i] instanceof Object[] ? printa(arr[i]) : arr[i].toString()) - + (i == arr.length - 1 ? "" : ", "); - } - } - out += "]"; - return out; - } - - /** - * Integrate the function with respect to idv. - * - * @param function Function - * @param idv independent variable - * @return Integrated function - */ - public String integrate(String function, String idv) { - return util.evaluate("integrate(" + function + "," + idv + ")").toString(); - } - - /** - * Integrate the function with respect to x. - * - * @param function Function - * @return Integrated function - */ - public String integrate(String function) { - return integrate(function, "x"); - } - - public String factor(String function) { - return sym("Factor(" + function + ")"); - } - - /** - * Simplify the given expression. - * - * @param expr expression - * @return simplified expression - */ - public String simplify(String expr) { - return sym("Simplify(" + expr + ")"); - } - - public Object vpa(String expr) { - IExpr ans = util.evaluate("N(" + expr + ")"); - if (ans.isNumber()) { - return Double.parseDouble(ans.toString()); - } - return ans.toString(); - } - - public int[] primes(int in) { - boolean[] prime = new boolean[in]; - for (int i = 0; i < prime.length; i++) { - prime[i] = true; - } - for (int i = 2; i < sqrt(in); i++) { - if (prime[i]) { - int x = 0; - for (int j = i * i; j < in; j = i * i + x * i) { - prime[j] = false; - x++; - } - } - } - List arr = new ArrayList<>(); - for (int i = 2; i < prime.length; i++) { - if (prime[i]) { - arr.add(i); - } - } - int[] out = new int[arr.size()]; - for (int i = 0; i < arr.size(); i++) { - out[i] = arr.get(i); - } - return out; - } - - public double sec(double d) { - return 1.0 / Math.cos(d); - } - - public double csc(double d) { - return 1.0 / Math.sin(d); - } - - public double cot(double d) { - return 1.0 / Math.tan(d); - } - - public double asec(double d) { - return Math.acos(1.0 / d); - } - - public double acsc(double d) { - return Math.asin(1.0 / d); - } - - public double acot(double d) { - return Math.atan(1.0 / d); - } - - public double sinh(double d) { - return Math.sinh(d); - } - - public double cosh(double d) { - return Math.cosh(d); - } - - public double tanh(double d) { - return Math.tanh(d); - } - - public double sech(double d) { - return pow(Math.cosh(d), -1); - } - - public double csch(double d) { - return pow(Math.sinh(d), -1); - } - - public double coth(double d) { - return Math.cosh(d) / Math.sinh(d); - } - - /** - * Multiplies the given numbers together. - * - * @param a numbers. Calculates first * second * third, etc. - * @return The product of the numbers or the value of input if there is only - * one input. - */ - public double times(double... a) { - double ans = 0; - for (int i = 0; i < a.length; i++) { - if (i == 0) { - ans = a[i]; - } else { - ans *= a[i]; - } - } - return ans; - } - - /** - * Multiplies the given numbers together. - * - * @param a - * @param b - * @return The product of the numbers or the value of input if there is only - * one input. - */ - public String times(String a, String b) { - return (new BigInteger(a).multiply(new BigInteger(b))).toString(); - } - - /** - * Divide the given numbers. - * - * @param a numbers. Calculates (first / second) / third, etc. - * @return The quotient of the numbers or the value of input if there is - * only one input. - */ - public double divide(double... a) { - double ans = 0; - for (int i = 0; i < a.length; i++) { - if (i == 0) { - ans = a[i]; - } else { - ans /= a[i]; - } - } - return ans; - } - - /** - * Divide the given numbers. - * - * @param a - * @param b - * @return The quotient of the numbers or the value of input if there is - * only one input. - */ - public String divide(String a, String b) { - return (new BigInteger(a).divide(new BigInteger(b))).toString(); - } - - /** - * Divide the first number by the second and return the remainder. - * - * @param a numbers. Calculates (first mod second) mod third, etc. - * @return The modulus of the numbers or the value of input if there is only - * one input. - */ - public double mod(double... a) { - double ans = 0; - for (int i = 0; i < a.length; i++) { - if (i == 0) { - ans = a[i]; - } else { - ans %= a[i]; - } - } - return ans; - } - - /** - * Divide the first number by the second and return the remainder. - * - * @param a - * @param b - * @return The modulus of the numbers or the value of input if there is only - * one input. - */ - public String mod(String a, String b) { - return (new BigInteger(a).mod(new BigInteger(b))).toString(); - } - - /** - * Add the given numbers together. - * - * @param a numbers. Calculates first + second + third, etc. - * @return The sum of the numbers or the value of input if there is only one - * input. - */ - public double add(double... a) { - double ans = 0; - for (double d : a) { - ans += d; - } - return ans; - } - - /** - * Add the given numbers together. - * - * @param a numbers. Calculates first + second + third, etc. - * @return The sum of the numbers or the value of input if there is only one - * input. - */ - public String add(String a, String b) { - return (new BigInteger(a).subtract(new BigInteger(b))).toString(); - } - - /** - * Subtract the given numbers. - * - * @param a numbers. Calculates (first - second) - third, etc. - * @return The difference of the numbers or the value of input if there is - * only one input. - */ - public double subtract(double... a) { - double ans = 0; - for (int i = 0; i < a.length; i++) { - if (i == 0) { - ans = a[i]; - } else { - ans -= a[i]; - } - } - return ans; - } - - /** - * Subtract the given numbers. - * - * @param a numbers. Calculates (first - second) - third, etc. - * @return The difference of the numbers or the value of input if there is - * only one input. - */ - public String subtract(String a, String b) { - BigInteger ans = new BigInteger(a); - ans = ans.subtract(new BigInteger(b)); - return ans.toString(); - } - - public double[][] minvert(double a[][]) { - int n = a.length; - double x[][] = new double[n][n]; - double b[][] = new double[n][n]; - int index[] = new int[n]; - for (int i = 0; i < n; ++i) { - b[i][i] = 1; - } - // Transform the matrix into an upper triangle - gaussian(a, index); - // Update the matrix b[i][j] with the ratios stored - for (int i = 0; i < n - 1; ++i) { - for (int j = i + 1; j < n; ++j) { - for (int k = 0; k < n; ++k) { - b[index[j]][k] - -= a[index[j]][i] * b[index[i]][k]; - } - } - } - // Perform backward substitutions - for (int i = 0; i < n; ++i) { - x[n - 1][i] = b[index[n - 1]][i] / a[index[n - 1]][n - 1]; - for (int j = n - 2; j >= 0; --j) { - x[j][i] = b[index[j]][i]; - for (int k = j + 1; k < n; ++k) { - x[j][i] -= a[index[j]][k] * x[k][i]; - } - x[j][i] /= a[index[j]][j]; - } - } - return x; - } - - // Method to carry out the partial-pivoting Gaussian - // elimination. Here index[] stores pivoting order. - private void gaussian(double a[][], int index[]) { - int n = index.length; - double c[] = new double[n]; - // Initialize the index - for (int i = 0; i < n; ++i) { - index[i] = i; - } - // Find the rescaling factors, one from each row - for (int i = 0; i < n; ++i) { - double c1 = 0; - for (int j = 0; j < n; ++j) { - double c0 = Math.abs(a[i][j]); - if (c0 > c1) { - c1 = c0; - } - } - c[i] = c1; - } - - // Search the pivoting element from each column - int k = 0; - for (int j = 0; j < n - 1; ++j) { - double pi1 = 0; - for (int i = j; i < n; ++i) { - double pi0 = Math.abs(a[index[i]][j]); - pi0 /= c[index[i]]; - if (pi0 > pi1) { - pi1 = pi0; - k = i; - } - } - - // Interchange rows according to the pivoting order - int itmp = index[j]; - index[j] = index[k]; - index[k] = itmp; - for (int i = j + 1; i < n; ++i) { - double pj = a[index[i]][j] / a[index[j]][j]; - // Record pivoting ratios below the diagonal - a[index[i]][j] = pj; - // Modify other elements accordingly - for (int l = j + 1; l < n; ++l) { - a[index[i]][l] -= pj * a[index[j]][l]; - } - } - } - } - - /** - * Get all prime factors of input number. - * - * @param n An integer number. - * @return Array of primes. - * - * Thanks to - * http://www.javacodegeeks.com/2014/05/how-to-find-prime-factors-of-integer-numbers-in-java-factorization.html - * and http://stackoverflow.com/a/2451219/2534036 - */ - public long[] factor(long n) { - long i; - Set primes = new HashSet<>(); - long copyOfInput = n; - - for (i = 2; i <= copyOfInput; i++) { - if (copyOfInput % i == 0) { - primes.add(i); // prime factor - copyOfInput /= i; - i--; - } - } - long[] a = new long[primes.size()]; - int j = 0; - for (Object val : primes) { - a[j++] = (long) val; - } - return a; - } - - public boolean isprime(long n) { - int i = 2; - while (i <= sqrt(n)) { - if (n % i == 0) { - return false; - } - i++; - } - return true; - } - - public boolean isprime(String nn) { - BigInteger n = new BigInteger(nn); - BigInteger i = new BigInteger("2"); - BigInteger ns = bigIntSqRootCeil(n); - while (i.compareTo(ns) <= 0) { - if (n.mod(i).toString().equals("0")) { - return false; - } - i = i.add(BigInteger.ONE); - } - return true; - } - - /** - * Thanks to http://stackoverflow.com/a/11962756/2534036 - * - * @param x - * @return - * @throws IllegalArgumentException - */ - private BigInteger bigIntSqRootCeil(BigInteger x) throws IllegalArgumentException { - if (x.compareTo(BigInteger.ZERO) < 0) { - throw new IllegalArgumentException("Negative argument."); - } - // square roots of 0 and 1 are trivial and - // y == 0 will cause a divide-by-zero exception - if (x == BigInteger.ZERO || x == BigInteger.ONE) { - return x; - } // end if - BigInteger two = BigInteger.valueOf(2L); - BigInteger y; - // starting with y = x / 2 avoids magnitude issues with x squared - for (y = x.divide(two); y.compareTo(x.divide(y)) > 0; y = ((x.divide(y)).add(y)).divide(two)) { - } - if (x.compareTo(y.multiply(y)) == 0) { - return y; - } else { - return y.add(BigInteger.ONE); - } - - } // end bigIntSqRootCeil - - /** - * Get all unique permutations of the given array. - * - * @param objs Array of items. - * @return Matrix - */ - public Object[] perms(Object... objs) { - Permutations perm = new Permutations<>(objs); - - Set perms = new HashSet<>(); - - while (perm.hasNext()) { - perms.add(perm.next()); - } - - Object[][] a = new Object[perms.size()][objs.length]; - return perms.toArray(a); - } - - /** - * Get a uniform random fraction between 0.0 (inclusive) and 1.0 - * (exclusive). - * - * @return random fraction - */ - public double rand() { - return rng.nextDouble(); - } - - /** - * Get a random boolean value. - * - * @return true or false - */ - public boolean randb() { - return rng.nextBoolean(); - } - - /** - * Get a uniform random integer. - * - * @param min Minimum value, inclusive - * @param max Maximum value, inclusive - * @return random integer - */ - public double rand(int min, int max) { - if (min == 0 && max == 0) { - return rand(); - } - return rng.nextInt((max - min) + 1) + min; - } - - /** - * Multiply two matrices. - * - * @param a First matrix - * @param b Second matrix - * @return The multiplied matrices - * @throws net.apocalypselabs.symat.BadInputException When the matrices are - * wrong. - */ - public double[][] mtimes(double[][] a, double[][] b) throws BadInputException { - double[][] ans = new double[a.length][b[0].length]; - double sum = 0; - int c, d, k, m = a.length, q = b[0].length, p = b.length; - - if (a[0].length != b.length) { - throw new BadInputException("First matrix column count must match " - + "second matrix row count."); - } - - for (c = 0; c < m; c++) { - for (d = 0; d < q; d++) { - for (k = 0; k < p; k++) { - sum = sum + a[c][k] * b[k][d]; - } - ans[c][d] = sum; - sum = 0; - } - } - return ans; - } - - /** - * Multiply the given matrix by itself b times. - * - * @param a Square matrix - * @param b Power ( >= 0 ) - * @return The matrix result - * @throws BadInputException if the matrix is not square or power is less - * than 0 - */ - public double[][] mpower(double[][] a, int b) throws BadInputException { - if (a.length != a[0].length) { - throw new BadInputException("Matrix needs to be square."); - } - if (b < 0) { - throw new BadInputException("Power cannot be negative."); - } - - double[][] ans = a; - - for (int i = 0; i < b; i++) { - if (i == 0) { - ans = a; - } else { - ans = mtimes(a, ans); - } - } - return ans; - } - - /** - * Convert the given number of degrees to radians. - * - * @param degrees Number in degrees - * @return Radians (degrees * (pi/180)) - */ - public double rad(double degrees) { - return degrees * (PI / 180); - } - - /** - * Convert the given number of radians to degrees. - * - * @param radians Number in radians - * @return Degrees (radians * (180/pi)) - */ - public double deg(double radians) { - return radians * (180 / PI); - } - - public String sym(String input) { - return util.evaluate(input).toString(); - } - - /** - * Evaluate the given text with the builtin Symja parser. - * - * @param input - * @return - */ - public String $(String input) { - return sym(input); - } - - /** - * Replace all occurrences of variable with newvar in function. - * - * @param function Text input - * @param variable Text to replace - * @param newvar Text to replace with - * @return function with text replaced. - */ - public String replace(String function, String variable, String newvar) { - return function.replaceAll(variable, newvar); - } - - /** - * Substitute newvar for variable in function and attempt to calculate a - * numerical answer. - *
Example: subs('32*x','x',2) = 64.0 - * - * @param function Function - * @param variable Variable to substitute - * @param newvar Value to replace with - * @return The numerical answer or zero if there is no numerical answer. - */ - public double subs(String function, String variable, String newvar) { - return numof(function.replaceAll(variable, newvar)); - } - - /** - * Attempt to find numerical value of input. - * - * @param f Function - * @return answer or zero if it doesn't exist - */ - public double numof(String f) { - try { - return Double.parseDouble(util.evaluate("N(" + f + ")").toString()); - } catch (MathException | NumberFormatException ex) { - return 0.0; - } - } - - /* - Graphing interfaces - */ - public void xlim(double xmin, double xmax) { - graphwin.setRange(xmin, xmax); - } - - public void plot(String function) { - showGraph(); - if (!function.equals("")) { - graphwin.graphFunction(function); - } - } - - public void plot(double[] x, double[] y) { - graphwin.plotPoints(x, y); - } - - public void plot(double[] x, double[] y, String name) { - graphwin.plotPoints(x, y, name); - } - - public void plot(String function, double xmin, double xmax) { - graphwin.setRange(xmin, xmax); - plot(function); - } - - public void ezplot(String f) { - plot(f); - } - - public void ezplot(String function, double xmin, double xmax) { - plot(function, xmin, xmax); - } - - public void graph(String f) { - plot(f); - } - - public String plotname() { - return graphwin.getTitle(); - } - - public String plotname(String t) { - if (t.equals("symatpythonnullplotname")) { - return graphwin.getTitle(); - } else { - graphwin.setWindowTitle(t); - graphwin.setLabel(t); - return ""; - } - } - - public void plot() { - showGraph(); - } - - public void plotclr() { - graphwin.clearDraw(); - } - - public void clearplot() { - plotclr(); - } - - public void plotclear() { - plotclr(); - } - - public void drawdot(double x, double y) { - showGraph(); - graphwin.drawDot(x, y); - } - - public String readfile(String path) throws IOException { - return FileUtils.readFile(path); - } - - public void savefile(String content, String path) throws IOException { - FileUtils.saveFile(content, path, false); - } - - /** - * Show a file dialog and return the path of the chosen file (or "" if - * canceled). - * - * @return - */ - public String filedialog() { - JFileChooser fc = new JFileChooser(); - int result = fc.showDialog(Main.maingui, "Choose"); - if (result == JFileChooser.APPROVE_OPTION) { - return fc.getSelectedFile().getPath(); - } - return ""; - } - - public String md5sum(String data) { - return FileUtils.MD5(data); - } - - public void save(String key, String val) { - Preferences prefs = Preferences.userNodeForPackage(Functions.class); - prefs.put(key, val); - try { - prefs.flush(); - } catch (Exception ex) { - - } - } - - public String load(String key) { - Preferences prefs = Preferences.userNodeForPackage(Functions.class); - return prefs.get(key, ""); - } - - /* - Other - */ - public String sysinfo() { - String info = "==Java Information==\n"; - info += "Java version: " + System.getProperty("java.version"); - info += "\nJava vendor: " + System.getProperty("java.vendor"); - info += "\nJava home: " + System.getProperty("java.home"); - - return info; - } - - /** - * Reset the license, quit the application. - */ - public void resetlicense() { - int result = JOptionPane.showConfirmDialog(null, - "Are you sure you want to reset your license?\n" - + "This will close SyMAT and all open files!", - "Reset license", - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (result == JOptionPane.YES_OPTION) { - PrefStorage.unset("license"); - System.exit(0); - } - } - - public String license() { - String expires = "Error"; - if (PrefStorage.getSetting("licensetype").equals("demo")) { - Calendar c = Calendar.getInstance(); - c.setTime(new Date()); - try { - long expire = Long.parseLong(PrefStorage.getSetting("license")); - long days = (((expire - c.getTimeInMillis()) / (60 * 60 * 24)) - 999) / 1000; - if (days < 0) { - if (days == -1) { - expires = "Today"; - } else { - expires = abs(days) + " days ago"; - } - } else { - expires = "In " + days + " days"; - } - } catch (NumberFormatException e) { - } - } else { - try { - URL url = new URL(API_URL + "expire.php?email=" + PrefStorage.getSetting("license")); - try (InputStream is = url.openStream(); - BufferedReader br - = new BufferedReader(new InputStreamReader(is))) { - expires = br.readLine(); - } catch (IOException ex) { - } - } catch (Exception ex) { - } - } - String lic = "==License Information==\n" - + "License: " + PrefStorage.getSetting("license") - + "\nType: " + PrefStorage.getSetting("licensetype") - + "\nExpires: " + expires; - return lic; - } - - /** - * Make sure the graph window shows. - */ - private void showGraph() { - graphwin.setVisible(true); - graphwin.toFront(); - } - - public TextBox textbox() { - return new TextBox(); - } - - public WebBrowser browser() { - return new WebBrowser(); - } - /* - Constructor. - */ - - public Functions() { - Main.loadFrame(graphwin, false); - } - - public void setLang(String l) { - lang = l; - } - - /** - * This class finds permutations of an array. - * - * Credit to http://stackoverflow.com/a/14444037/2534036 - * - * License: CC-BY-SA 3.0 - * - * @param - */ - class Permutations implements Iterator { - - private final E[] arr; - private final int[] ind; - private boolean has_next; - - public E[] output;//next() returns this array, make it public - - Permutations(E[] arr) { - this.arr = arr.clone(); - ind = new int[arr.length]; - //convert an array of any elements into array of integers - first occurrence is used to enumerate - Map hm = new HashMap<>(); - for (int i = 0; i < arr.length; i++) { - Integer n = hm.get(arr[i]); - if (n == null) { - hm.put(arr[i], i); - n = i; - } - ind[i] = n; - } - Arrays.sort(ind);//start with ascending sequence of integers - - //output = new E[arr.length]; <-- cannot do in Java with generics, so use reflection - output = (E[]) Array.newInstance(arr.getClass().getComponentType(), arr.length); - has_next = true; - } - - @Override - public boolean hasNext() { - return has_next; - } - - /** - * Computes next permutations. Same array instance is returned every - * time! - * - * @return - */ - @Override - public E[] next() { - if (!has_next) { - throw new NoSuchElementException(); - } - - for (int i = 0; i < ind.length; i++) { - output[i] = arr[ind[i]]; - } - - //get next permutation - has_next = false; - for (int tail = ind.length - 1; tail > 0; tail--) { - if (ind[tail - 1] < ind[tail]) {//still increasing - - //find last element which does not exceed ind[tail-1] - int s = ind.length - 1; - while (ind[tail - 1] >= ind[s]) { - s--; - } - - swap(ind, tail - 1, s); - - //reverse order of elements in the tail - for (int i = tail, j = ind.length - 1; i < j; i++, j--) { - swap(ind, i, j); - } - has_next = true; - break; - } - - } - return output; - } - - private void swap(int[] arr, int i, int j) { - int t = arr[i]; - arr[i] = arr[j]; - arr[j] = t; - } - - @Override - public void remove() { - - } - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Globals.java b/src/net/apocalypselabs/symat/Globals.java index a6fb1a5..7a50c0b 100644 --- a/src/net/apocalypselabs/symat/Globals.java +++ b/src/net/apocalypselabs/symat/Globals.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -326,322 +325,3 @@ public class Globals extends javax.swing.JInternalFrame { private javax.swing.JTextArea valBox; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.util.Arrays; -import javax.swing.JOptionPane; - -/** - * - * @author Skylar - */ -public class Globals extends javax.swing.JInternalFrame { - - /** - * Creates new form Globals - */ - public Globals() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - addBtn = new javax.swing.JButton(); - jPanel1 = new javax.swing.JPanel(); - jScrollPane1 = new javax.swing.JScrollPane(); - keyList = new javax.swing.JList(); - remBtn = new javax.swing.JButton(); - jPanel2 = new javax.swing.JPanel(); - jScrollPane2 = new javax.swing.JScrollPane(); - valBox = new javax.swing.JTextArea(); - refreshBtn = new javax.swing.JButton(); - saveBtn = new javax.swing.JButton(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Global Variables"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/globals.png"))); // NOI18N - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentShown(java.awt.event.ComponentEvent evt) { - formComponentShown(evt); - } - }); - - addBtn.setText("Add"); - addBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - addBtnActionPerformed(evt); - } - }); - - jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Variables")); - - keyList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - keyList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(javax.swing.event.ListSelectionEvent evt) { - keyListValueChanged(evt); - } - }); - jScrollPane1.setViewportView(keyList); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE) - .addContainerGap()) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)) - ); - - remBtn.setText("Remove"); - remBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - remBtnActionPerformed(evt); - } - }); - - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Value")); - - valBox.setColumns(1); - valBox.setRows(1); - valBox.setTabSize(4); - jScrollPane2.setViewportView(valBox); - - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); - jPanel2.setLayout(jPanel2Layout); - jPanel2Layout.setHorizontalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE) - .addContainerGap()) - ); - jPanel2Layout.setVerticalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addComponent(jScrollPane2)) - ); - - refreshBtn.setText("Refresh"); - refreshBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - refreshBtnActionPerformed(evt); - } - }); - - saveBtn.setText("Save"); - saveBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveBtnActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(addBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(remBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(saveBtn) - .addGap(37, 37, 37) - .addComponent(refreshBtn) - .addGap(0, 0, Short.MAX_VALUE))) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(addBtn) - .addComponent(remBtn) - .addComponent(refreshBtn) - .addComponent(saveBtn)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) - ); - - pack(); - }// //GEN-END:initComponents - - private void keyListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_keyListValueChanged - if (keyList.getSelectedValue() != null) { - valBox.setEditable(true); - try { - Object item = Functions.GLOBALS.get(keyList.getSelectedValue()); - /*if (item.getClass().equals(sun.org.mozilla.javascript.internal.NativeArray.class)) { - Object[] arr = ((sun.org.mozilla.javascript.internal.NativeArray) item).toArray(); - valBox.setText(Arrays.toString(arr)); - valBox.setEditable(false); - } else */ - if (item == null) { - valBox.setText(""); - valBox.setEditable(true); - } else if (item.getClass().equals(org.mozilla.javascript.NativeArray.class)) { - Object[] arr = ((org.mozilla.javascript.NativeArray) item).toArray(); - valBox.setText(Arrays.toString(arr)); - valBox.setEditable(false); -// } else if (item.getClass().equals(PyList.class)) { -// Object[] arr = ((PyList) item).toArray(); -// valBox.setText(Arrays.toString(arr)); -// valBox.setEditable(false); - } else { - valBox.setText(Functions.GLOBALS.get( - keyList.getSelectedValue()).toString()); - } - } catch (Exception ex) { - valBox.setText("error"); - valBox.setEditable(false); - Debug.stacktrace(ex); - } - } - }//GEN-LAST:event_keyListValueChanged - - private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addBtnActionPerformed - String name = JOptionPane.showInternalInputDialog(this, - "New variable name:", - "New global", - JOptionPane.PLAIN_MESSAGE); - if (name != null) { - if (!name.equals("")) { - Functions.GLOBALS.put(name, null); - refreshList(); - } - } - }//GEN-LAST:event_addBtnActionPerformed - - private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown - refreshList(); - }//GEN-LAST:event_formComponentShown - - private void remBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remBtnActionPerformed - if (keyList.getSelectedValue() != null) { - int choice = JOptionPane.showInternalConfirmDialog(this, - "Delete variable '" - + keyList.getSelectedValue().toString() + "'?", - "Delete?", - JOptionPane.YES_NO_OPTION); - if (choice == JOptionPane.YES_OPTION) { - Functions.GLOBALS.remove(keyList.getSelectedValue().toString()); - refreshList(); - } - } - }//GEN-LAST:event_remBtnActionPerformed - - private void refreshBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshBtnActionPerformed - refreshList(); - }//GEN-LAST:event_refreshBtnActionPerformed - - private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed - try { - setVar(keyList.getSelectedValue().toString(), valBox.getText()); - } catch (Exception ex) { - - } - }//GEN-LAST:event_saveBtnActionPerformed - - private void refreshList() { - keyList.setListData(Functions.GLOBALS.keySet().toArray()); - valBox.setText(""); - } - - private void setVar(String key, String val) { - try { - double value = Double.parseDouble(val); - Functions.GLOBALS.put(key, value); - } catch (Exception ex) { - Functions.GLOBALS.put(key, val); - } - refreshList(); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton addBtn; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JList keyList; - private javax.swing.JButton refreshBtn; - private javax.swing.JButton remBtn; - private javax.swing.JButton saveBtn; - private javax.swing.JTextArea valBox; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Graph.java b/src/net/apocalypselabs/symat/Graph.java index 86f891e..58893ef 100644 --- a/src/net/apocalypselabs/symat/Graph.java +++ b/src/net/apocalypselabs/symat/Graph.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -548,544 +547,3 @@ public class Graph extends javax.swing.JInternalFrame { private javax.swing.JMenuItem setTitleBtn; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.io.File; -import java.io.IOException; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import org.math.plot.plotObjects.BaseLabel; -import org.matheclipse.core.eval.EvalUtilities; - -/** - * - * @author Skylar - */ -public class Graph extends javax.swing.JInternalFrame { - - private final JFileChooser fc = new JFileChooser(); - - private boolean standalone = true; - - private BaseLabel lbl = new BaseLabel("", Color.black, 0.5, 1.1); - - // History, used for redrawing when scale changed. - private String history = ""; - - // If a graph is being drawn, set to true, else false - boolean graphing = false; - - // Graph min and max - private double xmin = -10; - private double xmax = 10; -// private double ymin = -10; -// private double ymax = 10; - - /** - * Creates new form Graph - */ - public Graph() { - init(); - } - - public Graph(boolean isInternal) { - init(); - standalone = !isInternal; - } - - private void init() { - initComponents(); - FileFilter filter = new FileNameExtensionFilter("PNG image (.png)", "png"); - fc.setFileFilter(filter); - fc.addChoosableFileFilter(filter); - plot.plotToolBar.remove(5); - plot.plotToolBar.remove(4); - plot.plotToolBar.remove(3); - lbl.setFont(new Font("Courier", Font.BOLD, 18)); - plot.addPlotable(lbl); - } - - @Override - public void doDefaultCloseAction() { - if (standalone) { - dispose(); - } else { - hide(); - } - } - - public void forceClose() { - dispose(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - inBox = new javax.swing.JTextField(); - jLabel1 = new javax.swing.JLabel(); - plotBtn = new javax.swing.JButton(); - plot = new org.math.plot.Plot2DPanel(); - jMenuBar1 = new javax.swing.JMenuBar(); - jMenu1 = new javax.swing.JMenu(); - exportBtn = new javax.swing.JMenuItem(); - jMenu2 = new javax.swing.JMenu(); - clrGraphBtn = new javax.swing.JMenuItem(); - setTitleBtn = new javax.swing.JMenuItem(); - - setClosable(true); - setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Graph"); - setToolTipText(""); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/graph.png"))); // NOI18N - setPreferredSize(new java.awt.Dimension(326, 402)); - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentShown(java.awt.event.ComponentEvent evt) { - formComponentShown(evt); - } - }); - - inBox.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - inBoxKeyTyped(evt); - } - }); - - jLabel1.setText("f(x)="); - - plotBtn.setText(">>"); - plotBtn.setToolTipText(""); - plotBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - plotBtnActionPerformed(evt); - } - }); - - plot.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - plotMouseClicked(evt); - } - }); - - jMenu1.setText("File"); - - exportBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); - exportBtn.setText("Export graph..."); - exportBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exportBtnActionPerformed(evt); - } - }); - jMenu1.add(exportBtn); - - jMenuBar1.add(jMenu1); - - jMenu2.setText("Edit"); - - clrGraphBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK)); - clrGraphBtn.setText("Clear Graph"); - clrGraphBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - clrGraphBtnActionPerformed(evt); - } - }); - jMenu2.add(clrGraphBtn); - - setTitleBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK)); - setTitleBtn.setText("Set Title..."); - setTitleBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - setTitleBtnActionPerformed(evt); - } - }); - jMenu2.add(setTitleBtn); - - jMenuBar1.add(jMenu2); - - setJMenuBar(jMenuBar1); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(inBox, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(plotBtn) - .addGap(10, 10, 10)) - .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(inBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1) - .addComponent(plotBtn)) - .addContainerGap()) - ); - - pack(); - }// //GEN-END:initComponents - - private void plotBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plotBtnActionPerformed - String[] frmlas = inBox.getText().split(";"); - for (String f : frmlas) { - new GraphThread(f).start(); - } - }//GEN-LAST:event_plotBtnActionPerformed - - /** - * Graph the graphs without holding up everything else. - */ - private class GraphThread extends Thread { - - String[] frmlas; - - public GraphThread(String frmla) { - frmlas = new String[1]; - frmlas[0] = frmla; - } - - public GraphThread(String[] frmla) { - frmlas = frmla; - } - - @Override - public void run() { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - inBox.setEnabled(false); - plotBtn.setEnabled(false); - for (Component mu : jMenuBar1.getComponents()) { - mu.setEnabled(false); - } - } - }); - for (String formula : frmlas) { - String niceformula = formula; - CodeRunner cr = new CodeRunner(); - formula = formula.replaceAll("x", "\\$x"); - EvalUtilities solver = new EvalUtilities(); - String xx = ""; - String yy = ""; - double x; - for (x = xmin; x <= xmax; x += ((xmax - xmin) / 400.0)) { - String res; - try { - cr.setVar("x", x); - res = solver.evaluate("$x=" + x + ";N[" + formula + "]").toString(); - } catch (Exception ex) { - res = "0"; - } - // Omit crazy numbers like 1/0 and stuff - try { - if (Double.parseDouble(res) > Integer.MIN_VALUE) { - xx += String.valueOf(x) + " "; - yy += res + " "; - } else { - - } - } catch (Exception ex) { - xx += String.valueOf(x) + " "; - yy += res + " "; - } - } - Debug.println(xx); - Debug.println(yy); - String[] xs = xx.trim().split(" "); - String[] ys = yy.trim().split(" "); - double[] xd = new double[xs.length]; - double[] yd = new double[ys.length]; - for (int i = 0; i < xs.length; i++) { - try { - xd[i] = Double.parseDouble(xs[i]); - } catch (Exception ex) { - xd[i] = 0.0; - } - } - for (int i = 0; i < ys.length; i++) { - try { - yd[i] = Double.parseDouble(ys[i]); - } catch (Exception ex) { - yd[i] = 0.0; - } - } - SwingUtilities.invokeLater(new Updater(niceformula, xd, yd)); - } - SwingUtilities.invokeLater(new Finisher()); - } - - private class Updater implements Runnable { - - final double[] xd; - final double[] yd; - final String formula; - - public Updater(String frmla, double[] x, double[] y) { - xd = x; - yd = y; - formula = frmla; - } - - @Override - public void run() { - plot.addLinePlot(formula, xd, yd); - history += formula + "\n"; - } - - } - - private class Finisher implements Runnable { - - @Override - public void run() { - inBox.setEnabled(true); - plotBtn.setEnabled(true); - for (Component mu : jMenuBar1.getComponents()) { - mu.setEnabled(true); - } - inBox.requestFocusInWindow(); - } - - } - } - - private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown - }//GEN-LAST:event_formComponentShown - - public void plotPoints(double[] x, double[] y) { - plotPoints(x, y, "Points"); - } - - public void plotPoints(double[] x, double[] y, String name) { - plot.addLinePlot(name, x, y); - } - - /** - * Get the zoom ratio. - * - * @param zoomLevel The zoom level to calculate from. - * @return The ratio. - */ - @Deprecated - public static double getScale(int zoomLevel) { - return 15.0; - } - - public void drawDot(double x, double y) { - double[] xpt = {x}; - double[] ypt = {y}; - - plot.addScatterPlot("", Color.BLACK, xpt, ypt); - } - - private void inBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inBoxKeyTyped - if (evt.getKeyChar() == '\n') { - plotBtn.doClick(); - } - }//GEN-LAST:event_inBoxKeyTyped - - private void clrGraphBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clrGraphBtnActionPerformed - clearDraw(); - }//GEN-LAST:event_clrGraphBtnActionPerformed - - private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportBtnActionPerformed - int result = fc.showSaveDialog(Main.mainPane); - if (result == JFileChooser.APPROVE_OPTION) { - File file = new File(addSaveExt(fc.getSelectedFile().toString())); - try { - plot.toGraphicFile(file); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(this, - "Image export failed!", - "Error", - JOptionPane.ERROR_MESSAGE); - } - } - }//GEN-LAST:event_exportBtnActionPerformed - - private void setTitleBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setTitleBtnActionPerformed - String wintitle = JOptionPane.showInternalInputDialog(this, - "New window title:", - "Rename", - JOptionPane.QUESTION_MESSAGE); - if (wintitle != null && !wintitle.equals("")) { - setWindowTitle(wintitle); - setLabel(wintitle); - } - }//GEN-LAST:event_setTitleBtnActionPerformed - - private void plotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_plotMouseClicked - - }//GEN-LAST:event_plotMouseClicked - - /** - * Get the range of the graph. - * - * @return {xmin, xmax} - */ - public double[] getRange() { - double[] range = {xmin, xmax}; - return range; - } - - public void setRange(double min, double max) { - xmin = min; - xmax = max; - - clearDraw(false); - plot.setFixedBounds(0, min, max); - if (!history.trim().equals("")) { - String temp = ""; - for (String cmd : history.trim().split("\n")) { - cmd = cmd.trim(); - if (!cmd.equals("")) { - temp += cmd + "\n"; - } - } - history = temp.trim(); - new GraphThread(history.split("\n")).start(); - inBox.setText(""); - } - } - - /** - * Graph the given function. Same as typing into input box and pressing - * Enter. - * - * @param f f(x) = f - */ - public void graphFunction(String f) { - inBox.setText(f); - plotBtnActionPerformed(null); - } - - public void setLabel(String label) { - lbl.setText(label); - } - - private String addSaveExt(String path) { - if (!path.matches(".*\\.(png)")) { - path += ".png"; - } - return path; - } - - /** - * Set the wintitle of this graph window. - * - * @param t The wintitle. - */ - public void setWindowTitle(String t) { - setTitle(t); - } - - /** - * Get the wintitle of the window. - * - * @return the wintitle, stupid! - */ - public String getWindowTitle() { - return getTitle(); - } - - /** - * Erase the graph. - */ - public void clearDraw() { - clearDraw(true); - } - - /** - * Erase the graph. - * - * @param alsoHistory True if history should be removed - */ - public void clearDraw(boolean alsoHistory) { - if (alsoHistory) { - history = ""; - } - plot.removeAllPlots(); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JMenuItem clrGraphBtn; - private javax.swing.JMenuItem exportBtn; - private javax.swing.JTextField inBox; - private javax.swing.JLabel jLabel1; - private javax.swing.JMenu jMenu1; - private javax.swing.JMenu jMenu2; - private javax.swing.JMenuBar jMenuBar1; - private org.math.plot.Plot2DPanel plot; - private javax.swing.JButton plotBtn; - private javax.swing.JMenuItem setTitleBtn; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Help.java b/src/net/apocalypselabs/symat/Help.java index b0d010f..ee372d9 100644 --- a/src/net/apocalypselabs/symat/Help.java +++ b/src/net/apocalypselabs/symat/Help.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -310,306 +309,3 @@ public class Help extends javax.swing.JInternalFrame { private javax.swing.JList topicList; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Color; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.Calendar; -import javax.swing.SwingUtilities; -import javax.swing.text.html.HTMLEditorKit; -import javax.swing.text.html.StyleSheet; - -/** - * - * @author Skylar - */ -public class Help extends javax.swing.JInternalFrame { - - /* - Some styling stuff. - */ - private final HTMLEditorKit kit; - private final StyleSheet styleSheet; - private final StyleSheet dark = new StyleSheet(); - private final StyleSheet light = new StyleSheet(); - private int styleloaded = -1; - - /** - * Creates new form Help - */ - public Help() { - kit = new HTMLEditorKit(); - initComponents(); - styleSheet = kit.getStyleSheet(); - loadStyleSheets(); - loadTheme(); - } - - /** - * Load the styles for the main box. - */ - private void loadStyleSheets() { - dark.addRule("body { background-color: #293134; }"); - dark.addRule("h1 { color: #ffffff; }"); - dark.addRule("h2 { color: #ffffff; }"); - dark.addRule("p { color: #ffffff; }"); - light.addRule("body { background-color: #ffffff; }"); - light.addRule("h1 { color: #000000; }"); - light.addRule("h2 { color: #000000; }"); - light.addRule("p { color: #000000; }"); - } - - /** - * (Re)load the theme for this window. - */ - private void loadTheme() { - if ((PrefStorage.getSetting("theme").equals("dark") && styleloaded == 0) - || (!PrefStorage.getSetting("theme").equals("dark") && styleloaded == 1)) { - styleloaded = -1; - } - if (styleloaded == -1) { - if (PrefStorage.getSetting("theme").equals("dark")) { - topicList.setBackground(new Color(41, 49, 52)); - topicList.setForeground(Color.WHITE); - styleSheet.addStyleSheet(dark); - styleSheet.removeStyleSheet(light); - setBackground(Color.DARK_GRAY); - styleloaded = 1; - } else { - topicList.setBackground(Color.WHITE); - topicList.setForeground(Color.BLACK); - styleSheet.addStyleSheet(light); - styleSheet.removeStyleSheet(dark); - setBackground(Color.LIGHT_GRAY); - styleloaded = 0; - } - loadTopic(topicList.getSelectedValue().toString().toLowerCase()); - } - } - - /** - * Load a help topic from the help package. - * - * @param topicName The name of the help file, without the ".html". - */ - public void loadTopic(String topicName) { - new LoadThread(topicName).start(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jSplitPane1 = new javax.swing.JSplitPane(); - jScrollPane1 = new javax.swing.JScrollPane(); - topicList = new javax.swing.JList(); - jScrollPane2 = new javax.swing.JScrollPane(); - topicBrowser = new javax.swing.JEditorPane(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Manual"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/help.png"))); // NOI18N - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentShown(java.awt.event.ComponentEvent evt) { - formComponentShown(evt); - } - }); - - jSplitPane1.setDividerLocation(100); - jSplitPane1.setDividerSize(3); - jSplitPane1.setResizeWeight(0.1); - - topicList.setModel(new javax.swing.AbstractListModel() { - String[] strings = { "Welcome", "Basics", "Editor", "Pads", "Graphing", "Tasks", "Commands", "Licenses" }; - public int getSize() { return strings.length; } - public Object getElementAt(int i) { return strings[i]; } - }); - topicList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - topicList.setSelectedIndex(0); - topicList.setVisibleRowCount(9); - topicList.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - topicListMouseClicked(evt); - } - }); - topicList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(javax.swing.event.ListSelectionEvent evt) { - topicListValueChanged(evt); - } - }); - jScrollPane1.setViewportView(topicList); - - jSplitPane1.setLeftComponent(jScrollPane1); - - topicBrowser.setEditable(false); - topicBrowser.setBorder(null); - topicBrowser.setContentType("text/html"); // NOI18N - topicBrowser.setText("\r\n \r\n\r\n \r\n \r\n

\r\n \rHi there\n

\r\n \r\n\r\n"); - topicBrowser.setEditorKit(kit); - topicBrowser.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - topicBrowserMouseClicked(evt); - } - }); - jScrollPane2.setViewportView(topicBrowser); - - jSplitPane1.setRightComponent(jScrollPane2); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE) - ); - - pack(); - }//
//GEN-END:initComponents - - private void topicListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_topicListValueChanged - loadTopic(topicList.getSelectedValue().toString().toLowerCase()); - }//GEN-LAST:event_topicListValueChanged - - private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown - topicList.setSelectedIndex(0); - loadTopic("welcome"); - }//GEN-LAST:event_formComponentShown - - private void topicListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topicListMouseClicked - loadTheme(); - }//GEN-LAST:event_topicListMouseClicked - - private void topicBrowserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topicBrowserMouseClicked - loadTheme(); - }//GEN-LAST:event_topicBrowserMouseClicked - - private class LoadThread extends Thread { - - String name; - - public LoadThread(String topic) { - name = topic; - } - - @Override - public void run() { - setText("

Loading...

", "Manual"); - if (name.equals("welcome")) { - final String text = "About SyMAT" - + "" - + "

Welcome to SyMAT!

" - + "

SyMAT is a Java-based algebra and calculus system. " - + "Scripts and commands can be written in " - + "JavaScript or Python.

" - + "

This is SyMAT version " - + Main.VERSION_NAME + " (" + (int) Main.APP_CODE + ")." - + "

" - + "

SyMAT is copyright © " - + Calendar.getInstance().get(Calendar.YEAR) - + " Netsyms Technologies." - + "
" - + "This built-in documentation falls under the SyMAT Media License.

"; - setText(text, "Manual"); - } else { - try { - String text = ""; - BufferedReader reader = new BufferedReader( - new InputStreamReader( - CodeRunner.class - .getResourceAsStream("help/" + name + ".html"))); - String line; - while ((line = reader.readLine()) != null) { - text += line; - } - setText(text, "Manual (" + topicList.getSelectedValue().toString() + ")"); - } catch (Exception e) { - //JOptionPane.showInternalMessageDialog(Main.mainPane, - //"Error: Cannot load help topic "+name+".\n\n"+e.getMessage()); - setText("

Error:
Cannot get help topic \"" - + name + "\".
(" + e.getMessage() + ")

", "Manual"); - } - } - } - - private void setText(String string, String wintitle) { - final String text = string; - final String title = wintitle; - SwingUtilities.invokeLater( - new Runnable() { - @Override - public void run() { - topicBrowser.setText(text); - topicBrowser.setCaretPosition(0); - setTitle(title); - } - }); - } - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JSplitPane jSplitPane1; - private javax.swing.JEditorPane topicBrowser; - private javax.swing.JList topicList; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/InstallPlugin.java b/src/net/apocalypselabs/symat/InstallPlugin.java index f75aec6..81b5b44 100644 --- a/src/net/apocalypselabs/symat/InstallPlugin.java +++ b/src/net/apocalypselabs/symat/InstallPlugin.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -316,312 +315,3 @@ public class InstallPlugin extends javax.swing.JInternalFrame { private javax.swing.JTextField website; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.File; -import java.io.IOException; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.filechooser.FileNameExtensionFilter; -import net.apocalypselabs.symat.plugin.LoadPlugin; -import net.apocalypselabs.symat.plugin.Plugin; -import org.python.google.common.io.Files; - -/** - * - * @author Skylar - */ -public class InstallPlugin extends javax.swing.JInternalFrame { - - private final JFileChooser fc = new JFileChooser(); - - private File f = null; - - /** - * Creates new form InstallPlugin - */ - public InstallPlugin() { - fc.setFileFilter(new FileNameExtensionFilter( - "Plugin (sypl)", - "sypl")); - initComponents(); - } - - public InstallPlugin(File f) { - this(); - openPlugin(f); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jLabel1 = new javax.swing.JLabel(); - pluginName = new javax.swing.JTextField(); - jLabel4 = new javax.swing.JLabel(); - author = new javax.swing.JTextField(); - jLabel3 = new javax.swing.JLabel(); - website = new javax.swing.JTextField(); - version = new javax.swing.JTextField(); - jLabel5 = new javax.swing.JLabel(); - jLabel6 = new javax.swing.JLabel(); - shortDesc = new javax.swing.JTextField(); - jLabel7 = new javax.swing.JLabel(); - jScrollPane1 = new javax.swing.JScrollPane(); - longDesc = new javax.swing.JTextArea(); - openPluginBtn = new javax.swing.JButton(); - iconBox = new javax.swing.JLabel(); - installBtn = new javax.swing.JButton(); - - setClosable(true); - setIconifiable(true); - setTitle("Install Plugin"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/plugins.png"))); // NOI18N - - jLabel1.setText("Plugin Name:"); - - pluginName.setEditable(false); - - jLabel4.setText("Author:"); - - author.setEditable(false); - - jLabel3.setText("Website:"); - - website.setEditable(false); - - version.setEditable(false); - - jLabel5.setText("Version:"); - - jLabel6.setText("Description:"); - - shortDesc.setEditable(false); - - jLabel7.setText("Long Description:"); - - longDesc.setEditable(false); - longDesc.setColumns(20); - longDesc.setRows(5); - jScrollPane1.setViewportView(longDesc); - - openPluginBtn.setText("Open Plugin"); - openPluginBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - openPluginBtnActionPerformed(evt); - } - }); - - iconBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - - installBtn.setText("Install Plugin"); - installBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - installBtnActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(openPluginBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(iconBox, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(installBtn)) - .addComponent(jScrollPane1)) - .addComponent(jLabel7) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel3) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() - .addComponent(website) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel5) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(version)) - .addGroup(layout.createSequentialGroup() - .addComponent(pluginName) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(author)) - .addComponent(shortDesc, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE))) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(openPluginBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iconBox, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(installBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(pluginName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel4) - .addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(website, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel5) - .addComponent(version, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel6) - .addComponent(shortDesc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel7) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) - ); - - pack(); - }// //GEN-END:initComponents - - private void openPluginBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openPluginBtnActionPerformed - int result = fc.showDialog(this, "Open Plugin"); - if (result == JFileChooser.APPROVE_OPTION) { - openPlugin(fc.getSelectedFile()); - } - }//GEN-LAST:event_openPluginBtnActionPerformed - - private void openPlugin(File file) { - try { - Plugin p = (new LoadPlugin(file)).getPlugin(); - pluginName.setText(p.getTitle()); - shortDesc.setText(p.getLongTitle()); - version.setText(p.getVersion()); - longDesc.setText(p.getDesc()); - website.setText(p.getWebsite()); - author.setText(p.getAuthor()); - iconBox.setIcon(p.getIcon()); - f = file; - } catch (Exception ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error opening plugin.\n\n" + ex.getMessage()); - } - } - - private void installBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installBtnActionPerformed - if (f == null) { - return; - } - try { - String fsep = System.getProperty("file.separator"); - Files.copy(f, - new File( - System.getProperty("user.home") - + fsep + ".symat" + fsep + "plugins" + fsep - + f.getName())); - Main.maingui.reloadRibbon(); - JOptionPane.showInternalMessageDialog(this, - "Plugin installed!", - "Success", - JOptionPane.PLAIN_MESSAGE); - } catch (IOException ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error: could not install plugin file: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - } catch (IllegalArgumentException ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error: could not install plugin file." - + "\nIs a plugin with the same name already " - + "installed?\n(" + ex.getMessage() + ")", - "Error", - JOptionPane.ERROR_MESSAGE); - } catch (Exception ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error: could not install plugin file." - + "Try restarting SyMAT.\n" - + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - } - }//GEN-LAST:event_installBtnActionPerformed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextField author; - private javax.swing.JLabel iconBox; - private javax.swing.JButton installBtn; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTextArea longDesc; - private javax.swing.JButton openPluginBtn; - private javax.swing.JTextField pluginName; - private javax.swing.JTextField shortDesc; - private javax.swing.JTextField version; - private javax.swing.JTextField website; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Interpreter.java b/src/net/apocalypselabs/symat/Interpreter.java index e09329b..6f664cf 100644 --- a/src/net/apocalypselabs/symat/Interpreter.java +++ b/src/net/apocalypselabs/symat/Interpreter.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -561,550 +560,3 @@ public class Interpreter extends javax.swing.JInternalFrame { private javax.swing.JMenuItem setDefaultLang; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Font; -import java.awt.event.KeyEvent; -import java.io.IOException; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.text.DefaultCaret; -import org.fife.ui.autocomplete.AutoCompletion; -import org.fife.ui.autocomplete.CompletionProvider; - -/** - * - * @author Skylar - */ -public class Interpreter extends javax.swing.JInternalFrame { - - private final CodeRunner cr; - private String[] history = new String[10]; // Command history buffer - private String commandsForExport = ""; // History for saving - private int historyIndex = 0; // For going back in time and keeping things straight - private String lang = "javascript"; - private Object ans = 0; - - private CompletionProvider jscomp = new CodeCompleter("js").getProvider(); - private CompletionProvider pycomp = new CodeCompleter("py").getProvider(); - private AutoCompletion jsac = new AutoCompletion(jscomp); - private AutoCompletion pyac = new AutoCompletion(pycomp); - - private Interpreter thisobject; - - /** - * Creates new form Interpreter - * - * @param useLang The script language to use. "javascript", "python", or - * "default". - */ - public Interpreter(String useLang) { - thisobject = this; - initComponents(); - - // Setup code runner - lang = useLang; - if (lang.equals("default")) { - lang = PrefStorage.getSetting("shellLang", "javascript"); - } - cr = new CodeRunner(lang); - - // Setup language - if (lang.equals("python")) { - javascriptMenu.setSelected(false); - pythonMenu.setSelected(true); - pyac.install(inputBox); - setTitle("Shell [python]"); - } else { - jsac.install(inputBox); - setTitle("Shell [javascript]"); - } - - // Set font - int font_size = 12; - try { - font_size = Integer.valueOf(PrefStorage.getSetting("editfont", "12")); - } catch (Exception ex) { - } - mainBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size)); - inputBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size)); - - // Set theme - loadTheme(); - - // Misc. setup - mainBox.setText(">>"); - inputBox.requestFocus(); - } - - public Interpreter() { - this("default"); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - langGroup = new javax.swing.ButtonGroup(); - jScrollPane1 = new javax.swing.JScrollPane(); - mainBox = new javax.swing.JTextArea(); - inputBox = new javax.swing.JTextField(); - runBtn = new javax.swing.JButton(); - jLabel1 = new javax.swing.JLabel(); - jMenuBar1 = new javax.swing.JMenuBar(); - jMenu3 = new javax.swing.JMenu(); - exportHistoryBtn = new javax.swing.JMenuItem(); - jMenu4 = new javax.swing.JMenu(); - clearBtn = new javax.swing.JMenuItem(); - langMenu = new javax.swing.JMenu(); - jMenu1 = new javax.swing.JMenu(); - javascriptMenu = new javax.swing.JRadioButtonMenuItem(); - pythonMenu = new javax.swing.JRadioButtonMenuItem(); - setDefaultLang = new javax.swing.JMenuItem(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Shell"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/shell.png"))); // NOI18N - addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - formMouseClicked(evt); - } - }); - addFocusListener(new java.awt.event.FocusAdapter() { - public void focusGained(java.awt.event.FocusEvent evt) { - formFocusGained(evt); - } - }); - - mainBox.setEditable(false); - mainBox.setColumns(20); - mainBox.setFont(new java.awt.Font("Courier New", 0, 15)); // NOI18N - mainBox.setLineWrap(true); - mainBox.setRows(2); - mainBox.setTabSize(4); - mainBox.setWrapStyleWord(true); - DefaultCaret caret = (DefaultCaret)mainBox.getCaret(); - caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); - mainBox.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - mainBoxMouseClicked(evt); - } - }); - jScrollPane1.setViewportView(mainBox); - - inputBox.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - inputBoxMouseClicked(evt); - } - }); - inputBox.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyPressed(java.awt.event.KeyEvent evt) { - inputBoxKeyPressed(evt); - } - public void keyTyped(java.awt.event.KeyEvent evt) { - inputBoxKeyTyped(evt); - } - }); - - runBtn.setText("Run"); - runBtn.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - runBtnMouseClicked(evt); - } - }); - runBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - runBtnActionPerformed(evt); - } - }); - - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel1.setText(">>"); - - jMenu3.setText("File"); - - exportHistoryBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); - exportHistoryBtn.setText("Save history..."); - exportHistoryBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exportHistoryBtnActionPerformed(evt); - } - }); - jMenu3.add(exportHistoryBtn); - - jMenuBar1.add(jMenu3); - - jMenu4.setText("Edit"); - - clearBtn.setText("Clear window"); - clearBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - clearBtnActionPerformed(evt); - } - }); - jMenu4.add(clearBtn); - - jMenuBar1.add(jMenu4); - - langMenu.setText("Language"); - - jMenu1.setText("Switch"); - - langGroup.add(javascriptMenu); - javascriptMenu.setSelected(true); - javascriptMenu.setText("JavaScript"); - javascriptMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - javascriptMenuActionPerformed(evt); - } - }); - jMenu1.add(javascriptMenu); - - langGroup.add(pythonMenu); - pythonMenu.setText("Python"); - pythonMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - pythonMenuActionPerformed(evt); - } - }); - jMenu1.add(pythonMenu); - - langMenu.add(jMenu1); - - setDefaultLang.setText("Set as default"); - setDefaultLang.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - setDefaultLangActionPerformed(evt); - } - }); - langMenu.add(setDefaultLang); - - jMenuBar1.add(langMenu); - - setJMenuBar(jMenuBar1); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(inputBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(runBtn)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(inputBox, javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(runBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addGap(2, 2, 2)) - ); - - pack(); - }// //GEN-END:initComponents - - private void runBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runBtnActionPerformed - doRunCode(); - }//GEN-LAST:event_runBtnActionPerformed - - private void loadTheme() { - mainBox.setBackground(Theme.boxColor()); - mainBox.setForeground(Theme.textColor()); - inputBox.setBackground(Theme.boxColor()); - inputBox.setForeground(Theme.textColor()); - setBackground(Theme.windowColor()); - } - - private void inputBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputBoxKeyTyped - if (evt.getKeyChar() == '\n') { - doRunCode(); - } - }//GEN-LAST:event_inputBoxKeyTyped - - private void inputBoxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputBoxKeyPressed - switch (evt.getKeyCode()) { - case KeyEvent.VK_UP: - if (historyIndex < 9) { - if (historyIndex < 0) { - historyIndex++; - } - inputBox.setText(history[historyIndex]); - historyIndex++; - } - break; - case KeyEvent.VK_DOWN: - if (historyIndex >= 0) { - historyIndex--; - if (historyIndex < 0) { - historyIndex = 0; - inputBox.setText(""); - } else { - inputBox.setText(history[historyIndex]); - } - } - break; - } - }//GEN-LAST:event_inputBoxKeyPressed - - private void setDefaultLangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setDefaultLangActionPerformed - String pref = "javascript"; - if (pythonMenu.isSelected()) { - pref = "python"; - } - PrefStorage.saveSetting("shellLang", pref); - PrefStorage.save(); - }//GEN-LAST:event_setDefaultLangActionPerformed - - private void javascriptMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javascriptMenuActionPerformed - if (!lang.equals("javascript")) { - Main.loadFrame(new Interpreter("javascript")); - dispose(); - } - }//GEN-LAST:event_javascriptMenuActionPerformed - - private void pythonMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pythonMenuActionPerformed - if (!lang.equals("python")) { - Main.loadFrame(new Interpreter("python")); - dispose(); - } - }//GEN-LAST:event_pythonMenuActionPerformed - - private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked - loadTheme(); - }//GEN-LAST:event_formMouseClicked - - private void mainBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainBoxMouseClicked - formMouseClicked(evt); - }//GEN-LAST:event_mainBoxMouseClicked - - private void inputBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_inputBoxMouseClicked - formMouseClicked(evt); - }//GEN-LAST:event_inputBoxMouseClicked - - private void runBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_runBtnMouseClicked - formMouseClicked(evt); - }//GEN-LAST:event_runBtnMouseClicked - - private void exportHistoryBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportHistoryBtnActionPerformed - JFileChooser fc = new JFileChooser(); - FileFilter filter; - if (javascriptMenu.isSelected()) { - filter = new FileNameExtensionFilter("SyMAT JavaScript (.syjs)", "syjs"); - } else { - filter = new FileNameExtensionFilter("SyMAT Python (.sypy)", "sypy"); - } - fc.setFileFilter(filter); - fc.addChoosableFileFilter(filter); - int result = fc.showSaveDialog(this); - if (result == JFileChooser.APPROVE_OPTION) { - try { - FileUtils.saveFile(commandsForExport, - FileUtils.getFileWithExtension(fc).toString(), - true); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(this, - "Error saving: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - } - } - }//GEN-LAST:event_exportHistoryBtnActionPerformed - - private void clearBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearBtnActionPerformed - mainBox.setText(">>"); - commandsForExport = ""; - }//GEN-LAST:event_clearBtnActionPerformed - - private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained - inputBox.requestFocusInWindow(); - }//GEN-LAST:event_formFocusGained - - private void doRunCode() { - String code = inputBox.getText(); - commandsForExport += code + "\n"; - mainBox.append(" " + code + "\n"); - runBtn.setEnabled(false); - inputBox.setEnabled(false); - new EvalThread(code).start(); - } - - private class EvalThread extends Thread { - - private String code = ""; - - public EvalThread(String cmd) { - code = cmd; - } - - /** - * Process control commands. - * - * @return True if the modified code should be executed, false if not. - */ - private boolean doSpecialCommands() { - switch (code) { - case "clc": - case "clear": - clrOutput(); - return false; - case "exit": - thisobject.dispose(); - } - - // Implement ans command - String ansfill; - try { - ansfill = String.valueOf(Double.parseDouble(ans.toString())); - } catch (NumberFormatException ex) { - ansfill = "\"" + ans.toString() + "\""; - } - code = code.replace("ans", ansfill); - return true; - } - - @Override - @SuppressWarnings("null") - public void run() { - try { - if (doSpecialCommands()) { - Object result = cr.evalString(code); - if (result != null && !result.toString().trim().equals("")) { - ans = result; - } - append(result.toString() + "\n"); - } - } catch (NullPointerException ex) { - - } - append(">>"); - for (int i = 9; i > 0; i--) { - history[i] = history[i - 1]; - } - history[0] = code; - clrInput(); - historyIndex = -1; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - inputBox.setEnabled(true); - runBtn.setEnabled(true); - inputBox.requestFocusInWindow(); - } - }); - } - - private void clrInput() { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - inputBox.setText(""); - } - }); - } - - private void clrOutput() { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - mainBox.setText(""); - commandsForExport = ""; - } - }); - } - - private void append(String out) { - final String output = out; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - mainBox.append(output); - mainBox.setCaretPosition(mainBox.getText().length()); - } - }); - } - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JMenuItem clearBtn; - private javax.swing.JMenuItem exportHistoryBtn; - private javax.swing.JTextField inputBox; - private javax.swing.JLabel jLabel1; - private javax.swing.JMenu jMenu1; - private javax.swing.JMenu jMenu3; - private javax.swing.JMenu jMenu4; - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JRadioButtonMenuItem javascriptMenu; - private javax.swing.ButtonGroup langGroup; - private javax.swing.JMenu langMenu; - private javax.swing.JTextArea mainBox; - private javax.swing.JRadioButtonMenuItem pythonMenu; - private javax.swing.JButton runBtn; - private javax.swing.JMenuItem setDefaultLang; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/KeyValListItem.java b/src/net/apocalypselabs/symat/KeyValListItem.java index 9868022..4fc3a17 100644 --- a/src/net/apocalypselabs/symat/KeyValListItem.java +++ b/src/net/apocalypselabs/symat/KeyValListItem.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -128,124 +127,3 @@ public class KeyValListItem { return (KEY.equals("") && VAL.equals("")); } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -/** - * A simple key/value pair for lists and stuff. - * - * @author Skylar - */ -public class KeyValListItem { - - // I know, not Java code standards. - // But it's easier and cleaner this way. - private String VAL = ""; - private String KEY = ""; - - public KeyValListItem() { - - } - - public KeyValListItem(String key) { - KEY = key; - } - - public KeyValListItem(String key, String val) { - KEY = key; - VAL = val; - } - - /** - * Get the key. - * - * @return the key. - */ - @Override - public String toString() { - return KEY; - } - - /** - * Get the value of this pair. - * - * @return duh. - */ - public String getValue() { - return VAL; - } - - /** - * Set the key. - *
To get it back use toString(). - * - * @param key the key. - */ - public void setKey(String key) { - KEY = key; - } - - /** - * Set the value for this pair. - * - * @param value - */ - public void setValue(String value) { - VAL = value; - } - - /** - * Is this pair populated? - * - * @return True if key and value are empty. - */ - public boolean isEmpty() { - return (KEY.equals("") && VAL.equals("")); - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/License.java b/src/net/apocalypselabs/symat/License.java index ffd6e87..2fe891a 100644 --- a/src/net/apocalypselabs/symat/License.java +++ b/src/net/apocalypselabs/symat/License.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -436,432 +435,3 @@ public class License extends javax.swing.JInternalFrame { private javax.swing.JRadioButton singLicSel; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Desktop; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Calendar; -import java.util.Date; -import javax.swing.JOptionPane; -import static net.apocalypselabs.symat.Main.API_URL; - -/** - * - * @author Skylar - */ -public class License extends javax.swing.JInternalFrame { - - /** - * Creates new form FirstRun - */ - public License() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - grp1 = new javax.swing.ButtonGroup(); - jLabel1 = new javax.swing.JLabel(); - singLicSel = new javax.swing.JRadioButton(); - orgLicSel = new javax.swing.JRadioButton(); - noLicSel = new javax.swing.JRadioButton(); - emailBox = new javax.swing.JTextField(); - emailLbl = new javax.swing.JLabel(); - contBtn = new javax.swing.JButton(); - exitBtn = new javax.swing.JButton(); - - setTitle("Welcome"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icon16.png"))); // NOI18N - setMaximumSize(new java.awt.Dimension(435, 367)); - setMinimumSize(new java.awt.Dimension(435, 367)); - setPreferredSize(new java.awt.Dimension(435, 367)); - try { - setSelected(true); - } catch (java.beans.PropertyVetoException e1) { - e1.printStackTrace(); - } - - jLabel1.setText("\n

Welcome to SyMAT!

\n

Please activate the software. \n
Until you do, features will be limited.\n
You may be eligible for a free 15-day trial.

\n
\n

Do you have a license?

"); - - grp1.add(singLicSel); - singLicSel.setText("Yes, I have a single-user license"); - singLicSel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - singLicSelActionPerformed(evt); - } - }); - - grp1.add(orgLicSel); - orgLicSel.setText("No, but my school or work might have one"); - orgLicSel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - orgLicSelActionPerformed(evt); - } - }); - - grp1.add(noLicSel); - noLicSel.setSelected(true); - noLicSel.setText("No, I don't have a license"); - noLicSel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - noLicSelActionPerformed(evt); - } - }); - - emailBox.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); - emailBox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - emailBoxActionPerformed(evt); - } - }); - emailBox.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyPressed(java.awt.event.KeyEvent evt) { - emailBoxKeyPressed(evt); - } - }); - - emailLbl.setText("Great! Enter your email address and we'll get things set up."); - - contBtn.setText("Continue"); - contBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - contBtnActionPerformed(evt); - } - }); - - exitBtn.setText("Exit"); - exitBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exitBtnActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(emailBox, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(noLicSel) - .addComponent(orgLicSel) - .addComponent(singLicSel) - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(emailLbl)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(contBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(exitBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(18, 18, 18)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(singLicSel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(orgLicSel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(noLicSel) - .addGap(17, 17, 17) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(emailLbl) - .addComponent(exitBtn)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(emailBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(contBtn)) - .addGap(40, 40, 40)) - ); - - emailBox.setVisible(false); - emailLbl.setVisible(false); - - pack(); - }//
//GEN-END:initComponents - - private void singLicSelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_singLicSelActionPerformed - emailLbl.setVisible(true); - emailBox.setVisible(true); - emailLbl.setText("Great! Now just enter your email address."); - }//GEN-LAST:event_singLicSelActionPerformed - - private void orgLicSelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orgLicSelActionPerformed - emailLbl.setVisible(true); - emailBox.setVisible(true); - emailLbl.setText("OK, enter your school or work email address."); - }//GEN-LAST:event_orgLicSelActionPerformed - - private void noLicSelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noLicSelActionPerformed - emailLbl.setVisible(false); - emailBox.setVisible(false); - }//GEN-LAST:event_noLicSelActionPerformed - - private void openShop() { - if (Desktop.isDesktopSupported()) { - try { - Desktop.getDesktop().browse(new URI(Main.API_URL + "shoplink.php")); - } catch (IOException | URISyntaxException ex) { - JOptionPane.showInternalMessageDialog(this, "Please go to symatapp.com to purchase a license."); - } - } else { - JOptionPane.showInternalMessageDialog(this, "Please go to symatapp.com to purchase a license."); - } - } - - private void contBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contBtnActionPerformed - if (noLicSel.isSelected()) { - if (PrefStorage.getSetting("licensetype").equals("demo") - && PrefStorage.getSetting("licensedemo").equals("used")) { - int ans = JOptionPane.showInternalConfirmDialog(this, - "You have already used a trial license." - + "\nWould you like to go online to get a license?", - "Expired", - JOptionPane.YES_NO_OPTION); - if (ans == JOptionPane.NO_OPTION) { - - } else { - openShop(); - } - } else { - int ans = JOptionPane.showInternalConfirmDialog(this, - "Would you like to go online and get a license?\n" - + "Select no to activate a 15-day trial.", - "Get License", - JOptionPane.YES_NO_OPTION); - if (ans == JOptionPane.NO_OPTION) { - Calendar c = Calendar.getInstance(); - c.setTime(new Date()); - c.add(Calendar.DATE, 15); // Adds 15 days - - PrefStorage.saveSetting("licensetype", "demo"); - PrefStorage.saveSetting("license", String.valueOf(c.getTimeInMillis())); - PrefStorage.saveSetting("licensedemo", "used"); - JOptionPane.showInternalMessageDialog(this, - "A trial license of 15 days has been activated.", - "Activated", - JOptionPane.INFORMATION_MESSAGE); - exit(); - } else { - openShop(); - } - } - } else { - if (checkRegex()) { - new CheckThread(emailBox.getText()).start(); - } - } - }//GEN-LAST:event_contBtnActionPerformed - - private void emailBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailBoxActionPerformed - checkRegex(); - }//GEN-LAST:event_emailBoxActionPerformed - - private void emailBoxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_emailBoxKeyPressed - checkRegex(); - }//GEN-LAST:event_emailBoxKeyPressed - - private void exitBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitBtnActionPerformed - int result = JOptionPane.showInternalConfirmDialog(this, - "Are you sure you want to exit SyMAT?", - "Quit", - JOptionPane.YES_NO_OPTION); - if (result == JOptionPane.YES_OPTION) { - System.exit(0); - } - }//GEN-LAST:event_exitBtnActionPerformed - - private boolean checkRegex() { - if (checkEmail(emailBox.getText())) { - contBtn.setEnabled(true); - return true; - } else { - contBtn.setEnabled(false); - return false; - } - } - - public static boolean checkEmail(String email) { - String regex = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+$"; - return (email.matches(regex)); - } - - public void exit() { - dispose(); - } - - /** - * Check the email address for a license. - */ - private class CheckThread extends Thread { - - private final String email; - - public CheckThread(String useremail) { - email = useremail; - } - - @Override - public void run() { - try { - System.out.println("Checking license..."); - URL url = new URL(API_URL + "liccheck.php?email=" + email); - String line; - try (InputStream is = url.openStream(); - BufferedReader br - = new BufferedReader(new InputStreamReader(is))) { - line = br.readLine(); - } - - switch (line) { - case "ok:single": - success("single"); - break; - case "ok:domain": - success("domain"); - break; - case "checkemail": - email(); - break; - default: - fail(); - } - } catch (IOException e) { - Debug.printerr("License check failed."); - Debug.stacktrace(e); - ioerror(); - } - } - - private void success(String type) { - PrefStorage.saveSetting("license", email); - PrefStorage.saveSetting("licensetype", type); - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Thank you for activating SyMAT!", - "Success", - JOptionPane.INFORMATION_MESSAGE); - Main.licenseRestrict(false); - exit(); - } - - private void fail() { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "There is not a valid license for that email address.", - "Activation failure", - JOptionPane.ERROR_MESSAGE); - } - - private void email() { - try { - String code = JOptionPane.showInternalInputDialog(Main.mainPane, - "A code has been emailed to you. " - + "Enter it below to verify.", - "Almost done!", - JOptionPane.QUESTION_MESSAGE); - Debug.println("Checking license code (" + code + ")..."); - URL url = new URL(API_URL + "emailverify.php?code=" + code + "&email=" + email); - String line; - try (InputStream is = url.openStream()) { - BufferedReader br - = new BufferedReader(new InputStreamReader(is)); - line = br.readLine(); - br.close(); - } - if (code.equals(line)) { - success("domain"); - } else { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Code invalid.", - "Error", - JOptionPane.ERROR_MESSAGE); - } - } catch (IOException ex) { - ioerror(); - } - } - - private void ioerror() { - JOptionPane.showMessageDialog(Main.mainPane, - "An error occured while verifying your license. " - + "Ensure you have an Internet connection and " - + "try again later.", - "Error", - JOptionPane.ERROR_MESSAGE); - } - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton contBtn; - private javax.swing.JTextField emailBox; - private javax.swing.JLabel emailLbl; - private javax.swing.JButton exitBtn; - private javax.swing.ButtonGroup grp1; - private javax.swing.JLabel jLabel1; - private javax.swing.JRadioButton noLicSel; - private javax.swing.JRadioButton orgLicSel; - private javax.swing.JRadioButton singLicSel; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Main.form b/src/net/apocalypselabs/symat/Main.form index 337488e..4724f09 100644 --- a/src/net/apocalypselabs/symat/Main.form +++ b/src/net/apocalypselabs/symat/Main.form @@ -49,11 +49,7 @@ -<<<<<<< HEAD -======= - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Main.java b/src/net/apocalypselabs/symat/Main.java index 06e05b2..4b42029 100644 --- a/src/net/apocalypselabs/symat/Main.java +++ b/src/net/apocalypselabs/symat/Main.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -1126,1127 +1125,3 @@ public class Main extends JRibbonFrame { public static javax.swing.JLabel recentItemsTitle; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontFormatException; -import static java.awt.Frame.MAXIMIZED_BOTH; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javafx.application.Platform; -import javafx.embed.swing.JFXPanel; -import javax.swing.ImageIcon; -import javax.swing.JFileChooser; -import javax.swing.JInternalFrame; -import javax.swing.JOptionPane; -import javax.swing.ListModel; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import net.apocalypselabs.symat.plugin.LoadPlugin; -import org.pushingpixels.flamingo.api.ribbon.*; -import org.pushingpixels.flamingo.api.ribbon.resize.*; -import org.pushingpixels.flamingo.api.common.*; -import org.pushingpixels.flamingo.api.common.icon.*; - -/** - * This class is like the Force: A light theme, a dark theme, and it binds the - * app together. Also like duct tape, but that's not as cool. - * - * Contains a bunch of important variables and constants that are used all over. - * - * There is only one Main per app instance, the important things are static. - * - * @author Skylar Ittner - */ -public class Main extends JRibbonFrame { - - // TODO: Add more code comments and stuff in case anybody else reads this - /** - * Version name, as it should be displayed. - */ - public static final String VERSION_NAME = "2.1"; - - /** - * The word "SyMAT". - */ - public static final String SYMAT = "SyMAT"; - /** - * Program name, with version name - */ - public static final String APP_NAME = SYMAT + " " + VERSION_NAME; - /** - * Version number, for updates and //needs in scripts - */ - public static final double APP_CODE = 23; - /** - * Base URL for building API calls - */ - public static final String API_URL = "http://apis.symatapp.com/"; - /** - * Contains the filename argument passed to SyMAT, if any. - */ - public static String argfile = ""; - - /** - * Ubuntu font. Loaded from Ubuntu-R.ttf in the default package at runtime. - * May become default sans-serif if something bad happens. - */ - public static Font ubuntuRegular; - public static boolean skipPython = false; // Skip python init on start? - public static boolean skipEditor = false; // Skip editor init on start? - - private static boolean recentItemsMinimized = false; - - public static boolean updateAvailable = false; // Update available? - public static String updateString = ""; - public static boolean licValid = false; // License valid? - - /** - * Application icon, for setting frame icons. Has different sizes. - */ - public static ArrayList symatlogo = new ArrayList<>(); - - /** - * The http server that handles opening other instances. - */ - public static SingleInstanceServer sisrv; - - public static Main maingui; - - public JRibbonBand pluginband; - - /** - * Creates the main app window and does some quick things that aren't - * threaded in SplashScreen. - */ - public Main() { - maingui = this; - // Set icon - setIconImages(symatlogo); - initComponents(); - loadRibbon(); - - // Center screen - setLocationRelativeTo(null); - - // Run things when app closed - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent we) { - int p = JOptionPane.showConfirmDialog(Main.mainPane, - "Are you sure you want to exit SyMAT?", - "Exit SyMAT", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (p == JOptionPane.YES_OPTION) { - if (getExtendedState() == MAXIMIZED_BOTH) { - PrefStorage.saveSetting("framemaxed", "yes"); - } else { - PrefStorage.saveSetting("framemaxed", "no"); - } - System.exit(0); - } - } - }); - - // Open initial windows - boolean loaded = false; - if (!argfile.equals("")) { - if (argfile.endsWith(".sytt")) { - Tasks tt = new Tasks(new File(argfile)); - loadFrame(tt); - argfile = ""; - } else if (argfile.endsWith(".sypl")) { - loadFrame(new InstallPlugin(new File(argfile))); - } else { - Editor ed = new Editor(); - loadFrame(ed); - ed.openFileFromName(argfile); - argfile = ""; - } - loaded = true; - } - - if (!licValid) { - licenseRestrict(true); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - loadFrame(new License()); - } - }); - loaded = true; - } - // Only load shell if nothing else is going on - - if (argfile.equals("") && !loaded) { - loadFrame(new Interpreter()); - } - if (updateAvailable) { - loadFrame(new Update(updateString)); - } - loadRecentFiles(); - updateDisplay(); - setVisible(true); - if (PrefStorage.getSetting("framemaxed", "no").equals("yes")) { - java.awt.EventQueue.invokeLater(() -> { - setExtendedState(MAXIMIZED_BOTH); - }); - } - - if (!PrefStorage.getSetting("showrecent", "").equals("")) { - recentItemsPanel.setVisible(false); - } - - // Pi Day easter egg - GregorianCalendar piday = new GregorianCalendar(); - if ((piday.get(Calendar.MONTH) == 2) - && (piday.get(Calendar.DAY_OF_MONTH) == 14)) { - JOptionPane.showInternalMessageDialog(mainPane, - "Happy Pi Day from the SyMAT team!", - "3/14", - JOptionPane.PLAIN_MESSAGE); - } - } - - /** - * Load plugins from disk. - */ - public void loadPlugins() { - pluginband = new JRibbonBand("Plugins", null); - installpluginbtn.setActionRichTooltip(new RichTooltip("Install Plugin", - "Install a plugin from a file and view plugin info.")); - installpluginbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new InstallPlugin()); - } - }); - pluginband.setResizePolicies((List) Arrays.asList( - new CoreRibbonResizePolicies.Mirror(pluginband.getControlPanel()))); - pluginband.addCommandButton(installpluginbtn, RibbonElementPriority.TOP); - String fsep = System.getProperty("file.separator"); - File dir = new File(System.getProperty("user.home") + fsep + ".symat" + fsep + "plugins"); - dir.mkdirs(); - File[] files = dir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(".sypl"); - } - }); - - Map galleryVisibleButtonCounts = new HashMap<>(); - galleryVisibleButtonCounts.put(RibbonElementPriority.LOW, 4); - galleryVisibleButtonCounts.put(RibbonElementPriority.MEDIUM, 4); - galleryVisibleButtonCounts.put(RibbonElementPriority.TOP, 4); - List>> appGalleryButtons = new ArrayList<>(); - List appGalleryButtonsList = new ArrayList<>(); - if (files != null) { - for (File pl : files) { - LoadPlugin lp; - try { - lp = new LoadPlugin(pl); - appGalleryButtonsList.add(lp.getGalleryBtn()); - } catch (Exception ex) { - Debug.stacktrace(ex); - System.err.println("Error loading plugin " + pl.getName() + ": " + ex.getMessage()); - } - } - } - - appGalleryButtons.add(new StringValuePair<>("Plugins", - appGalleryButtonsList)); - pluginband.addRibbonGallery("Plugins", appGalleryButtons, - galleryVisibleButtonCounts, 4, 3, - RibbonElementPriority.TOP); - } - - /** - * Reload the Ribbon tabs and all sub-components. - */ - public void reloadRibbon() { - getRibbon().removeAllTasks(); - loadRibbon(); - } - - /** - * Load the ribbon in all its glory. - */ - private void loadRibbon() { - ResizableIcon appico = ImageWrapperResizableIcon.getIcon( - Main.class.getResource("icon32.png"), - new Dimension(32, 32)); - setApplicationIcon(appico); - int tries = 0; // no infinite loops for us! - while (tries < 20) { - try { - Thread.sleep(10); - if (getApplicationIcon().equals(appico)) { - break; - } - setApplicationIcon(appico); - } catch (Exception ex) { - } - tries++; - } - JRibbon ribbon = getRibbon(); - JRibbonBand coreband = new JRibbonBand("Core", null); - JRibbonBand appsband = new JRibbonBand("Apps", null); - JRibbonBand webband = new JRibbonBand("Community", null); - JRibbonBand collabband = new JRibbonBand("Team", null); - //JRibbonBand getpluginband = new JRibbonBand("Install", null); - - try { - loadPlugins(); - } catch (Exception ex) { - JOptionPane.showMessageDialog(this, - "An error occurred while loading plugins: " - + ex.getMessage()); - } - - shellbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Interpreter()); - } - }); - editorbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Editor()); - } - }); - graphbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Graph()); - } - }); - notepadbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Notepad()); - } - }); - wikibtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new WebBrowser("SyMAT Wiki", - "http://wiki.symatapp.com", - WebBrowser.WIKI_LOGO)); - } - }); - forumbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new WebBrowser("Community Forum", - "http://forum.symatapp.com/", - WebBrowser.FORUM_LOGO)); - } - }); - padsbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Pads()); - } - }); - tasksbtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Tasks()); - } - }); - - shellbtn.setActionRichTooltip(new RichTooltip("Command Shell", - "Open a window for running interactive commands.")); - editorbtn.setActionRichTooltip(new RichTooltip("Code Editor", - "Write and run JavaScript and Python scripts.")); - graphbtn.setActionRichTooltip(new RichTooltip("Graph", - "Plot mathematical functions on a 2D graph.")); - notepadbtn.setActionRichTooltip(new RichTooltip("Notepad", - "Write quick notes on a virtual napkin.")); - wikibtn.setActionRichTooltip(new RichTooltip("SyMAT Wiki", - "View and edit online documentation and tutorials.")); - forumbtn.setActionRichTooltip(new RichTooltip("Support Forum", - "Discuss and share with the SyMAT community.")); - padsbtn.setActionRichTooltip(new RichTooltip("Code Pads", - "Collaborate over the Internet on projects.")); - tasksbtn.setActionRichTooltip(new RichTooltip("Task List", - "Manage tasks and to-do lists for projects.")); - - coreband.addCommandButton(shellbtn, RibbonElementPriority.TOP); - coreband.addCommandButton(editorbtn, RibbonElementPriority.TOP); - - appsband.addCommandButton(graphbtn, RibbonElementPriority.MEDIUM); - appsband.addCommandButton(notepadbtn, RibbonElementPriority.MEDIUM); - - webband.addCommandButton(wikibtn, RibbonElementPriority.LOW); - webband.addCommandButton(forumbtn, RibbonElementPriority.LOW); - - collabband.addCommandButton(padsbtn, RibbonElementPriority.MEDIUM); - collabband.addCommandButton(tasksbtn, RibbonElementPriority.MEDIUM); - - coreband.setResizePolicies((List) Arrays.asList( - new CoreRibbonResizePolicies.None(coreband.getControlPanel()), - new IconRibbonBandResizePolicy(coreband.getControlPanel()))); - appsband.setResizePolicies((List) Arrays.asList( - new CoreRibbonResizePolicies.None(appsband.getControlPanel()), - new IconRibbonBandResizePolicy(appsband.getControlPanel()))); - webband.setResizePolicies((List) Arrays.asList( - new CoreRibbonResizePolicies.None(webband.getControlPanel()), - new IconRibbonBandResizePolicy(webband.getControlPanel()))); - collabband.setResizePolicies((List) Arrays.asList( - new CoreRibbonResizePolicies.None(collabband.getControlPanel()), - new IconRibbonBandResizePolicy(collabband.getControlPanel()))); -// getpluginband.setResizePolicies((List) Arrays.asList( -// new CoreRibbonResizePolicies.None(appsband.getControlPanel()), -// new IconRibbonBandResizePolicy(pluginband.getControlPanel()))); -// pluginband.setResizePolicies((List) Arrays.asList( -// new CoreRibbonResizePolicies.None(appsband.getControlPanel()), -// new IconRibbonBandResizePolicy(pluginband.getControlPanel()))); - - RibbonTask hometask = new RibbonTask("Home", coreband, appsband); - RibbonTask webtask = new RibbonTask("Tools", webband, collabband); - RibbonTask plugintask = new RibbonTask("Plugins", pluginband); - - loadRibbonMenu(null); - - ribbon.addTask(hometask); - ribbon.addTask(webtask); - ribbon.addTask(plugintask); - } - - public static ResizableIcon getRibbonIcon(String name) { - return ImageWrapperResizableIcon.getIcon( - Main.class.getResource("images/" + name + ".png"), - new Dimension(100, 76)); - } - - public static ResizableIcon getTinyRibbonIcon(String name) { - int d = 32; - return ImageWrapperResizableIcon.getIcon( - Main.class.getResource("icons/" + name + ".png"), - new Dimension(d, d)); - } - - public static void licenseRestrict(boolean restricted) { - graphbtn.setEnabled(!restricted); - padsbtn.setEnabled(!restricted); - recentFileList.setEnabled(!restricted); - } - - /** - * (Re)load display settings. - */ - public static void updateDisplay() { - maingui.getRibbon().setBackground(Theme.tabColor()); - recentFileList.setForeground(Theme.textColor()); - recentFileList.setBackground(Theme.boxColor()); - recentItemsPanel.setVisible(PrefStorage.getSetting("showrecent", "") - .equals("")); - maingui.getRibbon().setMinimized(PrefStorage.getSetting( - "miniribbon", "").equals("yes")); - mainPane.paintImmediately(0, 0, - mainPane.getWidth(), mainPane.getHeight()); - } - - public static void loadRibbonMenu(RibbonApplicationMenuEntrySecondary[] recent) { - RibbonApplicationMenuEntryPrimary helpbtn - = new RibbonApplicationMenuEntryPrimary( - getRibbonIcon("help"), - "Manual", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Help()); - } - }, - JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntryPrimary cascadebtn - = new RibbonApplicationMenuEntryPrimary( - getRibbonIcon("cascade"), - "Arrange all", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - cascade(); - } - }, - JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntryPrimary exitbtn - = new RibbonApplicationMenuEntryPrimary( - getRibbonIcon("closeall"), - "Exit", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - maingui.dispatchEvent(new WindowEvent(maingui, - WindowEvent.WINDOW_CLOSING)); - } - }, - JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntrySecondary newjsbtn - = new RibbonApplicationMenuEntrySecondary( - getTinyRibbonIcon("jsicon"), - "JavaScript", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Editor()); - } - }, - JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntrySecondary newpybtn - = new RibbonApplicationMenuEntrySecondary( - getTinyRibbonIcon("pyicon"), - "Python", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Editor(true)); - } - }, - JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntrySecondary newtaskbtn - = new RibbonApplicationMenuEntrySecondary( - getTinyRibbonIcon("taskicon"), - "Task List", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Tasks()); - } - }, - JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntryPrimary newbtn - = new RibbonApplicationMenuEntryPrimary( - getRibbonIcon("newfile"), - "New", - null, - JCommandButton.CommandButtonKind.POPUP_ONLY); - openbtn = new RibbonApplicationMenuEntryPrimary( - getRibbonIcon("openfile"), - "Open", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - JFileChooser fc = new JFileChooser(); - FileFilter script - = new FileNameExtensionFilter("Script" - + "(syjs, sypy, js, py)", - "syjs", "sypy", "js", "py"); - FileFilter all - = new FileNameExtensionFilter("SyMAT File" - + "(syjs, sypy, js, py, sytt)", - "syjs", "sypy", "js", "py", "sytt"); - FileFilter tasklist - = new FileNameExtensionFilter("Task List (sytt)", - "sytt"); - fc.setFileFilter(all); - fc.addChoosableFileFilter(script); - fc.addChoosableFileFilter(tasklist); - int result = fc.showOpenDialog(maingui); - if (result == JFileChooser.APPROVE_OPTION) { - File f = fc.getSelectedFile(); - if (f.getName().endsWith(".sytt")) { - loadFrame(new Tasks(f)); - } else { - Editor ed = new Editor(); - ed.openFileFromName(f.getAbsolutePath()); - loadFrame(ed); - } - } - } - }, - JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION); - - if (recent == null) { - RibbonApplicationMenuEntrySecondary blanksubbtn - = new RibbonApplicationMenuEntrySecondary( - null, "No recent files", null, - JCommandButton.CommandButtonKind.ACTION_ONLY); - blanksubbtn.setEnabled(false); - openbtn.addSecondaryMenuGroup("Recent Files", blanksubbtn); - } else { - openbtn.addSecondaryMenuGroup("Recent Files", recent); - } - newbtn.addSecondaryMenuGroup("Code File", newjsbtn, newpybtn); - newbtn.addSecondaryMenuGroup("Other", newtaskbtn); - - RibbonApplicationMenuEntryFooter displaybtn - = new RibbonApplicationMenuEntryFooter( - getTinyRibbonIcon("settings"), - "Settings", - new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - loadFrame(new Settings()); - } - }); - - RibbonApplicationMenuEntryPrimary blankbtn - = new RibbonApplicationMenuEntryPrimary( - null, "", null, - JCommandButton.CommandButtonKind.ACTION_ONLY); - blankbtn.setEnabled(false); - - RibbonApplicationMenu menu = new RibbonApplicationMenu(); - menu.addMenuEntry(newbtn); - menu.addMenuEntry(openbtn); - menu.addMenuSeparator(); - menu.addMenuEntry(helpbtn); - menu.addMenuEntry(cascadebtn); - menu.addMenuSeparator(); - menu.addMenuEntry(exitbtn); - menu.addFooterEntry(displaybtn); - - menu.addMenuEntry(blankbtn); - menu.addMenuEntry(blankbtn); - menu.addMenuEntry(blankbtn); - menu.addMenuEntry(blankbtn); - - maingui.getRibbon().setApplicationMenu(menu); - maingui.getRibbon().setApplicationMenuRichTooltip( - new RichTooltip("SyMAT Menu", - "Create files, open documents, " - + "get help, and change settings") - ); - } - - /** - * (Re)load recent file lists from storage. - */ - public static void loadRecentFiles() { - String files = PrefStorage.getSetting("recentfiles"); - if (files.equals("")) { - loadRibbonMenu(null); - recentFileList.setListData(new String[0]); - return; - } - String[] fileList = files.split("\n"); - int neededLength = 0; - for (String file : fileList) { - if ((new File(file)).isFile()) { - neededLength++; - } - } - if (neededLength > 10) { - neededLength = 10; - } - KeyValListItem[] items = new KeyValListItem[neededLength]; - int i = 0; - RibbonApplicationMenuEntrySecondary[] recentmenu - = new RibbonApplicationMenuEntrySecondary[fileList.length]; - for (String f : fileList) { - File file = new File(f); - if (file.isFile() && i < neededLength) { - items[i] = new KeyValListItem(file.getName(), file.getPath()); - recentmenu[i] = (new RibbonApplicationMenuEntrySecondary( - null, - file.getName(), - new ActionListener() { - final String path = file.getPath(); - - @Override - public void actionPerformed(ActionEvent evt) { - Editor edit = new Editor(); - edit.openFileFromName(path); - loadFrame(edit); - } - }, - JCommandButton.CommandButtonKind.ACTION_ONLY)); - i++; - } - } - - loadRibbonMenu(recentmenu); - recentFileList.setListData(items); - - // Re-save list to remove bad entries - String list = ""; - for (KeyValListItem item : items) { - list += item.getValue() + "\n"; - } - PrefStorage.saveSetting("recentfiles", list); - } - - /** - * Add a file to the recent files lists. - * - * @param file The file path. - */ - public static void addRecentFile(String file) { - file = (new File(file)).getAbsolutePath(); - String files = PrefStorage.getSetting("recentfiles"); - String[] fileList = files.split("\n"); - for (int i = 0; i < fileList.length; i++) { - if (fileList[i].trim().equals(file)) { - fileList[i] = ""; - } - } - files = file + "\n"; - for (String f : fileList) { - if (!f.trim().equals("")) { - files += f + "\n"; - } - } - PrefStorage.saveSetting("recentfiles", files); - PrefStorage.save(); - loadRecentFiles(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jMenuItem1 = new javax.swing.JMenuItem(); - mainPane = mainPane = new javax.swing.JDesktopPane() { - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - if (PrefStorage.getSetting("theme").equals("dark")) { - g.setColor(Color.DARK_GRAY); - } else { - g.setColor(Color.LIGHT_GRAY); - } - g.fillRect(0, 0, getWidth(), getHeight()); - } - } - ; - jLabel2 = new javax.swing.JLabel(); - recentItemsPanel = new javax.swing.JPanel(); - jScrollPane1 = new javax.swing.JScrollPane(); - recentFileList = new javax.swing.JList(); - recentFileBtn = new javax.swing.JButton(); - recentItemsTitle = new javax.swing.JLabel(); - appPanel = new javax.swing.JPanel(); - - jMenuItem1.setText("jMenuItem1"); - - setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); - setTitle("SyMAT"); - setMinimumSize(new java.awt.Dimension(640, 540)); - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentShown(java.awt.event.ComponentEvent evt) { - formComponentShown(evt); - } - }); - - mainPane.setBackground(new java.awt.Color(204, 204, 204)); - mainPane.setAutoscrolls(true); - mainPane.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); - mainPane.setOpaque(false); - - jLabel2.setFont(Main.ubuntuRegular.deriveFont(48.0F)); - jLabel2.setForeground(new java.awt.Color(153, 153, 153)); - jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel2.setText("SyMAT"); - jLabel2.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); - - recentItemsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - recentItemsPanel.setForeground(new java.awt.Color(153, 153, 153)); - recentItemsPanel.setMaximumSize(new java.awt.Dimension(160, 273)); - recentItemsPanel.setOpaque(false); - - jScrollPane1.setMinimumSize(new java.awt.Dimension(23, 206)); - jScrollPane1.setName(""); // NOI18N - - recentFileList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - recentFileList.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - recentFileListMouseClicked(evt); - } - }); - recentFileList.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { - public void mouseMoved(java.awt.event.MouseEvent evt) { - recentFileListMouseMoved(evt); - } - }); - jScrollPane1.setViewportView(recentFileList); - - recentFileBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/openfile.png"))); // NOI18N - recentFileBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - recentFileBtnActionPerformed(evt); - } - }); - - recentItemsTitle.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N - recentItemsTitle.setForeground(new java.awt.Color(102, 102, 102)); - recentItemsTitle.setText(" Recent Files"); - recentItemsTitle.setOpaque(true); - recentItemsTitle.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - recentItemsTitleMouseClicked(evt); - } - }); - - javax.swing.GroupLayout recentItemsPanelLayout = new javax.swing.GroupLayout(recentItemsPanel); - recentItemsPanel.setLayout(recentItemsPanelLayout); - recentItemsPanelLayout.setHorizontalGroup( - recentItemsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(recentItemsPanelLayout.createSequentialGroup() - .addGroup(recentItemsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(recentItemsPanelLayout.createSequentialGroup() - .addGap(97, 97, 97) - .addComponent(recentFileBtn)) - .addGroup(recentItemsPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addComponent(recentItemsTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - recentItemsPanelLayout.setVerticalGroup( - recentItemsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(recentItemsPanelLayout.createSequentialGroup() - .addComponent(recentItemsTitle) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(recentFileBtn) - .addContainerGap()) - ); - - appPanel.setOpaque(false); - appPanel.setLayout(new java.awt.GridBagLayout()); - - javax.swing.GroupLayout mainPaneLayout = new javax.swing.GroupLayout(mainPane); - mainPane.setLayout(mainPaneLayout); - mainPaneLayout.setHorizontalGroup( - mainPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPaneLayout.createSequentialGroup() - .addContainerGap() - .addComponent(appPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(recentItemsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) - ); - mainPaneLayout.setVerticalGroup( - mainPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(mainPaneLayout.createSequentialGroup() - .addContainerGap() - .addGroup(mainPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(appPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(mainPaneLayout.createSequentialGroup() - .addComponent(recentItemsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, Short.MAX_VALUE) - .addComponent(jLabel2))) - .addContainerGap()) - ); - mainPane.setLayer(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER); - mainPane.setLayer(recentItemsPanel, javax.swing.JLayeredPane.DEFAULT_LAYER); - mainPane.setLayer(appPanel, javax.swing.JLayeredPane.DEFAULT_LAYER); - - getContentPane().add(mainPane, java.awt.BorderLayout.CENTER); - - pack(); - }// //GEN-END:initComponents - - private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown - setLocationRelativeTo(null); - }//GEN-LAST:event_formComponentShown - - private void recentFileBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recentFileBtnActionPerformed - if (recentFileList.getSelectedValue() == null) { - return; - } - KeyValListItem file = (KeyValListItem) recentFileList.getSelectedValue(); - if (file.isEmpty()) { - return; - } - Editor edit = new Editor(); - Debug.println(file.getValue()); - edit.openFileFromName(file.getValue()); - loadFrame(edit); - }//GEN-LAST:event_recentFileBtnActionPerformed - - private void recentFileListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_recentFileListMouseClicked - if (evt.getClickCount() == 2) { - recentFileBtnActionPerformed(null); - } - }//GEN-LAST:event_recentFileListMouseClicked - - private void recentFileListMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_recentFileListMouseMoved - try { - ListModel m = recentFileList.getModel(); - int index = recentFileList.locationToIndex(evt.getPoint()); - if (index > -1) { - recentFileList.setToolTipText( - ((KeyValListItem) m.getElementAt(index)).getValue()); - } - } catch (Exception ex) { - // This feature is optional. Just skip it if it's broken. - recentFileList.setToolTipText(""); - } - }//GEN-LAST:event_recentFileListMouseMoved - - private void recentItemsTitleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_recentItemsTitleMouseClicked - - }//GEN-LAST:event_recentItemsTitleMouseClicked - - /** - * Adds the given JInternalFrame to the mainPane. Automatically does layout - * and sets visible (if show==true). - * - * @param frame The frame - * @param show Should the frame be visible? - */ - public static void loadFrame(JInternalFrame frame, boolean show) { - int w = frame.getWidth(); - int h = frame.getHeight(); - int pw = mainPane.getWidth(); - int ph = mainPane.getHeight(); - if (frame.isResizable()) { - if (h > ph) { - h = ph; - } - if (w > pw) { - w = pw; - } - frame.setSize(w, h); - } - mainPane.add(frame); - frame.setLocation( - (pw / 2) - (w / 2), - (ph / 2) - (h / 2)); - if (frame.getLocation().y < 0) { - frame.setLocation(frame.getLocation().x, 0); - } - if (show) { - frame.setVisible(true); - } - } - - /** - * Adds the given JInternalFrame to the mainPane. Automatically does layout - * and sets visible. - * - * @param frame The frame - */ - public static void loadFrame(JInternalFrame frame) { - loadFrame(frame, true); - } - - /** - * Cascade all the frames in a stack. Somehow reverses the order each time - * around, I have no idea why but it's a "feature" now! - */ - public static void cascade() { - JInternalFrame[] frames = mainPane.getAllFrames(); - int x = 12; - int y = 24; - Debug.println("Cascading " + frames.length + " frames..."); - for (int i = 0; i < frames.length; i++) { - if (frames[i].isVisible()) { - Debug.println("Frame: " - + frames[i].getTitle() - + ", Times: " + i - + ", Xpos: " + x * i - + ", Ypos: " + y * i); - frames[i].setBounds(x * i, - y * i, - frames[i].getWidth(), - frames[i].getHeight()); - frames[i].toFront(); - } - } - } - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException e) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, e); - } - // - // - // - // - - try { - // Ubuntu font for prettifying - ubuntuRegular = Font.createFont(Font.TRUETYPE_FONT, Main.class. - getResourceAsStream("/Ubuntu-R.ttf")); - } catch (FontFormatException | IOException ex) { - ubuntuRegular = Font.getFont(Font.SANS_SERIF); - System.err.println("Error loading fonts: " + ex.getMessage()); - } catch (Exception ex) { - ubuntuRegular = Font.getFont(Font.SANS_SERIF); - System.err.println("Error loading fonts: " + ex.getMessage()); - } - - // Set icon - String[] sizes = {"16", "24", "32", "48", "64", "96", "128", "256", "512"}; - for (String s : sizes) { - symatlogo.add(new ImageIcon( - Main.class.getResource(s + "x" + s + ".png")).getImage()); - } - - // Command line args - for (String arg : args) { - switch (arg) { - case "skippython": - skipPython = true; - break; - case "skipeditor": - skipEditor = true; - break; - case "quickstart": - skipPython = true; - skipEditor = true; - break; - case "licensereset": - PrefStorage.saveSetting("license", ""); - break; - default: - argfile = arg; - break; - } - } - - SingleInstanceClient sicli = new SingleInstanceClient(argfile); - - try { - new SingleInstanceServer().start(); - } catch (IOException ex) { - Debug.printerr("Cannot start instance listener:\n\n"); - Debug.stacktrace(ex); - } - - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - new JFXPanel(); // this will prepare JavaFX toolkit and environment - Platform.runLater(new Runnable() { - @Override - public void run() { - Platform.setImplicitExit(false); - } - }); - } - }); - - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(() -> { - new SplashScreen().setVisible(true); - }); - } - - public static JCommandButton shellbtn - = new JCommandButton("Shell", getRibbonIcon("shell")); - public static JCommandButton editorbtn - = new JCommandButton("Editor", getRibbonIcon("editor")); - public static JCommandButton graphbtn - = new JCommandButton("Graph", getRibbonIcon("graph")); - public static JCommandButton notepadbtn - = new JCommandButton("Notepad", getRibbonIcon("notepad")); - public static JCommandButton wikibtn - = new JCommandButton("Wiki", getRibbonIcon("wiki")); - public static JCommandButton forumbtn - = new JCommandButton("Forum", getRibbonIcon("forum")); - public static JCommandButton padsbtn - = new JCommandButton("Pads", getRibbonIcon("pads")); - public static JCommandButton tasksbtn - = new JCommandButton("Tasks", getRibbonIcon("tasks")); - public static JCommandButton installpluginbtn - = new JCommandButton("Install", getRibbonIcon("installplugin")); - public static RibbonApplicationMenuEntryPrimary openbtn; - - // Variables declaration - do not modify//GEN-BEGIN:variables - public static javax.swing.JPanel appPanel; - public static javax.swing.JLabel jLabel2; - public static javax.swing.JMenuItem jMenuItem1; - public static javax.swing.JScrollPane jScrollPane1; - public static javax.swing.JDesktopPane mainPane; - public static javax.swing.JButton recentFileBtn; - public static javax.swing.JList recentFileList; - public static javax.swing.JPanel recentItemsPanel; - public static javax.swing.JLabel recentItemsTitle; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Notepad.form b/src/net/apocalypselabs/symat/Notepad.form index 66e6cc4..cbb222e 100644 --- a/src/net/apocalypselabs/symat/Notepad.form +++ b/src/net/apocalypselabs/symat/Notepad.form @@ -94,10 +94,7 @@ -<<<<<<< HEAD -======= ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Notepad.java b/src/net/apocalypselabs/symat/Notepad.java index 69f961c..b24deb7 100644 --- a/src/net/apocalypselabs/symat/Notepad.java +++ b/src/net/apocalypselabs/symat/Notepad.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -240,221 +239,3 @@ public class Notepad extends javax.swing.JInternalFrame { private javax.swing.JTextArea textBox; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.IOException; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; - -/** - * - * A simple persistent notepad. - * - * @author Skylar - */ -public class Notepad extends javax.swing.JInternalFrame { - - /** - * Creates new form Notepad - */ - public Notepad() { - initComponents(); - // Set font - int font_size = 12; - try { - font_size = Integer.valueOf(PrefStorage.getSetting("editfont", "12")); - } catch (Exception ex) { - } - textBox.setFont(Main.ubuntuRegular.deriveFont((float) font_size)); - textBox.setText(PrefStorage.getSetting("notepad")); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jScrollPane1 = new javax.swing.JScrollPane(); - textBox = new javax.swing.JTextArea(); - jMenuBar1 = new javax.swing.JMenuBar(); - jMenu1 = new javax.swing.JMenu(); - exportBtn = new javax.swing.JMenuItem(); - eraseBtn = new javax.swing.JMenuItem(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Notepad"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/notepad.png"))); // NOI18N - addInternalFrameListener(new javax.swing.event.InternalFrameListener() { - public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) { - formInternalFrameClosing(evt); - } - public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) { - } - }); - - textBox.setBackground(new java.awt.Color(255, 255, 204)); - textBox.setColumns(1); - textBox.setLineWrap(true); - textBox.setRows(1); - textBox.setTabSize(4); - textBox.setWrapStyleWord(true); - textBox.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - textBoxKeyTyped(evt); - } - }); - jScrollPane1.setViewportView(textBox); - - jMenu1.setText("File"); - - exportBtn.setText("Export text"); - exportBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exportBtnActionPerformed(evt); - } - }); - jMenu1.add(exportBtn); - - eraseBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK)); - eraseBtn.setText("Erase"); - eraseBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - eraseBtnActionPerformed(evt); - } - }); - jMenu1.add(eraseBtn); - - jMenuBar1.add(jMenu1); - - setJMenuBar(jMenuBar1); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - private void eraseBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eraseBtnActionPerformed - int ans = JOptionPane.showInternalConfirmDialog(this, "Erase notepad contents?", "Are you sure?", JOptionPane.YES_NO_OPTION); - if (ans == JOptionPane.YES_OPTION) { - textBox.setText(""); - save(); - } - }//GEN-LAST:event_eraseBtnActionPerformed - - private void textBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textBoxKeyTyped - save(); - }//GEN-LAST:event_textBoxKeyTyped - - private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportBtnActionPerformed - JFileChooser fc = new JFileChooser(); - FileFilter filter; - filter = new FileNameExtensionFilter("Plain Text (.txt)", "txt"); - fc.setFileFilter(filter); - fc.addChoosableFileFilter(filter); - int result = fc.showSaveDialog(this); - if (result == JFileChooser.APPROVE_OPTION) { - try { - FileUtils.saveFile(textBox.getText(), - FileUtils.getFileWithExtension(fc).toString(), - false); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(this, - "Error saving: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - } - } - }//GEN-LAST:event_exportBtnActionPerformed - - private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing - save(); - }//GEN-LAST:event_formInternalFrameClosing - - private void save() { - PrefStorage.saveSetting("notepad", textBox.getText()); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JMenuItem eraseBtn; - private javax.swing.JMenuItem exportBtn; - private javax.swing.JMenu jMenu1; - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTextArea textBox; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/PackagePlugin.java b/src/net/apocalypselabs/symat/PackagePlugin.java index 9204ada..8e9503d 100644 --- a/src/net/apocalypselabs/symat/PackagePlugin.java +++ b/src/net/apocalypselabs/symat/PackagePlugin.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -473,469 +472,3 @@ public class PackagePlugin extends javax.swing.JInternalFrame { private javax.swing.JTextField website; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import javax.imageio.ImageIO; -import javax.swing.ImageIcon; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.filechooser.FileNameExtensionFilter; -import net.apocalypselabs.symat.plugin.Plugin; - -/** - * - * @author Skylar - */ -public class PackagePlugin extends javax.swing.JInternalFrame { - - private final JFileChooser fcimg = new JFileChooser(); - private final JFileChooser fcexp = new JFileChooser(); - private ImageIcon icon; - - public PackagePlugin(String code, int lang) { - this(); - try { - icon = new ImageIcon( - ImageIO.read(PackagePlugin.class.getResource("images/plugin.png"))); - } catch (IOException ex) { - Debug.stacktrace(ex); - } - langSelect.setSelectedIndex(lang); - codeBox.setText(code); - iconPreview.setIcon(icon); - } - - /** - * Creates new form PackagePlugin - */ - public PackagePlugin() { - fcimg.setFileFilter(new FileNameExtensionFilter( - "Image (jpeg,jpg,gif,png,bmp)", - "jpeg", "jpg", "gif", "png", "bmp")); - fcexp.setFileFilter(new FileNameExtensionFilter( - "Plugin (sypl)", - "sypl")); - initComponents(); - author.setText(PrefStorage.getSetting("author")); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jTabbedPane1 = new javax.swing.JTabbedPane(); - jPanel1 = new javax.swing.JPanel(); - pluginName = new javax.swing.JTextField(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - packageID = new javax.swing.JTextField(); - jLabel3 = new javax.swing.JLabel(); - website = new javax.swing.JTextField(); - jLabel4 = new javax.swing.JLabel(); - author = new javax.swing.JTextField(); - jLabel5 = new javax.swing.JLabel(); - version = new javax.swing.JTextField(); - jLabel6 = new javax.swing.JLabel(); - shortDesc = new javax.swing.JTextField(); - jLabel7 = new javax.swing.JLabel(); - jScrollPane1 = new javax.swing.JScrollPane(); - longDesc = new javax.swing.JTextArea(); - jPanel4 = new javax.swing.JPanel(); - jLabel9 = new javax.swing.JLabel(); - iconPreview = new javax.swing.JLabel(); - openIconBtn = new javax.swing.JButton(); - jLabel10 = new javax.swing.JLabel(); - defaultIconBtn = new javax.swing.JButton(); - jPanel2 = new javax.swing.JPanel(); - jLabel8 = new javax.swing.JLabel(); - langSelect = new javax.swing.JComboBox(); - jScrollPane2 = new javax.swing.JScrollPane(); - codeBox = new javax.swing.JTextArea(); - jPanel3 = new javax.swing.JPanel(); - savePlugin = new javax.swing.JButton(); - - setClosable(true); - setIconifiable(true); - setTitle("Package Plugin"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/plugins.png"))); // NOI18N - - jLabel1.setText("Plugin Name:"); - - jLabel2.setText("Package ID:"); - - jLabel3.setText("Website:"); - - jLabel4.setText("Author:"); - - jLabel5.setText("Version:"); - - jLabel6.setText("Description:"); - - jLabel7.setText("Long Description:"); - - longDesc.setColumns(20); - longDesc.setRows(5); - jScrollPane1.setViewportView(longDesc); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel7) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1) - .addComponent(jLabel2) - .addComponent(jLabel3) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(website, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel5) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(version, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(pluginName) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(author)) - .addComponent(packageID) - .addComponent(shortDesc)))) - .addContainerGap()) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(pluginName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel4) - .addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(packageID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(website, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel5) - .addComponent(version, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel6) - .addComponent(shortDesc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel7) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE) - .addContainerGap()) - ); - - jTabbedPane1.addTab("Metadata", jPanel1); - - jLabel9.setText("Icon:"); - - iconPreview.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - iconPreview.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - - openIconBtn.setText("Open icon..."); - openIconBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - openIconBtnActionPerformed(evt); - } - }); - - jLabel10.setText("Recommended icon size is 100x76."); - jLabel10.setVerticalAlignment(javax.swing.SwingConstants.TOP); - - defaultIconBtn.setText("Use default"); - defaultIconBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - defaultIconBtnActionPerformed(evt); - } - }); - - javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); - jPanel4.setLayout(jPanel4Layout); - jPanel4Layout.setHorizontalGroup( - jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel4Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(jPanel4Layout.createSequentialGroup() - .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel4Layout.createSequentialGroup() - .addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(openIconBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(defaultIconBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addComponent(jLabel9)) - .addGap(0, 181, Short.MAX_VALUE))) - .addContainerGap()) - ); - jPanel4Layout.setVerticalGroup( - jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel4Layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel9) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel4Layout.createSequentialGroup() - .addComponent(openIconBtn) - .addGap(18, 18, 18) - .addComponent(defaultIconBtn)) - .addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE) - .addContainerGap()) - ); - - jTabbedPane1.addTab("Icon", jPanel4); - - jLabel8.setText("Language:"); - - langSelect.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "JavaScript", "Python" })); - - codeBox.setColumns(20); - codeBox.setRows(5); - jScrollPane2.setViewportView(codeBox); - - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); - jPanel2.setLayout(jPanel2Layout); - jPanel2Layout.setHorizontalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(jLabel8) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(langSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE))) - .addContainerGap()) - ); - jPanel2Layout.setVerticalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel8) - .addComponent(langSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE) - .addContainerGap()) - ); - - jTabbedPane1.addTab("Code", jPanel2); - - savePlugin.setText("Save Plugin"); - savePlugin.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - savePluginActionPerformed(evt); - } - }); - - javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); - jPanel3.setLayout(jPanel3Layout); - jPanel3Layout.setHorizontalGroup( - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel3Layout.createSequentialGroup() - .addGap(28, 28, 28) - .addComponent(savePlugin, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(235, Short.MAX_VALUE)) - ); - jPanel3Layout.setVerticalGroup( - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel3Layout.createSequentialGroup() - .addGap(27, 27, 27) - .addComponent(savePlugin, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(131, Short.MAX_VALUE)) - ); - - jTabbedPane1.addTab("Publish", jPanel3); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jTabbedPane1) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jTabbedPane1) - ); - - pack(); - }// //GEN-END:initComponents - - private void savePluginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savePluginActionPerformed - Plugin p = new Plugin(); - try { - p.setTitle(pluginName.getText()); - p.setAuthor(author.getText()); - p.setLongTitle(shortDesc.getText()); - p.setDesc(longDesc.getText()); - p.setPackage(packageID.getText()); - p.setVersion(version.getText()); - p.setWebsite(website.getText()); - p.setLang(langSelect.getSelectedIndex()); - p.setScript(codeBox.getText()); - p.setIcon(icon); - if (p.getTitle().equals("") - || p.getAuthor().equals("") - || p.getPackage().equals("") - || p.getVersion().equals("") - || p.getScript().equals("") - || p.getIcon() == null) { - throw new Exception("One or more required fields are empty."); - } - } catch (Exception ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error. Please check your data.\n\n" + ex.getMessage()); - return; - } - int result = fcexp.showDialog(this, "Publish"); - if (result == JFileChooser.APPROVE_OPTION) { - try { - FileOutputStream fout = new FileOutputStream(FileUtils.getFileWithExtension(fcexp)); - try (ObjectOutputStream oos = new ObjectOutputStream(fout)) { - oos.writeObject(p); - oos.close(); - } - JOptionPane.showInternalMessageDialog(this, - "Publish complete!"); - } catch (Exception ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error saving file.\n\n" + ex.getMessage()); - } - } - }//GEN-LAST:event_savePluginActionPerformed - - private void openIconBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openIconBtnActionPerformed - int result = fcimg.showDialog(this, "Select Icon"); - if (result == JFileChooser.APPROVE_OPTION) { - try { - icon = new ImageIcon(ImageIO.read(fcimg.getSelectedFile())); - iconPreview.setIcon(icon); - } catch (Exception ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error opening image.\n\n" + ex.getMessage()); - } - } - }//GEN-LAST:event_openIconBtnActionPerformed - - private void defaultIconBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_defaultIconBtnActionPerformed - try { - icon = new ImageIcon( - ImageIO.read(PackagePlugin.class.getResource("images/plugin.png"))); - iconPreview.setIcon(icon); - } catch (IOException ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog(this, - "Error opening default icon.\n\n" + ex.getMessage()); - } - }//GEN-LAST:event_defaultIconBtnActionPerformed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextField author; - private javax.swing.JTextArea codeBox; - private javax.swing.JButton defaultIconBtn; - private javax.swing.JLabel iconPreview; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel10; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; - private javax.swing.JLabel jLabel9; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JPanel jPanel3; - private javax.swing.JPanel jPanel4; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JTabbedPane jTabbedPane1; - private javax.swing.JComboBox langSelect; - private javax.swing.JTextArea longDesc; - private javax.swing.JButton openIconBtn; - private javax.swing.JTextField packageID; - private javax.swing.JTextField pluginName; - private javax.swing.JButton savePlugin; - private javax.swing.JTextField shortDesc; - private javax.swing.JTextField version; - private javax.swing.JTextField website; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Pads.java b/src/net/apocalypselabs/symat/Pads.java index b534738..a452d33 100644 --- a/src/net/apocalypselabs/symat/Pads.java +++ b/src/net/apocalypselabs/symat/Pads.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -567,563 +566,3 @@ public class Pads extends javax.swing.JInternalFrame { private javax.swing.JButton shareBtn; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Color; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Random; -import javax.swing.JOptionPane; -import org.etherpad_lite_client.EPLiteClient; -import org.etherpad_lite_client.EPLiteException; - -/** - * - * @author Skylar - */ -public class Pads extends javax.swing.JInternalFrame { - - public static final String PADS_URL = "http://pad.symatapp.com"; - - /** - * Creates new form Pads - */ - public Pads() { - initComponents(); - updateTheme(); - padPane.setListData(getPads()); - } - - private void updateTheme() { - padPane.setBackground(Theme.boxColor()); - padPane.setForeground(Theme.textColor()); - previewPane.setBackground(Theme.boxColor()); - previewPane.setForeground(Theme.textColor()); - setBackground(Theme.windowColor()); - } - - /** - * Add the given pad ID to the local pad list. - * - * @param id the pad ID. - */ - public static void addPad(String id) { - String pads = PrefStorage.getSetting("pads"); - - // Check for dupes - for (String p : pads.split("\\|")) { - if (p.equals(id)) { - return; - } - } - - if (pads.equals("")) { - pads = id; - } else { - pads += "|" + id; - } - PrefStorage.saveSetting("pads", pads); - } - - /** - * Delete the pad with the given ID from local memory. - *
It will still exist online. - * - * @param id the pad ID. - */ - public static void delPad(String id) { - String pads = PrefStorage.getSetting("pads"); - String result = ""; - int i = 0; - for (String pad : pads.split("\\|")) { - if (!pad.equals(id)) { - if (i > 0) { - result += "|"; - } - result += pad; - i++; - } - } - - PrefStorage.saveSetting("pads", result); - } - - /** - * Get an array of saved pads. - * - * @return String[] of pad IDs - */ - public static String[] getPads() { - String pads = PrefStorage.getSetting("pads"); - if (!pads.equals("")) { - if (pads.contains("|")) { - return pads.split("\\|"); - } else { - String[] padlist = {pads}; - return padlist; - } - } else { - String[] padlist = {}; - return padlist; - } - } - - /** - * Create a new pad on the server with the given ID. - * - * @param id The pad ID to create. If blank is auto-generated. - * @param content Text to initialize the pad with. - * @return Created pad ID. - * @throws Exception if things break. - */ - public static String genPad(String id, String content) throws Exception { - // Generate ID if blank - if (id.equals("")) { - id = genID(); - } - - // Create pad with given text. - try { - getClient().createPad(id, content); - } catch (EPLiteException ex) { - getClient().setText(id, content); - } - return id; - } - - /** - * Generate a random pad ID with length 15. - *
There are about 1.217 x 10^26 possibilities (121 septillion). - *
If this starts giving out used IDs, I'll be too rich to care. - * - * @return the ID. - */ - public static String genID() { - int length = 15; - String[] chars = ("0123456789" - + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - + "abcdefghijklmnopqrstuvwxyz").split(""); - String out = ""; - Random rng = new Random(); - - for (int i = 0; i < length; i++) { - out += chars[rng.nextInt(chars.length)]; - } - - return out; - } - - /** - * Get a client for the pad API. - * - * @return the client. - * @throws IOException if things break. - */ - public static EPLiteClient getClient() throws Exception { - String apikey; - // Enable key change without full SyMAT update - if (!PrefStorage.getSetting("padkey-override", "").equals("")) { - apikey = PrefStorage.getSetting("padkey-override", ""); - } else { - // Load the API key from a file, so it's not included with Git. - BufferedReader reader = new BufferedReader( - new InputStreamReader( - Pads.class - .getResourceAsStream("/padkey"))); - apikey = reader.readLine(); - } - // New client - return new EPLiteClient(PADS_URL, apikey); - } - - /** - * Get the pad text. - * - * @param id the pad ID. - * @return the text, or error message. - */ - public static String getPad(String id) { - String text = ""; - try { - text = getClient().getText(id).getOrDefault("text", "").toString(); - } catch (Exception ex) { - text = "Error: " + ex.getMessage(); - } - return text; - } - - /** - * Set pad text. - * - * @param id Pad ID - * @param content Pad text - */ - public static void setPad(String id, String content) { - try { - getClient().setText(id, content); - } catch (Exception ex) { - Debug.stacktrace(ex); - JOptionPane.showInternalMessageDialog( - Main.mainPane, - "Could not sync pad contents: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - } - } - - /** - * Delete the given pad ID. - * - * @param id the pad ID. - * @param purge If true will delete from server also. - */ - public static void delPad(String id, boolean purge) { - delPad(id); - if (purge) { - try { - getClient().deletePad(id); - } catch (Exception ex) { - // Meh. No big deal. - } - } - } - - /** - * Display a pad. - * - * @param pad the pad ID - */ - public static void loadPad(String pad) { - String theme = "?theme="; - if (Theme.currentTheme == Theme.THEME_DARK) { - theme += "terminal"; - } else { - theme += "default"; - } - Main.loadFrame(new WebBrowser("Pad " + pad, - PADS_URL + "/p/" + pad + theme, - WebBrowser.PAD_LOGO)); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jScrollPane1 = new javax.swing.JScrollPane(); - padPane = new javax.swing.JList(); - jLabel1 = new javax.swing.JLabel(); - openBtn = new javax.swing.JButton(); - delBtn = new javax.swing.JButton(); - previewBtn = new javax.swing.JButton(); - saveBtn = new javax.swing.JButton(); - jScrollPane2 = new javax.swing.JScrollPane(); - previewPane = new javax.swing.JTextArea(); - shareBtn = new javax.swing.JButton(); - jLabel2 = new javax.swing.JLabel(); - purgeBtn = new javax.swing.JButton(); - addBtn = new javax.swing.JButton(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Collaboration"); - setMinimumSize(new java.awt.Dimension(450, 280)); - setPreferredSize(new java.awt.Dimension(450, 280)); - addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseEntered(java.awt.event.MouseEvent evt) { - formMouseEntered(evt); - } - }); - - padPane.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - padPane.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(javax.swing.event.ListSelectionEvent evt) { - padPaneValueChanged(evt); - } - }); - jScrollPane1.setViewportView(padPane); - - jLabel1.setText("My Pads:"); - - openBtn.setText("Open"); - openBtn.setToolTipText("Open pad for editing"); - openBtn.setEnabled(false); - openBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - openBtnActionPerformed(evt); - } - }); - - delBtn.setText("Delete"); - delBtn.setToolTipText("Remove pad from list"); - delBtn.setEnabled(false); - delBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - delBtnActionPerformed(evt); - } - }); - - previewBtn.setText("Preview"); - previewBtn.setToolTipText("Preview pad contents"); - previewBtn.setEnabled(false); - previewBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - previewBtnActionPerformed(evt); - } - }); - - saveBtn.setText("Download"); - saveBtn.setToolTipText("Save pad locally"); - saveBtn.setEnabled(false); - saveBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveBtnActionPerformed(evt); - } - }); - - previewPane.setEditable(false); - previewPane.setColumns(1); - previewPane.setRows(1); - previewPane.setTabSize(4); - jScrollPane2.setViewportView(previewPane); - - shareBtn.setText("Share"); - shareBtn.setToolTipText("Share pad"); - shareBtn.setEnabled(false); - shareBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - shareBtnActionPerformed(evt); - } - }); - - jLabel2.setText("Preview:"); - - purgeBtn.setText("Purge"); - purgeBtn.setToolTipText("Delete pad completely"); - purgeBtn.setEnabled(false); - purgeBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - purgeBtnActionPerformed(evt); - } - }); - - addBtn.setText("+"); - addBtn.setToolTipText("Add pad by ID"); - addBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - addBtnActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(addBtn))) - .addGap(6, 6, 6) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(delBtn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(saveBtn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(openBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(previewBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE) - .addComponent(shareBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(purgeBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane2) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2) - .addGap(0, 144, Short.MAX_VALUE))) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(jLabel2) - .addComponent(addBtn)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane2) - .addComponent(jScrollPane1) - .addGroup(layout.createSequentialGroup() - .addComponent(openBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(saveBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(delBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(purgeBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(previewBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(shareBtn))) - .addContainerGap()) - ); - - pack(); - }// //GEN-END:initComponents - - private void delBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delBtnActionPerformed - int ans = JOptionPane.showInternalConfirmDialog(this, - "Remove pad from list? It will not be removed from the server.", - "Delete?", - JOptionPane.OK_CANCEL_OPTION); - if (ans == JOptionPane.OK_OPTION) { - delPad(getSelectedPad()); - } - updateList(); - }//GEN-LAST:event_delBtnActionPerformed - - private void previewBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previewBtnActionPerformed - previewPane.setText(getPad(getSelectedPad())); - updateList(); - }//GEN-LAST:event_previewBtnActionPerformed - - private void openBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openBtnActionPerformed - loadPad(getSelectedPad()); - }//GEN-LAST:event_openBtnActionPerformed - - private void purgeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_purgeBtnActionPerformed - int ans = JOptionPane.showInternalConfirmDialog(this, - "Remove pad from server and list? This cannot be undone!", - "Delete?", - JOptionPane.OK_CANCEL_OPTION); - if (ans == JOptionPane.OK_OPTION) { - delPad(getSelectedPad(), true); - } - updateList(); - }//GEN-LAST:event_purgeBtnActionPerformed - - private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed - Main.loadFrame(new Editor(getPad(getSelectedPad()), false)); - updateList(); - }//GEN-LAST:event_saveBtnActionPerformed - - private void padPaneValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_padPaneValueChanged - // Enable/disable action buttons to prevent errors. - boolean enable = true; - if (padPane.getSelectedValue() == null) { - enable = false; - } - openBtn.setEnabled(enable); - saveBtn.setEnabled(enable); - delBtn.setEnabled(enable); - shareBtn.setEnabled(enable); - previewBtn.setEnabled(enable); - purgeBtn.setEnabled(enable); - }//GEN-LAST:event_padPaneValueChanged - - private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addBtnActionPerformed - String id = JOptionPane.showInternalInputDialog(this, - "What is the pad ID?", - "Add Pad", - JOptionPane.QUESTION_MESSAGE); - if (id != null && !id.equals("")) { - if (id.contains("pad.symatapp.com/p/")) { - id = id.substring(id.lastIndexOf('/') + 1); - Debug.println(id); - } - addPad(id); - } - updateList(); - }//GEN-LAST:event_addBtnActionPerformed - - private void shareBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shareBtnActionPerformed - JOptionPane.showInternalMessageDialog(this, - new SharePad(getSelectedPad()), - "Share Pad", - JOptionPane.PLAIN_MESSAGE); - }//GEN-LAST:event_shareBtnActionPerformed - - private void formMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseEntered - updateTheme(); - }//GEN-LAST:event_formMouseEntered - - private String getSelectedPad() { - return padPane.getSelectedValue().toString(); - } - - private void updateList() { - padPane.setListData(getPads()); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton addBtn; - private javax.swing.JButton delBtn; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JButton openBtn; - private javax.swing.JList padPane; - private javax.swing.JButton previewBtn; - private javax.swing.JTextArea previewPane; - private javax.swing.JButton purgeBtn; - private javax.swing.JButton saveBtn; - private javax.swing.JButton shareBtn; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/PrefStorage.java b/src/net/apocalypselabs/symat/PrefStorage.java index c87071f..d24ac8b 100644 --- a/src/net/apocalypselabs/symat/PrefStorage.java +++ b/src/net/apocalypselabs/symat/PrefStorage.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -133,129 +132,3 @@ public class PrefStorage { // guaranteed to be random. } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.util.ArrayList; -import java.util.List; -import java.util.prefs.BackingStoreException; -import java.util.prefs.Preferences; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; - -/** - * - * @author Skylar Ittner - */ -public class PrefStorage { - - private static final Preferences prefs = Preferences.userNodeForPackage(PrefStorage.class); - - public static void saveSetting(String key, String value) { - prefs.put(key, value); - } - - public static boolean isset(String key) { - return !getSetting(key, "NULL").equals("NULL"); - } - - public static void unset(String key) { - saveSetting(key, ""); - save(); - prefs.remove(key); - save(); - } - - public static String getSetting(String key) { - return prefs.get(key, ""); - } - - public static String getSetting(String key, String emptyResponse) { - return prefs.get(key, emptyResponse); - } - - public static boolean save() { - try { - prefs.flush(); - } catch (BackingStoreException ex) { - System.err.println("Settings could not be saved!"); - return false; - } - return true; - } - - /** - * Wipe all settings. - * - * @throws java.util.prefs.BackingStoreException - */ - public static void wipe() throws BackingStoreException { - prefs.clear(); - } - - /** - * Get all settings in a List for a Sync. - * @return List of NameValuePairs. - * @throws BackingStoreException - */ - public static List syncdump() throws BackingStoreException { - String[] keys = prefs.keys(); - List nvps = new ArrayList<>(); - for (String key : keys) { - nvps.add(new BasicNameValuePair(key, prefs.get(key, ""))); - } - return nvps; - } - - // xkcd 221 compliance. - int getRandomNumber() { - return 4; // chosen by fair dice roll. - // guaranteed to be random. - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Settings.form b/src/net/apocalypselabs/symat/Settings.form index 7f9b83c..7c8b712 100644 --- a/src/net/apocalypselabs/symat/Settings.form +++ b/src/net/apocalypselabs/symat/Settings.form @@ -12,10 +12,7 @@ -<<<<<<< HEAD -======= ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 @@ -23,11 +20,7 @@ -<<<<<<< HEAD -======= - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 @@ -52,7 +45,6 @@ -<<<<<<< HEAD @@ -62,34 +54,10 @@ -======= - - - - - - - - - - - - - - - - - - - - - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 -<<<<<<< HEAD @@ -99,104 +67,19 @@ -======= - - - - - - - - - - - - - - - - - - - - - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 -<<<<<<< HEAD -======= - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 -<<<<<<< HEAD @@ -567,193 +450,5 @@ -======= - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Settings.java b/src/net/apocalypselabs/symat/Settings.java index 7a07f8e..5b6918b 100644 --- a/src/net/apocalypselabs/symat/Settings.java +++ b/src/net/apocalypselabs/symat/Settings.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -457,372 +456,3 @@ public class Settings extends javax.swing.JInternalFrame { private javax.swing.ButtonGroup themeGroup; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -/** - * - * @author Skylar - */ -public class Settings extends javax.swing.JInternalFrame { - - /** - * Creates new form Settings - */ - public Settings() { - initComponents(); - setBackground(Theme.windowColor()); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - themeGroup = new javax.swing.ButtonGroup(); - jPanel1 = new javax.swing.JPanel(); - themeLight = new javax.swing.JRadioButton(); - themeDark = new javax.swing.JRadioButton(); - saveBtn = new javax.swing.JButton(); - jPanel2 = new javax.swing.JPanel(); - showRecent = new javax.swing.JCheckBox(); - clrRecentBtn = new javax.swing.JButton(); - jPanel3 = new javax.swing.JPanel(); - quickStart = new javax.swing.JCheckBox(); - skipUpdates = new javax.swing.JCheckBox(); - applyBtn = new javax.swing.JButton(); - jPanel4 = new javax.swing.JPanel(); - jLabel1 = new javax.swing.JLabel(); - nameBox = new javax.swing.JTextField(); - jPanel5 = new javax.swing.JPanel(); - fontSizeSpinner = new javax.swing.JSpinner(); - - setClosable(true); - setIconifiable(true); - setTitle("Settings"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/settings.png"))); // NOI18N - setMaximumSize(new java.awt.Dimension(9999, 9999)); - setMinimumSize(new java.awt.Dimension(100, 100)); - setPreferredSize(new java.awt.Dimension(555, 280)); - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentShown(java.awt.event.ComponentEvent evt) { - formComponentShown(evt); - } - }); - - jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Theme")); - jPanel1.setToolTipText("Change the UI theme."); - - themeGroup.add(themeLight); - themeLight.setSelected(true); - themeLight.setText("Light"); - - themeGroup.add(themeDark); - themeDark.setText("Dark"); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(themeLight) - .addComponent(themeDark)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addComponent(themeLight) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(themeDark) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - saveBtn.setText("Save"); - saveBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveBtnActionPerformed(evt); - } - }); - - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Recent Items")); - - showRecent.setSelected(true); - showRecent.setText("Show recent items sidebar"); - - clrRecentBtn.setText("Clear recent items"); - clrRecentBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - clrRecentBtnActionPerformed(evt); - } - }); - - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); - jPanel2.setLayout(jPanel2Layout); - jPanel2Layout.setHorizontalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(showRecent) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addComponent(clrRecentBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addContainerGap()) - ); - jPanel2Layout.setVerticalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addComponent(showRecent) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(clrRecentBtn) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Startup")); - - quickStart.setText("Quick Start"); - - skipUpdates.setText("Skip Update Check"); - - javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); - jPanel3.setLayout(jPanel3Layout); - jPanel3Layout.setHorizontalGroup( - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel3Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(quickStart) - .addComponent(skipUpdates)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - jPanel3Layout.setVerticalGroup( - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel3Layout.createSequentialGroup() - .addContainerGap() - .addComponent(quickStart) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(skipUpdates) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - applyBtn.setText("Apply"); - applyBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - applyBtnActionPerformed(evt); - } - }); - - jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Default Values")); - - jLabel1.setText("Your name:"); - - javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); - jPanel4.setLayout(jPanel4Layout); - jPanel4Layout.setHorizontalGroup( - jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel4Layout.createSequentialGroup() - .addComponent(jLabel1) - .addGap(0, 0, Short.MAX_VALUE)) - .addComponent(nameBox) - ); - jPanel4Layout.setVerticalGroup( - jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel4Layout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(nameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)) - ); - - jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Font Size")); - - fontSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(12, 5, 48, 1)); - - javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); - jPanel5.setLayout(jPanel5Layout); - jPanel5Layout.setHorizontalGroup( - jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel5Layout.createSequentialGroup() - .addGap(22, 22, 22) - .addComponent(fontSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(30, Short.MAX_VALUE)) - ); - jPanel5Layout.setVerticalGroup( - jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel5Layout.createSequentialGroup() - .addGap(22, 22, 22) - .addComponent(fontSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(0, 0, 0) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createSequentialGroup() - .addComponent(applyBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(saveBtn))) - .addContainerGap(90, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(saveBtn) - .addComponent(applyBtn))) - .addContainerGap(56, Short.MAX_VALUE)) - ); - - pack(); - }// //GEN-END:initComponents - - private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown - if (PrefStorage.isset("theme")) { - switch (PrefStorage.getSetting("theme")) { - case "dark": - themeLight.setSelected(false); - themeDark.setSelected(true); - break; - default: - themeLight.setSelected(true); - themeDark.setSelected(false); - } - } - - showRecent.setSelected( - PrefStorage.getSetting("showrecent", "").equals("")); - quickStart.setSelected( - PrefStorage.getSetting("quickstart", "").equals("yes")); - skipUpdates.setSelected( - PrefStorage.getSetting("skipupdates", "").equals("yes")); - nameBox.setText(PrefStorage.getSetting("author", "")); - try { - fontSizeSpinner.setValue(Integer.parseInt(PrefStorage.getSetting("editfont", "12"))); - } catch (Exception ex) { - fontSizeSpinner.setValue(12); - } - }//GEN-LAST:event_formComponentShown - - private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed - doSave(); - dispose(); - }//GEN-LAST:event_saveBtnActionPerformed - - private void doSave() { - Theme.setTheme(themeDark.isSelected() ? "dark" : "light"); - PrefStorage.saveSetting("showrecent", showRecent.isSelected() ? "" : "no"); - PrefStorage.saveSetting("quickstart", quickStart.isSelected() ? "yes" : ""); - PrefStorage.saveSetting("skipupdates", skipUpdates.isSelected() ? "yes" : ""); - PrefStorage.saveSetting("author", nameBox.getText()); - PrefStorage.saveSetting("editfont", fontSizeSpinner.getValue().toString()); - PrefStorage.save(); - Main.updateDisplay(); - } - - private void clrRecentBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clrRecentBtnActionPerformed - PrefStorage.saveSetting("recentfiles", ""); - Main.loadRecentFiles(); - }//GEN-LAST:event_clrRecentBtnActionPerformed - - private void applyBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyBtnActionPerformed - doSave(); - }//GEN-LAST:event_applyBtnActionPerformed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton applyBtn; - private javax.swing.JButton clrRecentBtn; - private javax.swing.JSpinner fontSizeSpinner; - private javax.swing.JLabel jLabel1; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JPanel jPanel3; - private javax.swing.JPanel jPanel4; - private javax.swing.JPanel jPanel5; - private javax.swing.JTextField nameBox; - private javax.swing.JCheckBox quickStart; - private javax.swing.JButton saveBtn; - private javax.swing.JCheckBox showRecent; - private javax.swing.JCheckBox skipUpdates; - private javax.swing.JRadioButton themeDark; - private javax.swing.ButtonGroup themeGroup; - private javax.swing.JRadioButton themeLight; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/SharePad.java b/src/net/apocalypselabs/symat/SharePad.java index 7b77816..9a052d7 100644 --- a/src/net/apocalypselabs/symat/SharePad.java +++ b/src/net/apocalypselabs/symat/SharePad.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -288,284 +287,3 @@ public class SharePad extends javax.swing.JPanel { private javax.swing.JTextField padIDBox; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.SwingUtilities; - -/** - * - * @author Skylar - */ -public class SharePad extends javax.swing.JPanel { - - String padid = ""; - - /** - * Creates new form SharePad - * - * @param id The pad ID to share. - */ - public SharePad(String id) { - initComponents(); - padid = id; - padIDBox.setText(padid); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jLabel1 = new javax.swing.JLabel(); - padIDBox = new javax.swing.JTextField(); - jPanel1 = new javax.swing.JPanel(); - copyIDBtn = new javax.swing.JButton(); - copyLinkBtn = new javax.swing.JButton(); - emailBtn = new javax.swing.JButton(); - emailBox = new javax.swing.JTextField(); - jLabel2 = new javax.swing.JLabel(); - - setMinimumSize(new java.awt.Dimension(188, 172)); - - jLabel1.setText("Pad ID:"); - - padIDBox.setEditable(false); - - jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Share")); - - copyIDBtn.setText("Copy ID"); - copyIDBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - copyIDBtnActionPerformed(evt); - } - }); - - copyLinkBtn.setText("Copy Link"); - copyLinkBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - copyLinkBtnActionPerformed(evt); - } - }); - - emailBtn.setText("Send Email"); - emailBtn.setEnabled(false); - emailBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - emailBtnActionPerformed(evt); - } - }); - - emailBox.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - emailBoxKeyTyped(evt); - } - }); - - jLabel2.setText("Email Link:"); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(copyIDBtn) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(copyLinkBtn)) - .addComponent(emailBox) - .addComponent(emailBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel2) - .addGap(0, 0, Short.MAX_VALUE)) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(copyIDBtn) - .addComponent(copyLinkBtn)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(emailBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(emailBtn) - .addGap(5, 5, 5)) - ); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(padIDBox))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap(17, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(padIDBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(7, 7, 7)) - ); - }// //GEN-END:initComponents - - private void copyIDBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyIDBtnActionPerformed - toClipboard(padid); - }//GEN-LAST:event_copyIDBtnActionPerformed - - private void copyLinkBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyLinkBtnActionPerformed - toClipboard(Pads.PADS_URL + "/p/" + padid); - }//GEN-LAST:event_copyLinkBtnActionPerformed - - private void emailBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailBtnActionPerformed - if (License.checkEmail(emailBox.getText())) { - emailBtn.setEnabled(false); - emailBtn.setText("Sending..."); - new EmailThread(emailBox.getText(), padid).start(); - } - }//GEN-LAST:event_emailBtnActionPerformed - - private class EmailThread extends Thread { - - private final String email; - private final String pad; - - @Override - public void run() { - try { - String f = FileUtils.getUrl( - Main.API_URL + "sendpad.php?email=" - + email + "&padid=" + pad); - Debug.println(f); - if (f.contains("OK")) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - emailBtn.setText("Link Sent!"); - emailBox.setText(""); - } - }); - } else { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - emailBtn.setText("Error."); - } - }); - } - } catch (Exception ex) { - Debug.stacktrace(ex); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - emailBtn.setText("Error, retry?"); - } - }); - } - try { - Thread.sleep(1500); - } catch (InterruptedException ex) { - - } - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - emailBtn.setEnabled(License.checkEmail(emailBox.getText())); - emailBtn.setText("Send Email"); - } - }); - } - - public EmailThread(String e, String p) { - email = e; - pad = p; - } - } - - private void emailBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_emailBoxKeyTyped - emailBtn.setEnabled(License.checkEmail(emailBox.getText())); - }//GEN-LAST:event_emailBoxKeyTyped - - private void toClipboard(String text) { - StringSelection stringSelection = new StringSelection(text); - Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); - clpbrd.setContents(stringSelection, null); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton copyIDBtn; - private javax.swing.JButton copyLinkBtn; - private javax.swing.JTextField emailBox; - private javax.swing.JButton emailBtn; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JPanel jPanel1; - private javax.swing.JTextField padIDBox; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/SingleInstanceClient.java b/src/net/apocalypselabs/symat/SingleInstanceClient.java index cbbfd6b..d992d19 100644 --- a/src/net/apocalypselabs/symat/SingleInstanceClient.java +++ b/src/net/apocalypselabs/symat/SingleInstanceClient.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -91,87 +90,3 @@ public class SingleInstanceClient { } } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; - -/** - * This class attempts to send startup data to an existing instance, and if it - * succeeds it kills this instance of SyMAT. - * - * @author Skylar - */ -public class SingleInstanceClient { - - public SingleInstanceClient(String arg) { - String response = ""; - String args = (arg.equals("") ? "" : "?arg=" + arg); - try { - URL url = new URL("http://127.0.0.1:26879" + args); - InputStream is = url.openStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - - String line = br.readLine(); - br.close(); - is.close(); - response = line; - } catch (Exception ex) { - - } - - if (response.equals("OK")) { - Debug.println("Handing off to original instance..."); - System.exit(0); - } - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/SingleInstanceServer.java b/src/net/apocalypselabs/symat/SingleInstanceServer.java index b63fc4f..f8c50f1 100644 --- a/src/net/apocalypselabs/symat/SingleInstanceServer.java +++ b/src/net/apocalypselabs/symat/SingleInstanceServer.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -112,108 +111,3 @@ public class SingleInstanceServer extends NanoHTTPD { } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import fi.iki.elonen.NanoHTTPD; -import java.io.File; -import java.util.Map; - -/** - * - * @author Skylar - */ -public class SingleInstanceServer extends NanoHTTPD { - - public SingleInstanceServer() { - super(26879); - } - - @Override - public Response serve(IHTTPSession session) { - Debug.println("Another instance detected"); - String msg = "OK"; - Map parms = session.getParms(); - if (parms.get("arg") != null) { - (new LaunchThread(parms.get("arg"))).start(); - } - return new NanoHTTPD.Response(msg); - } - - private class LaunchThread extends Thread { - - String arg; - - @Override - public void run() { - if (arg.endsWith(".sytt")) { - Tasks tt = new Tasks(new File(arg)); - Main.loadFrame(tt); - } else if (arg.endsWith(".sypl")) { - Main.loadFrame(new InstallPlugin(new File(arg))); - } else { - Editor ed = new Editor(); - Main.loadFrame(ed); - ed.openFileFromName(arg); - } - java.awt.EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - Main.maingui.toFront(); - Main.maingui.repaint(); - } - }); - } - - public LaunchThread(String a) { - arg = a; - } - } - -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/SplashScreen.java b/src/net/apocalypselabs/symat/SplashScreen.java index 55cfc72..c829895 100644 --- a/src/net/apocalypselabs/symat/SplashScreen.java +++ b/src/net/apocalypselabs/symat/SplashScreen.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -328,324 +327,3 @@ public class SplashScreen extends javax.swing.JFrame { private javax.swing.JLayeredPane jLayeredPane1; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Color; -import java.io.BufferedReader; -import java.io.File; -import java.io.FilenameFilter; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Calendar; -import java.util.Date; -import javax.swing.SwingUtilities; -import static net.apocalypselabs.symat.Main.API_URL; -import static net.apocalypselabs.symat.Main.APP_CODE; -import static net.apocalypselabs.symat.Main.VERSION_NAME; - -/** - * - * @author Skylar - */ -public class SplashScreen extends javax.swing.JFrame { - - /** - * Creates new form SplashScreen - */ - public SplashScreen() { - initComponents(); - setBackground(new Color(255, 255, 255, 0)); - setIconImages(Main.symatlogo); - setLocationRelativeTo(null); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jLayeredPane1 = new javax.swing.JLayeredPane(); - dispLabel = new javax.swing.JLabel(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("SyMAT"); - setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); - setMinimumSize(new java.awt.Dimension(500, 400)); - setUndecorated(true); - setResizable(false); - setType(java.awt.Window.Type.POPUP); - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentShown(java.awt.event.ComponentEvent evt) { - formComponentShown(evt); - } - }); - - jLayeredPane1.setBackground(new java.awt.Color(255, 255, 255)); - - dispLabel.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(14.0F)); - dispLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - dispLabel.setText("Loading..."); - dispLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); - dispLabel.setMaximumSize(new java.awt.Dimension(400, 320)); - jLayeredPane1.add(dispLabel); - dispLabel.setBounds(140, 280, 220, 70); - - jLabel1.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(36.0F)); - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel1.setText(""+net.apocalypselabs.symat.Main.SYMAT+" "+net.apocalypselabs.symat.Main.VERSION_NAME+""); - jLayeredPane1.add(jLabel1); - jLabel1.setBounds(100, 220, 300, 50); - jLayeredPane1.setLayer(jLabel1, javax.swing.JLayeredPane.POPUP_LAYER); - - jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/images/splashscreen.png"))); // NOI18N - jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP); - jLayeredPane1.add(jLabel2); - jLabel2.setBounds(0, 0, 500, 400); - - jLabel3.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(12.0F)); - jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); - jLabel3.setText("Netsyms Technologies"); - jLayeredPane1.add(jLabel3); - jLabel3.setBounds(10, 370, 250, 30); - jLayeredPane1.setLayer(jLabel3, javax.swing.JLayeredPane.POPUP_LAYER); - - jLabel4.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(12.0F)); - jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel4.setText("symatapp.com"); - jLabel4.setMaximumSize(new java.awt.Dimension(118, 14)); - jLabel4.setMinimumSize(new java.awt.Dimension(118, 14)); - jLabel4.setPreferredSize(new java.awt.Dimension(118, 14)); - jLayeredPane1.add(jLabel4); - jLabel4.setBounds(380, 370, 110, 30); - jLayeredPane1.setLayer(jLabel4, javax.swing.JLayeredPane.POPUP_LAYER); - - getContentPane().add(jLayeredPane1, java.awt.BorderLayout.CENTER); - - pack(); - }// //GEN-END:initComponents - - private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown - new Loader().start(); - }//GEN-LAST:event_formComponentShown - - /** - * Bootstrapping everything. - */ - private class Loader extends Thread { - - @Override - public void run() { - setProgress("Starting up..."); - if (PrefStorage.getSetting("quickstart").equals("yes")) { - Main.skipPython = true; - Main.skipEditor = true; - } - if (!Main.skipPython) { - // Python laggggsss when used for first time, this fixes the wait later. - System.out.println("Warming up Python engine, to skip run with argument 'skippython'"); - setProgress("Initializing code engine..."); - try { - CodeRunner python = new CodeRunner(true); - } catch (Exception ex) { - // Ignore - } - } - - if (!Main.skipEditor) { - System.out.println("Preparing editor, to skip run with argument 'skipeditor'"); - setProgress("Preparing editor..."); - // Get editor going too - Editor edit = new Editor(); - } - - setProgress("Loading toolkits..."); - try { - String fsep = System.getProperty("file.separator"); - File dir = new File(System.getProperty("user.home") + fsep + ".symat" + fsep + "toolkits"); - dir.mkdirs(); - File[] files = dir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(".jar"); - } - }); - for (File f : files) { - addSoftwareLibrary(f); - } - } catch (Exception ex) { - Debug.stacktrace(ex); - } - - setProgress("Checking license..."); - checkLicense(); - - if (!PrefStorage.getSetting("skipupdates").equals("yes")) { - setProgress("Checking for updates..."); - checkUpdates(); - } - - setProgress("Loading main interface..."); - new Main(); - setProgress("Done!"); - dispose(); - } - - // Thanks to http://stackoverflow.com/a/9460999/2534036 - private void addSoftwareLibrary(File file) throws Exception { - Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); - method.setAccessible(true); - method.invoke(ClassLoader.getSystemClassLoader(), new Object[]{file.toURI().toURL()}); - Debug.println("Loaded toolkit " + file.getName()); - } - - private void checkLicense() { - if (PrefStorage.getSetting("license").equals("") - || PrefStorage.getSetting("licensetype").equals("demo")) { - if (PrefStorage.getSetting("licensetype").equals("demo")) { - Calendar c = Calendar.getInstance(); - c.setTime(new Date()); - try { - long expire = Long.parseLong(PrefStorage.getSetting("license")); - if (expire > c.getTimeInMillis()) { - Main.licValid = true; - } - } catch (NumberFormatException e) { - - } - } - } else { - try { - Debug.println("Checking license..."); - URL url = new URL(API_URL + "liccheck.php?email=" - + PrefStorage.getSetting("license") - + "&quick=1"); - String line; - try (InputStream is = url.openStream(); - BufferedReader br - = new BufferedReader(new InputStreamReader(is))) { - line = br.readLine(); - } - if (line.equals("ok")) { - Main.licValid = true; - } - } catch (Exception ex) { - // Assume valid - Main.licValid = true; - } - } - } - - private void checkUpdates() { - // Check for updates. - try { - Debug.println("Checking for updates..."); - URL url = new URL(API_URL + "version.php"); - InputStream is = url.openStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - - String line = br.readLine(); - br.close(); - is.close(); - double version = Double.parseDouble(line.split("\\|")[0]); - if (version > APP_CODE) { - if (PrefStorage.getSetting("update-ignore") - .equals(VERSION_NAME + "|" + line.split("\\|")[1])) { - System.out.println("An update was found, " - + "but has been ignored by the user."); - } else { - Debug.println("Update available."); - Main.updateString = line.split("\\|")[1]; - Main.updateAvailable = true; - } - } else { - Debug.println("No updates found."); - } - } catch (Exception e) { - System.err.println("Fail: Cannot check update server. \n" - + " Assuming local copy up-to-date."); - Debug.stacktrace(e); - } - } - - /** - * Set the progress text. - * - * @param label The String to put on the label. - */ - private void setProgress(String label) { - final String lbl = label; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - dispLabel.setText(lbl); - } - }); - } - } - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel dispLabel; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLayeredPane jLayeredPane1; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/SyncLogin.java b/src/net/apocalypselabs/symat/SyncLogin.java index c8d2605..1867196 100644 --- a/src/net/apocalypselabs/symat/SyncLogin.java +++ b/src/net/apocalypselabs/symat/SyncLogin.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -40,53 +39,11 @@ * software are copyright (c) 2015 Netsyms Technologies. You may not distribute * the graphics or any program, source code repository, or other digital storage * media containing them without permission from Netsyms Technologies. -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 * This ban on distribution only applies to publicly available systems. * A password-protected network file share, USB drive, or other storage scheme that * cannot be easily accessed by the public is generally allowed. If in doubt, * contact Netsyms Technologies. If Netsyms Technologies allows or denies * you permission, that decision is considered final and binding. -<<<<<<< HEAD * * You may only use the media for personal, * non-commercial, non-educational use unless: @@ -95,8 +52,6 @@ * Other uses are prohibited without permission. * If any part of this license is deemed unenforcable, the remainder * of the license remains in full effect. -======= ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 */ package net.apocalypselabs.symat; diff --git a/src/net/apocalypselabs/symat/Tasks.java b/src/net/apocalypselabs/symat/Tasks.java index 96a1731..4bdcb86 100644 --- a/src/net/apocalypselabs/symat/Tasks.java +++ b/src/net/apocalypselabs/symat/Tasks.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -373,369 +372,3 @@ public class Tasks extends javax.swing.JInternalFrame { private javax.swing.JScrollPane taskList; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Component; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import net.apocalypselabs.symat.components.Task; -import net.apocalypselabs.symat.components.TaskList; - -/** - * - * @author Skylar - */ -public class Tasks extends javax.swing.JInternalFrame { - - private String tltitle = "Untitled"; - - private final JFileChooser fc = new JFileChooser(); - - private File ondisk = null; - - /** - * Creates new form Tasks - */ - public Tasks() { - FileFilter filter = new FileNameExtensionFilter("Task List (.sytt)", "sytt"); - fc.setFileFilter(filter); - initComponents(); - } - - public Tasks(File f) { - this(); - try { - openTaskFile(f); - } catch (Exception ex) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Cannot open task list: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - Debug.stacktrace(ex); - } - } - - private void openTaskFile(File f) throws IOException, ClassNotFoundException { - FileInputStream fin = new FileInputStream(f); - ObjectInputStream ois = new ObjectInputStream(fin); - TaskList tl = (TaskList) ois.readObject(); - ois.close(); - - Task[] list = tl.getTasks(); - for (Task t : list) { - listPanel.add(t); - } - setTitle(tl.getTitle()); - tltitle = tl.getTitle(); - ondisk = f; - redraw(); - } - - private void saveTasks(File f) throws FileNotFoundException, IOException { - TaskList tl = new TaskList(); - for (Component c : listPanel.getComponents()) { - tl.addTask((Task) c); - } - tl.setTitle(tltitle); - FileOutputStream fout = new FileOutputStream(f); - try (ObjectOutputStream oos = new ObjectOutputStream(fout)) { - oos.writeObject(tl); - oos.close(); - ondisk = f; - } - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - taskList = new javax.swing.JScrollPane(); - listPanel = new javax.swing.JPanel(); - jMenuBar1 = new javax.swing.JMenuBar(); - jMenu1 = new javax.swing.JMenu(); - openBtn = new javax.swing.JMenuItem(); - appendBtn = new javax.swing.JMenuItem(); - saveBtn = new javax.swing.JMenuItem(); - saveAsBtn = new javax.swing.JMenuItem(); - exportBtn = new javax.swing.JMenuItem(); - jMenu2 = new javax.swing.JMenu(); - insertItemBtn = new javax.swing.JMenuItem(); - setTitleBtn = new javax.swing.JMenuItem(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Tasks"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/tasks.png"))); // NOI18N - - listPanel.setLayout(new javax.swing.BoxLayout(listPanel, javax.swing.BoxLayout.Y_AXIS)); - taskList.setViewportView(listPanel); - - jMenu1.setText("File"); - - openBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); - openBtn.setText("Open..."); - openBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - openBtnActionPerformed(evt); - } - }); - jMenu1.add(openBtn); - - appendBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); - appendBtn.setText("Append..."); - appendBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - appendBtnActionPerformed(evt); - } - }); - jMenu1.add(appendBtn); - - saveBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); - saveBtn.setText("Save..."); - saveBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveBtnActionPerformed(evt); - } - }); - jMenu1.add(saveBtn); - - saveAsBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); - saveAsBtn.setText("Save As..."); - saveAsBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - saveAsBtnActionPerformed(evt); - } - }); - jMenu1.add(saveAsBtn); - - exportBtn.setText("Export..."); - exportBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exportBtnActionPerformed(evt); - } - }); - jMenu1.add(exportBtn); - - jMenuBar1.add(jMenu1); - - jMenu2.setText("Edit"); - - insertItemBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK)); - insertItemBtn.setText("Insert item"); - insertItemBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - insertItemBtnActionPerformed(evt); - } - }); - jMenu2.add(insertItemBtn); - - setTitleBtn.setText("List title..."); - setTitleBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - setTitleBtnActionPerformed(evt); - } - }); - jMenu2.add(setTitleBtn); - - jMenuBar1.add(jMenu2); - - setJMenuBar(jMenuBar1); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(taskList, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(taskList, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - private void insertItemBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertItemBtnActionPerformed - Task t = new Task(0, "Untitled Task", - "No description"); - listPanel.add(t); - t.setVisible(true); - redraw(); - }//GEN-LAST:event_insertItemBtnActionPerformed - - private void openBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openBtnActionPerformed - int result = fc.showOpenDialog(this); - if (result == JFileChooser.APPROVE_OPTION) { - listPanel.removeAll(); - try { - openTaskFile(fc.getSelectedFile()); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Cannot open task list: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - Debug.stacktrace(ex); - } catch (ClassNotFoundException ex) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Cannot open task list: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - Debug.stacktrace(ex); - } - } - }//GEN-LAST:event_openBtnActionPerformed - - private void setTitleBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setTitleBtnActionPerformed - String res = JOptionPane.showInternalInputDialog(this, - "Task list title:", - "Change Title", - JOptionPane.QUESTION_MESSAGE); - if (res == null) { - return; - } - if (res.equals("")) { - return; - } - setTitle(res); - tltitle = res; - }//GEN-LAST:event_setTitleBtnActionPerformed - - private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed - int result; - if (ondisk == null) { - result = fc.showSaveDialog(this); - } else { - fc.setSelectedFile(ondisk); - result = JFileChooser.APPROVE_OPTION; - } - if (result == JFileChooser.APPROVE_OPTION) { - try { - saveTasks(FileUtils.getFileWithExtension(fc)); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Cannot save task list: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - Debug.stacktrace(ex); - } - } - }//GEN-LAST:event_saveBtnActionPerformed - - private void saveAsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsBtnActionPerformed - ondisk = null; - saveBtn.doClick(); - }//GEN-LAST:event_saveAsBtnActionPerformed - - private void appendBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_appendBtnActionPerformed - int result = fc.showDialog(this, "Merge List"); - if (result == JFileChooser.APPROVE_OPTION) { - try { - openTaskFile(fc.getSelectedFile()); - } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Cannot open task list: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - Debug.stacktrace(ex); - } catch (ClassNotFoundException ex) { - JOptionPane.showInternalMessageDialog(Main.mainPane, - "Cannot open task list: " + ex.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - Debug.stacktrace(ex); - } - } - }//GEN-LAST:event_appendBtnActionPerformed - - private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportBtnActionPerformed - TaskList tl = new TaskList(); - tl.setTitle(tltitle); - for (Component c : listPanel.getComponents()) { - tl.addTask((Task) c); - } - Main.loadFrame(new TasksExport(tl)); - }//GEN-LAST:event_exportBtnActionPerformed - - private void redraw() { - setSize(getWidth() + 1, getHeight()); - setSize(getWidth() - 1, getHeight()); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JMenuItem appendBtn; - private javax.swing.JMenuItem exportBtn; - private javax.swing.JMenuItem insertItemBtn; - private javax.swing.JMenu jMenu1; - private javax.swing.JMenu jMenu2; - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JPanel listPanel; - private javax.swing.JMenuItem openBtn; - private javax.swing.JMenuItem saveAsBtn; - private javax.swing.JMenuItem saveBtn; - private javax.swing.JMenuItem setTitleBtn; - private javax.swing.JScrollPane taskList; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/TasksExport.java b/src/net/apocalypselabs/symat/TasksExport.java index 251d12a..f89457a 100644 --- a/src/net/apocalypselabs/symat/TasksExport.java +++ b/src/net/apocalypselabs/symat/TasksExport.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -486,482 +485,3 @@ public class TasksExport extends javax.swing.JInternalFrame { private javax.swing.JPanel webPanel; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import com.itextpdf.text.BadElementException; -import com.itextpdf.text.Document; -import com.itextpdf.text.DocumentException; -import com.itextpdf.text.Image; -import com.itextpdf.text.pdf.PdfContentByte; -import com.itextpdf.text.pdf.PdfWriter; -import java.awt.BorderLayout; -import java.awt.image.BufferedImage; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.logging.Level; -import java.util.logging.Logger; -import javafx.application.Platform; -import javafx.collections.ObservableList; -import javafx.embed.swing.JFXPanel; -import javafx.embed.swing.SwingFXUtils; -import javafx.scene.Group; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.image.WritableImage; -import javafx.scene.web.WebEngine; -import javafx.scene.web.WebView; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import net.apocalypselabs.symat.components.Task; -import net.apocalypselabs.symat.components.TaskList; -import org.htmlcleaner.CleanerProperties; -import org.htmlcleaner.HtmlCleaner; -import org.htmlcleaner.SimpleHtmlSerializer; -import org.htmlcleaner.TagNode; - -/** - * - * @author Skylar - */ -public class TasksExport extends javax.swing.JInternalFrame { - - private String html; - private TaskList tl; - - private WebView browser; - private WebEngine webEngine; - private JFXPanel jfxPanel; - private Group root; - private Scene scene; - - /** - * Creates new form TasksExport - * - * @param t Task List to generate from. - */ - public TasksExport(TaskList t) { - initComponents(); - jfxPanel = new JFXPanel(); - Platform.runLater(new Runnable() { - @Override - public void run() { - browser = new WebView(); - browser.setPrefSize(getWidth(), getHeight()); - root = new Group(); - scene = new Scene(root); - ObservableList children = root.getChildren(); - children.add(browser); - jfxPanel.setScene(scene); - webEngine = browser.getEngine(); - webEngine.setUserAgent("SyMAT " + Main.VERSION_NAME); - webEngine.loadContent("

Loading...

"); - webPanel.add(jfxPanel, BorderLayout.CENTER); - } - }); - tl = t; - titleBox.setText(t.getTitle()); - html = genHtml(t); - loadString(html); - } - - private void resizeAll() { - Platform.runLater(new Runnable() { - @Override - public void run() { - jfxPanel.setSize(webPanel.getWidth(), webPanel.getHeight()); - browser.setPrefSize(webPanel.getWidth(), webPanel.getHeight()); - browser.resize(webPanel.getWidth(), webPanel.getHeight()); - } - }); - } - - public void loadString(final String content) { - Platform.runLater(new Runnable() { - @Override - public void run() { - webEngine.loadContent(content); - resizeAll(); - } - }); - } - - private String genHtml(TaskList tt) { - String css = ""; - BufferedReader reader = new BufferedReader( - new InputStreamReader( - TasksExport.class - .getResourceAsStream("tasks.css"))); - String line; - try { - while ((line = reader.readLine()) != null) { - css += line; - } - } catch (IOException ex) { - Logger.getLogger(TasksExport.class.getName()).log(Level.SEVERE, null, ex); - } - html = "" - + "" - + "" - + "" + titleBox.getText() + "" - + "" - + "" - + "" - + "

" + titleBox.getText() + "

"; - if (!authBox.getText().equals("")) { - html += "

Author: " + authBox.getText() + "

"; - } - if (!dateBox.getText().equals("")) { - html += "

Date: " + dateBox.getText() + "

"; - } - if (!headerBox.getText().equals("")) { - html += "

" + headerBox.getText() + "

"; - } - - for (Task t : tt.getTasks()) { - html += "
" - + "

" + t.toString() + "

" - + percentBar(t.getComplete()) - + "

" + t.getDesc() + "

" - + "
"; - } - - html += ""; - html = html.replace("\t", "    "); - html = html.replace("\n", "
"); - HtmlCleaner cleaner = new HtmlCleaner(); - CleanerProperties props = cleaner.getProperties(); - TagNode node = cleaner.clean(html); - html = new SimpleHtmlSerializer(props).getAsString(node); - html = html.replace("'", "'"); - html = html.replace("", ""); - Debug.println(html); - return html; - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jPanel1 = new javax.swing.JPanel(); - titleBox = new javax.swing.JTextField(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - authBox = new javax.swing.JTextField(); - dateBox = new javax.swing.JTextField(); - jLabel3 = new javax.swing.JLabel(); - jScrollPane2 = new javax.swing.JScrollPane(); - headerBox = new javax.swing.JTextArea(); - jLabel4 = new javax.swing.JLabel(); - previewBtn = new javax.swing.JButton(); - jPanel2 = new javax.swing.JPanel(); - exHtml = new javax.swing.JButton(); - webPanel = new javax.swing.JPanel(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Export Task List"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/export.png"))); // NOI18N - setMinimumSize(new java.awt.Dimension(599, 300)); - setPreferredSize(new java.awt.Dimension(599, 418)); - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentResized(java.awt.event.ComponentEvent evt) { - formComponentResized(evt); - } - }); - - titleBox.setText("Untitled"); - - jLabel1.setText("Title:"); - - jLabel2.setText("Author:"); - - authBox.setText(PrefStorage.getSetting("author", "")); - - jLabel3.setText("Date:"); - - headerBox.setColumns(20); - headerBox.setLineWrap(true); - headerBox.setRows(2); - headerBox.setTabSize(4); - headerBox.setWrapStyleWord(true); - jScrollPane2.setViewportView(headerBox); - - jLabel4.setText("Header:"); - - previewBtn.setText("Update Preview"); - previewBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - previewBtnActionPerformed(evt); - } - }); - - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Export to:")); - - exHtml.setText("HTML"); - exHtml.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exHtmlActionPerformed(evt); - } - }); - - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); - jPanel2.setLayout(jPanel2Layout); - jPanel2Layout.setHorizontalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addComponent(exHtml, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE) - .addContainerGap()) - ); - jPanel2Layout.setVerticalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addGap(19, 19, 19) - .addComponent(exHtml) - .addContainerGap(21, Short.MAX_VALUE)) - ); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel1) - .addGap(18, 18, 18) - .addComponent(titleBox, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) - .addComponent(jLabel3)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(dateBox) - .addComponent(authBox)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(previewBtn)) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(5, 5, 5) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1) - .addComponent(jLabel4) - .addComponent(previewBtn)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(authBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(dateBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel3))) - .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - webPanel.setLayout(new java.awt.BorderLayout()); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(webPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(webPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(10, 10, 10)) - ); - - pack(); - }// //GEN-END:initComponents - - private void previewBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previewBtnActionPerformed - html = genHtml(tl); - loadString(html); - }//GEN-LAST:event_previewBtnActionPerformed - - private void exHtmlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exHtmlActionPerformed - html = genHtml(tl); - doSave("html"); - }//GEN-LAST:event_exHtmlActionPerformed - - private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized - resizeAll(); - }//GEN-LAST:event_formComponentResized - - private void doSave(String format) { - JFileChooser fc = new JFileChooser(); - FileFilter filter; - switch (format) { - case "pdf": - filter = new FileNameExtensionFilter("Portable Document Format (PDF)", "pdf"); - break; - default: - filter = new FileNameExtensionFilter("Web Document (HTML)", "html"); - } - fc.setFileFilter(filter); - fc.addChoosableFileFilter(filter); - int r = fc.showSaveDialog(this); - if (r == JFileChooser.APPROVE_OPTION) { - String file = FileUtils.getFileWithExtension(fc).getAbsolutePath(); - switch (format) { - case "html": - saveFile(html, file); - break; - case "pdf": - savePdfFile(html, file); - break; - } - } - } - - private String percentBar(int p) { - int by5 = 5 * (Math.round(p / 5)); - String result = "

" + by5 + "%

"; - return result; - } - - private void savePdfFile(String html, String path) { - Platform.runLater(new Runnable() { - @Override - public void run() { - try { - String k = html; - OutputStream file = new FileOutputStream(new File(path)); - Document document = new Document(); - PdfWriter writer = PdfWriter.getInstance(document, file); - document.open(); - PdfContentByte pdfCB = new PdfContentByte(writer); - WritableImage image = browser.snapshot(null, null); - BufferedImage buffered = SwingFXUtils.fromFXImage(image, null); - Image img = Image.getInstance(pdfCB, buffered, 1); - document.open(); - document.add(img); - document.close(); - savedMsg(); - } catch (Exception ex) { - Debug.stacktrace(ex); - java.awt.EventQueue.invokeLater(() -> { - JOptionPane.showInternalMessageDialog(Main.mainPane, "Error saving: " + ex.getMessage()); - }); - } - } - }); - } - - private void saveFile(String content, String path) { - try { - PrintStream out = new PrintStream(new FileOutputStream(path)); - out.print(content); - savedMsg(); - } catch (Exception ex) { - JOptionPane.showInternalMessageDialog(this, "Error saving: " + ex.getMessage()); - } - } - - private void savedMsg() { - JOptionPane.showInternalMessageDialog(this, "Export complete!"); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextField authBox; - private javax.swing.JTextField dateBox; - private javax.swing.JButton exHtml; - private javax.swing.JTextArea headerBox; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JButton previewBtn; - private javax.swing.JTextField titleBox; - private javax.swing.JPanel webPanel; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Theme.java b/src/net/apocalypselabs/symat/Theme.java index a1419ad..9cc3009 100644 --- a/src/net/apocalypselabs/symat/Theme.java +++ b/src/net/apocalypselabs/symat/Theme.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -174,141 +173,3 @@ public class Theme { return (currentTheme == THEME_LIGHT) ? "default" : "dark"; } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Color; - -/** - * Handles theme colors and giving them out. - * - * @author Skylar - */ -public class Theme { - - // Theme colors. - private static final Color WHITE = Color.WHITE; - private static final Color BLACK = Color.BLACK; - private static final Color DBACK = new Color(41, 49, 52); - private static final Color LBACK = new Color(240, 240, 240); - private static final Color DGRAY = Color.DARK_GRAY; - private static final Color LGRAY = Color.LIGHT_GRAY; - - /** - * Light theme. - */ - public static final int THEME_LIGHT = 0; - /** - * Dark theme. - */ - public static final int THEME_DARK = 1; - - /** - * The current theme. - */ - public static int currentTheme = (PrefStorage.getSetting("theme") - .equals("dark") ? 1 : 0); - - /** - * Set the theme for the application. - * - * @param theme the theme id number. - */ - public static void setTheme(int theme) { - switch (theme) { - case THEME_DARK: - PrefStorage.saveSetting("theme", "dark"); - break; - case THEME_LIGHT: - default: - PrefStorage.saveSetting("theme", "light"); - } - currentTheme = theme; - } - - /** - * Set the theme for the application. - * - * @param theme The theme name, either "light" or "dark". - */ - public static void setTheme(String theme) { - switch (theme) { - case "dark": - setTheme(THEME_DARK); - break; - case "light": - default: - setTheme(THEME_LIGHT); - } - } - - public static String getTheme() { - return (currentTheme == THEME_LIGHT) ? "light" : "dark"; - } - - public static Color textColor() { - return (currentTheme == THEME_LIGHT) ? BLACK : WHITE; - } - - public static Color boxColor() { - return (currentTheme == THEME_LIGHT) ? WHITE : DBACK; - } - - public static Color windowColor() { - return (currentTheme == THEME_LIGHT) ? LGRAY : DGRAY; - } - - public static Color tabColor() { - return (currentTheme == THEME_LIGHT) ? LBACK : DBACK; - } - - public static String editorTheme() { - return (currentTheme == THEME_LIGHT) ? "default" : "dark"; - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/Update.java b/src/net/apocalypselabs/symat/Update.java index 6c7b324..1ce166c 100644 --- a/src/net/apocalypselabs/symat/Update.java +++ b/src/net/apocalypselabs/symat/Update.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -228,224 +227,3 @@ public class Update extends javax.swing.JInternalFrame { private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.Desktop; -import java.net.URI; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; - -/** - * - * @author Skylar - */ -public class Update extends javax.swing.JInternalFrame { - - private final String latestVersion; - - /** - * Creates new form Update - * - * @param latest The new version. - */ - public Update(String latest) { - latestVersion = latest; - initComponents(); - (new ChangesThread()).start(); - } - - private class ChangesThread extends Thread { - - @Override - public void run() { - final String html; - String content; - try { - content = FileUtils.getUrl(Main.API_URL + "changelog.php"); - } catch (Exception ex) { - content = "Error, cannot get changes."; - } - html = content; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - changelogBox.setText(html); - } - }); - } - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); - jButton1 = new javax.swing.JButton(); - jLabel5 = new javax.swing.JLabel(); - jScrollPane1 = new javax.swing.JScrollPane(); - changelogBox = new javax.swing.JTextArea(); - - setBackground(new java.awt.Color(255, 255, 255)); - setClosable(true); - setTitle("Update SyMAT"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/update.png"))); // NOI18N - setLayer(100); - - jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel1.setText("An update is available."); - - jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/96x96.png"))); // NOI18N - - jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N - jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel3.setText("Latest version: "+latestVersion); - - jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N - jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel4.setText("Your version: "+net.apocalypselabs.symat.Main.VERSION_NAME); - - jButton1.setBackground(new java.awt.Color(51, 153, 255)); - jButton1.setFont(new java.awt.Font("Tahoma", 3, 18)); // NOI18N - jButton1.setText("Download"); - jButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton1ActionPerformed(evt); - } - }); - - jLabel5.setText("Ignore"); - jLabel5.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - jLabel5MouseClicked(evt); - } - }); - - changelogBox.setEditable(false); - changelogBox.setColumns(1); - changelogBox.setRows(1); - changelogBox.setTabSize(4); - changelogBox.setText("Loading changes..."); - jScrollPane1.setViewportView(changelogBox); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(83, 83, 83) - .addComponent(jLabel5) - .addContainerGap()) - .addComponent(jScrollPane1) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE) - .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jLabel5) - .addContainerGap()) - .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))) - ); - - pack(); - }// //GEN-END:initComponents - - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed - try { - Desktop.getDesktop().browse(new URI(Main.API_URL + "dllink.php")); - } catch (Exception ex) { - JOptionPane.showInternalMessageDialog(this, "Cannot open browser. Please go to symatapp.com."); - } - }//GEN-LAST:event_jButton1ActionPerformed - - private void jLabel5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel5MouseClicked - PrefStorage.saveSetting("update-ignore", Main.VERSION_NAME + "|" + latestVersion); - dispose(); - }//GEN-LAST:event_jLabel5MouseClicked - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextArea changelogBox; - private javax.swing.JButton jButton1; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JScrollPane jScrollPane1; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/WebBrowser.java b/src/net/apocalypselabs/symat/WebBrowser.java index 9e74e5e..8653842 100644 --- a/src/net/apocalypselabs/symat/WebBrowser.java +++ b/src/net/apocalypselabs/symat/WebBrowser.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -422,418 +421,3 @@ public class WebBrowser extends javax.swing.JInternalFrame { private javax.swing.JTextField urlBox; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.awt.BorderLayout; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.collections.ObservableList; -import javafx.concurrent.Worker; -import javafx.concurrent.Worker.State; -import javafx.embed.swing.JFXPanel; -import javafx.event.EventHandler; -import javafx.scene.Group; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.web.PromptData; -import javafx.scene.web.WebEngine; -import javafx.scene.web.WebEvent; -import javafx.scene.web.WebView; -import javafx.util.Callback; -import javax.swing.ImageIcon; -import javax.swing.JInternalFrame; -import javax.swing.JOptionPane; - -/** - * - * @author Skylar - */ -public class WebBrowser extends javax.swing.JInternalFrame { - - private WebView browser; - private WebEngine webEngine; - private JFXPanel jfxPanel; - private Group root; - private Scene scene; - - public static final int DEFAULT_LOGO = 0; - public static final int WIKI_LOGO = 1; - public static final int FORUM_LOGO = 2; - public static final int PAD_LOGO = 3; - private JInternalFrame thisFrame; - - /** - * Creates new form WebBrowser - */ - public WebBrowser() { - initComponents(); - thisFrame = this; - jfxPanel = new JFXPanel(); - Platform.runLater(new Runnable() { - @Override - public void run() { - browser = new WebView(); - browser.setPrefSize(getWidth(), getHeight()); - root = new Group(); - scene = new Scene(root); - ObservableList children = root.getChildren(); - children.add(browser); - jfxPanel.setScene(scene); - webEngine = browser.getEngine(); - webEngine.getLoadWorker().stateProperty().addListener( - new ChangeListener() { - @Override - public void changed(ObservableValue ov, State oldState, State newState) { - if (newState == Worker.State.RUNNING) { - urlBox.setText("Loading..."); - } else if (newState == Worker.State.SCHEDULED - || newState == Worker.State.READY) { - - } else { - urlBox.setText(webEngine.getLocation()); - } - } - }); - webEngine.setOnAlert( - new EventHandler>() { - @Override - public void handle(WebEvent t) { - JOptionPane.showMessageDialog(thisFrame, t.getData(), "Message from webpage", JOptionPane.INFORMATION_MESSAGE); - } - }); - - webEngine.setPromptHandler( - new Callback() { - @Override - public String call(PromptData p) { - return JOptionPane.showInputDialog(thisFrame, p.getMessage(), "Question from webpage", JOptionPane.QUESTION_MESSAGE); - } - }); - webEngine.setConfirmHandler( - new Callback() { - - @Override - public Boolean call(String p) { - return (JOptionPane.showConfirmDialog( - thisFrame, - p, - "Question from webpage", - JOptionPane.OK_CANCEL_OPTION) - == JOptionPane.OK_OPTION ? true : false); - } - - }); - webEngine.setUserAgent("Mozilla/5.0 SyMAT/" + Main.VERSION_NAME); - webEngine.loadContent(homepage()); - } - }); - browserBox.add(jfxPanel, BorderLayout.CENTER); - } - - public WebBrowser(String title) { - this(); - setTitle(title); - loadURL("http://wiki.symatapp.com/"); - } - - public String homepage() { - try { - String text = ""; - BufferedReader reader = new BufferedReader( - new InputStreamReader( - WebBrowser.class - .getResourceAsStream("resources/homepage.html"))); - String line; - while ((line = reader.readLine()) != null) { - text += line; - } - return text; - } catch (IOException ex) { - return "Error: " + ex.getMessage(); - } - } - - public WebBrowser(String title, String url) { - this(); - setTitle(title); - loadURL(url); - } - - public WebBrowser(String title, String url, int icon) { - this(title, url); - switch (icon) { - case WIKI_LOGO: - setFrameIcon(new ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/wiki.png"))); - break; - case FORUM_LOGO: - setFrameIcon(new ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/forum.png"))); - break; - case PAD_LOGO: - navBar.setVisible(false); - goBtn.setEnabled(false); - backBtn.setEnabled(false); - setFrameIcon(new ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/editor.png"))); - break; - default: - setFrameIcon(new ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/browser.png"))); - } - - } - - public WebBrowser(String url, boolean isurl) { - this(); - loadURL(url); - } - - public void showNavbar(boolean yesno) { - navBar.setVisible(yesno); - goBtn.setEnabled(yesno); - backBtn.setEnabled(yesno); - } - - public void loadURL(final String url) { - Platform.runLater(new Runnable() { - @Override - public void run() { - webEngine.load(url); - resizeAll(); - } - }); - urlBox.setText(url); - } - - public void open() { - Main.loadFrame(this, true); - } - - public void loadString(final String content) { - Platform.runLater(new Runnable() { - @Override - public void run() { - webEngine.loadContent(content); - resizeAll(); - } - }); - urlBox.setText(""); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - navBar = new javax.swing.JToolBar(); - backBtn = new javax.swing.JButton(); - urlBox = new javax.swing.JTextField(); - goBtn = new javax.swing.JButton(); - browserBox = new javax.swing.JPanel(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setTitle("Browser"); - setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/browser.png"))); // NOI18N - setMinimumSize(new java.awt.Dimension(300, 300)); - setPreferredSize(new java.awt.Dimension(480, 400)); - addInternalFrameListener(new javax.swing.event.InternalFrameListener() { - public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) { - } - public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) { - formInternalFrameOpened(evt); - } - }); - addComponentListener(new java.awt.event.ComponentAdapter() { - public void componentResized(java.awt.event.ComponentEvent evt) { - formComponentResized(evt); - } - public void componentShown(java.awt.event.ComponentEvent evt) { - formComponentShown(evt); - } - }); - - navBar.setFloatable(false); - navBar.setRollover(true); - navBar.setLayout(new java.awt.BorderLayout()); - - backBtn.setFont(Main.ubuntuRegular.deriveFont(16.0f)); - backBtn.setText("<"); - backBtn.setFocusable(false); - backBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - backBtn.setMaximumSize(new java.awt.Dimension(30, 21)); - backBtn.setMinimumSize(new java.awt.Dimension(30, 21)); - backBtn.setPreferredSize(new java.awt.Dimension(30, 21)); - backBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - navBar.add(backBtn, java.awt.BorderLayout.WEST); - backBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - backBtnActionPerformed(evt); - } - }); - /* - navBar.add(backBtn); - */ - - urlBox.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - urlBoxKeyTyped(evt); - } - }); - navBar.add(urlBox, java.awt.BorderLayout.CENTER); - /* - navBar.add(urlBox); - */ - - goBtn.setText("Go"); - goBtn.setFocusable(false); - goBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - goBtn.setMaximumSize(new java.awt.Dimension(30, 21)); - goBtn.setMinimumSize(new java.awt.Dimension(30, 21)); - goBtn.setPreferredSize(new java.awt.Dimension(30, 21)); - goBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - navBar.add(goBtn, java.awt.BorderLayout.EAST); - goBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - goBtnActionPerformed(evt); - } - }); - /* - navBar.add(goBtn); - */ - - getContentPane().add(navBar, java.awt.BorderLayout.PAGE_START); - - browserBox.setLayout(new java.awt.BorderLayout()); - getContentPane().add(browserBox, java.awt.BorderLayout.CENTER); - - pack(); - }// //GEN-END:initComponents - - private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened -// resizeAll(); -// // Ensure scrollbars show up correctly. -// setSize(getWidth() + 1, getHeight()); -// setSize(getWidth() - 1, getHeight()); - }//GEN-LAST:event_formInternalFrameOpened - - private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized - resizeAll(); - }//GEN-LAST:event_formComponentResized - - private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown - resizeAll(); - }//GEN-LAST:event_formComponentShown - - private void urlBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_urlBoxKeyTyped - if (evt.getKeyChar() == '\n') { - goBtn.doClick(); - } - }//GEN-LAST:event_urlBoxKeyTyped - - private void goBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goBtnActionPerformed - if (urlBox.getText().equals("about:home")) { - loadString(homepage()); - } else { - if (!urlBox.getText().startsWith("http")) { - urlBox.setText("http://" + urlBox.getText()); - } - loadURL(urlBox.getText()); - } - }//GEN-LAST:event_goBtnActionPerformed - - private void backBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backBtnActionPerformed - Platform.runLater(new Runnable() { - @Override - public void run() { - try { - browser.getEngine().getHistory().go(-1); - } catch (Exception ex) { - } - } - }); - }//GEN-LAST:event_backBtnActionPerformed - - private void resizeAll() { - Platform.runLater(new Runnable() { - @Override - public void run() { - jfxPanel.setSize(browserBox.getWidth(), browserBox.getHeight()); - browser.setPrefSize(browserBox.getWidth(), browserBox.getHeight()); - browser.resize(browserBox.getWidth(), browserBox.getHeight()); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton backBtn; - private javax.swing.JPanel browserBox; - private javax.swing.JButton goBtn; - private javax.swing.JToolBar navBar; - private javax.swing.JTextField urlBox; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/components/Task.java b/src/net/apocalypselabs/symat/components/Task.java index 2fd0c88..3f3264a 100644 --- a/src/net/apocalypselabs/symat/components/Task.java +++ b/src/net/apocalypselabs/symat/components/Task.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -213,200 +212,3 @@ public class Task extends javax.swing.JPanel { private javax.swing.JLabel taskName; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat.components; - -import javax.swing.ImageIcon; -import javax.swing.JOptionPane; - -/** - * - * @author Skylar - */ -public class Task extends javax.swing.JPanel { - - private int percent = 0; - - public Task(boolean complete, String name, String desc) { - this((complete ? 100 : 0), name, desc); - } - - public Task(int complete, String name, String desc) { - this(); - percent = complete; - setComplete(percent); - taskName.setText(name); - taskDesc.setText(desc); - } - - @Override - public String toString() { - return taskName.getText(); - } - - public String getDesc() { - return taskDesc.getText(); - } - - public int getComplete() { - return percent; - } - - /** - * Creates new form Task - */ - public Task() { - initComponents(); - } - - private void setComplete(int i) { - percent = i; - statusLabel.setIcon(new ImageIcon( - getClass().getResource( - "/net/apocalypselabs/symat/icons/" - + (i == 100 ? "green" : "red") + "light.png" - ))); - statusLabel.setToolTipText(i == 100 ? "Complete" : "Incomplete"); - percentDone.setValue(i); - percentDone.setString(i + "%"); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - taskName = new javax.swing.JLabel(); - menuBtn = new javax.swing.JButton(); - statusLabel = new javax.swing.JLabel(); - percentDone = new javax.swing.JProgressBar(); - jScrollPane1 = new javax.swing.JScrollPane(); - taskDesc = new javax.swing.JTextArea(); - - setBorder(javax.swing.BorderFactory.createEtchedBorder()); - - taskName.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(20.0F)); - taskName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); - taskName.setText("Unnamed task"); - - menuBtn.setText("Menu"); - menuBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - menuBtnActionPerformed(evt); - } - }); - - statusLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/redlight.png"))); // NOI18N - - percentDone.setStringPainted(true); - - taskDesc.setEditable(false); - taskDesc.setColumns(1); - taskDesc.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(12.0F)); - taskDesc.setLineWrap(true); - taskDesc.setRows(1); - taskDesc.setWrapStyleWord(true); - jScrollPane1.setViewportView(taskDesc); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(menuBtn)) - .addComponent(percentDone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jScrollPane1) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(menuBtn) - .addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE) - .addComponent(taskName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(percentDone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE) - .addGap(0, 0, 0)) - ); - }// //GEN-END:initComponents - - private void menuBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBtnActionPerformed - TaskMenu tm = new TaskMenu(percent, - taskName.getText(), - taskDesc.getText()); - JOptionPane.showInternalMessageDialog(this, tm, - "Task Options", JOptionPane.PLAIN_MESSAGE); - percent = tm.getPercent(); - setComplete(percent); - taskName.setText(tm.toString()); - taskDesc.setText(tm.getDesc()); - if (tm.deleteMe()) { - getParent().remove(this); - } - }//GEN-LAST:event_menuBtnActionPerformed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JButton menuBtn; - private javax.swing.JProgressBar percentDone; - private javax.swing.JLabel statusLabel; - private javax.swing.JTextArea taskDesc; - private javax.swing.JLabel taskName; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/components/TaskList.java b/src/net/apocalypselabs/symat/components/TaskList.java index fdf1717..58d2e35 100644 --- a/src/net/apocalypselabs/symat/components/TaskList.java +++ b/src/net/apocalypselabs/symat/components/TaskList.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -53,11 +52,6 @@ * Other uses are prohibited without permission. * If any part of this license is deemed unenforcable, the remainder * of the license remains in full effect. -======= -/* - This code file defines a data storage standard. - It can be used for any purpose, and is hereby released into the public domain. ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 */ package net.apocalypselabs.symat.components; diff --git a/src/net/apocalypselabs/symat/components/TaskMenu.java b/src/net/apocalypselabs/symat/components/TaskMenu.java index d92007d..254ab01 100644 --- a/src/net/apocalypselabs/symat/components/TaskMenu.java +++ b/src/net/apocalypselabs/symat/components/TaskMenu.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -206,192 +205,3 @@ public class TaskMenu extends javax.swing.JPanel { private javax.swing.JSlider percentSlider; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat.components; - -/** - * - * @author Skylar - */ -public class TaskMenu extends javax.swing.JPanel { - - /** - * Creates new TaskMenu - * - * @param percent Task completion percentage. - * @param name Task name - * @param desc Task description - */ - public TaskMenu(int percent, String name, String desc) { - this(); - percentSlider.setValue(percent); - nameBox.setText(name); - descBox.setText(desc); - } - - /** - * Creates new TaskMenu - */ - public TaskMenu() { - initComponents(); - } - - public int getPercent() { - return percentSlider.getValue(); - } - - public boolean deleteMe() { - return delCheck.isSelected(); - } - - /** - * Get the name of the task. - * - * @return Task name. - */ - @Override - public String toString() { - return nameBox.getText(); - } - - /** - * Get the task description. - * - * @return The description. - */ - public String getDesc() { - return descBox.getText(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - nameBox = new javax.swing.JTextField(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - jScrollPane1 = new javax.swing.JScrollPane(); - descBox = new javax.swing.JTextArea(); - jLabel3 = new javax.swing.JLabel(); - percentSlider = new javax.swing.JSlider(); - delCheck = new javax.swing.JCheckBox(); - - jLabel1.setText("Task Name:"); - - jLabel2.setText("Task Description:"); - - descBox.setColumns(20); - descBox.setRows(5); - jScrollPane1.setViewportView(descBox); - - jLabel3.setText("Percent complete:"); - - percentSlider.setMajorTickSpacing(10); - percentSlider.setMinorTickSpacing(5); - percentSlider.setPaintLabels(true); - percentSlider.setPaintTicks(true); - percentSlider.setSnapToTicks(true); - percentSlider.setValue(0); - - delCheck.setText("Delete this task"); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(nameBox) - .addComponent(jScrollPane1) - .addComponent(percentSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) - .addComponent(jLabel1) - .addComponent(jLabel3)) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(delCheck) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(nameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(percentSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(delCheck) - .addContainerGap(16, Short.MAX_VALUE)) - ); - }// //GEN-END:initComponents - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JCheckBox delCheck; - private javax.swing.JTextArea descBox; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTextField nameBox; - private javax.swing.JSlider percentSlider; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/components/TextBox.java b/src/net/apocalypselabs/symat/components/TextBox.java index 6a6910b..ec15db6 100644 --- a/src/net/apocalypselabs/symat/components/TextBox.java +++ b/src/net/apocalypselabs/symat/components/TextBox.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -138,134 +137,3 @@ public class TextBox extends javax.swing.JInternalFrame { private javax.swing.JTextArea textBox; // End of variables declaration//GEN-END:variables } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat.components; - -import net.apocalypselabs.symat.Main; -import net.apocalypselabs.symat.PrefStorage; - -/** - * - * @author Netsyms Technologies - */ -public class TextBox extends javax.swing.JInternalFrame { - - /** - * Creates new form TextBox - */ - public TextBox() { - initComponents(); - int font_size = 12; - try { - font_size = Integer.valueOf(PrefStorage.getSetting("editfont", "12")); - } catch (Exception ex) { - } - textBox.setFont(Main.ubuntuRegular.deriveFont((float) font_size)); - } - - public void set(String txt) { - textBox.setText(txt); - } - - public String get() { - return textBox.getText(); - } - - public void edit(boolean is) { - textBox.setEditable(is); - } - - public void open() { - Main.loadFrame(this, true); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jScrollPane1 = new javax.swing.JScrollPane(); - textBox = new javax.swing.JTextArea(); - - setClosable(true); - setIconifiable(true); - setMaximizable(true); - setResizable(true); - setPreferredSize(new java.awt.Dimension(300, 300)); - - textBox.setColumns(1); - textBox.setLineWrap(true); - textBox.setRows(1); - textBox.setTabSize(4); - textBox.setWrapStyleWord(true); - jScrollPane1.setViewportView(textBox); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTextArea textBox; - // End of variables declaration//GEN-END:variables -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/functions.js b/src/net/apocalypselabs/symat/functions.js index 2cadd9c..50482b2 100644 --- a/src/net/apocalypselabs/symat/functions.js +++ b/src/net/apocalypselabs/symat/functions.js @@ -1,4 +1,3 @@ -<<<<<<< HEAD /*function mtimes(a,b) { var m = SyMAT_Functions.$mtimes(a,b); var out; @@ -30,37 +29,4 @@ function minvert(a) { } } return out; -======= -/*function mtimes(a,b) { - var m = SyMAT_Functions.$mtimes(a,b); - var out; - for (var i = 0; i < m.length; i++) { - for (var j = 0; j < m[i].length; j++) { - out[i][j] = m[i][j]; - } - } - return out; -} - -function mpower(a,b) { - var m = SyMAT_Functions.$mpower(a,b); - var out; - for (var i = 0; i < m.length; i++) { - for (var j = 0; j < m[i].length; j++) { - out[i][j] = m[i][j]; - } - } - return out; -} - -function minvert(a) { - var m = SyMAT_Functions.$minvert(a); - var out; - for (var i = 0; i < m.length; i++) { - for (var j = 0; j < m[i].length; j++) { - out[i][j] = m[i][j]; - } - } - return out; ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 }*/ \ No newline at end of file diff --git a/src/net/apocalypselabs/symat/help/licenses.html b/src/net/apocalypselabs/symat/help/licenses.html index 6e64bbf..d1dae68 100644 --- a/src/net/apocalypselabs/symat/help/licenses.html +++ b/src/net/apocalypselabs/symat/help/licenses.html @@ -1,4 +1,3 @@ -<<<<<<< HEAD Licenses @@ -1718,1724 +1717,3 @@ The code released under the CDDL shall be governed by the laws of the State of C

-======= - - - Licenses - - -

Licenses

-

SyMAT License

-

-
- Copyright (c) 2015, Netsyms Technologies - All rights reserved. -
- Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: -
- 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -
- 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. -
- 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. -
- 4. You adhere to the Media License detailed below. If you do not, this license - is automatically revoked and you must purge all copies of the software you - possess, in source or binary form. -
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-

All images and other graphical files (the "graphics") included with this - software are copyright (c) 2015 Netsyms Technologies. You may not distribute - the graphics or any program, source code repository, or other digital storage - media containing them without permission from Netsyms Technologies. - This ban on distribution only applies to publicly available systems. - A password-protected network file share, USB drive, or other storage scheme that - cannot be easily accessed by the public is generally allowed. If in doubt, - contact Netsyms Technologies. If Netsyms Technologies allows or denies - you permission, that decision is considered final and binding.

-

You must only use the software and graphics for personal, - non-commercial, non-educational use unless: - 1, You have paid for the software and graphics via the SyMAT website, - or 2, you are using it as part of the 15-day trial period. - Other uses are prohibited without permission.
- If any part of this license is deemed unenforcable, the remainder - of the license remains in full effect.

-

This application also uses libraries from third-parties.

-

tl;dr: Apache License, Modified BSD, GNU LGPL, Python Software License, CDDL V1.1, Mozilla Public License, Ubuntu Font License

-

Symja (parser), log4j, Java-Prettify, json-simple, java-etherpad-lite:

-

Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.

-
-

Rhino JavaScript

-
Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
-    means each individual or legal entity that creates, contributes to
-    the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
-    means the combination of the Contributions of others (if any) used
-    by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
-    means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
-    means Source Code Form to which the initial Contributor has attached
-    the notice in Exhibit A, the Executable Form of such Source Code
-    Form, and Modifications of such Source Code Form, in each case
-    including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
-    means
-
-    (a) that the initial Contributor has attached the notice described
-        in Exhibit B to the Covered Software; or
-
-    (b) that the Covered Software was made available under the terms of
-        version 1.1 or earlier of the License, but not also under the
-        terms of a Secondary License.
-
-1.6. "Executable Form"
-    means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
-    means a work that combines Covered Software with other material, in 
-    a separate file or files, that is not Covered Software.
-
-1.8. "License"
-    means this document.
-
-1.9. "Licensable"
-    means having the right to grant, to the maximum extent possible,
-    whether at the time of the initial grant or subsequently, any and
-    all of the rights conveyed by this License.
-
-1.10. "Modifications"
-    means any of the following:
-
-    (a) any file in Source Code Form that results from an addition to,
-        deletion from, or modification of the contents of Covered
-        Software; or
-
-    (b) any new file in Source Code Form that contains any Covered
-        Software.
-
-1.11. "Patent Claims" of a Contributor
-    means any patent claim(s), including without limitation, method,
-    process, and apparatus claims, in any patent Licensable by such
-    Contributor that would be infringed, but for the grant of the
-    License, by the making, using, selling, offering for sale, having
-    made, import, or transfer of either its Contributions or its
-    Contributor Version.
-
-1.12. "Secondary License"
-    means either the GNU General Public License, Version 2.0, the GNU
-    Lesser General Public License, Version 2.1, the GNU Affero General
-    Public License, Version 3.0, or any later versions of those
-    licenses.
-
-1.13. "Source Code Form"
-    means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
-    means an individual or a legal entity exercising rights under this
-    License. For legal entities, "You" includes any entity that
-    controls, is controlled by, or is under common control with You. For
-    purposes of this definition, "control" means (a) the power, direct
-    or indirect, to cause the direction or management of such entity,
-    whether by contract or otherwise, or (b) ownership of more than
-    fifty percent (50%) of the outstanding shares or beneficial
-    ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
-    Licensable by such Contributor to use, reproduce, make available,
-    modify, display, perform, distribute, and otherwise exploit its
-    Contributions, either on an unmodified basis, with Modifications, or
-    as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
-    for sale, have made, import, and otherwise transfer either its
-    Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
-    or
-
-(b) for infringements caused by: (i) Your and any other third party's
-    modifications of Covered Software, or (ii) the combination of its
-    Contributions with other software (except as part of its Contributor
-    Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
-    its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
-    Form, as described in Section 3.1, and You must inform recipients of
-    the Executable Form how they can obtain a copy of such Source Code
-    Form by reasonable means in a timely manner, at a charge no more
-    than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
-    License, or sublicense it under different terms, provided that the
-    license for the Executable Form does not attempt to limit or alter
-    the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-*                                                                      *
-*  6. Disclaimer of Warranty                                           *
-*  -------------------------                                           *
-*                                                                      *
-*  Covered Software is provided under this License on an "as is"       *
-*  basis, without warranty of any kind, either expressed, implied, or  *
-*  statutory, including, without limitation, warranties that the       *
-*  Covered Software is free of defects, merchantable, fit for a        *
-*  particular purpose or non-infringing. The entire risk as to the     *
-*  quality and performance of the Covered Software is with You.        *
-*  Should any Covered Software prove defective in any respect, You     *
-*  (not any Contributor) assume the cost of any necessary servicing,   *
-*  repair, or correction. This disclaimer of warranty constitutes an   *
-*  essential part of this License. No use of any Covered Software is   *
-*  authorized under this License except under this disclaimer.         *
-*                                                                      *
-************************************************************************
-
-************************************************************************
-*                                                                      *
-*  7. Limitation of Liability                                          *
-*  --------------------------                                          *
-*                                                                      *
-*  Under no circumstances and under no legal theory, whether tort      *
-*  (including negligence), contract, or otherwise, shall any           *
-*  Contributor, or anyone who distributes Covered Software as          *
-*  permitted above, be liable to You for any direct, indirect,         *
-*  special, incidental, or consequential damages of any character      *
-*  including, without limitation, damages for lost profits, loss of    *
-*  goodwill, work stoppage, computer failure or malfunction, or any    *
-*  and all other commercial damages or losses, even if such party      *
-*  shall have been informed of the possibility of such damages. This   *
-*  limitation of liability shall not apply to liability for death or   *
-*  personal injury resulting from such party's negligence to the       *
-*  extent applicable law prohibits such limitation. Some               *
-*  jurisdictions do not allow the exclusion or limitation of           *
-*  incidental or consequential damages, so this exclusion and          *
-*  limitation may not apply to You.                                    *
-*                                                                      *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
-  This Source Code Form is subject to the terms of the Mozilla Public
-  License, v. 2.0. If a copy of the MPL was not distributed with this
-  file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
-  This Source Code Form is "Incompatible With Secondary Licenses", as
-  defined by the Mozilla Public License, v. 2.0.
-        
-
-

JavaScript Engine

-
-COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)Version 1.1
-
-1. Definitions.
-
-    1.1. “Contributor” means each individual or entity that creates or contributes to the creation of Modifications.
-
-    1.2. “Contributor Version” means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
-
-    1.3. “Covered Software” means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
-
-    1.4. “Executable” means the Covered Software in any form other than Source Code.
-
-    1.5. “Initial Developer” means the individual or entity that first makes Original Software available under this License.
-
-    1.6. “Larger Work” means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
-
-    1.7. “License” means this document.
-
-    1.8. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
-
-    1.9. “Modifications” means the Source Code and Executable form of any of the following:
-
-    A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
-
-    B. Any new file that contains any part of the Original Software or previous Modification; or
-
-    C. Any new file that is contributed or otherwise made available under the terms of this License.
-
-    1.10. “Original Software” means the Source Code and Executable form of computer software code that is originally released under this License.
-
-    1.11. “Patent Claims” means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
-
-    1.12. “Source Code” means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
-
-    1.13. “You” (or “Your”) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, “You” includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
-
-2. License Grants.
-
-    2.1. The Initial Developer Grant.
-
-    Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
-
-    (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
-
-    (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
-
-    (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
-
-    (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
-
-    2.2. Contributor Grant.
-
-    Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
-
-    (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
-
-    (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
-
-    (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
-
-    (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
-
-3. Distribution Obligations.
-
-    3.1. Availability of Source Code.
-
-    Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
-
-    3.2. Modifications.
-
-    The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
-
-    3.3. Required Notices.
-
-    You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
-
-    3.4. Application of Additional Terms.
-
-    You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients' rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
-
-    3.5. Distribution of Executable Versions.
-
-    You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient's rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
-
-    3.6. Larger Works.
-
-    You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
-
-4. Versions of the License.
-
-    4.1. New Versions.
-
-    Oracle is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
-
-    4.2. Effect of New Versions.
-
-    You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
-
-    4.3. Modified Versions.
-
-    When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
-
-5. DISCLAIMER OF WARRANTY.
-
-    COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
-
-6. TERMINATION.
-
-    6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
-
-    6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as “Participant”) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
-
-    6.3. If You assert a patent infringement claim against Participant alleging that the Participant Software directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
-
-    6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
-
-7. LIMITATION OF LIABILITY.
-
-    UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-
-8. U.S. GOVERNMENT END USERS.
-
-    The Covered Software is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” (as that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial computer software documentation” as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
-
-9. MISCELLANEOUS.
-
-    This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction's conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
-
-10. RESPONSIBILITY FOR CLAIMS.
-
-    As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
-
-NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
-
-The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. 
-        
-
-

Flamingo, Trident

-

Copyright (c) 2005-2010 Flamingo Kirill Grouchnikov. All Rights Reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: -
- o Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -
- o Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. -
- o Neither the name of Flamingo Kirill Grouchnikov nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-

Jython

-

PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
- 1. This LICENSE AGREEMENT is between the Python Software Foundation - ("PSF"), and the Individual or Organization ("Licensee") accessing and - otherwise using this software ("Jython") in source or binary form and - its associated documentation.
- 2. Subject to the terms and conditions of this License Agreement, PSF - hereby grants Licensee a nonexclusive, royalty-free, world-wide - license to reproduce, analyze, test, perform and/or display publicly, - prepare derivative works, distribute, and otherwise use Jython alone - or in any derivative version, provided, however, that PSF's License - Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2007 - Python Software Foundation; All Rights Reserved" are retained in - Jython alone or in any derivative version prepared by Licensee.
- 3. In the event Licensee prepares a derivative work that is based on - or incorporates Jython or any part thereof, and wants to make - the derivative work available to others as provided herein, then - Licensee hereby agrees to include in any such work a brief summary of - the changes made to Jython.
- 4. PSF is making Jython available to Licensee on an "AS IS" - basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR - IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND - DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS - FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF JYTHON WILL NOT - INFRINGE ANY THIRD PARTY RIGHTS.
- 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF JYTHON - FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS - A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING JYTHON, - OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
- 6. This License Agreement will automatically terminate upon a material - breach of its terms and conditions.
- 7. Nothing in this License Agreement shall be deemed to create any - relationship of agency, partnership, or joint venture between PSF and - Licensee. This License Agreement does not grant permission to use PSF - trademarks or trade name in a trademark sense to endorse or promote - products or services of Licensee, or any third party.
- 8. By copying, installing or otherwise using Jython, Licensee - agrees to be bound by the terms and conditions of this License - Agreement.

-
-

RSyntaxTextArea, AutoComplete

-

Copyright (c) 2012, Robert Futrell
- All rights reserved.

- - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of its contributors may - be used to endorse or promote products derived from this software - without specific prior written permission.

- - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL ROBERT FUTRELL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
-

JMathPlot

-

Copyright (c) 2009, µ-Labs - All rights reserved.

- Redistribution and use in source and binary forms, - with or without modification, are permitted provided that the - following conditions are met:

-
    -
  1. Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer.
  2. -
  3. Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution.
  4. -
  5. Neither the name of the copyright holder nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission.
  6. -

- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE.

-

NanoHTTPD

-

- Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno - Elonen, 2010 by Konstantinos Togias All rights reserved. -
- Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -
- Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -
- Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -
- Neither the name of the NanoHttpd organization nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. -
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -

-

HtmlCleaner

-

Copyright (c) 2006-2014, HtmlCleaner team.
- All rights reserved.
- Redistribution and use of this software in source and binary forms,
- with or without modification, are permitted provided that the
- following conditions are met:
-
- * Redistributions of source code must retain the above
- copyright notice, this list of conditions and the
- following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the
- following disclaimer in the documentation and/or other
- materials provided with the distribution.
-
- * The name of HtmlCleaner may not be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-


-
-

iTextPDF, Symja (core):

-

GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. (http://fsf.org/)
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
- the terms and conditions of version 3 of the GNU General Public
- License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
- General Public License.
-
- "The Library" refers to a covered work governed by this License,
- other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
- by the Library, but which is not otherwise based on the Library.
- Defining a subclass of a class defined by the Library is deemed a mode
- of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
- Application with the Library. The particular version of the Library
- with which the Combined Work was made is also called the "Linked
- Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
- Corresponding Source for the Combined Work, excluding any source code
- for portions of the Combined Work that, considered in isolation, are
- based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
- object code and/or source code for the Application, including any data
- and utility programs needed for reproducing the Combined Work from the
- Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
- without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
- facility refers to a function or data to be supplied by an Application
- that uses the facility (other than as an argument passed when the
- facility is invoked), then you may convey a copy of the modified
- version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
- a header file that is part of the Library. You may convey such object
- code under terms of your choice, provided that, if the incorporated
- material is not limited to numerical parameters, data structure
- layouts and accessors, or small macros, inline functions and templates
- (ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
- taken together, effectively do not restrict modification of the
- portions of the Library contained in the Combined Work and reverse
- engineering for debugging such modifications, if you also do each of
- the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
- Library side by side in a single library together with other library
- facilities that are not Applications and are not covered by this
- License, and convey such a combined library under terms of your
- choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
- of the GNU Lesser General Public License from time to time. Such new
- versions will be similar in spirit to the present version, but may
- differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
- Library as you received it specifies that a certain numbered version
- of the GNU Lesser General Public License "or any later version"
- applies to it, you have the option of following the terms and
- conditions either of that published version or of any later version
- published by the Free Software Foundation. If the Library as you
- received it does not specify a version number of the GNU Lesser
- General Public License, you may choose any version of the GNU Lesser
- General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
- whether future versions of the GNU Lesser General Public License shall
- apply, that proxy's public statement of acceptance of any version is
- permanent authorization for you to choose that version for the
- Library.
-


-

GPL (inclusion required by LGPL)

-

GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. http://fsf.org/
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
- software and other kinds of works.
-
- The licenses for most software and other practical works are designed
- to take away your freedom to share and change the works. By contrast,
- the GNU General Public License is intended to guarantee your freedom to
- share and change all versions of a program--to make sure it remains free
- software for all its users. We, the Free Software Foundation, use the
- GNU General Public License for most of our software; it applies also to
- any other work released this way by its authors. You can apply it to
- your programs, too.
-
- When we speak of free software, we are referring to freedom, not
- price. Our General Public Licenses are designed to make sure that you
- have the freedom to distribute copies of free software (and charge for
- them if you wish), that you receive source code or can get it if you
- want it, that you can change the software or use pieces of it in new
- free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
- these rights or asking you to surrender the rights. Therefore, you have
- certain responsibilities if you distribute copies of the software, or if
- you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
- gratis or for a fee, you must pass on to the recipients the same
- freedoms that you received. You must make sure that they, too, receive
- or can get the source code. And you must show them these terms so they
- know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
- (1) assert copyright on the software, and (2) offer you this License
- giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
- that there is no warranty for this free software. For both users' and
- authors' sake, the GPL requires that modified versions be marked as
- changed, so that their problems will not be attributed erroneously to
- authors of previous versions.
-
- Some devices are designed to deny users access to install or run
- modified versions of the software inside them, although the manufacturer
- can do so. This is fundamentally incompatible with the aim of
- protecting users' freedom to change the software. The systematic
- pattern of such abuse occurs in the area of products for individuals to
- use, which is precisely where it is most unacceptable. Therefore, we
- have designed this version of the GPL to prohibit the practice for those
- products. If such problems arise substantially in other domains, we
- stand ready to extend this provision to those domains in future versions
- of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
- States should not allow patents to restrict development and use of
- software on general-purpose computers, but in those that do, we wish to
- avoid the special danger that patents applied to a free program could
- make it effectively proprietary. To prevent this, the GPL assures that
- patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
- modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
- works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
- License. Each licensee is addressed as "you". "Licensees" and
- "recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
- in a fashion requiring copyright permission, other than the making of an
- exact copy. The resulting work is called a "modified version" of the
- earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
- on the Program.
-
- To "propagate" a work means to do anything with it that, without
- permission, would make you directly or secondarily liable for
- infringement under applicable copyright law, except executing it on a
- computer or modifying a private copy. Propagation includes copying,
- distribution (with or without modification), making available to the
- public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
- parties to make or receive copies. Mere interaction with a user through
- a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
- to the extent that it includes a convenient and prominently visible
- feature that (1) displays an appropriate copyright notice, and (2)
- tells the user that there is no warranty for the work (except to the
- extent that warranties are provided), that licensees may convey the
- work under this License, and how to view a copy of this License. If
- the interface presents a list of user commands or options, such as a
- menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
- for making modifications to it. "Object code" means any non-source
- form of a work.
-
- A "Standard Interface" means an interface that either is an official
- standard defined by a recognized standards body, or, in the case of
- interfaces specified for a particular programming language, one that
- is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
- than the work as a whole, that (a) is included in the normal form of
- packaging a Major Component, but which is not part of that Major
- Component, and (b) serves only to enable use of the work with that
- Major Component, or to implement a Standard Interface for which an
- implementation is available to the public in source code form. A
- "Major Component", in this context, means a major essential component
- (kernel, window system, and so on) of the specific operating system
- (if any) on which the executable work runs, or a compiler used to
- produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
- the source code needed to generate, install, and (for an executable
- work) run the object code and to modify the work, including scripts to
- control those activities. However, it does not include the work's
- System Libraries, or general-purpose tools or generally available free
- programs which are used unmodified in performing those activities but
- which are not part of the work. For example, Corresponding Source
- includes interface definition files associated with source files for
- the work, and the source code for shared libraries and dynamically
- linked subprograms that the work is specifically designed to require,
- such as by intimate data communication or control flow between those
- subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
- can regenerate automatically from other parts of the Corresponding
- Source.
-
- The Corresponding Source for a work in source code form is that
- same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
- copyright on the Program, and are irrevocable provided the stated
- conditions are met. This License explicitly affirms your unlimited
- permission to run the unmodified Program. The output from running a
- covered work is covered by this License only if the output, given its
- content, constitutes a covered work. This License acknowledges your
- rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
- convey, without conditions so long as your license otherwise remains
- in force. You may convey covered works to others for the sole purpose
- of having them make modifications exclusively for you, or provide you
- with facilities for running those works, provided that you comply with
- the terms of this License in conveying all material for which you do
- not control copyright. Those thus making or running the covered works
- for you must do so exclusively on your behalf, under your direction
- and control, on terms that prohibit them from making any copies of
- your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
- the conditions stated below. Sublicensing is not allowed; section 10
- makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
- measure under any applicable law fulfilling obligations under article
- 11 of the WIPO copyright treaty adopted on 20 December 1996, or
- similar laws prohibiting or restricting circumvention of such
- measures.
-
- When you convey a covered work, you waive any legal power to forbid
- circumvention of technological measures to the extent such circumvention
- is effected by exercising rights under this License with respect to
- the covered work, and you disclaim any intention to limit operation or
- modification of the work as a means of enforcing, against the work's
- users, your or third parties' legal rights to forbid circumvention of
- technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
- receive it, in any medium, provided that you conspicuously and
- appropriately publish on each copy an appropriate copyright notice;
- keep intact all notices stating that this License and any
- non-permissive terms added in accord with section 7 apply to the code;
- keep intact all notices of the absence of any warranty; and give all
- recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
- and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
- produce it from the Program, in the form of source code under the
- terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
- works, which are not by their nature extensions of the covered work,
- and which are not combined with it such as to form a larger program,
- in or on a volume of a storage or distribution medium, is called an
- "aggregate" if the compilation and its resulting copyright are not
- used to limit the access or legal rights of the compilation's users
- beyond what the individual works permit. Inclusion of a covered work
- in an aggregate does not cause this License to apply to the other
- parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
- of sections 4 and 5, provided that you also convey the
- machine-readable Corresponding Source under the terms of this License,
- in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
- from the Corresponding Source as a System Library, need not be
- included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
- tangible personal property which is normally used for personal, family,
- or household purposes, or (2) anything designed or sold for incorporation
- into a dwelling. In determining whether a product is a consumer product,
- doubtful cases shall be resolved in favor of coverage. For a particular
- product received by a particular user, "normally used" refers to a
- typical or common use of that class of product, regardless of the status
- of the particular user or of the way in which the particular user
- actually uses, or expects or is expected to use, the product. A product
- is a consumer product regardless of whether the product has substantial
- commercial, industrial or non-consumer uses, unless such uses represent
- the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
- procedures, authorization keys, or other information required to install
- and execute modified versions of a covered work in that User Product from
- a modified version of its Corresponding Source. The information must
- suffice to ensure that the continued functioning of the modified object
- code is in no case prevented or interfered with solely because
- modification has been made.
-
- If you convey an object code work under this section in, or with, or
- specifically for use in, a User Product, and the conveying occurs as
- part of a transaction in which the right of possession and use of the
- User Product is transferred to the recipient in perpetuity or for a
- fixed term (regardless of how the transaction is characterized), the
- Corresponding Source conveyed under this section must be accompanied
- by the Installation Information. But this requirement does not apply
- if neither you nor any third party retains the ability to install
- modified object code on the User Product (for example, the work has
- been installed in ROM).
-
- The requirement to provide Installation Information does not include a
- requirement to continue to provide support service, warranty, or updates
- for a work that has been modified or installed by the recipient, or for
- the User Product in which it has been modified or installed. Access to a
- network may be denied when the modification itself materially and
- adversely affects the operation of the network or violates the rules and
- protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
- in accord with this section must be in a format that is publicly
- documented (and with an implementation available to the public in
- source code form), and must require no special password or key for
- unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
- License by making exceptions from one or more of its conditions.
- Additional permissions that are applicable to the entire Program shall
- be treated as though they were included in this License, to the extent
- that they are valid under applicable law. If additional permissions
- apply only to part of the Program, that part may be used separately
- under those permissions, but the entire Program remains governed by
- this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
- remove any additional permissions from that copy, or from any part of
- it. (Additional permissions may be written to require their own
- removal in certain cases when you modify the work.) You may place
- additional permissions on material, added by you to a covered work,
- for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
- add to a covered work, you may (if authorized by the copyright holders of
- that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
- restrictions" within the meaning of section 10. If the Program as you
- received it, or any part of it, contains a notice stating that it is
- governed by this License along with a term that is a further
- restriction, you may remove that term. If a license document contains
- a further restriction but permits relicensing or conveying under this
- License, you may add to a covered work material governed by the terms
- of that license document, provided that the further restriction does
- not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
- must place, in the relevant source files, a statement of the
- additional terms that apply to those files, or a notice indicating
- where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
- form of a separately written license, or stated as exceptions;
- the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
- provided under this License. Any attempt otherwise to propagate or
- modify it is void, and will automatically terminate your rights under
- this License (including any patent licenses granted under the third
- paragraph of section 11).
-
- However, if you cease all violation of this License, then your
- license from a particular copyright holder is reinstated (a)
- provisionally, unless and until the copyright holder explicitly and
- finally terminates your license, and (b) permanently, if the copyright
- holder fails to notify you of the violation by some reasonable means
- prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
- reinstated permanently if the copyright holder notifies you of the
- violation by some reasonable means, this is the first time you have
- received notice of violation of this License (for any work) from that
- copyright holder, and you cure the violation prior to 30 days after
- your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
- licenses of parties who have received copies or rights from you under
- this License. If your rights have been terminated and not permanently
- reinstated, you do not qualify to receive new licenses for the same
- material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
- run a copy of the Program. Ancillary propagation of a covered work
- occurring solely as a consequence of using peer-to-peer transmission
- to receive a copy likewise does not require acceptance. However,
- nothing other than this License grants you permission to propagate or
- modify any covered work. These actions infringe copyright if you do
- not accept this License. Therefore, by modifying or propagating a
- covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
- receives a license from the original licensors, to run, modify and
- propagate that work, subject to this License. You are not responsible
- for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
- organization, or substantially all assets of one, or subdividing an
- organization, or merging organizations. If propagation of a covered
- work results from an entity transaction, each party to that
- transaction who receives a copy of the work also receives whatever
- licenses to the work the party's predecessor in interest had or could
- give under the previous paragraph, plus a right to possession of the
- Corresponding Source of the work from the predecessor in interest, if
- the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
- rights granted or affirmed under this License. For example, you may
- not impose a license fee, royalty, or other charge for exercise of
- rights granted under this License, and you may not initiate litigation
- (including a cross-claim or counterclaim in a lawsuit) alleging that
- any patent claim is infringed by making, using, selling, offering for
- sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
- License of the Program or a work on which the Program is based. The
- work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
- owned or controlled by the contributor, whether already acquired or
- hereafter acquired, that would be infringed by some manner, permitted
- by this License, of making, using, or selling its contributor version,
- but do not include claims that would be infringed only as a
- consequence of further modification of the contributor version. For
- purposes of this definition, "control" includes the right to grant
- patent sublicenses in a manner consistent with the requirements of
- this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
- patent license under the contributor's essential patent claims, to
- make, use, sell, offer for sale, import and otherwise run, modify and
- propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
- agreement or commitment, however denominated, not to enforce a patent
- (such as an express permission to practice a patent or covenant not to
- sue for patent infringement). To "grant" such a patent license to a
- party means to make such an agreement or commitment not to enforce a
- patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
- and the Corresponding Source of the work is not available for anyone
- to copy, free of charge and under the terms of this License, through a
- publicly available network server or other readily accessible means,
- then you must either (1) cause the Corresponding Source to be so
- available, or (2) arrange to deprive yourself of the benefit of the
- patent license for this particular work, or (3) arrange, in a manner
- consistent with the requirements of this License, to extend the patent
- license to downstream recipients. "Knowingly relying" means you have
- actual knowledge that, but for the patent license, your conveying the
- covered work in a country, or your recipient's use of the covered work
- in a country, would infringe one or more identifiable patents in that
- country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
- arrangement, you convey, or propagate by procuring conveyance of, a
- covered work, and grant a patent license to some of the parties
- receiving the covered work authorizing them to use, propagate, modify
- or convey a specific copy of the covered work, then the patent license
- you grant is automatically extended to all recipients of the covered
- work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
- the scope of its coverage, prohibits the exercise of, or is
- conditioned on the non-exercise of one or more of the rights that are
- specifically granted under this License. You may not convey a covered
- work if you are a party to an arrangement with a third party that is
- in the business of distributing software, under which you make payment
- to the third party based on the extent of your activity of conveying
- the work, and under which the third party grants, to any of the
- parties who would receive the covered work from you, a discriminatory
- patent license (a) in connection with copies of the covered work
- conveyed by you (or copies made from those copies), or (b) primarily
- for and in connection with specific products or compilations that
- contain the covered work, unless you entered into that arrangement,
- or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
- any implied license or other defenses to infringement that may
- otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
- otherwise) that contradict the conditions of this License, they do not
- excuse you from the conditions of this License. If you cannot convey a
- covered work so as to satisfy simultaneously your obligations under this
- License and any other pertinent obligations, then as a consequence you may
- not convey it at all. For example, if you agree to terms that obligate you
- to collect a royalty for further conveying from those to whom you convey
- the Program, the only way you could satisfy both those terms and this
- License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
- permission to link or combine any covered work with a work licensed
- under version 3 of the GNU Affero General Public License into a single
- combined work, and to convey the resulting work. The terms of this
- License will continue to apply to the part which is the covered work,
- but the special requirements of the GNU Affero General Public License,
- section 13, concerning interaction through a network will apply to the
- combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
- the GNU General Public License from time to time. Such new versions will
- be similar in spirit to the present version, but may differ in detail to
- address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
- Program specifies that a certain numbered version of the GNU General
- Public License "or any later version" applies to it, you have the
- option of following the terms and conditions either of that numbered
- version or of any later version published by the Free Software
- Foundation. If the Program does not specify a version number of the
- GNU General Public License, you may choose any version ever published
- by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
- versions of the GNU General Public License can be used, that proxy's
- public statement of acceptance of a version permanently authorizes you
- to choose that version for the Program.
-
- Later license versions may give you additional or different
- permissions. However, no additional obligations are imposed on any
- author or copyright holder as a result of your choosing to follow a
- later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
- THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
- GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
- USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
- EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
- above cannot be given local legal effect according to their terms,
- reviewing courts shall apply local law that most closely approximates
- an absolute waiver of all civil liability in connection with the
- Program, unless a warranty or assumption of liability accompanies a
- copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
- possible use to the public, the best way to achieve this is to make it
- free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
- to attach them to the start of each source file to most effectively
- state the exclusion of warranty; and each file should have at least
- the "copyright" line and a pointer to where the full notice is found.
-
- (one line to give the program's name and a brief idea of what it does.)
- Copyright (C) (year) (name of author)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see http://www.gnu.org/licenses/ .
-
- Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
- notice like this when it starts in an interactive mode:
-
- (program) Copyright (C) (year) (name of author)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
- The hypothetical commands `show w' and `show c' should show the appropriate
- parts of the General Public License. Of course, your program's commands
- might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
- if any, to sign a "copyright disclaimer" for the program, if necessary.
- For more information on this, and how to apply and follow the GNU GPL, see
- http://www.gnu.org/licenses/ .
-
- The GNU General Public License does not permit incorporating your program
- into proprietary programs. If your program is a subroutine library, you
- may consider it more useful to permit linking proprietary applications with
- the library. If this is what you want to do, use the GNU Lesser General
- Public License instead of this License. But first, please read
- http://www.gnu.org/philosophy/why-not-lgpl.html .
-

-


-

-------------------------------
- UBUNTU FONT LICENCE Version 1.0
- -------------------------------
-
- PREAMBLE
- This licence allows the licensed fonts to be used, studied, modified and - redistributed freely. The fonts, including any derivative works, can be - bundled, embedded, and redistributed provided the terms of this licence - are met. The fonts and derivatives, however, cannot be released under - any other licence. The requirement for fonts to remain under this - licence does not require any document created using the fonts or their - derivatives to be published under this licence, as long as the primary - purpose of the document is not to be a vehicle for the distribution of - the fonts. -
- DEFINITIONS
- "Font Software" refers to the set of files released by the Copyright - Holder(s) under this licence and clearly marked as such. This may - include source files, build scripts and documentation. -
- "Original Version" refers to the collection of Font Software components - as received under this licence. -
- "Modified Version" refers to any derivative made by adding to, deleting, - or substituting -- in part or in whole -- any of the components of the - Original Version, by changing formats or by porting the Font Software to - a new environment. -
- "Copyright Holder(s)" refers to all individuals and companies who have a - copyright ownership of the Font Software. -
- "Substantially Changed" refers to Modified Versions which can be easily - identified as dissimilar to the Font Software by users of the Font - Software comparing the Original Version with the Modified Version. -
- To "Propagate" a work means to do anything with it that, without - permission, would make you directly or secondarily liable for - infringement under applicable copyright law, except executing it on a - computer or modifying a private copy. Propagation includes copying, - distribution (with or without modification and with or without charging - a redistribution fee), making available to the public, and in some - countries other activities as well. -
- PERMISSION & CONDITIONS
- This licence does not grant any rights under trademark law and all such - rights are reserved. -
- Permission is hereby granted, free of charge, to any person obtaining a - copy of the Font Software, to propagate the Font Software, subject to - the below conditions: -
- 1) Each copy of the Font Software must contain the above copyright - notice and this licence. These can be included either as stand-alone - text files, human-readable headers or in the appropriate machine- - readable metadata fields within text or binary files as long as those - fields can be easily viewed by the user. -
- 2) The font name complies with the following: - (a) The Original Version must retain its name, unmodified. - (b) Modified Versions which are Substantially Changed must be renamed to - avoid use of the name of the Original Version or similar names entirely. - (c) Modified Versions which are not Substantially Changed must be - renamed to both (i) retain the name of the Original Version and (ii) add - additional naming elements to distinguish the Modified Version from the - Original Version. The name of such Modified Versions must be the name of - the Original Version, with "derivative X" where X represents the name of - the new work, appended to that name. -
- 3) The name(s) of the Copyright Holder(s) and any contributor to the - Font Software shall not be used to promote, endorse or advertise any - Modified Version, except (i) as required by this licence, (ii) to - acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with - their explicit written permission. -
- 4) The Font Software, modified or unmodified, in part or in whole, must - be distributed entirely under this licence, and must not be distributed - under any other licence. The requirement for fonts to remain under this - licence does not affect any document created using the Font Software, - except any version of the Font Software extracted from a document - created using the Font Software may only be distributed under this - licence. -
- TERMINATION
- This licence becomes null and void if any of the above conditions are - not met. -
- DISCLAIMER
- THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE - COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL - DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER - DEALINGS IN THE FONT SOFTWARE. -

- - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/help/pads.html b/src/net/apocalypselabs/symat/help/pads.html index 89e0abb..960f79f 100644 --- a/src/net/apocalypselabs/symat/help/pads.html +++ b/src/net/apocalypselabs/symat/help/pads.html @@ -1,4 +1,3 @@ -<<<<<<< HEAD Pads @@ -15,21 +14,3 @@

-======= - - - Pads - - -

Pads

-

- You can work on code with other people around the world. - Select File > Share... to upload the current script to SyMAT's - servers. Share the address SyMAT gives you, and other people can - access the script online. -
To access a script, open Pads from the Tools tab. - You can add, share, edit, and download pads from this window. -

- - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/plugin/LoadPlugin.java b/src/net/apocalypselabs/symat/plugin/LoadPlugin.java index ff83945..10dc3ab 100644 --- a/src/net/apocalypselabs/symat/plugin/LoadPlugin.java +++ b/src/net/apocalypselabs/symat/plugin/LoadPlugin.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -145,141 +144,3 @@ public class LoadPlugin { } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat.plugin; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.ObjectInputStream; -import net.apocalypselabs.symat.CodeRunner; -import net.apocalypselabs.symat.Debug; -import net.apocalypselabs.symat.Main; -import org.pushingpixels.flamingo.api.common.JCommandButton; -import org.pushingpixels.flamingo.api.common.JCommandToggleButton; -import org.pushingpixels.flamingo.api.common.RichTooltip; -import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon; -import org.pushingpixels.flamingo.api.common.icon.ResizableIcon; - -/** - * Plugin loader class. - * - * @author Skylar - */ -public class LoadPlugin { - - private Plugin p = new Plugin(); - - public LoadPlugin(File f) throws FileNotFoundException, IOException, ClassNotFoundException { - FileInputStream fin = new FileInputStream(f); - ObjectInputStream ois = new ObjectInputStream(fin); - p = (Plugin) ois.readObject(); - ois.close(); - } - - public LoadPlugin(String path) throws FileNotFoundException, IOException, ClassNotFoundException { - this(new File(path)); - } - - private ResizableIcon getRibbonIcon() { - try { - ResizableIcon ico = ImageWrapperResizableIcon.getIcon( - p.getIcon().getImage(), - new Dimension(100, 76)); - return ico; - } catch (Exception ex) { - return Main.getRibbonIcon("plugin"); - } - } - - public JCommandButton getRibbonBtn() { - JCommandButton b = new JCommandButton((p.getTitle().equals("") ? "Untitled" : p.getTitle()), getRibbonIcon()); - if (!p.getLongTitle().equals("")) { - b.setActionRichTooltip(new RichTooltip(p.getLongTitle(), - (p.getDesc().equals("") ? " " : p.getDesc()))); - } - b.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - exec(); - } - }); - b.setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY); - return b; - } - - public JCommandToggleButton getGalleryBtn() { - JCommandToggleButton b = new JCommandToggleButton((p.getTitle().equals("") ? "Untitled" : p.getTitle()), getRibbonIcon()); - if (!p.getLongTitle().equals("")) { - b.setActionRichTooltip(new RichTooltip(p.getLongTitle(), - (p.getDesc().equals("") ? " " : p.getDesc()))); - } - b.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - exec(); - } - }); - return b; - } - - public void exec() { - CodeRunner cr = new CodeRunner(p.getLang()); - cr.evalString(p.getScript()); - } - - public Plugin getPlugin() { - return p; - } - -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/plugin/Plugin.java b/src/net/apocalypselabs/symat/plugin/Plugin.java index 8b355a0..40e838a 100644 --- a/src/net/apocalypselabs/symat/plugin/Plugin.java +++ b/src/net/apocalypselabs/symat/plugin/Plugin.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -53,11 +52,6 @@ * Other uses are prohibited without permission. * If any part of this license is deemed unenforcable, the remainder * of the license remains in full effect. -======= -/* - This code file defines a data storage standard. - It can be used for any purpose, and is hereby released into the public domain. ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 */ package net.apocalypselabs.symat.plugin; diff --git a/src/net/apocalypselabs/symat/pretty.css b/src/net/apocalypselabs/symat/pretty.css index 780b172..803cb05 100644 --- a/src/net/apocalypselabs/symat/pretty.css +++ b/src/net/apocalypselabs/symat/pretty.css @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* Public domain. */ @@ -24,31 +23,4 @@ Public domain. .pun { color: black; font-weight: bold; -======= -/* -Public domain. -*/ -.header { - -} -.com { - color: green; -} - -.kwd { - color: blue; -} - -.pln { - color: black; -} - -.lit { - color: #0099cc; -} - -.pun { - color: black; - font-weight: bold; ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 } \ No newline at end of file diff --git a/src/net/apocalypselabs/symat/resources/homepage.html b/src/net/apocalypselabs/symat/resources/homepage.html index fd0937e..d7a7971 100644 --- a/src/net/apocalypselabs/symat/resources/homepage.html +++ b/src/net/apocalypselabs/symat/resources/homepage.html @@ -1,4 +1,3 @@ -<<<<<<< HEAD - - - SyMAT Homepage - - - - - -
-

SyMAT

-

Home | - Wiki | - Forums

-
- - ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/sync/BackgroundSync.java b/src/net/apocalypselabs/symat/sync/BackgroundSync.java index 1ab96fa..b23246e 100644 --- a/src/net/apocalypselabs/symat/sync/BackgroundSync.java +++ b/src/net/apocalypselabs/symat/sync/BackgroundSync.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -92,88 +91,3 @@ public class BackgroundSync extends Thread { } } -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Netsyms Technologies. If Netsyms Technologies allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat.sync; - -import net.apocalypselabs.symat.Debug; -import static net.apocalypselabs.symat.Main.API_URL; -import net.apocalypselabs.symat.PrefStorage; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; - -/** - * Perform settings sync in another thread. - * - * @author Skylar - */ -public class BackgroundSync extends Thread { - - @Override - public void run() { - try { - Debug.println("Syncing profile..."); - CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpPost data = new HttpPost(API_URL + "sync.php"); - - data.setEntity(new UrlEncodedFormEntity(PrefStorage.syncdump())); - CloseableHttpResponse response = httpClient.execute(data); - - - } catch (Exception e) { - Debug.stacktrace(e); - } - } - - public BackgroundSync() { - - } -} ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 diff --git a/src/net/apocalypselabs/symat/sync/Start.java b/src/net/apocalypselabs/symat/sync/Start.java index 5706a6f..e5f4354 100644 --- a/src/net/apocalypselabs/symat/sync/Start.java +++ b/src/net/apocalypselabs/symat/sync/Start.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -40,53 +39,11 @@ * software are copyright (c) 2015 Netsyms Technologies. You may not distribute * the graphics or any program, source code repository, or other digital storage * media containing them without permission from Netsyms Technologies. -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 * This ban on distribution only applies to publicly available systems. * A password-protected network file share, USB drive, or other storage scheme that * cannot be easily accessed by the public is generally allowed. If in doubt, * contact Netsyms Technologies. If Netsyms Technologies allows or denies * you permission, that decision is considered final and binding. -<<<<<<< HEAD * * You may only use the media for personal, * non-commercial, non-educational use unless: @@ -95,8 +52,6 @@ * Other uses are prohibited without permission. * If any part of this license is deemed unenforcable, the remainder * of the license remains in full effect. -======= ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 */ package net.apocalypselabs.symat.sync; diff --git a/src/net/apocalypselabs/symat/sync/UserLogin.java b/src/net/apocalypselabs/symat/sync/UserLogin.java index 5ce3a75..b823521 100644 --- a/src/net/apocalypselabs/symat/sync/UserLogin.java +++ b/src/net/apocalypselabs/symat/sync/UserLogin.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* * Copyright (c) 2015, Netsyms Technologies * All rights reserved. @@ -40,53 +39,11 @@ * software are copyright (c) 2015 Netsyms Technologies. You may not distribute * the graphics or any program, source code repository, or other digital storage * media containing them without permission from Netsyms Technologies. -======= -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Netsyms Technologies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Netsyms Technologies. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Netsyms Technologies. ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 * This ban on distribution only applies to publicly available systems. * A password-protected network file share, USB drive, or other storage scheme that * cannot be easily accessed by the public is generally allowed. If in doubt, * contact Netsyms Technologies. If Netsyms Technologies allows or denies * you permission, that decision is considered final and binding. -<<<<<<< HEAD * * You may only use the media for personal, * non-commercial, non-educational use unless: @@ -95,8 +52,6 @@ * Other uses are prohibited without permission. * If any part of this license is deemed unenforcable, the remainder * of the license remains in full effect. -======= ->>>>>>> c1bd78b886a57d8f285747c749491ece75862a43 */ package net.apocalypselabs.symat.sync;