diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index dd6d1d0..0fd33bc 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -19,7 +19,7 @@ is divided into following sections: - cleanup --> - + @@ -54,8 +54,109 @@ is divided into following sections: - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + @@ -77,7 +178,9 @@ is divided into following sections: - + + + @@ -95,6 +198,9 @@ is divided into following sections: + + + @@ -185,20 +291,6 @@ is divided into following sections: - - - - - - - - - - - - - - @@ -251,11 +343,80 @@ is divided into following sections: - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -268,7 +429,7 @@ is divided into following sections: - + @@ -292,11 +453,13 @@ is divided into following sections: - + + + @@ -308,7 +471,7 @@ is divided into following sections: - + @@ -325,7 +488,7 @@ is divided into following sections: - + @@ -380,30 +543,59 @@ is divided into following sections: - - + + - - - + - - + + + + + + + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -411,25 +603,36 @@ is divided into following sections: - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -451,12 +654,16 @@ is divided into following sections: - + + + + + @@ -511,10 +718,6 @@ is divided into following sections: - - - - @@ -522,74 +725,20 @@ is divided into following sections: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - + + + + + + @@ -608,14 +757,14 @@ is divided into following sections: - + - + @@ -642,14 +791,10 @@ is divided into following sections: - - - - - + - + @@ -729,13 +874,20 @@ is divided into following sections: + + + + + + + @@ -751,18 +903,6 @@ is divided into following sections: - - - - - - - - - - - - @@ -772,38 +912,98 @@ is divided into following sections: + + - + - - - - - - - - - - - - - - - - - + + + + + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -821,6 +1021,7 @@ is divided into following sections: + @@ -910,7 +1111,9 @@ is divided into following sections: - + + + @@ -951,7 +1154,7 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - + @@ -971,6 +1174,25 @@ is divided into following sections: + + + + + + + + + + + + + + + + + + + @@ -1001,17 +1223,43 @@ is divided into following sections: To run this application from the command line without Ant, try: - java -jar "${dist.jar.resolved}" + ${platform.java} -jar "${dist.jar.resolved}" + + + + + + + + - + + + + + + + + + + + + + + + + + + + @@ -1030,8 +1278,73 @@ is divided into following sections: - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + @@ -1269,10 +1640,14 @@ is divided into following sections: - + Must select some files in the IDE or set javac.includes - + + + + + @@ -1290,7 +1665,7 @@ is divided into following sections: - + @@ -1302,14 +1677,14 @@ is divided into following sections: - + Must select some files in the IDE or set test.includes Some tests failed; see details above. - + Must select some files in the IDE or set test.class Must select some method in the IDE or set test.method @@ -1318,7 +1693,7 @@ is divided into following sections: Some tests failed; see details above. - + @@ -866,18 +842,6 @@ made subject to such option by the copyright holder. description="Debug javaws project in IDE"/> - - - - - - - - - - - - @@ -889,7 +853,7 @@ made subject to such option by the copyright holder. - + diff --git a/nbproject/jnlp-impl_backup.xml b/nbproject/jnlp-impl_backup.xml index 96d4bfd..b03f371 100644 --- a/nbproject/jnlp-impl_backup.xml +++ b/nbproject/jnlp-impl_backup.xml @@ -1,23 +1,47 @@ @@ -842,6 +866,18 @@ description="Debug javaws project in IDE"/> + + + + + + + + + + + + @@ -853,7 +889,7 @@ - + diff --git a/nbproject/project.properties b/nbproject/project.properties index c73b43e..d3aa394 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Fri, 30 Nov 2018 16:58:10 +0100 +#Sat, 01 Dec 2018 03:21:26 +0100 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= @@ -63,6 +63,7 @@ javac.test.processorpath=${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} +javadoc.html5=false javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false @@ -71,6 +72,8 @@ javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= +jlink.launcher=false +jlink.launcher.name=OpenSeSim jnlp.applet.height=300 jnlp.applet.width=300 jnlp.codebase.type=user @@ -97,7 +100,7 @@ manifest.custom.permissions= manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false -platform.active=default_platform +platform.active=JDK_1.11.0 project.license=bsd run.classpath=${javac.classpath}\:${build.classes.dir} # Space-separated list of JVM arguments used when running the project. @@ -111,4 +114,4 @@ source.encoding=UTF-8 src.dir=src test.src.dir=test ivy.home=/usr/share/java -ivy.classpath=lib/jackson-annotations-2.9.0.jar\:lib/jackson-annotations-2.9.7-javadoc.jar\:lib/jackson-annotations-2.9.7-sources.jar\:lib/jackson-annotations-2.9.7.jar\:lib/jackson-core-2.9.7-javadoc.jar\:lib/jackson-core-2.9.7-sources.jar\:lib/jackson-core-2.9.7.jar\:lib/jackson-databind-2.9.7-javadoc.jar\:lib/jackson-databind-2.9.7-sources.jar\:lib/jackson-databind-2.9.7.jar\:lib/javahelp-2.0.05-javadoc.jar\:lib/javahelp-2.0.05-sources.jar\:lib/javahelp-2.0.05.jar\:lib/json-20160810-javadoc.jar\:lib/json-20160810-sources.jar\:lib/json-20160810.jar +ivy.classpath=lib/gson-2.8.5-javadoc.jar\:lib/gson-2.8.5-sources.jar\:lib/gson-2.8.5.jar\:lib/jackson-annotations-2.9.0.jar\:lib/jackson-core-2.9.7-javadoc.jar\:lib/jackson-core-2.9.7-sources.jar\:lib/jackson-core-2.9.7.jar\:lib/jackson-databind-2.9.7-javadoc.jar\:lib/jackson-databind-2.9.7-sources.jar\:lib/jackson-databind-2.9.7.jar\:lib/javahelp-2.0.05-javadoc.jar\:lib/javahelp-2.0.05-sources.jar\:lib/javahelp-2.0.05.jar\:lib/json-20160810-javadoc.jar\:lib/json-20160810-sources.jar\:lib/json-20160810.jar diff --git a/nbproject/project.xml b/nbproject/project.xml index 878572a..d52871a 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -10,6 +10,7 @@ OpenSeSim + diff --git a/src/opensesim/gui/AssetEditor/AssetEditorDialog.java b/src/opensesim/gui/AssetEditor/AssetEditorDialog.java index 0893920..831753d 100644 --- a/src/opensesim/gui/AssetEditor/AssetEditorDialog.java +++ b/src/opensesim/gui/AssetEditor/AssetEditorDialog.java @@ -25,25 +25,22 @@ */ package opensesim.gui.AssetEditor; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.node.ObjectNode; import java.awt.Dialog; -import java.util.logging.Level; -import java.util.logging.Logger; +import java.awt.Window; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; import opensesim.AbstractAsset; import opensesim.World; + import opensesim.gui.EscDialog; import opensesim.gui.Globals; +import opensesim.gui.util.Json; +import opensesim.gui.util.Json.Export; import opensesim.util.IDGenerator.Id; import org.json.JSONException; import org.json.JSONObject; -@JsonIgnoreProperties(ignoreUnknown = true) /** * * @author 7u83 <7u83@mail.ru> @@ -63,6 +60,12 @@ public class AssetEditorDialog extends EscDialog { world = Globals.world; } + public AssetEditorDialog(Window parent) { + 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 @@ -124,6 +127,10 @@ public class AssetEditorDialog extends EscDialog { }// //GEN-END:initComponents private Id newId = null; + + @Export + public String hallo = "hallo"; + public Id getCreatedId() { return newId; @@ -185,6 +192,47 @@ public class AssetEditorDialog extends EscDialog { }//GEN-LAST:event_cancelButtonActionPerformed + static public boolean runDialog(Window parent, JSONObject o) { + //JSONObject jo = new org.json.JSONObject(parent, new String[]{"getMyName"}); + //System.out.printf("PARENT: %s", jo.toString()); + // JSONObject. + + + + + AssetEditorDialog d = new AssetEditorDialog(parent); + d.assetEditorPanel.symField.setText("Hallo"); + //d.assetEditorPanel.symField.setText("Herr"); + JSONObject jo = Json.get(d.assetEditorPanel); + + System.out.printf("Resulting JSONN %s\n", jo.toString(5)); + + //Class aClass = d.assetEditorPanel.getClass().getDeclaredFields(); + + Field[] fields = d.assetEditorPanel.getClass().getFields(); + + + + + + for (Field f : fields) { + + Export ex = f.getAnnotation(Export.class); + System.out.printf("Fieldname: %s\n",f.getName()); + + + + if (ex == null){ + continue; + } + + System.out.printf("EX: %s\n", ex.getClass().getName()); + + } + return true; + } + + /* static public Id runDialog(Dialog parent, AbstractAsset asset) { AssetEditorDialog dialog = new AssetEditorDialog(parent, asset); dialog.assetEditorPanel.initFields(asset); @@ -215,7 +263,7 @@ public class AssetEditorDialog extends EscDialog { return dialog.newId; } - + */ /** * @param args the command line arguments */ diff --git a/src/opensesim/gui/AssetEditor/AssetEditorPanel.java b/src/opensesim/gui/AssetEditor/AssetEditorPanel.java index 64ab24f..8885e08 100644 --- a/src/opensesim/gui/AssetEditor/AssetEditorPanel.java +++ b/src/opensesim/gui/AssetEditor/AssetEditorPanel.java @@ -25,7 +25,12 @@ */ package opensesim.gui.AssetEditor; -import com.fasterxml.jackson.annotation.JsonGetter; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Comparator; import java.util.logging.Level; @@ -37,6 +42,7 @@ import javax.swing.JPanel; import opensesim.AbstractAsset; import opensesim.gui.Globals; import opensesim.gui.util.JTextFieldLimit; +import opensesim.gui.util.Json.Export; /** * @@ -44,6 +50,10 @@ import opensesim.gui.util.JTextFieldLimit; */ public class AssetEditorPanel extends javax.swing.JPanel { + + + + ArrayList> asset_types; /** @@ -58,6 +68,19 @@ public class AssetEditorPanel extends javax.swing.JPanel { AbstractAsset a1, a2; try { a1 = o1.newInstance(); + try { + try { + a1 = o1.getConstructor().newInstance(null); + } catch (IllegalArgumentException ex) { + Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex); + } catch (InvocationTargetException ex) { + Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex); + } + } catch (NoSuchMethodException ex) { + Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex); + } catch (SecurityException ex) { + Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex); + } a2 = o2.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex); @@ -86,20 +109,25 @@ public class AssetEditorPanel extends javax.swing.JPanel { symField.setText(asset.getSymbol()); nameField.setText(asset.getName()); decimalsField.getModel().setValue(asset.getDecimals()); - + } - @JsonGetter("name") + public String getNameField() { return nameField.getText(); } - @JsonGetter("sym") + + public String getSymField() { return symField.getText(); } - + + @Export + public String hallo = "hello"; + public JDialog dialog; + ComboBoxModel getComboBoxModel() { ArrayList vector = new ArrayList(); @@ -116,7 +144,7 @@ public class AssetEditorPanel extends javax.swing.JPanel { for (i = 0; i < asset_types.size(); i++) { AbstractAsset ait; - Class asset_type = asset_types.get(i); + Class asset_type = asset_types.get(i); try { ait = asset_type.newInstance(); @@ -164,6 +192,12 @@ public class AssetEditorPanel extends javax.swing.JPanel { jLabel2.setText("Type:"); + symField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + symFieldActionPerformed(evt); + } + }); + jLabel3.setText("Name:"); jLabel4.setText("Decimals:"); @@ -279,6 +313,10 @@ public class AssetEditorPanel extends javax.swing.JPanel { }//GEN-LAST:event_assetTypesComboBoxActionPerformed + private void symFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_symFieldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_symFieldActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables public javax.swing.JComboBox assetTypesComboBox; @@ -291,6 +329,7 @@ public class AssetEditorPanel extends javax.swing.JPanel { private javax.swing.JLabel jLabel4; private javax.swing.JLabel label; protected opensesim.gui.util.JTextFieldLimit nameField; - protected opensesim.gui.util.JTextFieldLimit symField; + @Export + public opensesim.gui.util.JTextFieldLimit symField; // End of variables declaration//GEN-END:variables } diff --git a/src/opensesim/gui/AssetEditor/GuiSelectionList.java b/src/opensesim/gui/AssetEditor/GuiSelectionList.java new file mode 100644 index 0000000..b64473a --- /dev/null +++ b/src/opensesim/gui/AssetEditor/GuiSelectionList.java @@ -0,0 +1,36 @@ +/* + * 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 org.json.JSONObject; + +/** + * + * @author 7u83 <7u83@mail.ru> + */ +public interface GuiSelectionList { + JSONObject getSelectedObject(); +} diff --git a/src/opensesim/gui/SeSimApplication.java b/src/opensesim/gui/SeSimApplication.java index 0712782..16a4cae 100644 --- a/src/opensesim/gui/SeSimApplication.java +++ b/src/opensesim/gui/SeSimApplication.java @@ -25,6 +25,7 @@ */ package opensesim.gui; +import com.google.gson.Gson; import opensesim.chart.Help; import opensesim.chart.SuperDlg; import java.awt.Dialog; @@ -940,13 +941,50 @@ public class SeSimApplication extends javax.swing.JFrame { ExchangeListDialog.runDialog(this); }//GEN-LAST:event_exchangesMenuItemActionPerformed + public static class Pojo { + public String getSymbol() { + return symbol; + } + + public String getName() { + return name; + } + public String symbol = "EUR"; + public String name = "Euro"; + }; + + + /** * @param args the command line arguments * @throws java.lang.IllegalAccessException * @throws java.lang.InstantiationException */ public static void main(String args[]) throws IllegalAccessException, InstantiationException { + + + // testing + + Pojo p = new Pojo(); + + Gson g = new Gson(); + String r = g.toJson(p); + + System.out.printf("GSON: %s\n", r); + + JSONObject o = new JSONObject(p,new String[]{"name","symbol"}); + System.out.printf("OJSON: %s\n", o.toString(8)); + + + + + // System.exit(0); + + + // end testing + + // Initialize globals Class c = opensesim.gui.SeSimApplication.class; diff --git a/src/opensesim/gui/util/Json.java b/src/opensesim/gui/util/Json.java new file mode 100644 index 0000000..49845c0 --- /dev/null +++ b/src/opensesim/gui/util/Json.java @@ -0,0 +1,88 @@ +/* + * 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.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JTextField; +import org.json.JSONObject; + +/** + * + * @author 7u83 <7u83@mail.ru> + */ +public class Json { + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD, ElementType.METHOD}) + public static @interface Export { + + public String value() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD, ElementType.METHOD}) + public static @interface Import { + + public String value() default ""; + } + + + + public static JSONObject get(Object o) { + Field[] fields = o.getClass().getFields(); + JSONObject jo = new JSONObject(); + + for (Field f : fields) { + + System.out.printf("CHECKFIELD %s\n", f.getName()); + Export ex = f.getAnnotation(Export.class); + if (ex == null) { + continue; + } + + Class cls = f.getType(); + if (JTextField.class.isAssignableFrom(cls)){ + try { + JTextField tf = (JTextField) f.get(o); + jo.put(f.getName(), tf.getText()); + } catch (IllegalArgumentException | IllegalAccessException ex1) { + Logger.getLogger(Json.class.getName()).log(Level.SEVERE, null, ex1); + } + } + + System.out.printf("EX: %s\n", ex.getClass().getName()); + + } + + return jo; + } +}