Initial commit of multiasset branch

This commit is contained in:
7u83 2018-11-30 12:27:41 +01:00
parent 45684a9d0e
commit bb18f7cf03
205 changed files with 8656 additions and 2750 deletions

View File

@ -1,3 +1,3 @@
# SeSim
SeSim - Sock Exchange Simulator
OpenSeSim - Open Source Sock Exchange Simulator

View File

@ -109,30 +109,30 @@
-->
<target name="single-jar" depends="jar">
<property name="store.jar.name" value="SeSim"/>
<property name="store.dir" value="store"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
<delete dir="${store.dir}"/>
<mkdir dir="${store.dir}"/>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
<zip destfile="${store.jar}">
<zipfileset src="${store.dir}/temp_final.jar"
excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
</zip>
<delete file="${store.dir}/temp_final.jar"/>
</target>
<target name="single-jar" depends="jar">
<property name="store.jar.name" value="OpenSeSim"/>
<property name="store.dir" value="store"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
<delete dir="${store.dir}"/>
<mkdir dir="${store.dir}"/>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
<zip destfile="${store.jar}">
<zipfileset src="${store.dir}/temp_final.jar"
excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
</zip>
<delete file="${store.dir}/temp_final.jar"/>
</target>
<property name="ivy.install.version" value="2.1.0-rc2" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ant" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
@ -147,10 +147,10 @@
</target>
<target name="init-ivy" depends="download-ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>

View File

@ -1,22 +0,0 @@
<jnlp spec="1.0+" codebase="${jnlp.codebase}" href="launch.jnlp">
<information>
<title>${APPLICATION.TITLE}</title>
<vendor>${APPLICATION.VENDOR}</vendor>
<homepage href="${APPLICATION.HOMEPAGE}"/>
<description>${APPLICATION.DESC}</description>
<description kind="short">${APPLICATION.DESC.SHORT}</description>
<!--${JNLP.ICONS}-->
<!--${JNLP.OFFLINE.ALLOWED}-->
</information>
<!--${JNLP.UPDATE}-->
<!--${JNLP.SECURITY}-->
<resources>
<!--${JNLP.RESOURCES.RUNTIME}-->
<!--${JNLP.RESOURCES.MAIN.JAR}-->
<!--${JNLP.RESOURCES.JARS}-->
<!--${JNLP.RESOURCES.EXTENSIONS}-->
</resources>
<application-desc main-class="${jnlp.main.class}">
<!--${JNLP.APPLICATION.ARGS}-->
</application-desc>
</jnlp>

View File

@ -1,20 +0,0 @@
<jnlp spec="1.0+" codebase="${jnlp.codebase}" href="launch.jnlp">
<information>
<title>${APPLICATION.TITLE}</title>
<vendor>${APPLICATION.VENDOR}</vendor>
<homepage href="${APPLICATION.HOMEPAGE}"/>
<description>${APPLICATION.DESC}</description>
<description kind="short">${APPLICATION.DESC.SHORT}</description>
<!--${JNLP.ICONS}-->
<!--${JNLP.OFFLINE.ALLOWED}-->
</information>
<!--${JNLP.UPDATE}-->
<!--${JNLP.SECURITY}-->
<resources>
<!--${JNLP.RESOURCES.RUNTIME}-->
<!--${JNLP.RESOURCES.MAIN.JAR}-->
<!--${JNLP.RESOURCES.JARS}-->
<!--${JNLP.RESOURCES.EXTENSIONS}-->
</resources>
<component-desc/>
</jnlp>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +0,0 @@
$label=Web Start
$target.debug=jws-debug
$target.run=jws-run
compile.on.save.unsupported.javawebstart=true

View File

@ -1,8 +1,8 @@
build.xml.data.CRC32=fc4f97ad
build.xml.script.CRC32=72406d8f
build.xml.stylesheet.CRC32=8064a381@1.79.1.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=56c4c4cc
nbproject/build-impl.xml.script.CRC32=5f99364f
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
build.xml.data.CRC32=fc4f97ad
build.xml.script.CRC32=72406d8f
build.xml.stylesheet.CRC32=8064a381@1.79.1.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=65c6cbee
nbproject/build-impl.xml.script.CRC32=ae093a94
nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.89.1.48

View File

@ -1,47 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 1997-2013 Oracle and/or its affiliates. All rights reserved.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.
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.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://www.netbeans.org/cddl-gplv2.html
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License file at
nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
particular file as subject to the "Classpath" exception as provided
by Oracle in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
Contributor(s):
The Original Software is NetBeans. The Initial Developer of the Original
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
Microsystems, Inc. All Rights Reserved.
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 2, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 2] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 2 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 2 code and therefore, elected the GPL
Version 2 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
-->
<project name="jnlp-impl" default="default" basedir=".." xmlns:jnlp="http://www.netbeans.org/ns/j2se-project/jnlp" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3">
@ -261,7 +237,7 @@ made subject to such option by the copyright holder.
<macrodef name="extend-manifest" uri="http://www.netbeans.org/ns/j2se-project/jnlp">
<element name="customize"/>
<sequential>
<manifest file="${tmp.manifest.file}" mode="update">
<manifest file="${tmp.manifest.file}" mode="update" encoding="UTF-8">
<customize/>
</manifest>
</sequential>
@ -306,7 +282,7 @@ made subject to such option by the copyright holder.
<target name="-copy-tmp-manifest" if="manifest.file">
<property name="tmp.manifest.file" value="${build.dir}/manifest.mf"/>
<copy file="${manifest.file}" tofile="${build.dir}/manifest.mf"/>
<copy file="${manifest.file}" tofile="${build.dir}/manifest.mf" encoding="${manifest.encoding}" outputencoding="UTF-8"/>
</target>
<target name="-set-mixed-code-properties" depends="-check-signing-possible" if="jnlp.signed.true+signjars.task.available">
@ -866,18 +842,6 @@ made subject to such option by the copyright holder.
description="Debug javaws project in IDE"/>
<target name="-init-debug-args">
<property name="version-output" value="java version &quot;${ant.java.version}"/>
<condition property="have-jdk-older-than-1.4">
<or>
<contains string="${version-output}" substring="java version &quot;1.0"/>
<contains string="${version-output}" substring="java version &quot;1.1"/>
<contains string="${version-output}" substring="java version &quot;1.2"/>
<contains string="${version-output}" substring="java version &quot;1.3"/>
</or>
</condition>
<condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
<istrue value="${have-jdk-older-than-1.4}"/>
</condition>
<condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
<os family="windows"/>
</condition>
@ -889,7 +853,7 @@ made subject to such option by the copyright holder.
<target name="-debug-javaws-debuggee" depends="-init-debug-args,-init-platform,-check-webstart">
<echo message="Executing ${jnlp.dest.dir}${file.separator}${jnlp.file} in debug mode using ${active.webstart.executable}"/>
<exec executable="${active.webstart.executable}">
<env key="JAVAWS_VM_ARGS" value="${debug-args-line} -Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<env key="JAVAWS_VM_ARGS" value="-agentlib:jdwp=transport=${debug-transport},address=${jpda.address}"/>
<arg value="-wait"/>
<arg file="${jnlp.dest.dir}${file.separator}${jnlp.file}"/>
</exec>

View File

@ -1,4 +1,4 @@
#Sat, 27 Jan 2018 22:25:12 +0100
#Fri, 30 Nov 2018 10:49:27 +0100
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
@ -8,8 +8,17 @@ ant.customtasks.libs=JWSAntTasks
application.desc=SeSim - Stock Exchange Simulator
application.homepage=blog.cauwersin.com
application.splash=
application.title=SeSim
application.title=OpenSeSim
application.vendor=Cauwersin
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsEnabled=true
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@ -23,12 +32,14 @@ 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.modulepath=${run.modulepath}
debug.test.classpath=${run.test.classpath}
debug.test.modulepath=${run.test.modulepath}
# 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}/SeSim.jar
dist.jar=${dist.dir}/OpenSeSim.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
@ -41,10 +52,13 @@ javac.classpath=${ivy.classpath}\:${libs.absolutelayout.classpath}
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=${javac.classpath}\:${build.classes.dir}
javac.test.classpath=${javac.classpath}\:${build.classes.dir}\:${libs.junit_4.classpath}\:${libs.hamcrest.classpath}\:${libs.testng.classpath}
javac.test.modulepath=${javac.modulepath}
javac.test.processorpath=${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
@ -61,6 +75,7 @@ jnlp.applet.height=300
jnlp.applet.width=300
jnlp.codebase.type=user
jnlp.codebase.url=$$$$codebase
jnlp.codebase.user=
jnlp.descriptor=component
jnlp.enabled=false
jnlp.icon=
@ -69,7 +84,8 @@ jnlp.offline-allowed=true
jnlp.signed=true
jnlp.signing=key
jnlp.signing.alias=SeSim
main.class=gui.SeSimApplication
jnlp.signing.keystore=
main.class=opensesim.gui.SeSimApplication
# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found.
manifest.custom.application.library.allowable.codebase=
# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts.
@ -88,7 +104,9 @@ run.classpath=${javac.classpath}\:${build.classes.dir}
# 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.modulepath=${javac.modulepath}
run.test.classpath=${javac.test.classpath}\:${build.test.classes.dir}
run.test.modulepath=${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

View File

@ -9,7 +9,7 @@
</extension>
</buildExtensions>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>SeSim</name>
<name>OpenSeSim</name>
<source-roots>
<root id="src.dir"/>
</source-roots>

View File

@ -1,17 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test page for launching the application via JNLP</title>
</head>
<body>
<h3>Test page for launching the application via JNLP</h3>
<script src="http://java.com/js/deployJava.js"></script>
<script>
deployJava.createWebStartLaunchButton("${JNLP.FILE}")
</script>
<!-- Or use the following link element to launch with the application -->
<!--
<a href="${JNLP.FILE}">Launch the application</a>
-->
</body>
</html>

View File

@ -1,459 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[220, 262]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<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,41,0,0,2,75"/>
</AuxValues>
<SubComponents>
<Component class="gui.AskBook" name="askBook1">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[200, 200]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="gui.BidBook" name="bidBook1">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[200, 200]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
<Container class="gui.QuotePanel" name="quotePanel2">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[587, 200]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.5" weightY="0.5"/>
</Constraint>
</Constraints>
<LayoutCode>
<CodeStatement>
<CodeExpression id="1_quotePanel2Layout">
<CodeVariable name="quotePanel2Layout" type="4096" declaredType="java.awt.GridBagLayout"/>
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeExpression">
<CodeExpression id="1_quotePanel2Layout"/>
</StatementProvider>
</CodeStatement>
<CodeStatement>
<CodeExpression id="1_quotePanel2Layout"/>
<StatementProvider type="CodeField">
<CodeField name="columnWidths" class="java.awt.GridBagLayout"/>
</StatementProvider>
<Parameters>
<CodeExpression id="2">
<ExpressionOrigin>
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
<PropertyValue value="[0, 5, 0, 5, 0]"/>
</Value>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="1_quotePanel2Layout"/>
<StatementProvider type="CodeField">
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/>
</StatementProvider>
<Parameters>
<CodeExpression id="3">
<ExpressionOrigin>
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
<PropertyValue value="[0]"/>
</Value>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="4_quotePanel2">
<CodeVariable name="quotePanel2" type="8194" declaredType="gui.QuotePanel"/>
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="quotePanel2"/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeMethod">
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
</StatementProvider>
<Parameters>
<CodeExpression id="1_quotePanel2Layout"/>
</Parameters>
</CodeStatement>
</LayoutCode>
</Container>
</SubComponents>
<LayoutCode>
<CodeStatement>
<CodeExpression id="5_layout">
<CodeVariable name="layout" type="4096" declaredType="java.awt.GridBagLayout"/>
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeExpression">
<CodeExpression id="5_layout"/>
</StatementProvider>
</CodeStatement>
<CodeStatement>
<CodeExpression id="5_layout"/>
<StatementProvider type="CodeField">
<CodeField name="columnWidths" class="java.awt.GridBagLayout"/>
</StatementProvider>
<Parameters>
<CodeExpression id="6">
<ExpressionOrigin>
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
<PropertyValue value="[0]"/>
</Value>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="5_layout"/>
<StatementProvider type="CodeField">
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/>
</StatementProvider>
<Parameters>
<CodeExpression id="7">
<ExpressionOrigin>
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
<PropertyValue value="[0, 5, 0, 5, 0]"/>
</Value>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="8">
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="."/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeMethod">
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
</StatementProvider>
<Parameters>
<CodeExpression id="5_layout"/>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="9_gridBagConstraints">
<CodeVariable name="gridBagConstraints" type="20480" declaredType="java.awt.GridBagConstraints"/>
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeExpression">
<CodeExpression id="9_gridBagConstraints"/>
</StatementProvider>
</CodeStatement>
<CodeStatement>
<CodeExpression id="9_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="10">
<ExpressionOrigin>
<Value type="int" value="0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="9_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="11">
<ExpressionOrigin>
<Value type="int" value="0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="9_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="fill" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="12">
<ExpressionOrigin>
<Value type="int" value="1"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="9_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="weightx" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="13">
<ExpressionOrigin>
<Value type="double" value="1.0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="9_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="weighty" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="14">
<ExpressionOrigin>
<Value type="double" value="1.0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="8"/>
<StatementProvider type="CodeMethod">
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
</StatementProvider>
<Parameters>
<CodeExpression id="15_askBook1">
<CodeVariable name="askBook1" type="8194" declaredType="gui.AskBook"/>
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="askBook1"/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<CodeExpression id="9_gridBagConstraints"/>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="16_gridBagConstraints">
<CodeVariable name="gridBagConstraints"/>
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeExpression">
<CodeExpression id="16_gridBagConstraints"/>
</StatementProvider>
</CodeStatement>
<CodeStatement>
<CodeExpression id="16_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="17">
<ExpressionOrigin>
<Value type="int" value="0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="16_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="18">
<ExpressionOrigin>
<Value type="int" value="4"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="16_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="fill" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="19">
<ExpressionOrigin>
<Value type="int" value="1"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="16_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="weightx" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="20">
<ExpressionOrigin>
<Value type="double" value="1.0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="16_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="weighty" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="21">
<ExpressionOrigin>
<Value type="double" value="1.0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="8"/>
<StatementProvider type="CodeMethod">
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
</StatementProvider>
<Parameters>
<CodeExpression id="22_bidBook1">
<CodeVariable name="bidBook1" type="8194" declaredType="gui.BidBook"/>
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="bidBook1"/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<CodeExpression id="16_gridBagConstraints"/>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="23_gridBagConstraints">
<CodeVariable name="gridBagConstraints"/>
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeExpression">
<CodeExpression id="23_gridBagConstraints"/>
</StatementProvider>
</CodeStatement>
<CodeStatement>
<CodeExpression id="23_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="24">
<ExpressionOrigin>
<Value type="int" value="0"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="23_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="25">
<ExpressionOrigin>
<Value type="int" value="2"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="23_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="fill" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="26">
<ExpressionOrigin>
<Value type="int" value="1"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="23_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="weightx" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="27">
<ExpressionOrigin>
<Value type="double" value="0.5"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="23_gridBagConstraints"/>
<StatementProvider type="CodeField">
<CodeField name="weighty" class="java.awt.GridBagConstraints"/>
</StatementProvider>
<Parameters>
<CodeExpression id="28">
<ExpressionOrigin>
<Value type="double" value="0.5"/>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="8"/>
<StatementProvider type="CodeMethod">
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
</StatementProvider>
<Parameters>
<CodeExpression id="4_quotePanel2"/>
<CodeExpression id="23_gridBagConstraints"/>
</Parameters>
</CodeStatement>
</LayoutCode>
</Form>

View File

@ -0,0 +1,186 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;
import opensesim.sesim.interfaces.Configurable;
import opensesim.util.IDGenerator.Id;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public abstract class AbstractAsset implements Configurable {
private Id id;
private String symbol;
private String name;
private String description;
int decimals;
/**
* Constructor
*/
protected AbstractAsset() {
id = null;
}
public abstract String getTypeName();
public void setDecimals(int decimals) {
this.decimals = decimals;
}
public int getDecimals() {
return decimals;
}
public void setDescription(String description) {
this.description = description;
}
public Id getID() {
return id;
}
public String getSymbol() {
return symbol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public boolean isCurrency(){
return false;
}
public boolean isAsset(){
return false;
}
public static final String JSON_ID ="id";
public static final String JSON_CLASS = "class";
public static final String JSON_SYMBOL = "symbol";
public static final String JSON_NAME = "name";
public static final String JSON_DESCRIPTION = "description";
public static final String JSON_DECIMALS = "decimals";
public static final int DECIMALS_DEFAULT = 2;
public static void rename(World world, AbstractAsset a, String symbol) throws Exception {
if (world.assetsBySymbol.get(symbol) != null) {
throw new java.lang.Exception("Can't rename asset symbol. Symbol '" + symbol + "' is already in use.");
}
world.assetsBySymbol.remove(a.getSymbol());
a.symbol = symbol;
world.assetsBySymbol.put(a.getSymbol(), a);
}
public static AbstractAsset create(World world, Class<AbstractAsset> cls, String symbol) throws Exception {
AbstractAsset a = cls.newInstance();
if (world.assetsBySymbol.get(symbol) != null) {
throw new java.lang.Exception("Can't create asset. Symbol '" + symbol + "' is already in use.");
}
a.id = world.assetIdGenerator.getNext();
a.symbol=symbol;
world.assetsById.put(a.id, a);
world.assetsBySymbol.put(a.getSymbol(), a);
return a;
}
public static AbstractAsset create(World world, JSONObject cfg){
AbstractAsset a;
String class_name;
Class cls;
String symbol;
try {
symbol = cfg.getString(JSON_SYMBOL);
class_name = cfg.getString(JSON_CLASS);
cls = Class.forName(class_name);
a = create(world,cls,symbol);
a.name = cfg.optString(JSON_NAME, symbol);
a.description = cfg.optString(JSON_DESCRIPTION);
a.decimals = cfg.optInt(JSON_DECIMALS);
}catch (JSONException ex){
return null;
} catch (ClassNotFoundException ex) {
Logger.getLogger(AbstractAsset.class.getName()).log(Level.SEVERE, null, ex);
return null;
} catch (Exception ex) {
Logger.getLogger(AbstractAsset.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
@Override
public JSONObject getConfig() {
JSONObject cfg = new JSONObject();
cfg.put(AbstractAsset.JSON_ID,id.toString());
cfg.put(AbstractAsset.JSON_CLASS, this.getClass().getName());
cfg.put(AbstractAsset.JSON_SYMBOL, this.getSymbol());
cfg.put(AbstractAsset.JSON_DECIMALS, this.getDecimals());
cfg.put(AbstractAsset.JSON_NAME, this.getName());
cfg.put(AbstractAsset.JSON_DESCRIPTION, this.getDescription());
return cfg;
}
@Override
public void putConfig(JSONObject cfg) {
symbol = cfg.optString(AbstractAsset.JSON_SYMBOL);
decimals = cfg.optInt(AbstractAsset.JSON_DECIMALS, AbstractAsset.DECIMALS_DEFAULT);
name = cfg.optString(AbstractAsset.JSON_NAME, "");
description = cfg.optString(AbstractAsset.JSON_DESCRIPTION);
}
public JPanel getEditGui(){
return null;
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim;
import opensesim.Exchange;
import java.util.concurrent.ConcurrentHashMap;
import opensesim.sesim.interfaces.Asset;
import opensesim.sesim.interfaces.Trader;
/**
* Class to hold account data of traders
* @author 7u83 <7u83@mail.ru>
*/
public class Account {
ConcurrentHashMap <Asset,Double> assets;
Trader owner;
Account(Exchange exchange){
assets = new ConcurrentHashMap<>();
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim;
import opensesim.sesim.AssetPair;
import opensesim.sesim.interfaces.FeeModel;
import opensesim.util.AssetVol;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class DefaultFeeModel implements FeeModel{
public AssetVol xgetTakerFee(AssetPair pair) {
double vol = 5;
return new AssetVol(pair.getCurrency(),vol);
}
@Override
public double getTakerFee(double x) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}

133
src/opensesim/Exchange.java Normal file
View File

@ -0,0 +1,133 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.SortedSet;
import java.util.TreeSet;
import opensesim.World;
import opensesim.sesim.AssetPair;
import opensesim.sesim.Order;
import opensesim.sesim.interfaces.Configurable;
import org.json.JSONObject;
/**
*
* @author 7u83
*/
public class Exchange implements Configurable{
private World world;
private String name;
private String symbol;
public void setName(String name) {
this.name = name;
}
//private final HashMap<String, AssetPair> asset_pairs;
private final HashMap<AssetPair,TradingEnv> asset_pairs;
Exchange(World world, String symbol) {
asset_pairs = new HashMap<>();
this.world = world;
this.symbol=symbol;
}
private void reset() {
asset_pairs.clear();
}
public String getName() {
return name;
}
public String getSymbol(){
return symbol;
}
Account createAccount() {
Account a = new Account(this);
return a;
}
public Order createOrder(Account account, AssetPair pair, Order.Type type, double volume, double limit) {
return null;
}
public Collection getOrderBook(AssetPair a){
TradingEnv e = asset_pairs.get(a);
SortedSet<Order> ob = e.order_books.get(Order.Type.BUYLIMIT);
return Collections.unmodifiableCollection(ob);
}
@Override
public JSONObject getConfig() {
JSONObject cfg = new JSONObject();
cfg.put("symbol", getSymbol());
cfg.put("name", getName());
return cfg;
}
@Override
public void putConfig(JSONObject cfg) {
}
class TradingEnv {
protected HashMap<Order.Type, SortedSet<Order>> order_books;
TradingEnv() {
reset();
}
public final void reset() {
order_books = new HashMap();
// Create an order book for each order type
for (Order.Type type : Order.Type.values()) {
order_books.put(type, new TreeSet<>());
}
// quoteHistory = new TreeSet();
// ohlc_data = new HashMap();
}
}
// public void add
}

145
src/opensesim/World.java Normal file
View File

@ -0,0 +1,145 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import opensesim.sesim.AssetPair;
import opensesim.sesim.interfaces.Configurable;
import opensesim.util.IDGenerator;
import opensesim.util.IDGenerator.Id;
import opensesim.util.SeSimException;
import org.json.JSONArray;
import org.json.JSONObject;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class World implements Configurable {
HashMap<Id, AbstractAsset> assetsById = new HashMap<>();
HashMap<String, AbstractAsset> assetsBySymbol = new HashMap<>();
IDGenerator assetIdGenerator = new IDGenerator();
HashSet<AssetPair> assetPairs = new HashSet<>();
ArrayList<Exchange> exchanges = new ArrayList<>();
/**
* Create a World object.
*/
public World() {
}
public Collection<AbstractAsset> getAssetCollection() {
return Collections.unmodifiableCollection(assetsById.values());
}
public Collection<AssetPair> getAssetPairsCollection() {
return Collections.unmodifiableCollection(assetPairs);
}
public Collection<Exchange> getExchangeCollection() {
return Collections.unmodifiableCollection(exchanges);
}
public void add(AssetPair pair) {
assetPairs.add(pair);
}
public Exchange addExchange(String symbol) throws SeSimException {
for (Exchange ex : getExchangeCollection()) {
if (ex.getSymbol().equals(symbol)) {
throw (new SeSimException("Exchange already defined."));
}
}
Exchange ex = new Exchange(this, symbol);
exchanges.add(ex);
return ex;
}
static final String JSON_ASSET = "asset";
static final String JSON_EXCHANGES = "exchanges";
@Override
public JSONObject getConfig() {
JSONObject cfg = new JSONObject();
// save assets
JSONArray arr;
arr = new JSONArray();
for (AbstractAsset a : getAssetCollection()) {
arr.put(a.getConfig());
}
cfg.put(JSON_ASSET, arr);
// save exchanges
arr = new JSONArray();
for (Exchange ex : getExchangeCollection()) {
arr.put(ex.getConfig());
}
cfg.put(JSON_EXCHANGES, arr);
return cfg;
}
@Override
public void putConfig(JSONObject cfg) {
JSONArray arr = cfg.optJSONArray(JSON_ASSET);
if (arr == null) {
arr = new JSONArray();
}
for (Object o : arr) {
JSONObject acfg = (JSONObject) o;
AbstractAsset.create(this, acfg);
}
}
public AbstractAsset createAsset(Class cls, String symbol) throws Exception {
return AbstractAsset.create(this, cls, symbol);
}
/*
static public JSONArray toJson() {
JSONArray all = new JSONArray();
for (Map.Entry<Id, Asset> entry : assetsById.entrySet()) {
Id key = entry.getKey();
Asset value = entry.getValue();
all.put(value.getConfig());
}
return all;
}
*/
}

View File

@ -4,19 +4,19 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chart;
package opensesim.chart;
import sesim.OHLCDataItem;
import sesim.OHLCData;
import opensesim.old_sesim.OHLCDataItem;
import opensesim.old_sesim.OHLCData;
import java.awt.*;
import sesim.Exchange.*;
import sesim.Quote;
import gui.Globals;
import opensesim.old_sesim.Exchange.*;
import opensesim.old_sesim.Quote;
import opensesim.gui.Globals;
import java.util.ArrayList;
import javax.swing.JViewport;
import javax.swing.Scrollable;
import sesim.MinMax;
import sesim.Scheduler;
import opensesim.old_sesim.MinMax;
import opensesim.old_sesim.Scheduler;

View File

@ -25,10 +25,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="153" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" pref="123" max="-2" attributes="0"/>
<EmptySpace pref="124" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
@ -37,10 +37,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="137" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" pref="49" max="-2" attributes="0"/>
<EmptySpace pref="114" max="32767" attributes="0"/>
</Group>
</Group>
</Group>

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
package opensesim.chart;
import java.net.URL;
import java.util.Locale;
import javax.help.*;
@ -71,19 +71,19 @@ public class Help extends javax.swing.JDialog {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(0, 0, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(153, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(124, Short.MAX_VALUE)))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(0, 0, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(137, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(114, Short.MAX_VALUE)))
);
pack();

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
package opensesim.chart;
import javax.swing.JPanel;
import javax.swing.border.Border;

View File

@ -23,15 +23,15 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
package opensesim.chart;
import chart.painter.ChartCrossPainter;
import chart.painter.ChartPainter;
import chart.painter.OHLCChartPainter;
import chart.painter.XLegendDetail;
import chart.painter.XLegendPainter;
import chart.painter.YLegendPainter;
import gui.Globals;
import opensesim.chart.painter.ChartCrossPainter;
import opensesim.chart.painter.ChartPainter;
import opensesim.chart.painter.OHLCChartPainter;
import opensesim.chart.painter.XLegendDetail;
import opensesim.chart.painter.XLegendPainter;
import opensesim.chart.painter.YLegendPainter;
import opensesim.gui.Globals;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
@ -42,10 +42,10 @@ import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;
import sesim.ChartDef;
import sesim.ChartPanel;
import sesim.OHLCData;
import sesim.Stock;
import opensesim.old_sesim.ChartDef;
import opensesim.old_sesim.ChartPanel;
import opensesim.old_sesim.OHLCData;
import opensesim.old_sesim.Stock;
/**
*

View File

@ -68,7 +68,7 @@
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="sesim.ChartPanel" name="chart">
<Container class="old_sesim.ChartPanel" name="chart">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
@ -96,7 +96,7 @@
</DimensionLayout>
</Layout>
</Container>
<Container class="sesim.ChartPanel" name="yLegend">
<Container class="old_sesim.ChartPanel" name="yLegend">
<Layout>
<DimensionLayout dim="0">
@ -111,7 +111,7 @@
</DimensionLayout>
</Layout>
</Container>
<Container class="sesim.ChartPanel" name="xLegend">
<Container class="old_sesim.ChartPanel" name="xLegend">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
@ -142,4 +142,4 @@
</Events>
</Component>
</SubComponents>
</Form>
</Form>

View File

@ -23,25 +23,25 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
package opensesim.chart;
import sesim.ChartDef;
import chart.painter.CandleStickChartPainter;
import chart.painter.ChartPainter;
import chart.painter.XLegendPainter;
import chart.painter.ChartCrossPainter;
import chart.painter.LineChartPainter;
import chart.painter.OHLCChartPainter;
import chart.painter.YLegendPainter;
import gui.Globals;
import opensesim.old_sesim.ChartDef;
import opensesim.chart.painter.CandleStickChartPainter;
import opensesim.chart.painter.ChartPainter;
import opensesim.chart.painter.XLegendPainter;
import opensesim.chart.painter.ChartCrossPainter;
import opensesim.chart.painter.LineChartPainter;
import opensesim.chart.painter.OHLCChartPainter;
import opensesim.chart.painter.YLegendPainter;
import opensesim.gui.Globals;
import java.util.ArrayList;
import sesim.Exchange.QuoteReceiver;
import sesim.Indicator;
import sesim.MinMax;
import sesim.OHLCData;
import sesim.OHLCDataItem;
import sesim.Quote;
import indicators.SMAIndicator;
import opensesim.old_sesim.Exchange.QuoteReceiver;
import opensesim.old_sesim.Indicator;
import opensesim.old_sesim.MinMax;
import opensesim.old_sesim.OHLCData;
import opensesim.old_sesim.OHLCDataItem;
import opensesim.old_sesim.Quote;
import opensesim.indicators.SMAIndicator;
import java.util.Objects;
import javax.swing.ButtonGroup;
import javax.swing.JRadioButtonMenuItem;
@ -170,7 +170,7 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver {
chart.setXSCrollBar(xScrollBar);
chart.addChartPainter(new ChartCrossPainter());
sma1 = new indicators.SMAIndicator();
sma1 = new opensesim.indicators.SMAIndicator();
sma1.setParent(mydata);
JSONObject co;
@ -183,7 +183,7 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver {
chart.addChartPainter(p);
sma2 = new indicators.SMAIndicator();
sma2 = new opensesim.indicators.SMAIndicator();
sma2.setParent(mydata);
co = new JSONObject("{\"len\": 20}");
sma2.putConfig(co);
@ -213,9 +213,9 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver {
ctxMenu = new javax.swing.JPopupMenu();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
chart = new sesim.ChartPanel();
yLegend = new sesim.ChartPanel();
xLegend = new sesim.ChartPanel();
chart = new opensesim.old_sesim.ChartPanel();
yLegend = new opensesim.old_sesim.ChartPanel();
xLegend = new opensesim.old_sesim.ChartPanel();
xScrollBar = new javax.swing.JScrollBar();
jMenu1.setText("jMenu1");
@ -369,13 +369,13 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver {
// Variables declaration - do not modify//GEN-BEGIN:variables
private sesim.ChartPanel chart;
private opensesim.old_sesim.ChartPanel chart;
private javax.swing.JPopupMenu ctxMenu;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuItem jMenuItem1;
private sesim.ChartPanel xLegend;
private opensesim.old_sesim.ChartPanel xLegend;
private javax.swing.JScrollBar xScrollBar;
private sesim.ChartPanel yLegend;
private opensesim.old_sesim.ChartPanel yLegend;
// End of variables declaration//GEN-END:variables
@Override

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
package opensesim.chart;
/**
*

View File

@ -23,7 +23,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
package opensesim.chart;
import opensesim.*;
/**
*
@ -49,7 +50,7 @@ public class SuperDlg extends javax.swing.JDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
masterChart1 = new chart.MasterChart();
masterChart1 = new opensesim.chart.MasterChart();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -115,6 +116,6 @@ public class SuperDlg extends javax.swing.JDialog {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private chart.MasterChart masterChart1;
private opensesim.chart.MasterChart masterChart1;
// End of variables declaration//GEN-END:variables
}

View File

@ -23,13 +23,13 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import java.awt.Color;
import java.awt.Graphics2D;
import javax.swing.JScrollBar;
import sesim.OHLCData;
import sesim.OHLCDataItem;
import opensesim.old_sesim.OHLCData;
import opensesim.old_sesim.OHLCDataItem;
/**
*

View File

@ -23,13 +23,13 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import sesim.ChartDef;
import sesim.ChartPanel;
import opensesim.old_sesim.ChartDef;
import opensesim.old_sesim.ChartPanel;
import java.awt.Graphics2D;
import java.awt.Point;
import sesim.OHLCDataItem;
import opensesim.old_sesim.OHLCDataItem;
/**

View File

@ -23,15 +23,15 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import sesim.ChartDef;
import sesim.ChartPanel;
import opensesim.old_sesim.ChartDef;
import opensesim.old_sesim.ChartPanel;
import java.awt.Dimension;
import java.awt.Graphics2D;
import sesim.ChartPainterInterface;
import sesim.MinMax;
import sesim.OHLCData;
import opensesim.old_sesim.ChartPainterInterface;
import opensesim.old_sesim.MinMax;
import opensesim.old_sesim.OHLCData;
/**
*

View File

@ -23,11 +23,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import java.awt.Color;
import java.awt.Graphics2D;
import sesim.OHLCDataItem;
import opensesim.old_sesim.OHLCDataItem;
/**
*

View File

@ -23,18 +23,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import sesim.ChartDef;
import sesim.ChartPanel;
import opensesim.old_sesim.ChartDef;
import opensesim.old_sesim.ChartPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import sesim.MinMax;
import sesim.OHLCData;
import sesim.OHLCDataItem;
import opensesim.old_sesim.MinMax;
import opensesim.old_sesim.OHLCData;
import opensesim.old_sesim.OHLCDataItem;
/**
*

View File

@ -23,14 +23,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import sesim.ChartDef;
import sesim.ChartPanel;
import sesim.Scheduler;
import opensesim.old_sesim.ChartDef;
import opensesim.old_sesim.ChartPanel;
import opensesim.old_sesim.Scheduler;
/**
*

View File

@ -23,14 +23,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import sesim.ChartDef;
import sesim.ChartPanel;
import opensesim.old_sesim.ChartDef;
import opensesim.old_sesim.ChartPanel;
import java.awt.Dimension;
import java.awt.Graphics2D;
import sesim.OHLCData;
import sesim.OHLCDataItem;
import opensesim.old_sesim.OHLCData;
import opensesim.old_sesim.OHLCDataItem;
/**
* Paints an x-legend for OHLC charts
@ -42,7 +42,7 @@ public class XLegendPainter extends OHLCChartPainter {
private String getTimeStrAt(OHLCData data, int unit) {
int fs = data.getFrameSize();
return sesim.Scheduler.formatTimeMillis(0 + (long) unit * (long) fs);
return opensesim.old_sesim.Scheduler.formatTimeMillis(0 + (long) unit * (long) fs);
}

View File

@ -23,18 +23,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart.painter;
package opensesim.chart.painter;
import chart.Chart;
import opensesim.chart.Chart;
import java.awt.Color;
import sesim.ChartDef;
import sesim.ChartPanel;
import opensesim.old_sesim.ChartDef;
import opensesim.old_sesim.ChartPanel;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import sesim.MinMax;
import sesim.OHLCData;
import sesim.OHLCDataItem;
import opensesim.old_sesim.MinMax;
import opensesim.old_sesim.OHLCData;
import opensesim.old_sesim.OHLCDataItem;
/**
*

View File

@ -23,11 +23,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.util.ArrayList;
import sesim.Order.OrderType;
import sesim.Order;
import opensesim.old_sesim.Order.OrderType;
import opensesim.old_sesim.Order;
/**

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="modal" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="assetEditorPanel" alignment="0" pref="527" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="assetEditorPanel" pref="138" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="okButton">
<Properties>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
</Events>
</Component>
<Component class="opensesim.gui.AssetEditor.AssetEditorPanel" name="assetEditorPanel">
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,284 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim.gui.AssetEditor;
import java.awt.Dialog;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JTextField;
import opensesim.AbstractAsset;
import opensesim.World;
import opensesim.gui.EscDialog;
import opensesim.gui.Globals;
import opensesim.sesim.Assets.BasicAsset;
import opensesim.util.IDGenerator.Id;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetEditorDialog extends EscDialog {
AbstractAsset asset;
World world;
/**
* Creates new form CreateAssetDialog
*/
public AssetEditorDialog(Dialog parent, AbstractAsset asset) {
super(parent, true);
initComponents();
world = Globals.world;
}
/**
* 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() {
cancelButton = new javax.swing.JButton();
okButton = new javax.swing.JButton();
assetEditorPanel = new opensesim.gui.AssetEditor.AssetEditorPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setModal(true);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
okButton.setText("Ok");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton))
.addComponent(assetEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(assetEditorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(okButton))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private Id newId = null;
public Id getCreatedId() {
return newId;
}
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
if (this.asset == null) {
try {
int selected = this.assetEditorPanel.assetTypesComboBox.getSelectedIndex();
Class<AbstractAsset> cls = (Class<AbstractAsset>) this.assetEditorPanel.asset_types.get(selected);
asset = AbstractAsset.create(world, cls, assetEditorPanel.symField.getText());
//new BasicAsset(assetEditor.symField.getText());
// newId = BasicAsset.newAssed(asset);
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(this, ex.getMessage(),
"Error",
javax.swing.JOptionPane.ERROR_MESSAGE);
return;
}
}
/*else {
if (!this.asset.getSymbol().equals(assetEditor.symField.getText())) {
try {
BasicAsset.rename(asset, assetEditor.symField.getText());
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(this, ex.getMessage(),
"Error",
javax.swing.JOptionPane.ERROR_MESSAGE);
return;
}
} else {
}
}*/
asset.setName(assetEditorPanel.nameField.getText());
asset.setDecimals((int) assetEditorPanel.decimalsField.getValue());
JSONObject cfg = world.getConfig();
try {
String jstr = cfg.toString(5);
} catch (JSONException ex) {
System.out.println(ex.getMessage());
}
System.out.printf("JSONARRAY %s\n", cfg.toString(3));
JSONObject world_cfg = Globals.world.getConfig();
Globals.prefs.put("world", world_cfg.toString());
dispose();
}//GEN-LAST:event_okButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// TODO add your handling code here:
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
static public Id runDialog(Dialog parent, AbstractAsset asset) {
AssetEditorDialog dialog = new AssetEditorDialog(parent, asset);
dialog.assetEditorPanel.initFields(asset);
dialog.assetEditorPanel.dialog = dialog;
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
return dialog.newId;
}
/**
* @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(AssetEditorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AssetEditorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AssetEditorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AssetEditorDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
/* java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
CreateAssetDialog dialog = new CreateAssetDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
//</editor-fold>
/* Create and display the dialog */
/* java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
CreateAssetDialog dialog = new CreateAssetDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
//</editor-fold>
/* Create and display the dialog */
/* java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
CreateAssetDialog dialog = new CreateAssetDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
//</editor-fold>
/* Create and display the dialog */
/* java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
CreateAssetDialog dialog = new CreateAssetDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});*/
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private opensesim.gui.AssetEditor.AssetEditorPanel assetEditorPanel;
private javax.swing.JButton cancelButton;
private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" 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">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="guiPanel" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jLabel3" max="32767" attributes="0"/>
<Component id="jLabel1" pref="67" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="symField" min="-2" pref="125" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="assetTypesComboBox" max="32767" attributes="0"/>
</Group>
<Component id="nameField" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" pref="67" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="decimalsField" min="-2" pref="55" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="assetTypesComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="symField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="nameField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="decimalsField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="guiPanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Symbol:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="assetTypesComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getComboBoxModel()" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="assetTypesComboBoxActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Type:"/>
</Properties>
</Component>
<Component class="opensesim.gui.util.JTextFieldLimit" name="symField">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Component class="opensesim.gui.util.JTextFieldLimit" name="nameField">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="Decimals:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="decimalsField">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="8" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
<Container class="javax.swing.JPanel" name="guiPanel">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="defaultGuiPanel">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[360, 25]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="360" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="148" max="32767" attributes="0"/>
<Component id="label" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="149" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="25" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="5" max="32767" attributes="0"/>
<Component id="label" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="5" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="label">
<Properties>
<Property name="text" type="java.lang.String" value="no config"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,292 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim.gui.AssetEditor;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.util.ArrayList;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JDialog;
import javax.swing.JPanel;
import opensesim.AbstractAsset;
import opensesim.gui.Globals;
import opensesim.sesim.interfaces.Asset;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetEditorPanel extends javax.swing.JPanel {
/**
* Creates new form AssetEditor
*/
public AssetEditorPanel() {
super();
asset_types = Globals.getAvailableAssetsTypes();
initComponents();
symField.setLimit(Globals.MAX.SYMLEN);
nameField.setLimit(Globals.MAX.NAMELEN);
}
void initFields(AbstractAsset asset){
if(asset==null)
return;
symField.setText(asset.getSymbol());
nameField.setText(asset.getName());
}
public JDialog dialog;
ArrayList<Class<AbstractAsset>> asset_types;
ComboBoxModel getComboBoxModel() {
ArrayList vector = new ArrayList();
// in case asset types are not initialized return a demo
// combo box, so it will be displaeyd in NetBens designer
if (asset_types == null) {
vector.add(0, "Currency");
vector.add(1, "Stock");
return new DefaultComboBoxModel(vector.toArray());
}
int i;
for (i = 0; i < asset_types.size(); i++) {
AbstractAsset ait;
Class<?> asset_type = asset_types.get(i);
try {
ait = (AbstractAsset) asset_type.newInstance();
vector.add(i, ait.getTypeName());
// assetTypesComboBox.addItem(ait.getTypeName());
} catch (InstantiationException | IllegalAccessException | ClassCastException ex) {
Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
return new DefaultComboBoxModel(vector.toArray());
}
/**
* 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();
assetTypesComboBox = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
symField = new opensesim.gui.util.JTextFieldLimit();
jLabel3 = new javax.swing.JLabel();
nameField = new opensesim.gui.util.JTextFieldLimit();
jLabel4 = new javax.swing.JLabel();
decimalsField = new javax.swing.JSpinner();
guiPanel = new javax.swing.JPanel();
defaultGuiPanel = new javax.swing.JPanel();
label = new javax.swing.JLabel();
jLabel1.setText("Symbol:");
assetTypesComboBox.setModel(getComboBoxModel());
assetTypesComboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
assetTypesComboBoxActionPerformed(evt);
}
});
jLabel2.setText("Type:");
jLabel3.setText("Name:");
jLabel4.setText("Decimals:");
decimalsField.setModel(new javax.swing.SpinnerNumberModel(0, 0, 8, 1));
guiPanel.setLayout(new java.awt.BorderLayout());
defaultGuiPanel.setMinimumSize(new java.awt.Dimension(360, 25));
label.setText("no config");
javax.swing.GroupLayout defaultGuiPanelLayout = new javax.swing.GroupLayout(defaultGuiPanel);
defaultGuiPanel.setLayout(defaultGuiPanelLayout);
defaultGuiPanelLayout.setHorizontalGroup(
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 360, Short.MAX_VALUE)
.addGroup(defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
.addGap(0, 148, Short.MAX_VALUE)
.addComponent(label)
.addGap(0, 149, Short.MAX_VALUE)))
);
defaultGuiPanelLayout.setVerticalGroup(
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 25, Short.MAX_VALUE)
.addGroup(defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
.addGap(0, 5, Short.MAX_VALUE)
.addComponent(label)
.addGap(0, 5, Short.MAX_VALUE)))
);
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(guiPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE))
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(symField, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(assetTypesComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(nameField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(decimalsField, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(assetTypesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(symField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(decimalsField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(guiPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void assetTypesComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_assetTypesComboBoxActionPerformed
int i = this.assetTypesComboBox.getSelectedIndex();
AbstractAsset a;
try {
a = (AbstractAsset) asset_types.get(i).newInstance();
} catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
return;
}
JPanel gui = a.getEditGui();
guiPanel.removeAll();
if (gui != null) {
guiPanel.add(gui, java.awt.BorderLayout.CENTER);
gui.setVisible(true);
} else {
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
}
//dialog.setPreferredSize(new Dimension(200,200));
dialog.pack();
dialog.revalidate();
// dialog.validate();
//validate();
//this.getParent().getW;
//((Dialog)(this.dialog)).getS
/* this.getParent().validate();
this.getParent().repaint();
(this.getParent().getParent()).repaint();
this.dialog.pack();
this.dialog.validate();
this.dialog.repaint();
Dimension rrr = this.dialog.getContentPane().getSize();
this.dialog.resize(rrr);
*/
// dialog.pack();
System.out.printf("Action performed on combobox %d %s\n", i, a.getTypeName());
}//GEN-LAST:event_assetTypesComboBoxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
public javax.swing.JComboBox<String> assetTypesComboBox;
public javax.swing.JSpinner decimalsField;
private javax.swing.JPanel defaultGuiPanel;
private javax.swing.JPanel guiPanel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel label;
protected opensesim.gui.util.JTextFieldLimit nameField;
protected opensesim.gui.util.JTextFieldLimit symField;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="Edit Assets"/>
<Property name="modal" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="250" max="32767" attributes="0"/>
<Component id="jButton3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="editButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="newButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="assetListPanel1" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="assetListPanel1" pref="282" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="newButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="editButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Done"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="newButton">
<Properties>
<Property name="text" type="java.lang.String" value="New ..."/>
<Property name="toolTipText" type="java.lang.String" value="Creates a new Asset"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton3">
<Properties>
<Property name="text" type="java.lang.String" value="Delete"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="editButton">
<Properties>
<Property name="text" type="java.lang.String" value="Edit ..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="editButtonActionPerformed"/>
</Events>
</Component>
<Component class="opensesim.gui.AssetEditor.AssetListPanel" name="assetListPanel1">
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,247 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim.gui.AssetEditor;
import com.sun.rowset.internal.Row;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import opensesim.gui.EscDialog;
import opensesim.sesim.Assets.BasicAsset;
import opensesim.util.IDGenerator.Id;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetListDialog extends EscDialog {
/**
* Creates new form EditAssetsDialog
*/
public AssetListDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
newButton = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
editButton = new javax.swing.JButton();
assetListPanel1 = new opensesim.gui.AssetEditor.AssetListPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Edit Assets");
setModal(true);
jButton1.setText("Done");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
newButton.setText("New ...");
newButton.setToolTipText("Creates a new Asset");
newButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newButtonActionPerformed(evt);
}
});
jButton3.setText("Delete");
editButton.setText("Edit ...");
editButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
editButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 250, Short.MAX_VALUE)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(editButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(newButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(assetListPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(assetListPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(newButton)
.addComponent(jButton1)
.addComponent(jButton3)
.addComponent(editButton))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
AssetEditorDialog.runDialog(this, null);
this.assetListPanel1.reload();
/* javax.swing.JOptionPane.showMessageDialog(this, "Hello", "Error",
javax.swing.JOptionPane.ERROR_MESSAGE);*/
/* Id id = AssteEditorDialog.runDialog(this, null);
if (id != null) {
assetList1.addAsset(id);
}
*/ this.repaint();
// JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(this);
/*
// CreateAssetDialog dlg = new CreateAssetDialog();
CreateAssetDialog.runDialog(this);
javax.swing.JOptionPane.showMessageDialog(this, "Hello", "Error",
javax.swing.JOptionPane.ERROR_MESSAGE);
frame = (JFrame) SwingUtilities.getAncestorOfClass(Frame.class, this);
dialog = new CreateAssetDialog(frame, false);
dialog.setModal(true);
this.setModal(true);
this.setModalityType(ModalityType.DOCUMENT_MODAL);
// addPropertyChangeListener(new ValuePropertyHandler(dialog));
//dialog.setAlwaysOnTop(true);
//this.setVisible(false);
dialog.setLocationRelativeTo(this);
dialog.setModalityType(ModalityType.DOCUMENT_MODAL);
dialog.setModal(true);
// dialog.setVisible(true);
dialog.show();
Id id = dialog.getCreatedId();
this.setModal(true);
this.setVisible(true);
dialog.dispose();
if (id != null) {
assetList1.addAsset(id);
}
this.repaint();
*/
}//GEN-LAST:event_newButtonActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
// int row = assetList1.assetList.getSelectedRow();
// Id selId = (Id)assetList1.assetList.getValueAt(row, 0);
/*
BasicAsset a = BasicAsset.getAsset(selId);
Id id = AssteEditorDialog.runDialog(this, a);
if (id != null) {
// assetList1.addAsset(id);
}
this.assetList1.reload();
this.repaint();
*/
}//GEN-LAST:event_editButtonActionPerformed
/**
* @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(AssetListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AssetListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AssetListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AssetListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
AssetListDialog dialog = new AssetListDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private opensesim.gui.AssetEditor.AssetListPanel assetListPanel1;
private javax.swing.JButton editButton;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton3;
private javax.swing.JButton newButton;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.6" 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">
<EmptySpace min="0" pref="548" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="1" pref="548" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="362" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="362" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="assetList">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getModel()" type="code"/>
</Property>
<Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
<JTableSelectionModel selectionMode="0"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,167 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim.gui.AssetEditor;
import java.util.AbstractMap;
import java.util.Map;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import opensesim.AbstractAsset;
import opensesim.sesim.Assets.BasicAsset;
import opensesim.World;
import opensesim.gui.Globals;
import opensesim.util.IDGenerator.Id;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetListPanel extends javax.swing.JPanel {
World world;
/**
* Creates new form AssetList
*/
public AssetListPanel() {
world = Globals.world;
initComponents();
reload();
assetList.setRowSelectionAllowed(true);
assetList.getColumnModel().getColumn(0).setPreferredWidth(10);
assetList.getColumnModel().getColumn(1).setPreferredWidth(30);
assetList.getColumnModel().getColumn(2).setPreferredWidth(300);
assetList.getColumnModel().getColumn(3).setPreferredWidth(30);
}
final void reload() {
DefaultTableModel m = (DefaultTableModel) assetList.getModel();
/* m.setRowCount(0);
Map assets = BasicAsset.getAssets();
for (Object key : assets.keySet()) {
addAsset((Id) key);
}
m.fireTableDataChanged();
*/
if (world == null) {
return;
}
m.setRowCount(0);
for (AbstractAsset a : world.getAssetCollection()) {
m.addRow(new Object[]{
a.getID(),
a.getSymbol(),
a.getName(),
a.getTypeName()
});
}
}
public TableModel getModel() {
class TModel extends DefaultTableModel {
private TModel(Object[] object, int i) {
super(object, i);
}
@Override
public boolean isCellEditable(int row, int column) {
//all cells false
return false;
}
}
DefaultTableModel model = new TModel(
new Object[]{"ID", "Symbol", "Name", "Type"}, 0
);
assetList.setAutoCreateRowSorter(true);
assetList.getTableHeader().setReorderingAllowed(false);
return model;
}
public void uppdate() {
DefaultTableModel m;
m = (DefaultTableModel) this.assetList.getModel();
m.fireTableDataChanged();
}
/* public void addAsset(Id id) {
BasicAsset a = (BasicAsset) BasicAsset.getAsset(id);
DefaultTableModel m = (DefaultTableModel) this.assetList.getModel();
m.addRow(new Object[]{
a.getID(),
a.getSymbol(),
a.getName()});
}
*/
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
assetList = new javax.swing.JTable();
assetList.setModel(getModel());
assetList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane1.setViewportView(assetList);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 548, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 362, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
public javax.swing.JTable assetList;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.9" 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"/>
<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,-109,0,0,2,-93"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextFieldLimit1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="532" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextFieldLimit1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="353" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="opensesim.gui.util.JTextFieldLimit" name="jTextFieldLimit1">
<Properties>
<Property name="text" type="java.lang.String" value="jTextFieldLimit1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextFieldLimit1ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* 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 opensesim.gui.AssetEditor;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewJPanel extends javax.swing.JPanel {
/**
* Creates new form NewJPanel
*/
public NewJPanel() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTextFieldLimit1 = new opensesim.gui.util.JTextFieldLimit();
jTextFieldLimit1.setText("jTextFieldLimit1");
jTextFieldLimit1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldLimit1ActionPerformed(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()
.addContainerGap()
.addComponent(jTextFieldLimit1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(532, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTextFieldLimit1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(353, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jTextFieldLimit1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldLimit1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextFieldLimit1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private opensesim.gui.util.JTextFieldLimit jTextFieldLimit1;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,94 @@
<?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" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="assetBox" pref="376" max="32767" attributes="0"/>
<Component id="currencyBox" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="currencyBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="assetBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Currency:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="currencyBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Asset:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="assetBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,125 @@
package opensesim.gui.AssetPairEditor;
import java.util.Collection;
import opensesim.AbstractAsset;
import opensesim.World;
import opensesim.gui.Globals;
/*
* Copyright (c) 2018, tohe
* 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.
*/
/**
*
* @author tohe
*/
public class EditAssetPairPanel extends javax.swing.JPanel {
World world;
/**
* Creates new form EditAssetPairPanel
*/
public EditAssetPairPanel() {
world = Globals.world;
initComponents();
if (world == null)
return;
assetBox.removeAllItems();
currencyBox.removeAllItems();
Collection<AbstractAsset> ac = world.getAssetCollection();
for (AbstractAsset asset: ac ){
if (asset.isCurrency()){
this.currencyBox.addItem(asset.getSymbol());
}
if (asset.isAsset()){
this.assetBox.addItem(asset.getSymbol());
}
}
}
/**
* 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();
currencyBox = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
assetBox = new javax.swing.JComboBox<>();
jLabel1.setText("Currency:");
currencyBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel2.setText("Asset:");
assetBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(assetBox, 0, 376, Short.MAX_VALUE)
.addComponent(currencyBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(currencyBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(assetBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox<String> assetBox;
private javax.swing.JComboBox<String> currencyBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="editAssetPairPanel2" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="editAssetPairPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Add"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="opensesim.gui.AssetPairEditor.EditAssetPairPanel" name="editAssetPairPanel2">
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,149 @@
/*
* Copyright (c) 2018, tohe
* 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 opensesim.gui.AssetPairEditor;
import opensesim.World;
import opensesim.gui.EscDialog;
import opensesim.gui.Globals;
/**
*
* @author tohe
*/
public class NewJDialog extends EscDialog /*javax.swing.JDialog*/ {
World world;
/**
* Creates new form NewJDialog
*/
public NewJDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
world = Globals.world;
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
editAssetPairPanel2 = new opensesim.gui.AssetPairEditor.EditAssetPairPanel();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jButton1.setText("Add");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Cancel");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addContainerGap())
.addComponent(editAssetPairPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(editAssetPairPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @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(NewJDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
NewJDialog dialog = new NewJDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private opensesim.gui.AssetPairEditor.EditAssetPairPanel editAssetPairPanel2;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
// End of variables declaration//GEN-END:variables
}

View File

@ -23,12 +23,12 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.util.ArrayList;
import sesim.Order;
import sesim.Order.OrderType;
import opensesim.old_sesim.Order;
import opensesim.old_sesim.Order.OrderType;
/**
*

View File

@ -23,12 +23,12 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.util.Timer;
import java.util.TimerTask;
import sesim.Exchange.Statistics;
import sesim.Scheduler;
import opensesim.old_sesim.Exchange.Statistics;
import opensesim.old_sesim.Scheduler;
/**
*
@ -40,7 +40,7 @@ public class Clock extends javax.swing.JPanel {
TimerTask clockUpdater;
class ClockUpdater implements sesim.Scheduler.TimerTaskRunner{
class ClockUpdater implements opensesim.old_sesim.Scheduler.TimerTaskRunner{
@Override
public long timerTask() {

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
/**
*
@ -49,7 +49,7 @@ public class ClockDialog extends javax.swing.JDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
clock1 = new gui.Clock();
clock1 = new opensesim.gui.Clock();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -138,7 +138,7 @@ public class ClockDialog extends javax.swing.JDialog {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private gui.Clock clock1;
private opensesim.gui.Clock clock1;
private javax.swing.JButton jButton1;
// End of variables declaration//GEN-END:variables
}

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.io.IOException;
import java.util.ArrayList;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
/**
*
@ -55,7 +55,7 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
jButton1 = new javax.swing.JButton();
jOkButton = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
editAutoTraderList1 = new gui.EditAutoTraderList();
editAutoTraderList1 = new opensesim.gui.EditAutoTraderList();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -173,7 +173,7 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private gui.EditAutoTraderList editAutoTraderList1;
private opensesim.gui.EditAutoTraderList editAutoTraderList1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jOkButton;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import org.json.JSONObject;

View File

@ -23,9 +23,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import static gui.Globals.LOGGER;
import static opensesim.gui.Globals.LOGGER;
import java.awt.Frame;
import java.util.ArrayList;
import java.util.HashMap;
@ -36,8 +36,8 @@ import java.util.logging.Logger;
import javax.swing.JPanel;
import org.json.JSONArray;
import org.json.JSONObject;
import sesim.AutoTraderGui;
import sesim.AutoTraderInterface;
import opensesim.old_sesim.AutoTraderGui;
import opensesim.old_sesim.AutoTraderInterface;
/**
*

View File

@ -8,9 +8,6 @@
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="formKeyReleased"/>
</Events>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>

View File

@ -23,7 +23,15 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
/**
*
@ -31,21 +39,38 @@ package gui;
*/
public class EscDialog extends javax.swing.JDialog {
/**
* Creates new form EscDialog
*/
public EscDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
System.out.printf("Adding Key Listener\n", "");
addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
formKeyReleased(evt);
}
});
this.setLocationRelativeTo(parent);
final void addEscListener() {
javax.swing.JDialog dialog = this;
ActionListener escListener = (ActionEvent e) -> {
dispatchEvent(new WindowEvent(
dialog, WindowEvent.WINDOW_CLOSING
));
};
getRootPane().registerKeyboardAction(escListener,
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true),
JComponent.WHEN_IN_FOCUSED_WINDOW);
}
/**
* Creates new form EscDialog
*
* @param parent
* @param modal
*/
public EscDialog(java.awt.Window parent, boolean modal) {
super(parent, modal ? ModalityType.DOCUMENT_MODAL : ModalityType.MODELESS);
initComponents();
addEscListener();
}
/* public EscDialog(Dialog parent, boolean modal) {
super(parent, modal);
initComponents();
addEscListener();
}
*/
/**
* 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
@ -56,11 +81,6 @@ public class EscDialog extends javax.swing.JDialog {
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
formKeyReleased(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -76,10 +96,6 @@ public class EscDialog extends javax.swing.JDialog {
pack();
}// </editor-fold>//GEN-END:initComponents
private void formKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyReleased
dispose();
}//GEN-LAST:event_formKeyReleased
/**
* @param args the command line arguments
*/
@ -109,6 +125,7 @@ public class EscDialog extends javax.swing.JDialog {
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
EscDialog dialog = new EscDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {

View File

@ -23,12 +23,15 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
@ -38,26 +41,35 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import opensesim.AbstractAsset;
import opensesim.World;
import org.json.JSONArray;
import org.json.JSONObject;
import sesim.AutoTraderInterface;
import sesim.AutoTraderLoader;
import sesim.Indicator;
import sesim.IndicatorLoader;
import sesim.SeSimClassLoader;
import opensesim.old_sesim.AutoTraderInterface;
import opensesim.old_sesim.AutoTraderLoader;
import opensesim.old_sesim.Indicator;
import opensesim.old_sesim.IndicatorLoader;
import opensesim.sesim.interfaces.Asset;
import opensesim.util.XClassLoader;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class Globals {
public static World world;
public static final String SESIM_FILEEXTENSION = "sesim";
public static final Double SESIM_FILEVERSION = 0.1;
public static final String SESIM_APPTITLE = "SeSim - Stock Exchange Simulator";
public static final String SESIM_APPTITLE = "OpenSeSim - Stock Exchange Simulator";
public interface CfgListener {
@ -80,16 +92,19 @@ public class Globals {
// static final String STRATEGYPREFS = "Strategies";
// static final String TRADERPREFS = "Traders";
static final String DEVELSTATUS = "devel_status";
public static final String DEVELSTATUS = "devel_status";
public static final String GODMODE = "godmode";
static public sesim.Exchange se;
static public opensesim.old_sesim.Exchange se;
/**
* Defines keys for preferences
*/
public static final class PrefKeys {
public static final String XCLASSPATH = "xclasspath";
public static final String LAF = "laf";
public static String WORKDIR = "workdir";
public static final String CURRENTFILE = "currentfile";
@ -98,12 +113,21 @@ public class Globals {
public static final String TRADERS = "traders";
}
public static final class MAX{
public static final int SYMLEN = 6;
public static final int NAMELEN = 64;
}
/**
* Preferences
*/
static public Preferences prefs;
public static class CfgStrings {
public static final String GODMODE = "godmode";
}
public static String DEFAULT_EXCHANGE_CFG
@ -112,57 +136,173 @@ public class Globals {
+ " shares_decimals: 0"
+ "}";
//CfgStrings
static void setLookAndFeel(String selected) {
try {
String look = "com.seaglasslookandfeel.SeaGlassLookAndFeel";
Class.forName(look);
UIManager.installLookAndFeel("Sea Glass", look);
} catch (ClassNotFoundException e) {
}
/**
*
* @param selected
*/
public static void setLookAndFeel(String selected) {
ClassLoader old;
old = Globals.setXClassLoader();
Logger.getLogger(Globals.class.getName()).log(Level.SEVERE, "Setting LAF:" + selected);
UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
if (lafInfo1.getName().equals(selected)) {
String lafClassName = lafInfo1.getClassName();
try {
Logger.getLogger(Globals.class.getName()).log(Level.SEVERE, "Setting LAF:" + lafClassName);
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
UIManager.setLookAndFeel(lafClassName);
// UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
break;
} catch (Exception e) {
Logger.getLogger(Globals.class.getName()).log(Level.SEVERE, null, e);
}
}
}
Globals.unsetXClassLoader(old);
}
static AutoTraderLoader tloader;
static IndicatorLoader iloader;
static void initGlobals() {
ArrayList default_pathlist = new ArrayList<>();
String default_path = new java.io.File(SeSimApplication.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).toString();
static ArrayList default_pathlist = new ArrayList<>();
default_pathlist.add(default_path);
static ArrayList<URL> urllist;
static public void updateUrlList() {
urllist = new ArrayList<>();
URL url;
try {
url = new java.io.File(Globals.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).toURI().toURL();
urllist.add(url);
} catch (MalformedURLException ex) {
Logger.getLogger(Globals.class.getName()).log(Level.SEVERE, null, ex);
}
String xpath;
xpath = prefs.get(Globals.PrefKeys.XCLASSPATH, null);
urllist.addAll(opensesim.util.XClassLoader.getXPathUrlList(xpath));
}
static ClassLoader setXClassLoader() {
ClassLoader old_classloader = Thread.currentThread().getContextClassLoader();
if (urllist ==null)
return old_classloader;
URL[] urls = urllist.toArray(new URL[urllist.size()]);
URLClassLoader cl;
cl = new URLClassLoader(urls, old_classloader);
Thread.currentThread().setContextClassLoader(cl);
return old_classloader;
}
static void unsetXClassLoader(ClassLoader old_classloader) {
Thread.currentThread().setContextClassLoader(old_classloader);
}
static public ArrayList<Class<AbstractAsset>> getAvailableAssetsTypes(){
ArrayList<Class<?>> asset_types_raw;
ClassLoader old = setXClassLoader();
asset_types_raw = opensesim.util.XClassLoader.getClassesList(urllist, AbstractAsset.class);
unsetXClassLoader(old);
ArrayList<Class<AbstractAsset>> asset_types=new ArrayList<>();
for (Class a: asset_types_raw ){
Class <AbstractAsset> aa = a;
asset_types.add(aa);
// asset_types.put(a.cast(AbstractAsset.class));
}
return asset_types;
}
static public void installLookAndFeels() {
ArrayList<Class<?>> lafs;
lafs = opensesim.util.XClassLoader.getClassesList(urllist, LookAndFeel.class);
ClassLoader currentThreadClassLoader
= Thread.currentThread().getContextClassLoader();
URL[] urls = urllist.toArray(new URL[urllist.size()]);
URLClassLoader cl;
cl = new URLClassLoader(urls, currentThreadClassLoader);
Thread.currentThread().setContextClassLoader(cl);
for (Class<?> cls : lafs) {
System.out.println("Class:");
System.out.println(cls.getName());
Class<LookAndFeel> lafc;
lafc = (Class<LookAndFeel>) cls;
LookAndFeel laf;
try {
laf = lafc.newInstance();
} catch (InstantiationException | IllegalAccessException | InternalError ex) {
Logger.getLogger(SeSimApplication.class.getName()).log(Level.SEVERE, null, ex);
continue;
}
System.out.println("LAF:");
System.out.println(laf.getName());
UIManager.installLookAndFeel(laf.getName()+" - "+laf.getDescription(), lafc.getName());
}
Thread.currentThread().setContextClassLoader(currentThreadClassLoader);
// UIManager.installLookAndFeel(laf.getName(), lafc.getName());
}
static void initGlobals(Class<?> c) {
prefs = Preferences.userNodeForPackage(c);
world = new World();
// initialize urllist used by class loader
updateUrlList();
installLookAndFeels();
/*
ArrayList<Class<LookAndFeelInfo>> res;
res = cl.getInstalledClasses(default_pathlist);
for (Class<LookAndFeelInfo> laf : res) {
System.out.print(laf.getCanonicalName());
}
*/
/* System.out.print("PATH LIST\n");
System.out.print(default_pathlist);
System.out.print("END PL\n");
*/
tloader = new AutoTraderLoader(default_pathlist);
iloader = new IndicatorLoader(default_pathlist);
iloader.getNames();
// SeSimClassLoader<Indicator> il = new SeSimClassLoader<>(Indicator.class);
// il.setDefaultPathList(default_pathlist);
// ArrayList<Class<Indicator>> ires = il.getInstalledClasses();
}
static public final Logger LOGGER = Logger.getLogger("com.cauwersin.sesim");
static public final JSONArray getTraders() {
String traders_json = Globals.prefs.get(PrefKeys.TRADERS, "[]");
JSONArray traders = new JSONArray(traders_json);
return traders;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

View File

@ -3,9 +3,9 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gui;
package opensesim.gui;
import chart.Chart;
import opensesim.chart.Chart;
import java.awt.Color;
import java.awt.Cursor;
import java.util.ArrayList;
@ -14,14 +14,14 @@ import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import sesim.Exchange;
import sesim.OHLCData;
import opensesim.old_sesim.Exchange;
import opensesim.old_sesim.OHLCData;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class MainChart extends chart.Chart {
public class MainChart extends opensesim.chart.Chart {
class MyCursor extends Cursor{

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.util.ArrayList;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
/**
*
@ -47,9 +47,9 @@ public class OderBookPanelNew extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
quotePanel1 = new gui.QuotePanel();
orderBookNew3 = new gui.orderbook.OrderBook();
orderBookNew4 = new gui.orderbook.OrderBook();
quotePanel1 = new opensesim.gui.QuotePanel();
orderBookNew3 = new opensesim.gui.orderbook.OrderBook();
orderBookNew4 = new opensesim.gui.orderbook.OrderBook();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@ -88,8 +88,8 @@ public class OderBookPanelNew extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.Box.Filler filler1;
private gui.orderbook.OrderBook orderBookNew3;
private gui.orderbook.OrderBook orderBookNew4;
private gui.QuotePanel quotePanel1;
private opensesim.gui.orderbook.OrderBook orderBookNew3;
private opensesim.gui.orderbook.OrderBook orderBookNew4;
private opensesim.gui.QuotePanel quotePanel1;
// End of variables declaration//GEN-END:variables
}

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.awt.MouseInfo;
@ -34,10 +34,10 @@ import java.util.Map;
import javax.swing.table.DefaultTableModel;
import sesim.Account;
import sesim.Order;
import sesim.Order.OrderType;
import traders.ManTrader.CreateOrderDialog;
import opensesim.old_sesim.Account;
import opensesim.old_sesim.Order;
import opensesim.old_sesim.Order.OrderType;
import opensesim.traders.ManTrader.CreateOrderDialog;
/**
*

View File

@ -23,10 +23,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import sesim.Exchange;
import sesim.Exchange.*;
import opensesim.old_sesim.Exchange;
import opensesim.old_sesim.Exchange.*;
import java.util.ArrayList;
import java.util.Formatter;
import javax.swing.table.AbstractTableModel;
@ -36,7 +36,7 @@ import java.awt.*;
import java.text.DecimalFormat;
import javax.swing.*;
import javax.swing.table.*;
import sesim.Order;
import opensesim.old_sesim.Order;
/**
*

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
/**
*
@ -48,9 +48,9 @@ public class OrderBookDialog extends javax.swing.JDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
orderBookNew1 = new gui.orderbook.OrderBook();
quotePanel1 = new gui.QuotePanel();
orderBookNew2 = new gui.orderbook.OrderBook();
orderBookNew1 = new opensesim.gui.orderbook.OrderBook();
quotePanel1 = new opensesim.gui.QuotePanel();
orderBookNew2 = new opensesim.gui.orderbook.OrderBook();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new java.awt.FlowLayout());
@ -104,8 +104,8 @@ public class OrderBookDialog extends javax.swing.JDialog {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private gui.orderbook.OrderBook orderBookNew1;
private gui.orderbook.OrderBook orderBookNew2;
private gui.QuotePanel quotePanel1;
private opensesim.gui.orderbook.OrderBook orderBookNew1;
private opensesim.gui.orderbook.OrderBook orderBookNew2;
private opensesim.gui.QuotePanel quotePanel1;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[220, 262]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<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,41,0,0,2,75"/>
</AuxValues>
<LayoutCode>
<CodeStatement>
<CodeExpression id="1_layout">
<CodeVariable name="layout" type="4096" declaredType="java.awt.GridBagLayout"/>
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeExpression">
<CodeExpression id="1_layout"/>
</StatementProvider>
</CodeStatement>
<CodeStatement>
<CodeExpression id="1_layout"/>
<StatementProvider type="CodeField">
<CodeField name="columnWidths" class="java.awt.GridBagLayout"/>
</StatementProvider>
<Parameters>
<CodeExpression id="2">
<ExpressionOrigin>
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
<PropertyValue value="[0]"/>
</Value>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="1_layout"/>
<StatementProvider type="CodeField">
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/>
</StatementProvider>
<Parameters>
<CodeExpression id="3">
<ExpressionOrigin>
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
<PropertyValue value="[0, 5, 0, 5, 0]"/>
</Value>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="4">
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="."/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeMethod">
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
</StatementProvider>
<Parameters>
<CodeExpression id="1_layout"/>
</Parameters>
</CodeStatement>
</LayoutCode>
</Form>

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
//import SeSim.*;
import static java.lang.Thread.sleep;
@ -39,7 +39,7 @@ import static java.lang.Thread.sleep;
*/
public class OrderBookPanel_old extends javax.swing.JPanel {
sesim.Exchange se;
opensesim.old_sesim.Exchange se;
public OrderBookPanel_old() {
this.se = Globals.se;
@ -61,51 +61,15 @@ public class OrderBookPanel_old extends javax.swing.JPanel {
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
askBook1 = new gui.AskBook();
bidBook1 = new gui.BidBook();
quotePanel2 = new gui.QuotePanel();
setPreferredSize(new java.awt.Dimension(220, 262));
java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
layout.columnWidths = new int[] {0};
layout.rowHeights = new int[] {0, 5, 0, 5, 0};
setLayout(layout);
askBook1.setPreferredSize(new java.awt.Dimension(200, 200));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(askBook1, gridBagConstraints);
bidBook1.setPreferredSize(new java.awt.Dimension(200, 200));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(bidBook1, gridBagConstraints);
quotePanel2.setOpaque(false);
quotePanel2.setPreferredSize(new java.awt.Dimension(587, 200));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.5;
gridBagConstraints.weighty = 0.5;
add(quotePanel2, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private gui.AskBook askBook1;
private gui.BidBook bidBook1;
private gui.QuotePanel quotePanel2;
// End of variables declaration//GEN-END:variables
}

View File

@ -3,6 +3,10 @@
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="OpenSeSim Preferences"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[551, 343]"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
@ -27,17 +31,13 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="80" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="lafComboBox" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="201" max="32767" attributes="0"/>
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="applyButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="418" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
@ -46,30 +46,62 @@
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="applyButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="xClassPath" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="classPathChoseButton" min="-2" pref="124" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lafComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="godmodeCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jDevleopmentFeaturesCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="188" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="godmodeCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jDevleopmentFeaturesCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="classPathChoseButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="xClassPath" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="68" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -135,5 +167,20 @@
<Property name="text" type="java.lang.String" value="Godmode"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="classPathChoseButton">
<Properties>
<Property name="text" type="java.lang.String" value="Choose ..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="classPathChoseButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Additional Path:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="xClassPath">
</Component>
</SubComponents>
</Form>

View File

@ -23,12 +23,17 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui.PreferencesEditor;
import opensesim.gui.Globals;
import java.awt.Frame;
import java.awt.Window;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
@ -38,7 +43,7 @@ import javax.swing.UnsupportedLookAndFeelException;
*
* @author 7u83 <7u83@mail.ru>
*/
public class EditPreferencesDialog extends javax.swing.JDialog {
public class EditPreferencesDialog extends opensesim.gui.EscDialog {
UIManager.LookAndFeelInfo[] lafInfo;
@ -60,7 +65,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
lafComboBox.addItem(lafInfo1.getName());
}
lafComboBox.setSelectedItem(Globals.prefs.get("laf", "Nimbus"));
lafComboBox.setSelectedItem(Globals.prefs.get(Globals.PrefKeys.LAF, "Nimbus"));
String selstr;
selstr = Globals.prefs.get(Globals.DEVELSTATUS, "false");
@ -68,8 +73,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
selstr = Globals.prefs.get(Globals.GODMODE, "false");
this.godmodeCheckBox.setSelected(selstr.equals("true"));
xClassPath.setText(Globals.prefs.get(Globals.PrefKeys.XCLASSPATH, ""));
}
@ -89,8 +94,13 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
jLabel1 = new javax.swing.JLabel();
jDevleopmentFeaturesCheckBox = new javax.swing.JCheckBox();
godmodeCheckBox = new javax.swing.JCheckBox();
classPathChoseButton = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
xClassPath = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("OpenSeSim Preferences");
setMinimumSize(new java.awt.Dimension(551, 343));
lafComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
lafComboBox.addActionListener(new java.awt.event.ActionListener() {
@ -129,6 +139,15 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
godmodeCheckBox.setText("Godmode");
classPathChoseButton.setText("Choose ...");
classPathChoseButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
classPathChoseButtonActionPerformed(evt);
}
});
jLabel2.setText("Additional Path:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@ -137,21 +156,31 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(80, 80, 80)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(lafComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 201, Short.MAX_VALUE)
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(applyButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton))
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(418, 418, 418))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(godmodeCheckBox)
.addComponent(jDevleopmentFeaturesCheckBox))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(applyButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(xClassPath)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(classPathChoseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(3, 3, 3)))
.addContainerGap())
);
layout.setVerticalGroup(
@ -161,16 +190,26 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(godmodeCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jDevleopmentFeaturesCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 188, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(applyButton)
.addComponent(okButton))
.addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(godmodeCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jDevleopmentFeaturesCheckBox)
.addGap(28, 28, 28)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(classPathChoseButton)
.addComponent(xClassPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(68, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(applyButton)
.addComponent(okButton))
.addContainerGap())))
);
pack();
@ -183,6 +222,10 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
if (old_laf != new_laf) {
try {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
UIManager.setLookAndFeel(old_laf);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(EditPreferencesDialog.class.getName()).log(Level.SEVERE, null, ex);
@ -201,15 +244,13 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
}
private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
String selected = (String) this.lafComboBox.getSelectedItem();
Globals.setLookAndFeel(selected);
new_laf = UIManager.getLookAndFeel();
resetUI();
}//GEN-LAST:event_applyButtonActionPerformed
@ -222,10 +263,43 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
Globals.prefs.put(Globals.DEVELSTATUS, sel);
sel = this.godmodeCheckBox.isSelected() == true ? "true" : "false";
Globals.prefs.put(Globals.GODMODE, sel);
Globals.notifyCfgListeners();
Globals.prefs.put(Globals.PrefKeys.XCLASSPATH, xClassPath.getText());
Globals.notifyCfgListeners();
this.dispose();
}//GEN-LAST:event_okButtonActionPerformed
private void classPathChoseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_classPathChoseButtonActionPerformed
JFileChooser chooser = new JFileChooser();
File dir = null;
if (!"".equals(xClassPath.getText())) {
dir = new File(xClassPath.getText());
if (!dir.exists()) {
dir = null;
}
}
if (dir == null) {
dir = new File(System.getProperty("user.home"));
}
chooser.setCurrentDirectory(dir);
chooser.setDialogTitle("Chose Directory");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
int rc = chooser.showOpenDialog(null);
if ( rc == JFileChooser.APPROVE_OPTION){
xClassPath.setText(chooser.getSelectedFile().getAbsolutePath());
}
}//GEN-LAST:event_classPathChoseButtonActionPerformed
/**
* @param args the command line arguments
*/
@ -271,10 +345,13 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton applyButton;
private javax.swing.JButton cancelButton;
private javax.swing.JButton classPathChoseButton;
private javax.swing.JCheckBox godmodeCheckBox;
private javax.swing.JCheckBox jDevleopmentFeaturesCheckBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JComboBox<String> lafComboBox;
private javax.swing.JButton okButton;
private javax.swing.JTextField xClassPath;
// End of variables declaration//GEN-END:variables
}

View File

@ -23,9 +23,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import sesim.Quote;
import opensesim.old_sesim.Quote;
import java.awt.Color;
import javax.swing.SwingUtilities;
import java.util.*;
@ -34,7 +34,7 @@ import java.util.*;
*
* @author 7u83 <7u83@mail.ru>
*/
public class QuotePanel extends javax.swing.JPanel implements sesim.Exchange.QuoteReceiver{
public class QuotePanel extends javax.swing.JPanel implements opensesim.old_sesim.Exchange.QuoteReceiver{
/**
* Creates new form QuotePanel

View File

@ -34,7 +34,7 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Component class="gui.orderbook.OrderBook" name="orderBookNew1">
<Component class="opensesim.gui.orderbook.OrderBook" name="orderBookNew1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
@ -141,8 +141,42 @@
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator1">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="assetsMenuItem">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="F2"/>
</Property>
<Property name="mnemonic" type="int" value="97"/>
<Property name="text" type="java.lang.String" value="Assets ..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="assetsMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="exchangesMenuItem">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="F3"/>
</Property>
<Property name="text" type="java.lang.String" value="Exchanges ..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exchangesMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
<Properties>
<Property name="text" type="java.lang.String" value="Asset Pairs"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="pasteMenuItem">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="S"/>
</Property>
<Property name="mnemonic" type="int" value="115"/>
<Property name="text" type="java.lang.String" value="Strategies ..."/>
</Properties>
@ -337,7 +371,7 @@
<Component class="javax.swing.JButton" name="stopButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/resources/icons/stop.gif"/>
<Image iconType="3" name="/opensesim/resources/icons/stop.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Stop"/>
<Property name="focusable" type="boolean" value="false"/>
@ -356,7 +390,7 @@
</FontInfo>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/resources/icons/run.gif"/>
<Image iconType="3" name="/opensesim/resources/icons/run.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Run sim!"/>
<Property name="toolTipText" type="java.lang.String" value="Run the simmulation"/>
@ -371,7 +405,7 @@
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/resources/icons/pause.gif"/>
<Image iconType="3" name="/opensesim/resources/icons/pause.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Pause"/>
<Property name="focusable" type="boolean" value="false"/>
@ -396,7 +430,7 @@
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="NewMDIApplication_accelSpinner"/>
</AuxValues>
</Component>
<Component class="gui.Clock" name="clock">
<Component class="opensesim.gui.Clock" name="clock">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
@ -427,14 +461,14 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Component class="gui.orderbook.OrderBooksHorizontal" name="orderBooksHorizontal1">
<Component class="opensesim.gui.orderbook.OrderBooksHorizontal" name="orderBooksHorizontal1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="bottom"/>
</Constraint>
</Constraints>
</Component>
<Component class="chart.MasterChart" name="chart">
<Component class="opensesim.chart.MasterChart" name="chart">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
@ -443,7 +477,7 @@
</Component>
</SubComponents>
</Container>
<Component class="gui.orderbook.QuoteVertical" name="quoteVertical1">
<Component class="opensesim.gui.orderbook.QuoteVertical" name="quoteVertical1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
@ -462,20 +496,13 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Component class="gui.Statistics" name="statistics1">
<Component class="opensesim.gui.Statistics" name="statistics1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="top"/>
</Constraint>
</Constraints>
</Component>
<Component class="chart.MMChart" name="mMChart2">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@ -23,10 +23,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import chart.Help;
import chart.SuperDlg;
import opensesim.chart.Help;
import opensesim.chart.SuperDlg;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.GraphicsDevice;
@ -38,22 +38,36 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.LookAndFeel;
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import opensesim.gui.AssetPairEditor.NewJDialog;
import opensesim.gui.exchangeeditor.ExchangeEditorDialog;
import opensesim.gui.exchangeeditor.ExchangeListDialog;
import org.json.JSONArray;
import org.json.JSONObject;
import sesim.AutoTraderInterface;
import sesim.Exchange;
import sesim.Scheduler;
import opensesim.old_sesim.AutoTraderInterface;
import opensesim.old_sesim.Exchange;
import opensesim.old_sesim.Scheduler;
import opensesim.util.IDGenerator.Id;
import opensesim.util.XClassLoader;
/**
*
@ -66,6 +80,9 @@ public class SeSimApplication extends javax.swing.JFrame {
*/
public SeSimApplication() {
Globals.setXClassLoader();
Globals.setLookAndFeel(Globals.prefs.get(Globals.PrefKeys.LAF, "Nimbus"));
// Globals.setLookAndFeel("Metal");
initComponents();
// Get default screen and place our window
@ -87,7 +104,6 @@ public class SeSimApplication extends javax.swing.JFrame {
}
// this.chartSrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
}
AutoTraderInterface createTrader(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
@ -117,7 +133,15 @@ public class SeSimApplication extends javax.swing.JFrame {
for (int i = 0; i < tlist.length(); i++) {
JSONObject t = tlist.getJSONObject(i);
String strategy_name = t.getString("Strategy");
JSONObject strategy = Globals.getStrategy(strategy_name);
JSONObject strategy = null;
try {
strategy = Globals.getStrategy(strategy_name);
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(chart, "Strategy not defined:\n\"" + strategy_name + " \"", "Error",
javax.swing.JOptionPane.ERROR_MESSAGE);
return;
}
String base = strategy.getString("base");
AutoTraderInterface ac = Globals.tloader.getAutoTraderInterface(base);
@ -172,22 +196,21 @@ public class SeSimApplication extends javax.swing.JFrame {
jTextArea1 = new javax.swing.JTextArea();
jSplitPane1 = new javax.swing.JSplitPane();
jSplitPane2 = new javax.swing.JSplitPane();
orderBookNew1 = new gui.orderbook.OrderBook();
orderBookNew1 = new opensesim.gui.orderbook.OrderBook();
jPanel2 = new javax.swing.JPanel();
stopButton = new javax.swing.JButton();
runButton = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
accelSpinner = new javax.swing.JSpinner();
clock = new gui.Clock();
clock = new opensesim.gui.Clock();
jLabel1 = new javax.swing.JLabel();
jSplitPane3 = new javax.swing.JSplitPane();
jSplitPane4 = new javax.swing.JSplitPane();
orderBooksHorizontal1 = new gui.orderbook.OrderBooksHorizontal();
chart = new chart.MasterChart();
quoteVertical1 = new gui.orderbook.QuoteVertical();
orderBooksHorizontal1 = new opensesim.gui.orderbook.OrderBooksHorizontal();
chart = new opensesim.chart.MasterChart();
quoteVertical1 = new opensesim.gui.orderbook.QuoteVertical();
jSplitPane5 = new javax.swing.JSplitPane();
statistics1 = new gui.Statistics();
mMChart2 = new chart.MMChart();
statistics1 = new opensesim.gui.Statistics();
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
openMenuItem = new javax.swing.JMenuItem();
@ -202,6 +225,9 @@ public class SeSimApplication extends javax.swing.JFrame {
editMenu = new javax.swing.JMenu();
editExchangeMenuItem = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
assetsMenuItem = new javax.swing.JMenuItem();
exchangesMenuItem = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
pasteMenuItem = new javax.swing.JMenuItem();
deleteMenuItem = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
@ -231,7 +257,7 @@ public class SeSimApplication extends javax.swing.JFrame {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(640, 480));
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/stop.gif"))); // NOI18N
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/opensesim/resources/icons/stop.gif"))); // NOI18N
stopButton.setText("Stop");
stopButton.setFocusable(false);
stopButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -243,7 +269,7 @@ public class SeSimApplication extends javax.swing.JFrame {
});
runButton.setFont(runButton.getFont());
runButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/run.gif"))); // NOI18N
runButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/opensesim/resources/icons/run.gif"))); // NOI18N
runButton.setText("Run sim!");
runButton.setToolTipText("Run the simmulation");
runButton.setFocusable(false);
@ -255,7 +281,7 @@ public class SeSimApplication extends javax.swing.JFrame {
}
});
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/pause.gif"))); // NOI18N
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/opensesim/resources/icons/pause.gif"))); // NOI18N
jButton2.setText("Pause");
jButton2.setFocusable(false);
jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -326,7 +352,6 @@ public class SeSimApplication extends javax.swing.JFrame {
jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane5.setTopComponent(statistics1);
jSplitPane5.setRightComponent(mMChart2);
jSplitPane3.setLeftComponent(jSplitPane5);
@ -417,6 +442,34 @@ public class SeSimApplication extends javax.swing.JFrame {
editMenu.add(editExchangeMenuItem);
editMenu.add(jSeparator1);
assetsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
assetsMenuItem.setMnemonic('a');
assetsMenuItem.setText("Assets ...");
assetsMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
assetsMenuItemActionPerformed(evt);
}
});
editMenu.add(assetsMenuItem);
exchangesMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0));
exchangesMenuItem.setText("Exchanges ...");
exchangesMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exchangesMenuItemActionPerformed(evt);
}
});
editMenu.add(exchangesMenuItem);
jMenuItem2.setText("Asset Pairs");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
editMenu.add(jMenuItem2);
pasteMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, 0));
pasteMenuItem.setMnemonic('s');
pasteMenuItem.setText("Strategies ...");
pasteMenuItem.addActionListener(new java.awt.event.ActionListener() {
@ -533,7 +586,7 @@ public class SeSimApplication extends javax.swing.JFrame {
}//GEN-LAST:event_exitMenuItemActionPerformed
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
Dialog d = new gui.AboutDialog(this, rootPaneCheckingEnabled);
Dialog d = new opensesim.gui.misc.AboutDialog(this, rootPaneCheckingEnabled);
d.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_aboutMenuItemActionPerformed
@ -600,7 +653,7 @@ public class SeSimApplication extends javax.swing.JFrame {
private void editPreferencesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editPreferencesActionPerformed
Globals.LOGGER.info("Edit prefs...");
Dialog d = new gui.EditPreferencesDialog(this, rootPaneCheckingEnabled);
Dialog d = new opensesim.gui.PreferencesEditor.EditPreferencesDialog(this, rootPaneCheckingEnabled);
d.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_editPreferencesActionPerformed
@ -745,7 +798,7 @@ public class SeSimApplication extends javax.swing.JFrame {
}//GEN-LAST:event_editExchangeMenuItemActionPerformed
private void resetToDefaults() {
InputStream is = getClass().getResourceAsStream("/resources/files/defaultcfg.json");
InputStream is = getClass().getResourceAsStream("/opensesim/resources/files/defaultcfg.json");
String df = new Scanner(is, "UTF-8").useDelimiter("\\A").next();
try {
@ -799,7 +852,7 @@ public class SeSimApplication extends javax.swing.JFrame {
}//GEN-LAST:event_stopButtonActionPerformed
private void jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem1ActionPerformed
JDialog jd = new gui.orderbook.OrderBookDialog(this, false);
JDialog jd = new opensesim.gui.orderbook.OrderBookDialog(this, false);
jd.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed
@ -858,59 +911,72 @@ public class SeSimApplication extends javax.swing.JFrame {
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
//SuperDlg d = new SuperDlg(this, false);
//d.setVisible(true);
//Help hs = new Help(this,true);
//hs.setVisible(true);
SeSimHelp h = new SeSimHelp();
h.setVisible(true);
}//GEN-LAST:event_jMenuItem1ActionPerformed
private void assetsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_assetsMenuItemActionPerformed
opensesim.gui.AssetEditor.AssetListDialog dialog;
dialog = new opensesim.gui.AssetEditor.AssetListDialog(this,true);
dialog.setLocationRelativeTo(this);
dialog.setVisible(rootPaneCheckingEnabled);
dialog.dispose();
}//GEN-LAST:event_assetsMenuItemActionPerformed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
JDialog dialog = new NewJDialog(this,true);
dialog.setVisible(true);
dialog.dispose();
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void exchangesMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exchangesMenuItemActionPerformed
ExchangeListDialog.runDialog(this);
}//GEN-LAST:event_exchangesMenuItemActionPerformed
/**
* @param args the command line arguments
* @throws java.lang.IllegalAccessException
* @throws java.lang.InstantiationException
*/
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// Initialize globals
Class<?> c = opensesim.gui.SeSimApplication.class;
Globals.initGlobals(c);
String world_source = Globals.prefs.get("world", "{}");
JSONObject world = new org.json.JSONObject(world_source);
Globals.world.putConfig(world);
//Globals.installLookAndFeels();
GraphicsDevice[] gs = ge.getScreenDevices();
for (GraphicsDevice d : gs) {
System.out.printf("ID %s\n", d.getIDstring());
// Globals.setLookAndFeel("Metal");
}
//System.exit(0);
//JDialog.setDefaultLookAndFeelDecorated(true);
//System.exit(0);
Globals.initGlobals();
//System.exit(0);
Globals.se = new Exchange();
Class<?> c = sesim.Exchange.class;
Globals.prefs = Preferences.userNodeForPackage(c);
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
JDialog.setDefaultLookAndFeelDecorated(true);
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
/* String x = new java.io.File(SeSimApplication.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).toString(); //.getName();
*/
// System.out.printf("Creating Application\n");
new SeSimApplication().setVisible(true);
}
});
@ -919,14 +985,16 @@ public class SeSimApplication extends javax.swing.JFrame {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem aboutMenuItem;
private javax.swing.JSpinner accelSpinner;
private chart.MasterChart chart;
private javax.swing.JMenuItem assetsMenuItem;
private opensesim.chart.MasterChart chart;
private javax.swing.JMenuItem clearMenuItem;
private gui.Clock clock;
private opensesim.gui.Clock clock;
private javax.swing.JMenuItem closeMenuItem;
private javax.swing.JMenuItem deleteMenuItem;
private javax.swing.JMenuItem editExchangeMenuItem;
private javax.swing.JMenu editMenu;
private javax.swing.JMenuItem editPreferences;
private javax.swing.JMenuItem exchangesMenuItem;
private javax.swing.JMenuItem exitMenuItem;
private javax.swing.JMenu fileMenu;
private javax.swing.JMenu helpMenu;
@ -934,6 +1002,7 @@ public class SeSimApplication extends javax.swing.JFrame {
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JPopupMenu.Separator jSeparator1;
@ -946,13 +1015,12 @@ public class SeSimApplication extends javax.swing.JFrame {
private javax.swing.JSplitPane jSplitPane4;
private javax.swing.JSplitPane jSplitPane5;
private javax.swing.JTextArea jTextArea1;
private chart.MMChart mMChart2;
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenuItem openMenuItem;
private gui.orderbook.OrderBook orderBookNew1;
private gui.orderbook.OrderBooksHorizontal orderBooksHorizontal1;
private opensesim.gui.orderbook.OrderBook orderBookNew1;
private opensesim.gui.orderbook.OrderBooksHorizontal orderBooksHorizontal1;
private javax.swing.JMenuItem pasteMenuItem;
private gui.orderbook.QuoteVertical quoteVertical1;
private opensesim.gui.orderbook.QuoteVertical quoteVertical1;
private javax.swing.JMenuItem resetToDefaultsMenuItem;
private javax.swing.JButton runButton;
private javax.swing.JMenuItem saveAsMenuItem;
@ -961,7 +1029,7 @@ public class SeSimApplication extends javax.swing.JFrame {
private javax.swing.JMenuItem simMenuPause;
private javax.swing.JMenuItem simMenuStart;
private javax.swing.JMenuItem simMenuStop;
private gui.Statistics statistics1;
private opensesim.gui.Statistics statistics1;
private javax.swing.JButton stopButton;
private javax.swing.JMenu viewMenu;
private javax.swing.JCheckBoxMenuItem viewTraderListCheckBox;

View File

@ -23,9 +23,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import chart.Help;
import opensesim.chart.Help;
import java.net.URL;
import javax.help.HelpSet;
import javax.help.JHelp;

View File

@ -23,11 +23,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.util.Timer;
import java.util.TimerTask;
import sesim.Exchange;
import opensesim.old_sesim.Exchange;
/**
*

View File

@ -23,11 +23,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
package opensesim.gui;
import java.util.Timer;
import java.util.TimerTask;
import sesim.Scheduler;
import opensesim.old_sesim.Scheduler;
/**
*

Some files were not shown because too many files have changed in this diff Show More