@ -0,0 +1 @@
|
||||
/src/padkey
|
@ -0,0 +1,229 @@
|
||||
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:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
This application also contains JSON.simple, under the Apache License:
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="SyMAT_Pad_Viewer" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project SyMAT Pad Viewer.</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_Pad_Viewer-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,7 @@
|
||||
libs.absolutelayout.classpath=\
|
||||
${base}/absolutelayout/AbsoluteLayout.jar
|
||||
libs.absolutelayout.displayName=Absolute Layout
|
||||
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=f1252578
|
||||
build.xml.script.CRC32=27e95213
|
||||
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=f1252578
|
||||
nbproject/build-impl.xml.script.CRC32=33b38239
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
|
@ -0,0 +1,79 @@
|
||||
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.title=SyMAT Pad Viewer
|
||||
application.vendor=Skylar
|
||||
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_Pad_Viewer.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.json-simple-1.1.1.jar=lib/json-simple-1.1.1.jar
|
||||
includes=**
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.json-simple-1.1.1.jar}:\
|
||||
${libs.absolutelayout.classpath}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.8
|
||||
javac.target=1.8
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=com.netsyms.symat.padview.GUI
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
platform.active=default_platform
|
||||
project.license=bsd
|
||||
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=src
|
||||
test.src.dir=test
|
@ -0,0 +1,18 @@
|
||||
<?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 Pad Viewer</name>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||
<definitions>.\lib\nblibraries.properties</definitions>
|
||||
</libraries>
|
||||
</configuration>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
9947fbabf37cd9e01faa8653f49be351 *PadViewer_windows_1_0.exe
|
@ -0,0 +1,3 @@
|
||||
# List of generated media files. The columns are tab-separated:
|
||||
# id | media file type | display name | media file path
|
||||
26 windows Windows C:\Users\Skylar\Documents\NetBeansProjects\SyMAT Pad Viewer\pub\PadViewer_windows_1_0.exe
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<updateDescriptor baseUrl="">
|
||||
<entry targetMediaFileId="26" updatableVersionMin="" updatableVersionMax="" fileName="PadViewer_windows_1_0.exe" newVersion="1.0" newMediaFileId="26" fileSize="28837760" bundledJre="windows-x86-1.8.0_51" archive="false">
|
||||
<comment language="en" />
|
||||
</entry>
|
||||
</updateDescriptor>
|
@ -0,0 +1,449 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<install4j version="6.0.2" transformSequenceNumber="5">
|
||||
<directoryPresets config="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/pub" />
|
||||
<application name="SyMAT Pad Viewer" distributionSourceDir="" applicationId="7784-7258-6804-9056" mediaDir="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/pub" mediaFilePattern="${compiler:sys.shortName}_${compiler:sys.platform}_${compiler:sys.version}" compression="6" lzmaCompression="false" pack200Compression="true" excludeSignedFromPacking="true" commonExternalFiles="false" createMd5Sums="true" shrinkRuntime="true" shortName="PadViewer" publisher="Netsyms Technologies" publisherWeb="http://symatapp.com" version="1.0" allPathsRelative="false" backupOnSave="false" autoSave="false" convertDotsToUnderscores="true" macSignature="????" macVolumeId="c773a4b297437087" javaMinVersion="1.8" javaMaxVersion="" allowBetaVM="false" jdkMode="runtimeJre" jdkName="">
|
||||
<languages skipLanguageSelection="false" languageSelectionInPrincipalLanguage="false">
|
||||
<principalLanguage id="en" customLocalizationFile="" />
|
||||
<additionalLanguages />
|
||||
</languages>
|
||||
<searchSequence>
|
||||
<registry />
|
||||
<envVar name="JAVA_HOME" />
|
||||
<envVar name="JDK_HOME" />
|
||||
</searchSequence>
|
||||
<variables />
|
||||
<mergedProjects />
|
||||
<codeSigning macEnabled="false" macPkcs12File="" windowsEnabled="true" windowsKeySource="pkcs12" windowsPvkFile="C:/Users/Skylar/Documents/codesigning.pvk" windowsSpcFile="C:/Users/Skylar/Documents/cert.spc" windowsPkcs12File="C:/Users/Skylar/Documents/certchain.pfx" />
|
||||
</application>
|
||||
<files keepModificationTimes="false" missingFilesStrategy="warn" globalExcludeSuffixes="" defaultOverwriteMode="4" defaultUninstallMode="0" launcherOverwriteMode="3" defaultFileMode="644" defaultDirMode="755">
|
||||
<filesets />
|
||||
<roots />
|
||||
<mountPoints>
|
||||
<mountPoint id="23" root="" location="" mode="755" />
|
||||
<mountPoint id="24" root="" location="lib" mode="755" />
|
||||
</mountPoints>
|
||||
<entries>
|
||||
<fileEntry mountPoint="23" file="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/dist/SyMAT_Pad_Viewer.jar" overwriteMode="1" shared="false" fileMode="644" uninstallMode="0" overrideFileMode="false" overrideOverwriteMode="true" overrideUninstallMode="false" />
|
||||
<dirEntry mountPoint="24" file="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/dist/lib" overwriteMode="2" shared="false" fileMode="644" uninstallMode="0" overrideFileMode="false" overrideOverwriteMode="true" overrideUninstallMode="true" entryMode="direct" subDirectory="lib" excludeSuffixes="" dirMode="755" overrideDirMode="false">
|
||||
<exclude />
|
||||
</dirEntry>
|
||||
</entries>
|
||||
<components />
|
||||
</files>
|
||||
<launchers>
|
||||
<launcher name="padview" id="22" customizedId="" external="false" excludeFromMenu="false" unixMode="755" menuName="" icnsFile="" customMacBundleIdentifier="false" macBundleIdentifier="" swtApp="false" fileset="" macBundleBinary="JavaApplicationStub" addMacEntitlements="false" macEntitlementsFile="" useCustomMacosExecutableName="false" customMacosExecutableName="">
|
||||
<executable name="padview" type="1" iconSet="true" iconFile="" executableDir="" redirectStderr="true" stderrFile="error.log" stderrMode="overwrite" redirectStdout="false" stdoutFile="output.log" stdoutMode="overwrite" failOnStderrOutput="true" executableMode="1" changeWorkingDirectory="true" workingDirectory="." singleInstance="false" serviceStartType="2" serviceDependencies="" serviceDescription="" jreLocation="" executionLevel="asInvoker" checkConsoleParameter="false" globalSingleInstance="false" singleInstanceActivate="true" dpiAware="false">
|
||||
<versionInfo include="false" fileVersion="" fileDescription="" legalCopyright="" internalName="" productName="" />
|
||||
</executable>
|
||||
<splashScreen show="false" width="0" height="0" bitmapFile="" windowsNative="false" textOverlay="false">
|
||||
<text>
|
||||
<statusLine x="20" y="20" text="" fontSize="8" fontColor="0,0,0" bold="false" />
|
||||
<versionLine x="20" y="40" text="version ${compiler:sys.version}" fontSize="8" fontColor="0,0,0" bold="false" />
|
||||
</text>
|
||||
</splashScreen>
|
||||
<java mainClass="com.netsyms.symat.padview.GUI" vmParameters="" arguments="" allowVMPassthroughParameters="true" preferredVM="" bundleRuntime="true">
|
||||
<classPath>
|
||||
<scanDirectory location="lib" failOnError="false" />
|
||||
<archive location="SyMAT_Pad_Viewer.jar" failOnError="false" />
|
||||
</classPath>
|
||||
<nativeLibraryDirectories />
|
||||
</java>
|
||||
<includedFiles />
|
||||
<unextractableFiles />
|
||||
<vmOptionsFile mode="template" overwriteMode="0" fileMode="644">
|
||||
<content />
|
||||
</vmOptionsFile>
|
||||
<customScript mode="1" file="">
|
||||
<content />
|
||||
</customScript>
|
||||
<infoPlist mode="1" file="">
|
||||
<content />
|
||||
</infoPlist>
|
||||
<iconImageFiles>
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/16x16.png" />
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/24x24.png" />
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/32x32.png" />
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/48x48.png" />
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/64x64.png" />
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/128x128.png" />
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/256x256.png" />
|
||||
<file path="C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/src/com/netsyms/symat/padview/512x512.png" />
|
||||
</iconImageFiles>
|
||||
</launcher>
|
||||
</launchers>
|
||||
<installerGui installerType="1" addOnAppId="" suggestPreviousLocations="true" autoUpdateDescriptorUrl="" useAutoUpdateBaseUrl="false" autoUpdateBaseUrl="">
|
||||
<staticMembers script="" />
|
||||
<customCode />
|
||||
<autoUpdate useMinUpdatableVersion="false" minUpdatableVersion="" useMaxUpdatableVersion="false" maxUpdatableVersion="">
|
||||
<commentFiles />
|
||||
<customAttributes />
|
||||
</autoUpdate>
|
||||
<applications>
|
||||
<application name="" id="installer" customizedId="" beanClass="com.install4j.runtime.beans.applications.InstallerApplication" enabled="true" commentSet="false" comment="" actionElevationType="elevated" fileset="" customIcnsFile="" customIcoFile="" macEntitlementsFile="" automaticLauncherIntegration="false" launchMode="startupFirstWindow" launchInNewProcess="false" launchSchedule="updateSchedule" allLaunchers="true">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.applications.InstallerApplication">
|
||||
<void property="customWatermarkText">
|
||||
<string>${compiler:sys.publisher}</string>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<launcherIds />
|
||||
<variables />
|
||||
<startup>
|
||||
<screen name="" id="1" customizedId="" beanClass="com.install4j.runtime.beans.screens.StartupScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.StartupScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions>
|
||||
<action name="" id="13" customizedId="" beanClass="com.install4j.runtime.beans.actions.misc.RequestPrivilegesAction" enabled="true" commentSet="false" comment="" actionElevationType="none" rollbackBarrier="false" multiExec="false" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.misc.RequestPrivilegesAction">
|
||||
<void property="failIfNotObtainedMac">
|
||||
<boolean>false</boolean>
|
||||
</void>
|
||||
<void property="failIfNotObtainedWin">
|
||||
<boolean>false</boolean>
|
||||
</void>
|
||||
<void property="obtainIfAdminMac">
|
||||
<boolean>true</boolean>
|
||||
</void>
|
||||
<void property="obtainIfNormalMac">
|
||||
<boolean>true</boolean>
|
||||
</void>
|
||||
<void property="obtainIfNormalWin">
|
||||
<boolean>true</boolean>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
</action>
|
||||
</actions>
|
||||
<formComponents />
|
||||
</screen>
|
||||
</startup>
|
||||
<screens>
|
||||
<screen name="" id="2" customizedId="" beanClass="com.install4j.runtime.beans.screens.WelcomeScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.WelcomeScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions>
|
||||
<action name="" id="3" customizedId="" beanClass="com.install4j.runtime.beans.actions.misc.LoadResponseFileAction" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" multiExec="true" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.misc.LoadResponseFileAction">
|
||||
<void property="excludedVariables">
|
||||
<array class="java.lang.String" length="1">
|
||||
<void index="0">
|
||||
<string>sys.installationDir</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition>context.getBooleanVariable("sys.confirmedUpdateInstallation")</condition>
|
||||
</action>
|
||||
</actions>
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="25" customizedId="" beanClass="com.install4j.runtime.beans.screens.LicenseScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.LicenseScreen" id="LicenseScreen0">
|
||||
<void property="acceptInitiallySelected">
|
||||
<boolean>true</boolean>
|
||||
</void>
|
||||
<void id="LocalizedExternalFile0" property="displayedTextFile">
|
||||
<void property="languageIdToExternalFile">
|
||||
<void method="put">
|
||||
<string>en</string>
|
||||
<object class="com.install4j.api.beans.ExternalFile">
|
||||
<string>C:/Users/Skylar/Documents/NetBeansProjects/SyMAT Pad Viewer/LICENSE.txt</string>
|
||||
</object>
|
||||
</void>
|
||||
</void>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions />
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="4" customizedId="" beanClass="com.install4j.runtime.beans.screens.InstallationDirectoryScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.InstallationDirectoryScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition>!context.getBooleanVariable("sys.confirmedUpdateInstallation")</condition>
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions>
|
||||
<action name="" id="5" customizedId="" beanClass="com.install4j.runtime.beans.actions.misc.LoadResponseFileAction" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" multiExec="true" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.misc.LoadResponseFileAction">
|
||||
<void property="excludedVariables">
|
||||
<array class="java.lang.String" length="1">
|
||||
<void index="0">
|
||||
<string>sys.installationDir</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition>context.getVariable("sys.responseFile") == null</condition>
|
||||
</action>
|
||||
</actions>
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="6" customizedId="" beanClass="com.install4j.runtime.beans.screens.ComponentsScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.ComponentsScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions />
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="7" customizedId="" beanClass="com.install4j.runtime.beans.screens.StandardProgramGroupScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.StandardProgramGroupScreen">
|
||||
<void property="programGroupName">
|
||||
<string>${compiler:sys.fullName}</string>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition>!context.getBooleanVariable("sys.confirmedUpdateInstallation")</condition>
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions />
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="8" customizedId="" beanClass="com.install4j.runtime.beans.screens.InstallationScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="true" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.InstallationScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions>
|
||||
<action name="" id="9" customizedId="" beanClass="com.install4j.runtime.beans.actions.InstallFilesAction" enabled="true" commentSet="false" comment="" actionElevationType="elevated" rollbackBarrier="false" multiExec="false" failureStrategy="2" errorMessage="${i18n:FileCorrupted}">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.InstallFilesAction" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
</action>
|
||||
<action name="" id="10" customizedId="" beanClass="com.install4j.runtime.beans.actions.desktop.CreateProgramGroupAction" enabled="true" commentSet="false" comment="" actionElevationType="elevated" rollbackBarrier="false" multiExec="false" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.desktop.CreateProgramGroupAction">
|
||||
<void property="programGroupName">
|
||||
<string>SyMAT</string>
|
||||
</void>
|
||||
<void property="uninstallerMenuName">
|
||||
<string>${i18n:UninstallerMenuEntry(${compiler:sys.fullName})}</string>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition>!context.getBooleanVariable("sys.programGroupDisabled")</condition>
|
||||
</action>
|
||||
<action name="" id="11" customizedId="" beanClass="com.install4j.runtime.beans.actions.desktop.RegisterAddRemoveAction" enabled="true" commentSet="false" comment="" actionElevationType="elevated" rollbackBarrier="false" multiExec="false" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.desktop.RegisterAddRemoveAction">
|
||||
<void property="itemName">
|
||||
<string>${compiler:sys.fullName} ${compiler:sys.version}</string>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
</action>
|
||||
</actions>
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="12" customizedId="" beanClass="com.install4j.runtime.beans.screens.FinishedScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="true" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.FinishedScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions />
|
||||
<formComponents />
|
||||
</screen>
|
||||
</screens>
|
||||
</application>
|
||||
<application name="" id="uninstaller" customizedId="" beanClass="com.install4j.runtime.beans.applications.UninstallerApplication" enabled="true" commentSet="false" comment="" actionElevationType="elevated" fileset="" customIcnsFile="" customIcoFile="" macEntitlementsFile="" automaticLauncherIntegration="false" launchMode="startupFirstWindow" launchInNewProcess="false" launchSchedule="updateSchedule" allLaunchers="true">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.applications.UninstallerApplication">
|
||||
<void property="customMacosExecutableName">
|
||||
<string>${i18n:UninstallerMenuEntry(${compiler:sys.fullName})}</string>
|
||||
</void>
|
||||
<void property="customWatermarkText">
|
||||
<string>${compiler:sys.publisher}</string>
|
||||
</void>
|
||||
<void property="useCustomMacosExecutableName">
|
||||
<boolean>true</boolean>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
</serializedBean>
|
||||
<launcherIds />
|
||||
<variables />
|
||||
<startup>
|
||||
<screen name="" id="14" customizedId="" beanClass="com.install4j.runtime.beans.screens.StartupScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.StartupScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions>
|
||||
<action name="" id="20" customizedId="" beanClass="com.install4j.runtime.beans.actions.misc.LoadResponseFileAction" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" multiExec="false" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.misc.LoadResponseFileAction" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
</action>
|
||||
<action name="" id="21" customizedId="" beanClass="com.install4j.runtime.beans.actions.misc.RequireInstallerPrivilegesAction" enabled="true" commentSet="false" comment="" actionElevationType="none" rollbackBarrier="false" multiExec="false" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.misc.RequireInstallerPrivilegesAction" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
</action>
|
||||
</actions>
|
||||
<formComponents />
|
||||
</screen>
|
||||
</startup>
|
||||
<screens>
|
||||
<screen name="" id="15" customizedId="" beanClass="com.install4j.runtime.beans.screens.UninstallWelcomeScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.UninstallWelcomeScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions />
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="16" customizedId="" beanClass="com.install4j.runtime.beans.screens.UninstallationScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="false" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.UninstallationScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions>
|
||||
<action name="" id="17" customizedId="" beanClass="com.install4j.runtime.beans.actions.UninstallFilesAction" enabled="true" commentSet="false" comment="" actionElevationType="elevated" rollbackBarrier="false" multiExec="false" failureStrategy="1" errorMessage="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.actions.UninstallFilesAction" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
</action>
|
||||
</actions>
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="19" customizedId="" beanClass="com.install4j.runtime.beans.screens.UninstallFailureScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="true" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.UninstallFailureScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions />
|
||||
<formComponents />
|
||||
</screen>
|
||||
<screen name="" id="18" customizedId="" beanClass="com.install4j.runtime.beans.screens.UninstallSuccessScreen" enabled="true" commentSet="false" comment="" actionElevationType="inherit" rollbackBarrier="false" backButton="2" finishScreen="true" wizardIndexChangeType="unchanged" wizardIndexKey="">
|
||||
<serializedBean>
|
||||
<java class="java.beans.XMLDecoder">
|
||||
<object class="com.install4j.runtime.beans.screens.UninstallSuccessScreen" />
|
||||
</java>
|
||||
</serializedBean>
|
||||
<condition />
|
||||
<validation />
|
||||
<preActivation />
|
||||
<postActivation />
|
||||
<actions />
|
||||
<formComponents />
|
||||
</screen>
|
||||
</screens>
|
||||
</application>
|
||||
</applications>
|
||||
</installerGui>
|
||||
<mediaSets>
|
||||
<windows name="Windows" id="26" customizedId="" mediaFileName="" installDir="${compiler:sys.shortName}" overridePrincipalLanguage="false" jreBitType="32" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" useLegacyMediaFileIds="false" legacyMediaFileIds="" includedJRE="windows-x86-1.8.0_51" manualJREEntry="false" bundleType="1" jreURL="" jreShared="true" directDownload="false" installOnlyIfNecessary="true" customInstallBaseDir="" contentFilesType="1" downloadURL="" verifyIntegrity="true">
|
||||
<excludedLaunchers />
|
||||
<excludedBeans />
|
||||
<overriddenPrincipalLanguage id="en" customLocalizationFile="" />
|
||||
<exclude />
|
||||
<variables />
|
||||
<autoUpdate useMinUpdatableVersion="false" minUpdatableVersion="" useMaxUpdatableVersion="false" maxUpdatableVersion="">
|
||||
<commentFiles />
|
||||
<customAttributes />
|
||||
</autoUpdate>
|
||||
<excludedComponents />
|
||||
<includedDownloadableComponents />
|
||||
</windows>
|
||||
</mediaSets>
|
||||
<buildIds buildAll="true" />
|
||||
<buildOptions verbose="false" faster="false" disableSigning="false" disableJreBundling="false" debug="false" />
|
||||
</install4j>
|
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 983 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<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">
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" 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="0" max="-2" attributes="0">
|
||||
<Component id="delBtn" max="32767" attributes="0"/>
|
||||
<Component id="previewBtn" max="32767" attributes="0"/>
|
||||
<Component id="saveBtn" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="openBtn" alignment="1" pref="79" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="296" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</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="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="jScrollPane1" alignment="0" pref="0" 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="previewBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="delBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<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="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>
|
||||
<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.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="saveBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Save..."/>
|
||||
<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.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Preview:"/>
|
||||
</Properties>
|
||||
</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="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>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Skylar
|
||||
*/
|
||||
public class Controls extends javax.swing.JPanel {
|
||||
|
||||
private JFileChooser fc = new JFileChooser();
|
||||
|
||||
/**
|
||||
* Creates new form Controls
|
||||
*/
|
||||
public Controls() {
|
||||
FileFilter filter = new FileNameExtensionFilter("Plain Text (txt, text)", "txt", "text");
|
||||
fc.setFileFilter(filter);
|
||||
fc.addChoosableFileFilter(filter);
|
||||
fc.addChoosableFileFilter(new FileNameExtensionFilter(
|
||||
"Javascript (syjs, js)", "syjs", "js"));
|
||||
fc.addChoosableFileFilter(new FileNameExtensionFilter(
|
||||
"Python (sypy, py)", "sypy", "py"));
|
||||
initComponents();
|
||||
updateList();
|
||||
}
|
||||
|
||||
public void saveFile(String contents) {
|
||||
contents = contents.replaceAll("(?<!\r)\n", "\r\n");
|
||||
int r = fc.showSaveDialog(this);
|
||||
if (r == JFileChooser.APPROVE_OPTION) {
|
||||
try {
|
||||
File filedata = FileUtils.getFileWithExtension(fc);
|
||||
FileUtils.saveFile(contents, filedata.getAbsolutePath(), true);
|
||||
GUI.statusLbl.setText("Saved "+filedata.getName());
|
||||
} catch (IOException ex) {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"Error: Cannot save file: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
addBtn = new javax.swing.JButton();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
padPane = new javax.swing.JList();
|
||||
openBtn = new javax.swing.JButton();
|
||||
saveBtn = new javax.swing.JButton();
|
||||
jScrollPane2 = new javax.swing.JScrollPane();
|
||||
previewPane = new javax.swing.JTextArea();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
previewBtn = new javax.swing.JButton();
|
||||
delBtn = new javax.swing.JButton();
|
||||
|
||||
jLabel1.setText("My Pads:");
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
saveBtn.setText("Save...");
|
||||
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);
|
||||
|
||||
jLabel2.setText("Preview:");
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.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.LEADING, false)
|
||||
.addComponent(delBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(previewBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(saveBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(openBtn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel2)
|
||||
.addGap(0, 296, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane2)))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.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(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(openBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(saveBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(previewBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(delBtn)
|
||||
.addContainerGap())
|
||||
.addComponent(jScrollPane2)))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addBtnActionPerformed
|
||||
String id = JOptionPane.showInputDialog(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);
|
||||
}
|
||||
PadUtils.addPad(id);
|
||||
}
|
||||
updateList();
|
||||
}//GEN-LAST:event_addBtnActionPerformed
|
||||
|
||||
private String getSelectedPad() {
|
||||
return padPane.getSelectedValue().toString();
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
padPane.setListData(PadUtils.getPads());
|
||||
}
|
||||
|
||||
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);
|
||||
previewBtn.setEnabled(enable);
|
||||
delBtn.setEnabled(enable);
|
||||
}//GEN-LAST:event_padPaneValueChanged
|
||||
|
||||
private void openBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openBtnActionPerformed
|
||||
GUI.loadPad(getSelectedPad());
|
||||
}//GEN-LAST:event_openBtnActionPerformed
|
||||
|
||||
private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed
|
||||
saveFile(PadUtils.getPad(getSelectedPad()));
|
||||
updateList();
|
||||
}//GEN-LAST:event_saveBtnActionPerformed
|
||||
|
||||
private void previewBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previewBtnActionPerformed
|
||||
previewPane.setText(PadUtils.getPad(getSelectedPad()));
|
||||
previewPane.setCaretPosition(0);
|
||||
|
||||
updateList();
|
||||
}//GEN-LAST:event_previewBtnActionPerformed
|
||||
|
||||
private void delBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delBtnActionPerformed
|
||||
int ans = JOptionPane.showConfirmDialog(this,
|
||||
"Remove pad from list? It will not be removed from the server.",
|
||||
"Delete?",
|
||||
JOptionPane.OK_CANCEL_OPTION);
|
||||
if (ans == JOptionPane.OK_OPTION) {
|
||||
PadUtils.delPad(getSelectedPad());
|
||||
}
|
||||
updateList();
|
||||
}//GEN-LAST:event_delBtnActionPerformed
|
||||
|
||||
|
||||
// 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 saveBtn;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
/**
|
||||
* 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,123 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" 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 Pad Viewer"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[600, 600]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
</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="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,88,0,0,2,88"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[400, 20]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Last"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="statusLbl">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Welcome!"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</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>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Image;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Skylar
|
||||
*/
|
||||
public class GUI extends javax.swing.JFrame {
|
||||
|
||||
public static ArrayList<Image> logo = new ArrayList<>();
|
||||
public static WebView web;
|
||||
public static Controls controls;
|
||||
|
||||
public static final String VERSION = "1.0";
|
||||
public static final int VERSIONCODE = 1;
|
||||
public static final String SYMAT = "SyMAT";
|
||||
public static final String PRODUCT = "Pad Viewer";
|
||||
|
||||
/**
|
||||
* Creates new form GUI
|
||||
*/
|
||||
public GUI() {
|
||||
initComponents();
|
||||
setIconImages(logo);
|
||||
web = new WebView();
|
||||
controls = new Controls();
|
||||
add(controls, BorderLayout.NORTH);
|
||||
add(web, BorderLayout.CENTER);
|
||||
web.setVisible(true);
|
||||
controls.setVisible(true);
|
||||
}
|
||||
|
||||
public static void loadPad(String pad) {
|
||||
web.loadURL(PadUtils.PADS_URL + "/p/" + pad, pad);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
statusLbl = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setTitle("SyMAT Pad Viewer");
|
||||
setPreferredSize(new java.awt.Dimension(600, 600));
|
||||
|
||||
jPanel1.setPreferredSize(new java.awt.Dimension(400, 20));
|
||||
jPanel1.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
statusLbl.setText("Welcome!");
|
||||
statusLbl.setToolTipText("");
|
||||
jPanel1.add(statusLbl, java.awt.BorderLayout.CENTER);
|
||||
|
||||
getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END);
|
||||
|
||||
pack();
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
// Set icon
|
||||
String[] sizes = {"16", "24", "32", "48", "64", "96", "128", "256", "512"};
|
||||
for (String s : sizes) {
|
||||
logo.add(new ImageIcon(
|
||||
GUI.class.getResource(s + "x" + s + ".png")).getImage());
|
||||
}
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new SplashScreen().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
public static javax.swing.JPanel jPanel1;
|
||||
public static javax.swing.JLabel statusLbl;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
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 PadUtils {
|
||||
|
||||
public static final String PADS_URL = "http://pad.symatapp.com";
|
||||
|
||||
/**
|
||||
* 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 Exception 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(
|
||||
PadUtils.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) {
|
||||
JOptionPane.showMessageDialog(
|
||||
null,
|
||||
"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.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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();
|
||||
prefs.sync();
|
||||
} 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();
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="undecorated" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
</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"/>
|
||||
<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,46,0,0,1,-112"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="false"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Netsyms Technologies"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="10" y="270" width="130" height="30"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="24" style="0"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""<html>"
+ GUI.SYMAT 
+ " <span style=\"color:#555555;\">"
+ GUI.PRODUCT
+ "</span>"
" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="0" y="180" width="400" height="-1"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="11"/>
|
||||
<Property name="text" type="java.lang.String" value="symatapp.com"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="280" y="270" width="110" height="30"/>
|
||||
</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="/com/netsyms/symat/padview/splash.png"/>
|
||||
</Property>
|
||||
</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="-1" height="-1"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
import static com.netsyms.symat.padview.GUI.logo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Skylar
|
||||
*/
|
||||
public class SplashScreen extends javax.swing.JFrame {
|
||||
|
||||
public SplashScreen me;
|
||||
|
||||
/**
|
||||
* Creates new form SplashScreen
|
||||
*/
|
||||
public SplashScreen() {
|
||||
initComponents();
|
||||
setIconImages(logo);
|
||||
me = this;
|
||||
|
||||
new java.util.Timer().schedule(
|
||||
new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
new GUI().setVisible(true);
|
||||
me.dispose();
|
||||
}
|
||||
},
|
||||
3000
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setUndecorated(true);
|
||||
setResizable(false);
|
||||
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
|
||||
|
||||
jLabel3.setText("Netsyms Technologies");
|
||||
getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 270, 130, 30));
|
||||
|
||||
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel1.setText("<html>"
|
||||
+ GUI.SYMAT
|
||||
+ " <span style=\"color:#555555;\">"
|
||||
+ GUI.PRODUCT
|
||||
+ "</span>"
|
||||
);
|
||||
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 180, 400, -1));
|
||||
|
||||
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel4.setText("symatapp.com");
|
||||
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 270, 110, 30));
|
||||
|
||||
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/netsyms/symat/padview/splash.png"))); // NOI18N
|
||||
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
|
||||
|
||||
pack();
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Events>
|
||||
<EventHandler event="componentResized" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentResized"/>
|
||||
</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 class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Form>
|
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package com.netsyms.symat.padview;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.concurrent.Worker;
|
||||
import javafx.embed.swing.JFXPanel;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.web.PromptData;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebEvent;
|
||||
import javafx.util.Callback;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Skylar
|
||||
*/
|
||||
public class WebView extends javax.swing.JPanel {
|
||||
|
||||
private javafx.scene.web.WebView browser;
|
||||
private WebEngine webEngine;
|
||||
private JFXPanel jfxPanel;
|
||||
private Group root;
|
||||
private Scene scene;
|
||||
|
||||
private String loaded = "";
|
||||
|
||||
/**
|
||||
* Creates new form WebView
|
||||
*/
|
||||
public WebView() {
|
||||
initComponents();
|
||||
jfxPanel = new JFXPanel();
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
browser = new javafx.scene.web.WebView();
|
||||
browser.setPrefSize(getWidth(), getHeight());
|
||||
root = new Group();
|
||||
scene = new Scene(root);
|
||||
ObservableList<Node> children = root.getChildren();
|
||||
children.add(browser);
|
||||
jfxPanel.setScene(scene);
|
||||
webEngine = browser.getEngine();
|
||||
webEngine.getLoadWorker().stateProperty().addListener(
|
||||
new ChangeListener<Worker.State>() {
|
||||
@Override
|
||||
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
|
||||
if (newState == Worker.State.RUNNING) {
|
||||
GUI.statusLbl.setText("Loading...");
|
||||
} else if (newState == Worker.State.SCHEDULED
|
||||
|| newState == Worker.State.READY) {
|
||||
|
||||
} else {
|
||||
GUI.statusLbl.setText(loaded);
|
||||
}
|
||||
}
|
||||
});
|
||||
webEngine.setOnAlert(
|
||||
new EventHandler<WebEvent<String>>() {
|
||||
@Override
|
||||
public void handle(WebEvent<String> t) {
|
||||
JOptionPane.showMessageDialog(jfxPanel, t.getData(), "Message from webpage", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
});
|
||||
|
||||
webEngine.setPromptHandler(
|
||||
new Callback<PromptData, String>() {
|
||||
@Override
|
||||
public String call(PromptData p) {
|
||||
return JOptionPane.showInputDialog(jfxPanel, p.getMessage(), "Question from webpage", JOptionPane.QUESTION_MESSAGE);
|
||||
}
|
||||
});
|
||||
webEngine.setConfirmHandler(
|
||||
new Callback<String, Boolean>() {
|
||||
|
||||
@Override
|
||||
public Boolean call(String p) {
|
||||
return (JOptionPane.showConfirmDialog(
|
||||
jfxPanel,
|
||||
p,
|
||||
"Question from webpage",
|
||||
JOptionPane.OK_CANCEL_OPTION)
|
||||
== JOptionPane.OK_OPTION);
|
||||
}
|
||||
|
||||
});
|
||||
webEngine.setUserAgent("Mozilla/5.0 SyMAT/PadView1.0");
|
||||
}
|
||||
});
|
||||
add(jfxPanel, BorderLayout.CENTER);
|
||||
loadHomepage();
|
||||
}
|
||||
|
||||
public void loadURL(final String url, String finishedText) {
|
||||
loaded = finishedText;
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
webEngine.load(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadHomepage() {
|
||||
String homepage = "<!DOCTYPE html>"
|
||||
+ "<html>"
|
||||
+ "<head>"
|
||||
+ "<title></title>"
|
||||
+ "<style>"
|
||||
+ "html,body{font-family: Tahoma, sans-serif;}"
|
||||
+ "</style>"
|
||||
+ "</head>"
|
||||
+ "<body>"
|
||||
+ "<h1>" + GUI.SYMAT + " " + GUI.PRODUCT + " " + GUI.VERSION + "</h1>"
|
||||
+ "<p>To add a pad, press the <b>+</b> button above, and enter the pad ID or URL."
|
||||
+ "<br />To preview a pad before loading it, press the <b>Preview</b> button."
|
||||
+ "<br />To open a pad for viewing or editing, press <b>Open</b>."
|
||||
+ "<br />To save a pad's contents to your computer, press <b>Save...</b>"
|
||||
+ "</p>"
|
||||
+ "</body>"
|
||||
+ "</html>";
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
webEngine.loadContent(homepage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||
public void componentResized(java.awt.event.ComponentEvent evt) {
|
||||
formComponentResized(evt);
|
||||
}
|
||||
});
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
jfxPanel.setSize(getWidth(), getHeight());
|
||||
browser.setPrefSize(getWidth(), getHeight());
|
||||
browser.resize(getWidth(), getHeight());
|
||||
}
|
||||
});
|
||||
}//GEN-LAST:event_formComponentResized
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,639 @@
|
||||
package org.etherpad_lite_client;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* A client for talking to Etherpad Lite's HTTP JSON API.<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* EPLiteClient api = new EPLiteClient("http://etherpad.mysite.com", "FJ7jksalksdfj83jsdflkj");<br />
|
||||
* HashMap pad = api.getText("my_pad");<br />
|
||||
* String pad = pad.get("text").toString();
|
||||
* </code>
|
||||
*/
|
||||
public class EPLiteClient {
|
||||
/**
|
||||
* The Etherpad Lite API version this client targets by default
|
||||
*/
|
||||
public static final String DEFAULT_API_VERSION = "1.2.11";
|
||||
|
||||
/**
|
||||
* The connection object
|
||||
*/
|
||||
public EPLiteConnection connection;
|
||||
|
||||
/**
|
||||
* Initializes a new org.etherpad_lite_client.EPLiteClient object.
|
||||
* The default Etherpad Lite API version (in DEFAULT_API_VERSION) will be used.
|
||||
*
|
||||
* @param url an absolute url, including protocol, to the EPL api
|
||||
* @param apiKey the API Key
|
||||
*/
|
||||
public EPLiteClient(String url, String apiKey) {
|
||||
this.connection = new EPLiteConnection(url, apiKey, DEFAULT_API_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new org.etherpad_lite_client.EPLiteClient object.
|
||||
* The specified Etherpad Lite API version will be used.
|
||||
*
|
||||
* @param url an absolute url, including protocol, to the EPL api
|
||||
* @param apiKey the API Key
|
||||
* @param apiVersion the API version
|
||||
*/
|
||||
public EPLiteClient(String url, String apiKey, String apiVersion) {
|
||||
this.connection = new EPLiteConnection(url, apiKey, apiVersion);
|
||||
}
|
||||
|
||||
// Groups
|
||||
// Pads may belong to a group. These pads are not considered "public", and won't be available through the Web UI without a session.
|
||||
|
||||
/**
|
||||
* Creates a new Group. The group id is returned in "groupID" in the HashMap.
|
||||
*
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createGroup() {
|
||||
return this.connection.post("createGroup");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Group for groupMapper if one doesn't already exist. Helps you map your application's groups to Etherpad Lite's groups.
|
||||
* The group id is returned in "groupID" in the HashMap.
|
||||
*
|
||||
* @param groupMapper your group mapper string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createGroupIfNotExistsFor(String groupMapper) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("groupMapper", groupMapper);
|
||||
return this.connection.post("createGroupIfNotExistsFor", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete group.
|
||||
*
|
||||
* @param groupID string
|
||||
*/
|
||||
public void deleteGroup(String groupID) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("groupID", groupID);
|
||||
this.connection.post("deleteGroup", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the padIDs in a group. They will be in an array inside "padIDs".
|
||||
*
|
||||
* @param groupID string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap listPads(String groupID) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("groupID", groupID);
|
||||
return this.connection.get("listPads", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pad in this group.
|
||||
*
|
||||
* @param groupID string
|
||||
* @param padName string
|
||||
*/
|
||||
public HashMap createGroupPad(String groupID, String padName) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("groupID", groupID);
|
||||
args.put("padName", padName);
|
||||
return this.connection.post("createGroupPad", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pad in this group.
|
||||
*
|
||||
* @param groupID string
|
||||
* @param padName string
|
||||
* @param text string
|
||||
*/
|
||||
public void createGroupPad(String groupID, String padName, String text) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("groupID", groupID);
|
||||
args.put("padName", padName);
|
||||
args.put("text", text);
|
||||
this.connection.post("createGroupPad", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all existing groups. The group ids are returned in "groupIDs".
|
||||
*
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap listAllGroups() {
|
||||
return this.connection.get("listAllGroups");
|
||||
}
|
||||
|
||||
// Authors
|
||||
// These authors are bound to the attributes the users choose (color and name). The author id is returned in "authorID".
|
||||
|
||||
/**
|
||||
* Create a new author.
|
||||
*
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createAuthor() {
|
||||
return this.connection.post("createAuthor");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new author with the given name. The author id is returned in "authorID".
|
||||
*
|
||||
* @param name string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createAuthor(String name) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("name", name);
|
||||
return this.connection.post("createAuthor", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Author for authorMapper if one doesn't already exist. Helps you map your application's authors to Etherpad Lite's authors.
|
||||
* The author id is returned in "authorID".
|
||||
*
|
||||
* @param authorMapper string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createAuthorIfNotExistsFor(String authorMapper) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("authorMapper", authorMapper);
|
||||
return this.connection.post("createAuthorIfNotExistsFor", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Author for authorMapper if one doesn't already exist. Helps you map your application's authors to Etherpad Lite's authors.
|
||||
* The author id is returned in "authorID".
|
||||
*
|
||||
* @param authorMapper string
|
||||
* @param name string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createAuthorIfNotExistsFor(String authorMapper, String name) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("authorMapper", authorMapper);
|
||||
args.put("name", name);
|
||||
return this.connection.post("createAuthorIfNotExistsFor", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the ids of pads the author has edited. They will be in an array inside "padIDs".
|
||||
*
|
||||
* @param authorId the authors's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap listPadsOfAuthor(String authorId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("authorID", authorId);
|
||||
return this.connection.get("listPadsOfAuthor", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Author Name of the author.
|
||||
*
|
||||
* @param authorId the author's id string
|
||||
* @return String
|
||||
*/
|
||||
public String getAuthorName(String authorId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("authorID", authorId);
|
||||
return this.connection.get("getAuthorName", args).toString();
|
||||
}
|
||||
|
||||
// Sessions
|
||||
// Sessions can be created between a group and an author. This allows an author to access more than one group. The sessionID will be set as a
|
||||
// cookie to the client and is valid until a certain date. Only users with a valid session for this group, can access group pads. You can create a
|
||||
// session after you authenticated the user at your web application, to give them access to the pads. You should save the sessionID of this session
|
||||
// and delete it after the user logged out.
|
||||
|
||||
/**
|
||||
* Create a new session for the given author in the given group, valid until the given UNIX time.
|
||||
* The session id will be returned in "sessionID".<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* import java.util.Date;<br />
|
||||
* ...<br />
|
||||
* Date now = new Date();<br />
|
||||
* long in1Hour = (now.getTime() + (60L * 60L * 1000L) / 1000L);<br />
|
||||
* String sessID1 = api.createSession(groupID, authorID, in1Hour).get("sessionID").toString();
|
||||
* </code>
|
||||
*
|
||||
* @param groupID string
|
||||
* @param authorID string
|
||||
* @param validUntil long UNIX timestamp <strong>in seconds</strong>
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createSession(String groupID, String authorID, long validUntil) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("groupID", groupID);
|
||||
args.put("authorID", authorID);
|
||||
args.put("validUntil", String.valueOf(validUntil));
|
||||
return this.connection.post("createSession", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new session for the given author in the given group valid for the given number of hours.
|
||||
* The session id will be returned in "sessionID".<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* // in 2 hours<br />
|
||||
* String sessID1 = api.createSession(groupID, authorID, 2).get("sessionID").toString();
|
||||
* </code>
|
||||
*
|
||||
* @param groupID string
|
||||
* @param authorID string
|
||||
* @param validUntil int length of session in hours
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createSession(String groupID, String authorID, int length) {
|
||||
long inNHours = ((new Date()).getTime() + ((long)length * 60L * 60L * 1000L)) / 1000L;
|
||||
return this.createSession(groupID, authorID, inNHours);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new session for the given author in the given group, valid until the given datetime.
|
||||
* The session id will be returned in "sessionID".<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* import java.util.Date;<br />
|
||||
* import java.text.DateFormat;<br />
|
||||
* import java.text.SimpleDateFormat;<br />
|
||||
* import java.util.TimeZone;<br />
|
||||
* ...<br />
|
||||
* DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");<br />
|
||||
* dfm.setTimeZone(TimeZone.getTimeZone("GMT-5"));<br />
|
||||
* Date longTime = dfm.parse("2056-01-15 20:15:00");<br />
|
||||
* String sessID = api.createSession(groupID, authorID, longTime).get("sessionID").toString();
|
||||
* </code>
|
||||
*
|
||||
* @param groupID string
|
||||
* @param authorID string
|
||||
* @param validUntil Date
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap createSession(String groupID, String authorID, Date validUntil) {
|
||||
long seconds = validUntil.getTime() / 1000L;
|
||||
return this.createSession(groupID, authorID, seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a session.
|
||||
*
|
||||
* @param sessionID string
|
||||
*/
|
||||
public void deleteSession(String sessionID) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("sessionID", sessionID);
|
||||
this.connection.post("deleteSession", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about a session: authorID, groupID and validUntil.
|
||||
*
|
||||
* @param sessionID string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getSessionInfo(String sessionID) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("sessionID", sessionID);
|
||||
return this.connection.get("getSessionInfo", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the sessions IDs in a group. Returned as a HashMap of sessionIDs keys, with values of HashMaps containing
|
||||
* groupID, authorID, and validUntil.
|
||||
*
|
||||
* @param groupID string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap listSessionsOfGroup(String groupID) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("groupID", groupID);
|
||||
return this.connection.get("listSessionsOfGroup", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the sessions IDs belonging to an author. Returned as a HashMap of sessionIDs keys, with values of HashMaps containing
|
||||
* groupID, authorID, and validUntil.
|
||||
*
|
||||
* @param authorID string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap listSessionsOfAuthor(String authorID) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("authorID", authorID);
|
||||
return this.connection.get("listSessionsOfAuthor", args);
|
||||
}
|
||||
|
||||
// Pad content
|
||||
|
||||
/**
|
||||
* Returns a list of all pads.
|
||||
*
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap listAllPads() {
|
||||
return this.connection.get("listAllPads");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashMap containing the latest revision of the pad's text.
|
||||
* The text is stored under "text".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getText(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("getText", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashMap containing the a specific revision of the pad's text.
|
||||
* The text is stored under "text".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @param rev the revision number
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getText(String padId, int rev) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("rev", new Integer(rev));
|
||||
return this.connection.get("getText", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new revision with the given text (or creates a new pad).
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @param text the pad's new text
|
||||
*/
|
||||
public void setText(String padId, String text) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("text", text);
|
||||
this.connection.post("setText", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashMap containing the current revision of the pad's text as HTML.
|
||||
* The html is stored under "html".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getHTML(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("getHTML", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashMap containing the a specific revision of the pad's text as HTML.
|
||||
* The html is stored under "html".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @param rev the revision number
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getHTML(String padId, int rev) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("rev", new Integer(rev));
|
||||
return this.connection.get("getHTML", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new revision with the given html (or creates a new pad).
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @param html the pad's new html text
|
||||
*/
|
||||
public void setHTML(String padId, String html) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("html", html);
|
||||
this.connection.post("setHTML", args);
|
||||
}
|
||||
|
||||
// Pads
|
||||
// Group pads are normal pads, but with the name schema GROUPID$PADNAME. A security manager controls access of them and its
|
||||
// forbidden for normal pads to include a $ in the name.
|
||||
|
||||
/**
|
||||
* Create a new pad.
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
*/
|
||||
public void createPad(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
this.connection.post("createPad", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new pad with the given initial text.
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @param text the initial text string
|
||||
*/
|
||||
public void createPad(String padId, String text) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("text", text);
|
||||
this.connection.post("createPad", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of revisions of this pad. The number is in "revisions".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getRevisionsCount(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("getRevisionsCount", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the ids of authors who have edited a pad. They will be in an array inside "authorIDs".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap listAuthorsOfPad(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("listAuthorsOfPad", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pad.
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
*/
|
||||
public void deletePad(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
this.connection.post("deletePad", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pad's read-only id. The id will be in "readOnlyID".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getReadOnlyID(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("getReadOnlyID", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pad's last edit date as a Unix timestamp. The timestamp will be in "lastEdited".
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getLastEdited(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("getLastEdited", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of users currently editing a pad.
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return Long
|
||||
*/
|
||||
public Long padUsersCount(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
Long userCount = (Long) this.connection.get("padUsersCount", args).get("padUsersCount");
|
||||
return userCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of users that are currently editing this pad.
|
||||
* A padUser has the values: "colorId", "name" and "timestamp".
|
||||
*
|
||||
* @param padId
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap padUsers(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("padUsers", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pad's public status.
|
||||
* This is only applicable to group pads.
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @param publicStatus boolean
|
||||
*/
|
||||
public void setPublicStatus(String padId, Boolean publicStatus) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("publicStatus", publicStatus);
|
||||
this.connection.post("setPublicStatus", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pad's public status. The boolean is in "publicStatus".
|
||||
* This is only applicable to group pads.<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* Boolean is_public = (Boolean)api.getPublicStatus("g.kjsdfj7ask$foo").get("publicStatus");
|
||||
* </code>
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap getPublicStatus(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("getPublicStatus", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pad's password. This is only applicable to group pads.
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @param password string
|
||||
*/
|
||||
public void setPassword(String padId, String password) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("password", password);
|
||||
this.connection.post("setPassword", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the pad is password-protected or not. The boolean is in "isPasswordProtected".
|
||||
* This is only applicable to group pads.<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* Boolean pass = (Boolean)api.isPasswordProtected("g.kjsdfj7ask$foo").get("isPasswordProtected");
|
||||
* </code>
|
||||
*
|
||||
* @param padId the pad's id string
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap isPasswordProtected(String padId) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
return this.connection.get("isPasswordProtected", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a custom message of type msg to the pad.
|
||||
*
|
||||
* @param padId
|
||||
* @param msg
|
||||
*/
|
||||
public void sendClientsMessage(String padId, String msg) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("padID", padId);
|
||||
args.put("msg", msg);
|
||||
this.connection.post("sendClientsMessage", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the connection is using SSL/TLS, false if not.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isSecure() {
|
||||
if (this.connection.uri.getPort() == 443) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,259 @@
|
||||
package org.etherpad_lite_client;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import com.netsyms.symat.padview.Debug;
|
||||
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
/**
|
||||
* Connection object for talking to and parsing responses from the Etherpad Lite
|
||||
* Server.
|
||||
*/
|
||||
public class EPLiteConnection {
|
||||
|
||||
public static final int CODE_OK = 0;
|
||||
public static final int CODE_INVALID_PARAMETERS = 1;
|
||||
public static final int CODE_INTERNAL_ERROR = 2;
|
||||
public static final int CODE_INVALID_METHOD = 3;
|
||||
public static final int CODE_INVALID_API_KEY = 4;
|
||||
|
||||
/**
|
||||
* The url of the API
|
||||
*/
|
||||
public URI uri;
|
||||
|
||||
/**
|
||||
* The API key
|
||||
*/
|
||||
public String apiKey;
|
||||
|
||||
/**
|
||||
* The Etherpad Lite API version
|
||||
*/
|
||||
public String apiVersion;
|
||||
|
||||
/**
|
||||
* Initializes a new org.etherpad_lite_client.EPLiteConnection object.
|
||||
*
|
||||
* @param url an absolute url, including protocol, to the EPL api
|
||||
* @param apiKey the API Key
|
||||
* @param apiVersion the API version
|
||||
*/
|
||||
public EPLiteConnection(String url, String apiKey, String apiVersion) {
|
||||
this.uri = URI.create(url);
|
||||
this.apiKey = apiKey;
|
||||
this.apiVersion = apiVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* GETs from the HTTP JSON API.
|
||||
*
|
||||
* @param apiMethod the name of the API method to call
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap get(String apiMethod) {
|
||||
return this.get(apiMethod, new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* GETs from the HTTP JSON API.
|
||||
*
|
||||
* @param apiMethod the name of the API method to call
|
||||
* @param apiArgs a HashMap of url/form parameters. apikey will be set
|
||||
* automatically
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap get(String apiMethod, HashMap apiArgs) {
|
||||
String path = this.apiPath(apiMethod);
|
||||
String query = this.queryString(apiArgs);
|
||||
URL url = apiUrl(path, query);
|
||||
Request request = new GETRequest(url);
|
||||
return this.call(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* POSTs to the HTTP JSON API.
|
||||
*
|
||||
* @param apiMethod the name of the API method to call
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap post(String apiMethod) {
|
||||
return this.post(apiMethod, new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* POSTs to the HTTP JSON API.
|
||||
*
|
||||
* @param apiMethod the name of the API method to call
|
||||
* @param apiArgs a HashMap of url/form parameters. apikey will be set
|
||||
* automatically
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap post(String apiMethod, HashMap apiArgs) {
|
||||
String path = this.apiPath(apiMethod);
|
||||
String query = this.queryString(apiArgs);
|
||||
URL url = apiUrl(path, null);
|
||||
Request request = new POSTRequest(url, query);
|
||||
return this.call(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the HTTP JSON API.
|
||||
*
|
||||
* @param request the request object to send
|
||||
* @return HashMap
|
||||
*/
|
||||
private HashMap call(Request request) {
|
||||
trustServerAndCertificate();
|
||||
|
||||
try {
|
||||
String response = request.send();
|
||||
return this.handleResponse(response);
|
||||
} catch (EPLiteException e) {
|
||||
throw new EPLiteException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
throw new EPLiteException("Unable to connect to SyMAT: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the API resonse's JSON string into a HashMap.
|
||||
*
|
||||
* @param jsonString a valid JSON string
|
||||
* @return HashMap
|
||||
*/
|
||||
private HashMap handleResponse(String jsonString) {
|
||||
try {
|
||||
JSONParser parser = new JSONParser();
|
||||
Map response = (Map) parser.parse(jsonString);
|
||||
// Act on the response code
|
||||
if (!response.get("code").equals(null)) {
|
||||
int code = ((Long) response.get("code")).intValue();
|
||||
switch (code) {
|
||||
// Valid code, parse the response
|
||||
case CODE_OK:
|
||||
HashMap data = (HashMap) response.get("data");
|
||||
return data != null ? data : new HashMap();
|
||||
// Invalid code, throw an exception with the message
|
||||
case CODE_INVALID_PARAMETERS:
|
||||
case CODE_INVALID_API_KEY:
|
||||
case CODE_INVALID_METHOD:
|
||||
throw new EPLiteException((String) response.get("message"));
|
||||
default:
|
||||
throw new EPLiteException("An unknown error has occurred while handling the response: " + jsonString);
|
||||
}
|
||||
// No response code, something's really wrong
|
||||
} else {
|
||||
throw new EPLiteException("An unknown error has occurred while handling the response: " + jsonString);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
System.err.println("Unable to parse JSON response (" + jsonString + "): " + e.getMessage());
|
||||
return new HashMap();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL for the api path and query.
|
||||
*
|
||||
* @param path the api path
|
||||
* @param query the query string (may be null)
|
||||
* @return URL
|
||||
*/
|
||||
private URL apiUrl(String path, String query) {
|
||||
try {
|
||||
URL url = new URL(new URI(this.uri.getScheme(), null, this.uri.getHost(), this.uri.getPort(), path, query, null).toString());
|
||||
return url;
|
||||
} catch (Exception e) {
|
||||
throw new EPLiteException("Unable to connect to SyMAT: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URI path for the API method
|
||||
*
|
||||
* @param apiMethod the api method
|
||||
* @return String
|
||||
*/
|
||||
private String apiPath(String apiMethod) {
|
||||
return this.uri.getPath() + "/api/" + this.apiVersion + "/" + apiMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a query string made from HashMap keys and values
|
||||
*
|
||||
* @param apiArgs the api arguments in a HashMap
|
||||
* @return String
|
||||
*/
|
||||
private String queryString(HashMap apiArgs) {
|
||||
String strArgs = "";
|
||||
apiArgs.put("apikey", this.apiKey);
|
||||
Iterator i = apiArgs.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
Map.Entry e = (Map.Entry) i.next();
|
||||
Object value = e.getValue();
|
||||
if (value != null) {
|
||||
try {
|
||||
strArgs += e.getKey() + "=" + URLEncoder.encode(value.toString(), "utf-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Debug.stacktrace(ex);
|
||||
}
|
||||
if (i.hasNext()) {
|
||||
strArgs += "&";
|
||||
}
|
||||
}
|
||||
}
|
||||
return strArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a trust manager to trust all certificates if you open a ssl
|
||||
* connection
|
||||
*/
|
||||
private void trustServerAndCertificate() {
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] certs, String authType) {
|
||||
}
|
||||
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] certs, String authType) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting trust manager
|
||||
try {
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
HostnameVerifier hv = new HostnameVerifier() {
|
||||
//@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(hv);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package org.etherpad_lite_client;
|
||||
|
||||
public class EPLiteException extends RuntimeException {
|
||||
public EPLiteException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.etherpad_lite_client;
|
||||
|
||||
import java.net.URL;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* A class for easily executing an HTTP GET request.<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* Request req = new GETRequest(url_object);<br />
|
||||
* String resp = req.send();<br />
|
||||
* </code>
|
||||
*/
|
||||
public class GETRequest implements Request {
|
||||
/**
|
||||
* The URL object.
|
||||
*/
|
||||
private URL url;
|
||||
|
||||
/**
|
||||
* Instantiates a new GETRequest.
|
||||
*
|
||||
* @param url the URL object
|
||||
*/
|
||||
public GETRequest(URL url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the request and returns the response.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String send() throws Exception {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
String response = "";
|
||||
String buffer;
|
||||
while ((buffer = in.readLine()) != null) {
|
||||
response += buffer;
|
||||
}
|
||||
in.close();
|
||||
return response;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package org.etherpad_lite_client;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
/**
|
||||
* A class for easily executing an HTTP POST request.<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <br />
|
||||
* <code>
|
||||
* Request req = new POSTRequest(url_object);<br />
|
||||
* String resp = req.send();<br />
|
||||
* </code>
|
||||
*/
|
||||
public class POSTRequest implements Request {
|
||||
/**
|
||||
* The URL object.
|
||||
*/
|
||||
private URL url;
|
||||
|
||||
/**
|
||||
* Instantiates a new POSTRequest.
|
||||
*
|
||||
* @param url the URL object
|
||||
*/
|
||||
private String args;
|
||||
|
||||
public POSTRequest(URL url, String args) {
|
||||
this.url = url;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the request and returns the response.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String send() throws Exception {
|
||||
URLConnection con = this.url.openConnection();
|
||||
con.setDoOutput(true);
|
||||
|
||||
OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
|
||||
out.write(this.args);
|
||||
out.close();
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String response = "";
|
||||
String buffer;
|
||||
while ((buffer = in.readLine()) != null) {
|
||||
response += buffer;
|
||||
}
|
||||
in.close();
|
||||
return response;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package org.etherpad_lite_client;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public interface Request {
|
||||
URL url = null;
|
||||
|
||||
public abstract String send() throws Exception;
|
||||
}
|