Re-init Git, minor tweaks
@ -0,0 +1,6 @@
|
||||
bin/
|
||||
dist/
|
||||
*.exe
|
||||
/src/padkey
|
||||
/nbproject/private/
|
||||
/build/
|
@ -0,0 +1,58 @@
|
||||
==============================
|
||||
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.
|
||||
Consult their license information or the Manual system for more information.
|
@ -0,0 +1,18 @@
|
||||
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
|
||||
------
|
||||
To report bugs, go to: https://github.com/Netsyms/SyMAT/issues
|
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 2015, Netsyms Technologies
|
||||
All rights reserved.
|
||||
|
||||
|
||||
CODE LICENSE ==========
|
||||
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 ("media") included with this
|
||||
software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
the graphics or any program, source code repository, or other digital storage
|
||||
media containing them without permission from Netsyms Technologies.
|
||||
This ban on distribution only applies to publicly available systems.
|
||||
A password-protected network file share, USB drive, or other storage scheme that
|
||||
cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
you permission, that decision is considered final and binding.
|
||||
|
||||
You may only use the media for personal,
|
||||
non-commercial, non-educational use unless:
|
||||
1, You have paid for the software and media via the SyMAT website,
|
||||
or 2, you are using it as part of the 15-day trial period.
|
||||
Other uses are prohibited without permission.
|
||||
If any part of this license is deemed unenforcable, the remainder
|
||||
of the license remains in full effect.
|
||||
-->
|
||||
|
||||
<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>
|
@ -0,0 +1,89 @@
|
||||
#
|
||||
# Copyright (c) 2015, Netsyms Technologies
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
# CODE LICENSE ==========
|
||||
# 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 ("media") included with this
|
||||
# software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
# the graphics or any program, source code repository, or other digital storage
|
||||
# media containing them without permission from Netsyms Technologies.
|
||||
# This ban on distribution only applies to publicly available systems.
|
||||
# A password-protected network file share, USB drive, or other storage scheme that
|
||||
# cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
# contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
# you permission, that decision is considered final and binding.
|
||||
#
|
||||
# You may only use the media for personal,
|
||||
# non-commercial, non-educational use unless:
|
||||
# 1, You have paid for the software and media via the SyMAT website,
|
||||
# or 2, you are using it as part of the 15-day trial period.
|
||||
# Other uses are prohibited without permission.
|
||||
# If any part of this license is deemed unenforcable, the remainder
|
||||
# of the license remains in full effect.
|
||||
#
|
||||
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
|
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
X-COMMENT: Main-Class will be added automatically by build
|
||||
|
@ -0,0 +1,8 @@
|
||||
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
|
@ -0,0 +1,59 @@
|
||||
<#if licenseFirst??>
|
||||
${licenseFirst}
|
||||
</#if>
|
||||
${licensePrefix}Copyright (c) 2015, Netsyms Technologies
|
||||
${licensePrefix}All rights reserved.
|
||||
${licensePrefix}
|
||||
${licensePrefix}
|
||||
${licensePrefix}CODE LICENSE ==========
|
||||
${licensePrefix}Redistribution and use in source and binary forms, with or without modification,
|
||||
${licensePrefix}are permitted provided that the following conditions are met:
|
||||
${licensePrefix}
|
||||
${licensePrefix}1. Redistributions of source code must retain the above copyright notice, this
|
||||
${licensePrefix}list of conditions and the following disclaimer.
|
||||
${licensePrefix}
|
||||
${licensePrefix}2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
${licensePrefix}this list of conditions and the following disclaimer in the documentation and/or
|
||||
${licensePrefix}other materials provided with the distribution.
|
||||
${licensePrefix}
|
||||
${licensePrefix}3. Neither the name of the copyright holder nor the names of its contributors
|
||||
${licensePrefix}may be used to endorse or promote products derived from this software without
|
||||
${licensePrefix}specific prior written permission.
|
||||
${licensePrefix}
|
||||
${licensePrefix}4. You adhere to the Media License detailed below. If you do not, this license
|
||||
${licensePrefix}is automatically revoked and you must purge all copies of the software you
|
||||
${licensePrefix}possess, in source or binary form.
|
||||
${licensePrefix}
|
||||
${licensePrefix}THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
${licensePrefix}ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
${licensePrefix}WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
${licensePrefix}DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
${licensePrefix}ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
${licensePrefix}(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
${licensePrefix}LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
${licensePrefix}ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
${licensePrefix}(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
${licensePrefix}SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
${licensePrefix}
|
||||
${licensePrefix}
|
||||
${licensePrefix}MEDIA LICENSE ==========
|
||||
${licensePrefix}All images and other graphical files ("media") included with this
|
||||
${licensePrefix}software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
${licensePrefix}the graphics or any program, source code repository, or other digital storage
|
||||
${licensePrefix}media containing them without permission from Netsyms Technologies.
|
||||
${licensePrefix}This ban on distribution only applies to publicly available systems.
|
||||
${licensePrefix}A password-protected network file share, USB drive, or other storage scheme that
|
||||
${licensePrefix}cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
${licensePrefix}contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
${licensePrefix}you permission, that decision is considered final and binding.
|
||||
${licensePrefix}
|
||||
${licensePrefix}You may only use the media for personal,
|
||||
${licensePrefix}non-commercial, non-educational use unless:
|
||||
${licensePrefix}1, You have paid for the software and media via the SyMAT website,
|
||||
${licensePrefix}or 2, you are using it as part of the 15-day trial period.
|
||||
${licensePrefix}Other uses are prohibited without permission.
|
||||
${licensePrefix}If any part of this license is deemed unenforcable, the remainder
|
||||
${licensePrefix}of the license remains in full effect.
|
||||
<#if licenseLast??>
|
||||
${licenseLast}
|
||||
</#if>
|
@ -0,0 +1,149 @@
|
||||
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=licenseheader
|
||||
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}
|
@ -0,0 +1,16 @@
|
||||
<?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>
|
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 759 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 5.9 KiB |
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,287 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Export Code"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/export.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="583" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="10" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="273" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextPane" name="previewPane">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
|
||||
<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">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="outputPlaceBox" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="titleBox" min="-2" pref="154" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="authBox" max="32767" attributes="0"/>
|
||||
<Component id="dateBox" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane2" pref="239" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="5" pref="5" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="titleBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jScrollPane2" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="authBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="dateBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="outputPlaceBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextField" name="titleBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="SyMAT Project"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Title:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Author:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="authBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="PrefStorage.getSetting("author", "")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="dateBox">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Date:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="headerBox">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="lineWrap" type="boolean" value="true"/>
|
||||
<Property name="rows" type="int" value="2"/>
|
||||
<Property name="tabSize" type="int" value="4"/>
|
||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Header:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Update Preview"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</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="Export to:"/>
|
||||
</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="exPdf" max="32767" attributes="0"/>
|
||||
<Component id="exHtml" alignment="0" pref="80" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<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 min="-2" pref="18" max="-2" attributes="0"/>
|
||||
<Component id="exHtml" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="exPdf" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="exHtml">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="HTML"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exHtmlActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="exPdf">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="PDF"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exPdfActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JComboBox" name="outputPlaceBox">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="Below code"/>
|
||||
<StringItem index="1" value="Above code"/>
|
||||
<StringItem index="2" value="No"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="selectedIndex" type="int" value="2"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Include output:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,488 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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\"> </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("'", "'");
|
||||
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("<", "<").
|
||||
replace("&", "&").
|
||||
replace(">", ">").
|
||||
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
|
||||
}
|
@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,439 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.JMenuItem" name="jMenuItem4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jMenuItem4"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JMenuBar" name="jMenuBar2">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.ButtonGroup" name="langBtnGroup">
|
||||
</Component>
|
||||
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="fileMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="openMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+O"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Open..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<Menu class="javax.swing.JMenu" name="openSampleBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Open Code Sample"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="sampleHelloWorld">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Shift+Ctrl+1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="helloworld"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sampleHelloWorldActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="sampleGraph">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Shift+Ctrl+2"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="graph"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sampleGraphActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+S"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Save..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveAsMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Shift+Ctrl+S"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Save as..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveAsMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Publish"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exportMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+E"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Export code"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="packPluginMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Shift+Ctrl+P"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Package as plugin"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="packPluginMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="shareMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+B"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Share..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shareMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="shareAsMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Shift+Ctrl+B"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Share as..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shareAsMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="editMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="undoBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+Z"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Undo"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="undoBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="redoBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+Y"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Redo"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="redoBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator1">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="cutBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+X"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Cut"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cutBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="copyBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+C"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Copy"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="copyBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="pasteBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+V"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Paste"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pasteBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="runMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Run"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="runCodeBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="F5"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Run code"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="runCodeBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="killButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Kill script"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="killButtonActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<Menu class="javax.swing.JMenu" name="codeLangMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Language"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JRadioButtonMenuItem" name="javascriptOption">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+J"/>
|
||||
</Property>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="langBtnGroup"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Javascript"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javascriptOptionActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JRadioButtonMenuItem" name="pythonOption">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+P"/>
|
||||
</Property>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="langBtnGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Python"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pythonOptionActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Editor"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/editor.png"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[125, 50]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[550, 375]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jSplitPane1" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jSplitPane1" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
|
||||
<Properties>
|
||||
<Property name="dividerLocation" type="int" value="200"/>
|
||||
<Property name="orientation" type="int" value="0"/>
|
||||
<Property name="resizeWeight" type="double" value="0.7"/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="outputPanel">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="right"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<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 max="32767" attributes="0"/>
|
||||
<Component id="clearBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" pref="532" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="clearBtn" min="-2" pref="18" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="100" 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="Output:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="outputBox">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="lineWrap" type="boolean" value="true"/>
|
||||
<Property name="rows" type="int" value="3"/>
|
||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="outputBoxMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="clearBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Clear"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clearBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="editPanel">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="left"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[110, 50]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[110, 50]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jSpinner1" min="-2" pref="70" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<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"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jSpinner1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="19" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JSpinner" name="jSpinner1">
|
||||
<Properties>
|
||||
<Property name="value" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="12" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="jSpinner1StateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="pt"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Global Variables"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/globals.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<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">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel1" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="addBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="remBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="saveBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="37" max="-2" attributes="0"/>
|
||||
<Component id="refreshBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="addBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="remBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="refreshBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="saveBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" max="32767" attributes="0"/>
|
||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="addBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Add"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<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="Variables"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="109" 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="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="212" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JList" name="keyList">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
|
||||
<StringArray count="0"/>
|
||||
</Property>
|
||||
<Property name="selectionMode" type="int" value="0"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="keyListValueChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="remBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Remove"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="remBtnActionPerformed"/>
|
||||
</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="Value"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane2" pref="202" 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="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="valBox">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="1"/>
|
||||
<Property name="rows" type="int" value="1"/>
|
||||
<Property name="tabSize" type="int" value="4"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="refreshBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Refresh"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="refreshBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="saveBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Save"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,327 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exportBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+S"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Export graph..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="clrGraphBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+W"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Clear Graph"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clrGraphBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="setTitleBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+T"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Set Title..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="setTitleBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="defaultCloseOperation" type="int" value="1"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Graph"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/graph.png"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[326, 402]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="inBox" pref="215" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="plotBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="plot" alignment="0" 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="plot" pref="311" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="inBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="plotBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextField" name="inBox">
|
||||
<Events>
|
||||
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inBoxKeyTyped"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="f(x)="/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="plotBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value=">>"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="plotBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="org.math.plot.Plot2DPanel" name="plot">
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="plotMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,549 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Manual"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/help.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jSplitPane1" alignment="0" pref="394" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jSplitPane1" alignment="0" pref="278" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
|
||||
<Properties>
|
||||
<Property name="dividerLocation" type="int" value="100"/>
|
||||
<Property name="dividerSize" type="int" value="3"/>
|
||||
<Property name="resizeWeight" type="double" value="0.1"/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="left"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JList" name="topicList">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
|
||||
<StringArray count="8">
|
||||
<StringItem index="0" value="Welcome"/>
|
||||
<StringItem index="1" value="Basics"/>
|
||||
<StringItem index="2" value="Editor"/>
|
||||
<StringItem index="3" value="Pads"/>
|
||||
<StringItem index="4" value="Graphing"/>
|
||||
<StringItem index="5" value="Tasks"/>
|
||||
<StringItem index="6" value="Commands"/>
|
||||
<StringItem index="7" value="Licenses"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="selectionMode" type="int" value="0"/>
|
||||
<Property name="selectedIndex" type="int" value="0"/>
|
||||
<Property name="visibleRowCount" type="int" value="9"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="topicListMouseClicked"/>
|
||||
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="topicListValueChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="right"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JEditorPane" name="topicBrowser">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
|
||||
<Property name="text" type="java.lang.String" value="<html>
 <head>

 </head>
 <body>
 <p style="margin-top: 0">
 
Hi there
 </p>
 </body>
</html>
"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="topicBrowserMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="topicBrowser.setEditorKit(kit);"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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 © "
|
||||
+ 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
|
||||
}
|
@ -0,0 +1,198 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Install Plugin"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/plugins.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="2" attributes="0">
|
||||
<Group type="102" alignment="2" attributes="0">
|
||||
<Component id="openPluginBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="iconBox" min="-2" pref="104" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="installBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" alignment="2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" alignment="0" min="-2" pref="72" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="website" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="version" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="pluginName" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" pref="39" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="author" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="shortDesc" alignment="0" min="-2" pref="317" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="2" attributes="0">
|
||||
<Component id="openPluginBtn" alignment="2" min="-2" pref="32" max="-2" attributes="0"/>
|
||||
<Component id="iconBox" alignment="2" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<Component id="installBtn" alignment="2" min="-2" pref="32" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="pluginName" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="author" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="website" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="version" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="shortDesc" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" min="-2" pref="150" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Plugin Name:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="pluginName">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Author:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="author">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Website:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="website">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="version">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Version:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel6">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Description:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="shortDesc">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel7">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Long Description:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="longDesc">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="openPluginBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Open Plugin"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openPluginBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="iconBox">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="installBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Install Plugin"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="installBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,317 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="langGroup">
|
||||
</Component>
|
||||
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exportHistoryBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+S"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Save history..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportHistoryBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="clearBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Clear window"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clearBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="langMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Language"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Switch"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JRadioButtonMenuItem" name="javascriptMenu">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="langGroup"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="JavaScript"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javascriptMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JRadioButtonMenuItem" name="pythonMenu">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="langGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Python"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pythonMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="setDefaultLang">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Set as default"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="setDefaultLangActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Shell"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/shell.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
|
||||
<EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="formFocusGained"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="422" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="inputBox" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="runBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="245" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="jLabel1" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="inputBox" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="runBtn" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="mainBox">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Courier New" size="15" style="0"/>
|
||||
</Property>
|
||||
<Property name="lineWrap" type="boolean" value="true"/>
|
||||
<Property name="rows" type="int" value="2"/>
|
||||
<Property name="tabSize" type="int" value="4"/>
|
||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="mainBoxMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="DefaultCaret caret = (DefaultCaret)mainBox.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JTextField" name="inputBox">
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="inputBoxMouseClicked"/>
|
||||
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputBoxKeyPressed"/>
|
||||
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputBoxKeyTyped"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="runBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Run"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="runBtnMouseClicked"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="runBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value=">>"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,562 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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;
|
||||
|
||||
private String cursorStr = ">>";
|
||||
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
jLabel1.setText(" >>");
|
||||
|
||||
cursorStr = (PrefStorage.getSetting("shellcursor", "").equals("") ? ""
|
||||
: (lang.startsWith("j") ? "js" : "py")) + ">>";
|
||||
|
||||
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(cursorStr);
|
||||
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(cursorStr);
|
||||
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(cursorStr);
|
||||
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
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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(""));
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="grp1">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" value="Welcome"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icon16.png"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[435, 367]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[435, 367]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[435, 367]"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<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="emailBox" alignment="0" min="-2" pref="267" max="-2" attributes="0"/>
|
||||
<Component id="noLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="orgLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="singLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="emailLbl" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="28" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="contBtn" max="32767" attributes="0"/>
|
||||
<Component id="exitBtn" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="18" 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="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="singLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="orgLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="noLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="emailLbl" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="exitBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="emailBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="contBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html>
<h1>Welcome to SyMAT!</h1>
<p>Please activate the software. 
<br />Until you do, features will be limited.
<br />You may be eligible for a free 15-day trial.</p>
<br />
<p>Do you have a license?</p>"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="singLicSel">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="grp1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Yes, I have a single-user license"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="singLicSelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="orgLicSel">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="grp1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="No, but my school or work might have one"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="orgLicSelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="noLicSel">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="grp1"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="No, I don't have a license"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="noLicSelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="emailBox">
|
||||
<Properties>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Text Cursor"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="emailBoxActionPerformed"/>
|
||||
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="emailBoxKeyPressed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="emailBox.setVisible(false);"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="emailLbl">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Great! Enter your email address and we'll get things set up."/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="emailLbl.setVisible(false);
"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="contBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Continue"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="contBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="exitBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Exit"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,437 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.JMenuItem" name="jMenuItem1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jMenuItem1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="0"/>
|
||||
<Property name="title" type="java.lang.String" value="SyMAT"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[640, 540]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="9"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,32,0,0,2,-31"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JDesktopPane" name="mainPane">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="cc" green="cc" red="cc" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="autoscrolls" type="boolean" value="true"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="mainPane = new javax.swing.JDesktopPane() {
 @Override
 protected void paintComponent(Graphics g) {
 super.paintComponent(g);
 g.setColor(Theme.windowColor());
 g.fillRect(0, 0, getWidth(), getHeight());
 }
}
"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="appPanel" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="recentItemsPanel" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<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"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="appPanel" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="recentItemsPanel" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="84" max="32767" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Main.ubuntuRegular.deriveFont(48.0F)" type="code"/>
|
||||
</Property>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="99" green="99" red="99" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="SyMAT"/>
|
||||
<Property name="verticalAlignment" type="int" value="3"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="recentItemsPanel">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
|
||||
<EtchetBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="99" green="99" red="99" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[160, 273]"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="97" max="-2" attributes="0"/>
|
||||
<Component id="recentFileBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" min="-2" pref="136" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="recentItemsTitle" alignment="0" 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="recentItemsTitle" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="357" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="recentFileBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<Properties>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[23, 206]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="" noResource="true"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JList" name="recentFileList">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
|
||||
<StringArray count="0"/>
|
||||
</Property>
|
||||
<Property name="selectionMode" type="int" value="0"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="recentFileListMouseClicked"/>
|
||||
<EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="recentFileListMouseMoved"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="recentFileBtn">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/openfile.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="recentFileBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="recentItemsTitle">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="12" style="1"/>
|
||||
</Property>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="66" green="66" red="66" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value=" Recent Files"/>
|
||||
<Property name="opaque" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="recentItemsTitleMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="appPanel">
|
||||
<Properties>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exportBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Export text"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="eraseBtn">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+E"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Erase"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="eraseBtnActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Notepad"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/notepad.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="internalFrameClosing" listener="javax.swing.event.InternalFrameListener" parameters="javax.swing.event.InternalFrameEvent" handler="formInternalFrameClosing"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="394" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="277" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="textBox">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="cc" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="columns" type="int" value="1"/>
|
||||
<Property name="lineWrap" type="boolean" value="true"/>
|
||||
<Property name="rows" type="int" value="1"/>
|
||||
<Property name="tabSize" type="int" value="4"/>
|
||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="textBoxMouseClicked"/>
|
||||
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="textBoxKeyTyped"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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"));
|
||||
loadTheme();
|
||||
}
|
||||
|
||||
private void loadTheme() {
|
||||
textBox.setBackground(Theme.notepadColor());
|
||||
textBox.setForeground(Theme.textColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
textBoxMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
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 textBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_textBoxMouseClicked
|
||||
loadTheme();
|
||||
}//GEN-LAST:event_textBoxMouseClicked
|
||||
|
||||
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
|
||||
}
|
@ -0,0 +1,408 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Package Plugin"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/plugins.png"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jTabbedPane1" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jTabbedPane1" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Metadata">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Metadata"/>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<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" max="-2" attributes="0">
|
||||
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" alignment="0" pref="393" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" alignment="0" min="-2" pref="72" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="website" pref="129" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="version" pref="129" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="pluginName" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" pref="39" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="author" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="packageID" max="32767" attributes="0"/>
|
||||
<Component id="shortDesc" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<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"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="pluginName" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="author" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="packageID" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="website" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="version" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="shortDesc" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="112" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextField" name="pluginName">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Plugin Name:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Package ID:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="packageID">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Website:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="website">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Author:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="author">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Version:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="version">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel6">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Description:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="shortDesc">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel7">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Long Description:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="longDesc">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel4">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Icon">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Icon"/>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel10" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="iconPreview" min="-2" pref="115" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="openIconBtn" max="32767" attributes="0"/>
|
||||
<Component id="defaultIconBtn" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="181" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<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="jLabel9" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="openIconBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="defaultIconBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="iconPreview" min="-2" pref="83" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel10" pref="122" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel9">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Icon:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="iconPreview">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="openIconBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Open icon..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openIconBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel10">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Recommended icon size is 100x76."/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="defaultIconBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Use default"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="defaultIconBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Code">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Code"/>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane2" pref="393" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="langSelect" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<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"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="langSelect" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane2" pref="210" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel8">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Language:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="langSelect">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="2">
|
||||
<StringItem index="0" value="JavaScript"/>
|
||||
<StringItem index="1" value="Python"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="codeBox">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Publish">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Publish"/>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
|
||||
<Component id="savePlugin" min="-2" pref="150" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="235" 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="27" max="-2" attributes="0"/>
|
||||
<Component id="savePlugin" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="131" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="savePlugin">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Save Plugin"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="savePluginActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,474 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Collaboration"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[450, 280]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[450, 280]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseEntered"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="jScrollPane1" min="-2" pref="132" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" pref="69" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="addBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="delBtn" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="saveBtn" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="openBtn" max="32767" attributes="0"/>
|
||||
<Component id="previewBtn" pref="84" max="32767" attributes="0"/>
|
||||
<Component id="shareBtn" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="purgeBtn" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane2" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="144" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<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"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="addBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane2" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="openBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="saveBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="delBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="purgeBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="previewBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="shareBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JList" name="padPane">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
|
||||
<StringArray count="0"/>
|
||||
</Property>
|
||||
<Property name="selectionMode" type="int" value="0"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="padPaneValueChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="My Pads:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="openBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Open"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Open pad for editing"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="delBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Delete"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Remove pad from list"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="delBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="previewBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Preview"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Preview pad contents"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="previewBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="saveBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Download"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Save pad locally"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="previewPane">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="columns" type="int" value="1"/>
|
||||
<Property name="rows" type="int" value="1"/>
|
||||
<Property name="tabSize" type="int" value="4"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="shareBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Share"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Share pad"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shareBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Preview:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="purgeBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Purge"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Delete pad completely"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="purgeBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="addBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="+"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Add pad by ID"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,568 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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.
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
/**
|
||||
* *****************************************************************************
|
||||
* Copyright 2013 Jeremie Bresson
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
* ****************************************************************************
|
||||
*/
|
||||
package net.apocalypselabs.symat; // Package name changed.
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import syntaxhighlight.ParseResult;
|
||||
import syntaxhighlight.Style;
|
||||
import syntaxhighlight.Theme;
|
||||
|
||||
public class PrettifyToHtml {
|
||||
|
||||
private static final String MAIN_CLASS = "prettyprint";
|
||||
|
||||
/**
|
||||
* Format the {@link ParseResult} into an HTML file.
|
||||
*
|
||||
* @param content
|
||||
* @param parseResults
|
||||
* @return
|
||||
*/
|
||||
public static String toHtml(String content, List<ParseResult> parseResults) {
|
||||
int endIndex = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<div class=\"" + MAIN_CLASS + "\">");
|
||||
sb.append("<pre>");
|
||||
for (ParseResult pr : parseResults) {
|
||||
int startIndex = pr.getOffset();
|
||||
if (startIndex > endIndex) {
|
||||
sb.append(content.substring(endIndex, startIndex));
|
||||
}
|
||||
endIndex = startIndex + pr.getLength();
|
||||
sb.append("<span class=\"" + pr.getStyleKeysString() + "\">");
|
||||
sb.append(content.substring(startIndex, endIndex));
|
||||
sb.append("</span>");
|
||||
}
|
||||
if (content.length() > endIndex) {
|
||||
sb.append(content.substring(endIndex, content.length()));
|
||||
}
|
||||
sb.append("</pre>");
|
||||
sb.append("</div>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String toCss(Theme theme) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("." + MAIN_CLASS + " {");
|
||||
sb.append("font-family:monospace; ");
|
||||
appendCssColor(sb, "background-color", theme.getBackground());
|
||||
sb.append("}\n");
|
||||
for (Entry<String, Style> entry : theme.getStyles().entrySet()) {
|
||||
sb.append("." + MAIN_CLASS + " ." + entry.getKey() + " {");
|
||||
Style style = entry.getValue();
|
||||
appendCssColor(sb, "background-color", style.getBackground());
|
||||
appendCssColor(sb, "color", style.getColor());
|
||||
appendCssText(sb, "font-weight: bold", style.isBold());
|
||||
appendCssText(sb, "font-style: italic", style.isItalic());
|
||||
appendCssText(sb, "text-decoration: underline", style.isUnderline());
|
||||
sb.append("}\n");
|
||||
}
|
||||
theme.getStyles();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void appendCssColor(StringBuilder sb, String cssKey, Color color) {
|
||||
if (color != null) {
|
||||
sb.append(cssKey + ": " + encode(color) + "; ");
|
||||
}
|
||||
}
|
||||
|
||||
private final static String encode(Color color) {
|
||||
String s = Integer.toHexString(color.getRGB() & 0xffffff);
|
||||
if (s.length() < 6) {
|
||||
s = "000000".substring(0, 6 - s.length()) + s;
|
||||
}
|
||||
return '#' + s;
|
||||
}
|
||||
|
||||
private static void appendCssText(StringBuilder sb, String cssProp, boolean isSet) {
|
||||
if (isSet) {
|
||||
sb.append(cssProp + "; ");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,454 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="themeGroup">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="Settings"/>
|
||||
<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>
|
||||
<Property name="icon" type="boolean" value="true"/>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[9999, 9999]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[100, 100]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[449, 352]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="cancelBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" 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"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jTabbedPane1" alignment="0" pref="433" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jTabbedPane1" min="-2" pref="263" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="applyBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="saveBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cancelBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="saveBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="OK"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<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.JTabbedPane" name="jTabbedPane1">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel6">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Display">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Display"/>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="jPanel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="220" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="jPanel5" max="32767" attributes="0"/>
|
||||
<Component id="jPanel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="93" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<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="jLabel4" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="themeBox" pref="154" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<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">
|
||||
<Component id="themeBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html><p>The dark theme is easier on the eyes at night. The light theme should be used during the day for better visibility.</p></html>"/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="themeBox">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="Light"/>
|
||||
<StringItem index="1" value="Dark"/>
|
||||
<StringItem index="2" value="Neo"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
</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 max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="jLabel5" alignment="1" min="-2" pref="79" max="-2" attributes="0"/>
|
||||
<Component id="fontSizeSpinner" min="-2" pref="67" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="21" 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 type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" pref="67" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" 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>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html><p>Set the font size for the Shell, Editor, Notepad, etc.</p></html>"/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel7">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Startup">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Startup"/>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<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 min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jLabel2" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="jLabel3" pref="218" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="77" 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"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="skipUpdates" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="quickStart" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="21" 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>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html><p>Quick Start skips some startup tasks,
such as loading the Editor and Python engine. 
These tasks will instead run when they are actually needed. 
This will speed up application launch, 
but slow down some operations the first time they are used,
 i.e. when the editor is launched or Python code is run.</p></html>"/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html><p>
Skips checking for updates at startup. If you do this, you should check for updates manually on the SyMAT website or in your email.
</p></html>"/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Personalization">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Personalization"/>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jPanel4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="203" 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"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jPanel4" max="32767" attributes="0"/>
|
||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="85" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<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 list"/>
|
||||
</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="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">
|
||||
<Component id="nameBox" max="32767" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" alignment="0" min="-2" pref="148" max="-2" 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 max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" pref="59" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" 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>
|
||||
<Component class="javax.swing.JLabel" name="jLabel6">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html><p>Used in the code publishing tool as the default author name.</p></html>"/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="cancelBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,458 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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();
|
||||
saveBtn = new javax.swing.JButton();
|
||||
applyBtn = new javax.swing.JButton();
|
||||
jTabbedPane1 = new javax.swing.JTabbedPane();
|
||||
jPanel6 = new javax.swing.JPanel();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
themeBox = new javax.swing.JComboBox();
|
||||
jPanel5 = new javax.swing.JPanel();
|
||||
fontSizeSpinner = new javax.swing.JSpinner();
|
||||
jLabel5 = new javax.swing.JLabel();
|
||||
jPanel7 = new javax.swing.JPanel();
|
||||
quickStart = new javax.swing.JCheckBox();
|
||||
skipUpdates = new javax.swing.JCheckBox();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
showRecent = new javax.swing.JCheckBox();
|
||||
clrRecentBtn = new javax.swing.JButton();
|
||||
jPanel4 = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
nameBox = new javax.swing.JTextField();
|
||||
jLabel6 = new javax.swing.JLabel();
|
||||
cancelBtn = new javax.swing.JButton();
|
||||
|
||||
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(449, 352));
|
||||
addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||
public void componentShown(java.awt.event.ComponentEvent evt) {
|
||||
formComponentShown(evt);
|
||||
}
|
||||
});
|
||||
|
||||
saveBtn.setText("OK");
|
||||
saveBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
saveBtnActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
applyBtn.setText("Apply");
|
||||
applyBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
applyBtnActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Theme"));
|
||||
jPanel1.setToolTipText("Change the UI theme.");
|
||||
|
||||
jLabel4.setText("<html><p>The dark theme is easier on the eyes at night. The light theme should be used during the day for better visibility.</p></html>");
|
||||
jLabel4.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
|
||||
themeBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Light", "Dark", "Neo" }));
|
||||
|
||||
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(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addComponent(themeBox, 0, 154, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(themeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jLabel4)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Font Size"));
|
||||
|
||||
fontSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(12, 5, 48, 1));
|
||||
|
||||
jLabel5.setText("<html><p>Set the font size for the Shell, Editor, Notepad, etc.</p></html>");
|
||||
jLabel5.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
|
||||
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
|
||||
jPanel5.setLayout(jPanel5Layout);
|
||||
jPanel5Layout.setHorizontalGroup(
|
||||
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel5Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(fontSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(21, 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)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
|
||||
jPanel6.setLayout(jPanel6Layout);
|
||||
jPanel6Layout.setHorizontalGroup(
|
||||
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel6Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(220, 220, 220))
|
||||
);
|
||||
jPanel6Layout.setVerticalGroup(
|
||||
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jPanel5, 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))
|
||||
.addGap(93, 93, 93))
|
||||
);
|
||||
|
||||
jTabbedPane1.addTab("Display", jPanel6);
|
||||
|
||||
quickStart.setText("Quick Start");
|
||||
|
||||
skipUpdates.setText("Skip Update Check");
|
||||
|
||||
jLabel2.setText("<html><p>Quick Start skips some startup tasks,\nsuch as loading the Editor and Python engine. \nThese tasks will instead run when they are actually needed. \nThis will speed up application launch, \nbut slow down some operations the first time they are used,\n i.e. when the editor is launched or Python code is run.</p></html>");
|
||||
jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
|
||||
jLabel3.setText("<html><p>\nSkips checking for updates at startup. If you do this, you should check for updates manually on the SyMAT website or in your email.\n</p></html>");
|
||||
jLabel3.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
|
||||
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
|
||||
jPanel7.setLayout(jPanel7Layout);
|
||||
jPanel7Layout.setHorizontalGroup(
|
||||
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel7Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(quickStart)
|
||||
.addComponent(skipUpdates))
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE))
|
||||
.addContainerGap(77, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel7Layout.setVerticalGroup(
|
||||
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel7Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel7Layout.createSequentialGroup()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(skipUpdates)))
|
||||
.addComponent(quickStart))
|
||||
.addContainerGap(21, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jTabbedPane1.addTab("Startup", jPanel7);
|
||||
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Recent Items"));
|
||||
|
||||
showRecent.setSelected(true);
|
||||
showRecent.setText("Show recent items sidebar");
|
||||
|
||||
clrRecentBtn.setText("Clear recent list");
|
||||
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))
|
||||
);
|
||||
|
||||
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Default Values"));
|
||||
|
||||
jLabel1.setText("Your name:");
|
||||
|
||||
jLabel6.setText("<html><p>Used in the code publishing tool as the default author name.</p></html>");
|
||||
jLabel6.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
|
||||
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
|
||||
jPanel4.setLayout(jPanel4Layout);
|
||||
jPanel4Layout.setHorizontalGroup(
|
||||
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(nameBox)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
);
|
||||
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)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
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()
|
||||
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(203, 203, 203))
|
||||
);
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jPanel4, 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(85, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jTabbedPane1.addTab("Personalization", jPanel3);
|
||||
|
||||
cancelBtn.setText("Cancel");
|
||||
cancelBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cancelBtnActionPerformed(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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(cancelBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(applyBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(saveBtn)
|
||||
.addContainerGap())
|
||||
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 433, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(applyBtn)
|
||||
.addComponent(saveBtn)
|
||||
.addComponent(cancelBtn))
|
||||
.addGap(30, 30, 30))
|
||||
);
|
||||
|
||||
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":
|
||||
themeBox.setSelectedIndex(1);
|
||||
break;
|
||||
case "neo":
|
||||
themeBox.setSelectedIndex(2);
|
||||
break;
|
||||
default:
|
||||
themeBox.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
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(themeBox.getSelectedItem().toString().toLowerCase());
|
||||
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
|
||||
|
||||
private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
|
||||
dispose();
|
||||
}//GEN-LAST:event_cancelBtnActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton applyBtn;
|
||||
private javax.swing.JButton cancelBtn;
|
||||
private javax.swing.JButton clrRecentBtn;
|
||||
private javax.swing.JSpinner fontSizeSpinner;
|
||||
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.JLabel jLabel6;
|
||||
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.JPanel jPanel6;
|
||||
private javax.swing.JPanel jPanel7;
|
||||
private javax.swing.JTabbedPane jTabbedPane1;
|
||||
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.JComboBox themeBox;
|
||||
private javax.swing.ButtonGroup themeGroup;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[188, 172]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="padIDBox" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</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 pref="17" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="padIDBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Pad ID:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="padIDBox">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<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="Share"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="copyIDBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="copyLinkBtn" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="emailBox" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="emailBtn" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="copyIDBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="copyLinkBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="emailBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="emailBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="copyIDBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Copy ID"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="copyIDBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="copyLinkBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Copy Link"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="copyLinkBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="emailBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Send Email"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="emailBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="emailBox">
|
||||
<Events>
|
||||
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="emailBoxKeyTyped"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Email Link:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="title" type="java.lang.String" value="SyMAT"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[500, 400]"/>
|
||||
</Property>
|
||||
<Property name="undecorated" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
<Property name="type" type="java.awt.Window$Type" editor="org.netbeans.modules.form.editors.EnumEditor">
|
||||
<Value id="POPUP"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-112,0,0,1,-12"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JLayeredPane" name="jLayeredPane1">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="dispLabel">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(14.0F)" type="code"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="Loading..."/>
|
||||
<Property name="horizontalTextPosition" type="int" value="2"/>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[400, 320]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="140" y="280" width="220" height="70"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(36.0F)" type="code"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""<html>"+net.apocalypselabs.symat.Main.SYMAT+" <span style=\"color: #555555;\">"+net.apocalypselabs.symat.Main.VERSION_NAME+"</span>"" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JLayeredPane.layer" type="java.lang.Integer" value="300"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="100" y="220" width="300" height="50"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/images/splashscreen.png"/>
|
||||
</Property>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="0" y="0" width="500" height="400"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(12.0F)" type="code"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="2"/>
|
||||
<Property name="text" type="java.lang.String" value="Netsyms Technologies"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JLayeredPane.layer" type="java.lang.Integer" value="300"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="10" y="370" width="250" height="30"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(12.0F)" type="code"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="symatapp.com"/>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[118, 14]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[118, 14]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[118, 14]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JLayeredPane.layer" type="java.lang.Integer" value="300"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="380" y="370" width="110" height="30"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Netsyms Technologies
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* CODE LICENSE ==========
|
||||
* 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 ("media") included with this
|
||||
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||
* the graphics or any program, source code repository, or other digital storage
|
||||
* media containing them without permission from Netsyms Technologies.
|
||||
* This ban on distribution only applies to publicly available systems.
|
||||
* A password-protected network file share, USB drive, or other storage scheme that
|
||||
* cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||
* you permission, that decision is considered final and binding.
|
||||
*
|
||||
* You may only use the media for personal,
|
||||
* non-commercial, non-educational use unless:
|
||||
* 1, You have paid for the software and media via the SyMAT website,
|
||||
* or 2, you are using it as part of the 15-day trial period.
|
||||
* Other uses are prohibited without permission.
|
||||
* If any part of this license is deemed unenforcable, the remainder
|
||||
* of the license remains in full effect.
|
||||
*/
|
||||
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
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="closable" type="boolean" value="true"/>
|
||||
<Property name="iconifiable" type="boolean" value="true"/>
|
||||
<Property name="maximizable" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="true"/>
|
||||
<Property name="title" type="java.lang.String" value="SyMAT Sync"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icons/sync.png"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[400, 386]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[400, 386]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" pref="384" max="32767" attributes="0"/>
|
||||
<Component id="wizPanel" alignment="1" pref="0" 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" pref="150" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="wizPanel" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="b8" red="0" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/images/SyncLogo.png"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="wizPanel">
|
||||
<Properties>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 200]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[400, 200]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|