Fix repo errors

master
Skylar Ittner 9 years ago
commit 8151c89237

@ -1,3 +1,4 @@
<<<<<<< HEAD
==============================
Code License
==============================
@ -55,4 +56,63 @@ 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.

@ -1,3 +1,4 @@
<<<<<<< HEAD
SyMAT
=====
@ -15,4 +16,23 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, Netsyms Technologies
@ -119,3 +120,78 @@ of the license remains in full effect.
-->
</project>
=======
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="SyMAT" default="default" basedir=".">
<description>Builds, tests, and runs the project SyMAT.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="SyMAT-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43

@ -1,3 +1,4 @@
<<<<<<< HEAD
#
# Copyright (c) 2015, Netsyms Technologies
# All rights reserved.
@ -87,3 +88,68 @@ 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 <product> 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

File diff suppressed because it is too large Load Diff

@ -1,3 +1,4 @@
<<<<<<< HEAD
build.xml.data.CRC32=70b2413f
build.xml.script.CRC32=cfce77fe
build.xml.stylesheet.CRC32=8064a381@1.75.2.48
@ -6,3 +7,13 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
@ -147,3 +148,154 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
@ -14,3 +15,21 @@
</libraries>
</configuration>
</project>
=======
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>SyMAT</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots/>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>.\lib\nblibraries.properties</definitions>
</libraries>
</configuration>
</project>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -71,3 +72,68 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -119,3 +120,116 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -486,3 +487,483 @@ 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 = "<!DOCTYPE html>"
+ "<html><head>"
+ "<meta charset=\"utf-8\">"
+ "<title></title>"
+ "<style type=\"text/css\"><!--" + css + "--></style>"
+ "</head>"
+ "<body>"
+ "<h1>" + titleBox.getText() + "</h1>";
if (!authBox.getText().equals("")) {
html += "<h2>Author: " + authBox.getText() + "</h2>";
}
if (!dateBox.getText().equals("")) {
html += "<h3>Date: " + dateBox.getText() + "</h3>";
}
if (!headerBox.getText().equals("")) {
html += "<p class=\"header\">" + headerBox.getText() + "</p>";
}
if (outputPlaceBox.getSelectedIndex() == 1) {
html += getOutput();
}
PrettifyParser parser = new PrettifyParser();
List<ParseResult> parseResults = parser.parse(codeLang, code);
html += PrettifyToHtml.toHtml(code, parseResults);
if (outputPlaceBox.getSelectedIndex() == 0) {
html += getOutput();
}
html += "</body></html>";
html = html.replace("\t", "<span class=\"tab\">&nbsp;&nbsp;&nbsp;&nbsp;</span>");
html = html.replace("\n", "<br>");
HtmlCleaner cleaner = new HtmlCleaner();
CleanerProperties props = cleaner.getProperties();
TagNode node = cleaner.clean(html);
html = new SimpleHtmlSerializer(props).getAsString(node);
html = html.replace("&apos;", "'");
html = html.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
Debug.println(html);
return html;
}
private String getOutput() {
return "<p><b>Output:</b></p><pre class=\"plaintxt\">"
+ outputTxt.replace("<", "&lt;").
replace("&", "&amp;").
replace(">", "&gt;").
replace("\"", "''")
+ "\n\n</pre>";
}
/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -312,3 +313,309 @@ 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<InputStream> loadResources(final String name,
final ClassLoader classLoader) throws IOException {
final List<InputStream> list = new ArrayList<InputStream>();
final Enumeration<URL> 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<InputStream> 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("<Unknown source>", "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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -117,3 +118,78 @@ 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

File diff suppressed because it is too large Load Diff

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -154,3 +155,151 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -143,3 +144,140 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
);
}// </editor-fold>//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

File diff suppressed because it is too large Load Diff

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -325,3 +326,322 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -547,3 +548,544 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -309,3 +310,306 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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("<html>\r\n <head>\r\n\r\n </head>\r\n <body>\r\n <p style=\"margin-top: 0\">\r\n \rHi there\n </p>\r\n </body>\r\n</html>\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();
}// </editor-fold>//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("<p><i>Loading...</i></p>", "Manual");
if (name.equals("welcome")) {
final String text = "<html><head><title>About SyMAT</title></head>"
+ "<body>"
+ "<h1>Welcome to SyMAT!</h1>"
+ "<p>SyMAT is a Java-based algebra and calculus system. "
+ "Scripts and commands can be written in "
+ "JavaScript or Python.</p>"
+ "<p>This is SyMAT version "
+ Main.VERSION_NAME + " (" + (int) Main.APP_CODE + ")."
+ "</p>"
+ "<p>SyMAT is copyright &copy; "
+ Calendar.getInstance().get(Calendar.YEAR)
+ " Netsyms Technologies."
+ "<br />"
+ "This built-in documentation falls under the SyMAT Media License.</p>";
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("<html><head></head><body><p><b>Error:</b><br>Cannot get help topic \""
+ name + "\".<br>(" + e.getMessage() + ")</p></body></html>", "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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -315,3 +316,312 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -560,3 +561,550 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -127,3 +128,124 @@ 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.
* <br>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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -435,3 +436,432 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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("<html>\n<h1>Welcome to SyMAT!</h1>\n<p>Please activate the software. \n<br />Until you do, features will be limited.\n<br />You may be eligible for a free 15-day trial.</p>\n<br />\n<p>Do you have a license?</p>");
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();
}// </editor-fold>//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

@ -49,7 +49,11 @@
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<AuxValues>
<<<<<<< HEAD
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="mainPane = new javax.swing.JDesktopPane() {&#xd;&#xa; @Override&#xd;&#xa; protected void paintComponent(Graphics g) {&#xd;&#xa; super.paintComponent(g);&#xd;&#xa; g.setColor(Theme.windowColor());&#xd;&#xa; g.fillRect(0, 0, getWidth(), getHeight());&#xd;&#xa; }&#xd;&#xa;}&#xd;&#xa;"/>
=======
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="mainPane = new javax.swing.JDesktopPane() {&#xd;&#xa; @Override&#xd;&#xa; protected void paintComponent(Graphics g) {&#xd;&#xa; super.paintComponent(g);&#xd;&#xa; if (PrefStorage.getSetting(&quot;theme&quot;).equals(&quot;dark&quot;)) {&#xd;&#xa; g.setColor(Color.DARK_GRAY);&#xd;&#xa; } else {&#xd;&#xa; g.setColor(Color.LIGHT_GRAY);&#xd;&#xa; }&#xd;&#xa; g.fillRect(0, 0, getWidth(), getHeight());&#xd;&#xa; }&#xd;&#xa;}&#xd;&#xa;"/>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/>
</AuxValues>
<Constraints>

File diff suppressed because it is too large Load Diff

@ -94,7 +94,10 @@
<Property name="wrapStyleWord" type="boolean" value="true"/>
</Properties>
<Events>
<<<<<<< HEAD
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="textBoxMouseClicked"/>
=======
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="textBoxKeyTyped"/>
</Events>
</Component>

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -239,3 +240,221 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -472,3 +473,469 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -566,3 +567,563 @@ 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.
* <br />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.
* <br />There are about 1.217 x 10^26 possibilities (121 septillion).
* <br />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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -132,3 +133,129 @@ 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<NameValuePair> 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

@ -12,7 +12,10 @@
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/settings.png"/>
</Property>
<<<<<<< HEAD
<Property name="icon" type="boolean" value="true"/>
=======
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[9999, 9999]"/>
</Property>
@ -20,7 +23,11 @@
<Dimension value="[100, 100]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<<<<<<< HEAD
<Dimension value="[449, 352]"/>
=======
<Dimension value="[555, 280]"/>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
</Property>
</Properties>
<SyntheticProperties>
@ -45,6 +52,7 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<<<<<<< HEAD
<EmptySpace max="32767" attributes="0"/>
<Component id="cancelBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -54,10 +62,34 @@
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="jTabbedPane1" alignment="0" pref="433" max="32767" attributes="0"/>
=======
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel3" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<Component id="jPanel4" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel5" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="applyBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="saveBtn" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="90" max="32767" attributes="0"/>
</Group>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<<<<<<< HEAD
<Group type="102" attributes="0">
<Component id="jTabbedPane1" min="-2" pref="263" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -67,19 +99,104 @@
<Component id="cancelBtn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
=======
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel5" max="32767" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel3" alignment="1" max="32767" attributes="0"/>
<Component id="jPanel4" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="saveBtn" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="applyBtn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="56" max="32767" attributes="0"/>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<<<<<<< HEAD
<Component class="javax.swing.JButton" name="saveBtn">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
=======
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Theme"/>
</Border>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Change the UI theme."/>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="themeLight" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="themeDark" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="themeLight" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="themeDark" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="themeLight">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="themeGroup"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Light"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="themeDark">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="themeGroup"/>
</Property>
<Property name="text" type="java.lang.String" value="Dark"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="saveBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Save"/>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBtnActionPerformed"/>
</Events>
</Component>
<<<<<<< HEAD
<Component class="javax.swing.JButton" name="applyBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Apply"/>
@ -450,5 +567,193 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/>
</Events>
</Component>
=======
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Recent Items"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="showRecent" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="clrRecentBtn" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="showRecent" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="clrRecentBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="showRecent">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Show recent items sidebar"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="clrRecentBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Clear recent items"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clrRecentBtnActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Startup"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="quickStart" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="skipUpdates" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="quickStart" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="skipUpdates" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="quickStart">
<Properties>
<Property name="text" type="java.lang.String" value="Quick Start"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="skipUpdates">
<Properties>
<Property name="text" type="java.lang.String" value="Skip Update Check"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="applyBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Apply"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="applyBtnActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="jPanel4">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Default Values"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="nameBox" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="nameBox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Your name:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="nameBox">
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Font Size"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Component id="fontSizeSpinner" min="-2" pref="67" max="-2" attributes="0"/>
<EmptySpace pref="30" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Component id="fontSizeSpinner" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSpinner" name="fontSizeSpinner">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="12" maximum="48" minimum="5" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43
</SubComponents>
</Form>

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -456,3 +457,372 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -287,3 +288,284 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
);
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -90,3 +91,87 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -111,3 +112,108 @@ 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<String, String> 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -327,3 +328,324 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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("<html>"+net.apocalypselabs.symat.Main.SYMAT+" <span style=\"color: #555555;\">"+net.apocalypselabs.symat.Main.VERSION_NAME+"</span>");
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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -39,11 +40,53 @@
* 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:
@ -52,6 +95,8 @@
* 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;

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -372,3 +373,369 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -485,3 +486,482 @@ 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<Node> children = root.getChildren();
children.add(browser);
jfxPanel.setScene(scene);
webEngine = browser.getEngine();
webEngine.setUserAgent("SyMAT " + Main.VERSION_NAME);
webEngine.loadContent("<html><head><title></title></head><body><h3 style=\"font-family: sans-serif; text-align: center;\">Loading...</h3></body></html>");
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 = "<!DOCTYPE html>"
+ "<html><head>"
+ "<meta charset=\"utf-8\">"
+ "<title>" + titleBox.getText() + "</title>"
+ "<style type=\"text/css\"><!--" + css + "--></style>"
+ "</head>"
+ "<body>"
+ "<h1>" + titleBox.getText() + "</h1>";
if (!authBox.getText().equals("")) {
html += "<h2>Author: " + authBox.getText() + "</h2>";
}
if (!dateBox.getText().equals("")) {
html += "<h3>Date: " + dateBox.getText() + "</h3>";
}
if (!headerBox.getText().equals("")) {
html += "<p class=\"header\">" + headerBox.getText() + "</p>";
}
for (Task t : tt.getTasks()) {
html += "<div class=\"task\">"
+ "<h4 class=\"taskheading\">" + t.toString() + "</h4>"
+ percentBar(t.getComplete())
+ "<p>" + t.getDesc() + "</p>"
+ "</div>";
}
html += "</body></html>";
html = html.replace("\t", "<span class=\"tab\">&nbsp;&nbsp;&nbsp;&nbsp;</span>");
html = html.replace("\n", "<br>");
HtmlCleaner cleaner = new HtmlCleaner();
CleanerProperties props = cleaner.getProperties();
TagNode node = cleaner.clean(html);
html = new SimpleHtmlSerializer(props).getAsString(node);
html = html.replace("&apos;", "'");
html = html.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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 = "<p>" + by5 + "% <span class=\"progress progress-" + by5 + "\""
+ "style=\"width: " + by5 + "%\"></span></p>";
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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -173,3 +174,141 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -227,3 +228,224 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -421,3 +422,418 @@ 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<Node> children = root.getChildren();
children.add(browser);
jfxPanel.setScene(scene);
webEngine = browser.getEngine();
webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<State>() {
@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<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> t) {
JOptionPane.showMessageDialog(thisFrame, t.getData(), "Message from webpage", JOptionPane.INFORMATION_MESSAGE);
}
});
webEngine.setPromptHandler(
new Callback<PromptData, String>() {
@Override
public String call(PromptData p) {
return JOptionPane.showInputDialog(thisFrame, p.getMessage(), "Question from webpage", JOptionPane.QUESTION_MESSAGE);
}
});
webEngine.setConfirmHandler(
new Callback<String, Boolean>() {
@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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -212,3 +213,200 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
);
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -52,6 +53,11 @@
* 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;

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -205,3 +206,192 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
);
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -137,3 +138,134 @@ 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*function mtimes(a,b) {
var m = SyMAT_Functions.$mtimes(a,b);
var out;
@ -29,4 +30,37 @@ 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
}*/

File diff suppressed because it is too large Load Diff

@ -1,3 +1,4 @@
<<<<<<< HEAD
<html>
<head>
<title>Pads</title>
@ -14,3 +15,21 @@
</p>
</body>
</html>
=======
<html>
<head>
<title>Pads</title>
</head>
<body>
<h1>Pads</h1>
<p>
You can work on code with other people around the world.
Select File &gt; Share... to upload the current script to SyMAT's
servers. Share the address SyMAT gives you, and other people can
access the script online.
<br>To access a script, open Pads from the Tools tab.
You can add, share, edit, and download pads from this window.
</p>
</body>
</html>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -144,3 +145,141 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -52,6 +53,11 @@
* 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;

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
Public domain.
*/
@ -23,4 +24,31 @@ 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
}

@ -1,3 +1,4 @@
<<<<<<< HEAD
<!DOCTYPE html>
<!--
CODE LICENSE =====================
@ -79,3 +80,86 @@ you permission, that decision is considered final and binding.
</div>
</body>
</html>
=======
<!DOCTYPE html>
<!--
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.
-->
<html>
<head>
<title>SyMAT Homepage</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.main {
text-align: center;
font-family: ubuntu, arial, sans-serif;
}
a {
text-decoration: none;
color: #000;
}
a:hover {
text-decoration: underline;
color: #000;
}
a:visited {
color: #000;
}
</style>
</head>
<body>
<div class="main">
<h1>SyMAT</h1>
<p><a href="http://symatapp.com">Home</a> |
<a href="http://wiki.symatapp.com/doku.php">Wiki</a> |
<a href="http://forum.symatapp.com">Forums</a></p>
</div>
</body>
</html>
>>>>>>> c1bd78b886a57d8f285747c749491ece75862a43

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -91,3 +92,88 @@ 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

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -39,11 +40,53 @@
* 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:
@ -52,6 +95,8 @@
* 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;

@ -1,3 +1,4 @@
<<<<<<< HEAD
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
@ -39,11 +40,53 @@
* 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:
@ -52,6 +95,8 @@
* 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;

Loading…
Cancel
Save