Testings with ObjectMapper
This commit is contained in:
@ -30,19 +30,15 @@ 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 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;
|
||||
@ -208,12 +204,15 @@ public class AssetEditorDialog extends EscDialog {
|
||||
|
||||
String vs;
|
||||
try {
|
||||
|
||||
vs = mapper.writeValueAsString(dialog.assetEditorPanel);
|
||||
System.out.print(vs);
|
||||
} catch (JsonProcessingException ex) {
|
||||
Logger.getLogger(AssetEditorDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
ObjectNode n = mapper.valueToTree(dialog.assetEditorPanel);
|
||||
|
||||
return dialog.newId;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,14 @@
|
||||
*/
|
||||
package opensesim.gui.AssetEditor;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableModel;
|
||||
@ -35,6 +41,7 @@ import opensesim.sesim.Assets.BasicAsset;
|
||||
import opensesim.World;
|
||||
import opensesim.gui.Globals;
|
||||
import opensesim.util.IDGenerator.Id;
|
||||
import opensesim.util.SeSimObjectMapper;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -72,6 +79,7 @@ public class AssetListPanel extends javax.swing.JPanel {
|
||||
return;
|
||||
}
|
||||
m.setRowCount(0);
|
||||
|
||||
for (AbstractAsset a : world.getAssetCollection()) {
|
||||
m.addRow(new Object[]{
|
||||
a.getID(),
|
||||
@ -79,12 +87,23 @@ public class AssetListPanel extends javax.swing.JPanel {
|
||||
a.getName(),
|
||||
a.getTypeName()
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
Collection ac;
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
|
||||
try {
|
||||
String s = om.writeValueAsString(world.getAssetCollection());
|
||||
System.out.printf("MyValues %s", s);
|
||||
} catch (JsonProcessingException ex) {
|
||||
Logger.getLogger(AssetListPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public TableModel getModel() {
|
||||
private TableModel getModel() {
|
||||
|
||||
class TModel extends DefaultTableModel {
|
||||
|
||||
|
Reference in New Issue
Block a user