Uses GodWorld.getTypeName to get name of asset

This commit is contained in:
7u83 2018-12-10 12:37:45 +01:00
parent 254d57d834
commit fe7af043b7

View File

@ -42,6 +42,7 @@ import opensesim.gui.util.Json.Import;
import opensesim.util.SeSimException; import opensesim.util.SeSimException;
import opensesim.world.GodWorld; import opensesim.world.GodWorld;
import opensesim.world.RealWorld; import opensesim.world.RealWorld;
import opensesim.world.World;
import org.json.JSONObject; import org.json.JSONObject;
@ -97,12 +98,15 @@ public class AssetEditorPanel extends javax.swing.JPanel {
AbstractAsset ait; AbstractAsset ait;
Class<AbstractAsset> asset_type = asset_types.get(i); Class<AbstractAsset> asset_type = asset_types.get(i);
try { // try {
ait = asset_type.newInstance(); // ait = asset_type.newInstance();
vector.add(i, ait.getTypeName()); // vector.add(i, ait.getTypeName());
} catch (InstantiationException | IllegalAccessException | ClassCastException ex) {
Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex); vector.add(i,GodWorld.getTypeName(asset_type));
}
// } catch (InstantiationException | IllegalAccessException | ClassCastException ex) {
// Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
// }
} }
return new DefaultComboBoxModel(vector.toArray()); return new DefaultComboBoxModel(vector.toArray());
} }
@ -250,7 +254,7 @@ public class AssetEditorPanel extends javax.swing.JPanel {
AbstractAsset a; AbstractAsset a;
try { try {
a = ac.getConstructor(RealWorld.class, JSONObject.class).newInstance(null, null); a = ac.getConstructor(GodWorld.class, JSONObject.class).newInstance(null, null);
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
return; return;