From 84c6718c8ed1b690787172217915fb1f71e8eb48 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@mail.ru> Date: Wed, 5 Dec 2018 17:58:49 +0100 Subject: [PATCH] Removed dead code --- nbproject/project.properties | 2 +- .../gui/AssetEditor/AssetListDialog.form | 16 +++--- .../gui/AssetEditor/AssetListDialog.java | 40 +++++++------- .../gui/AssetEditor/AssetListPanel.java | 54 +------------------ src/opensesim/world/World.java | 4 ++ 5 files changed, 35 insertions(+), 81 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index e457d56..ebf37d6 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Wed, 05 Dec 2018 17:40:04 +0100 +#Wed, 05 Dec 2018 17:57:49 +0100 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/opensesim/gui/AssetEditor/AssetListDialog.form b/src/opensesim/gui/AssetEditor/AssetListDialog.form index 123e04a..b500b10 100644 --- a/src/opensesim/gui/AssetEditor/AssetListDialog.form +++ b/src/opensesim/gui/AssetEditor/AssetListDialog.form @@ -29,13 +29,13 @@ - + - + @@ -54,8 +54,8 @@ - - + + @@ -64,12 +64,12 @@ - + - + @@ -81,12 +81,12 @@ - + - + diff --git a/src/opensesim/gui/AssetEditor/AssetListDialog.java b/src/opensesim/gui/AssetEditor/AssetListDialog.java index 684752a..459e8f5 100644 --- a/src/opensesim/gui/AssetEditor/AssetListDialog.java +++ b/src/opensesim/gui/AssetEditor/AssetListDialog.java @@ -91,9 +91,9 @@ public class AssetListDialog extends EscDialog { // //GEN-BEGIN:initComponents private void initComponents() { - jButton1 = new javax.swing.JButton(); + doneButton = new javax.swing.JButton(); newButton = new javax.swing.JButton(); - jButton3 = new javax.swing.JButton(); + deleteButton = new javax.swing.JButton(); editButton = new javax.swing.JButton(); assetListPanel = new opensesim.gui.AssetEditor.AssetListPanel(worldadm); @@ -101,10 +101,10 @@ public class AssetListDialog extends EscDialog { setTitle("Edit Assets"); setModal(true); - jButton1.setText("Done"); - jButton1.addActionListener(new java.awt.event.ActionListener() { + doneButton.setText("Done"); + doneButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton1ActionPerformed(evt); + doneButtonActionPerformed(evt); } }); @@ -116,10 +116,10 @@ public class AssetListDialog extends EscDialog { } }); - jButton3.setText("Delete"); - jButton3.addActionListener(new java.awt.event.ActionListener() { + deleteButton.setText("Delete"); + deleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton3ActionPerformed(evt); + deleteButtonActionPerformed(evt); } }); @@ -138,13 +138,13 @@ public class AssetListDialog extends EscDialog { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) - .addComponent(jButton3) + .addComponent(deleteButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(editButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(newButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jButton1)) + .addComponent(doneButton)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(assetListPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) @@ -158,8 +158,8 @@ public class AssetListDialog extends EscDialog { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(newButton) - .addComponent(jButton1) - .addComponent(jButton3) + .addComponent(doneButton) + .addComponent(deleteButton) .addComponent(editButton)) .addContainerGap()) ); @@ -180,13 +180,13 @@ public class AssetListDialog extends EscDialog { }//GEN-LAST:event_newButtonActionPerformed - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + private void doneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneButtonActionPerformed dispose(); - }//GEN-LAST:event_jButton1ActionPerformed + }//GEN-LAST:event_doneButtonActionPerformed private void doEdit() { JSONObject o = assetListPanel.getSelectedObject(); - // AssetEditorDialog.runDialog(this, o, o); + AssetEditorDialog.runDialog(this, worldadm, o, o); assetListPanel.reload(); } @@ -197,13 +197,13 @@ public class AssetListDialog extends EscDialog { }//GEN-LAST:event_editButtonActionPerformed - private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed JSONObject o = assetListPanel.getSelectedObject(); JSONObject ass = Globals.getAssets(); - ass.remove(o.getString("symbol")); + ass.remove(o.getString(World.JKEYS.ASSET_SYMBOL)); Globals.putAssets(ass); assetListPanel.reload(); - }//GEN-LAST:event_jButton3ActionPerformed + }//GEN-LAST:event_deleteButtonActionPerformed /** * @param args the command line arguments @@ -250,9 +250,9 @@ public class AssetListDialog extends EscDialog { // Variables declaration - do not modify//GEN-BEGIN:variables private opensesim.gui.AssetEditor.AssetListPanel assetListPanel; + private javax.swing.JButton deleteButton; + private javax.swing.JButton doneButton; 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 } diff --git a/src/opensesim/gui/AssetEditor/AssetListPanel.java b/src/opensesim/gui/AssetEditor/AssetListPanel.java index 7209541..d9046b5 100644 --- a/src/opensesim/gui/AssetEditor/AssetListPanel.java +++ b/src/opensesim/gui/AssetEditor/AssetListPanel.java @@ -45,8 +45,6 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi WorldAdm worldadm; - JSONObject json_set; - /** * Creates new form AssetList */ @@ -58,12 +56,6 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi return; } - json_set = new JSONObject(Globals.prefs.get("myassets", "{" - + "EUR:{name:Euro,decimals:8,type:opensesim.sesim.Assets.FurtureAsset}}")); - - json_set = Globals.getAssets(); - // reload(); - assetTable.setRowSelectionAllowed(true); assetTable.getColumnModel().getColumn(0).setPreferredWidth(30); @@ -82,45 +74,11 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi public JSONObject getSelectedObject() { int row = assetTable.getSelectedRow(); String symbol = (String) assetTable.getValueAt(row, 0); - return json_set.getJSONObject(symbol); + return worldadm.world.getAssetBySymbol(symbol).getJson(); } final void reload() { - /* json_set = Globals.getAssets(); - DefaultTableModel m = (DefaultTableModel) assetTable.getModel(); - - - m.setRowCount(0); - for (String symbol : json_set.keySet()) { - JSONObject o = json_set.optJSONObject(symbol); - if (o == null) { - continue; - } - - Class a = Globals.getClassByName(o.optString("type")); - String type_name; - - try { - type_name=a.getConstructor(World.class,JSONObject.class).newInstance(null,null).getTypeName(); - - } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - Logger.getLogger(AssetListPanel.class.getName()).log(Level.SEVERE, null, ex); - continue; - } - - - - - - m.addRow(new Object[]{ - - symbol, - o.opt("name"), - type_name - }); - - }*/ - + Collection assets; assets = worldadm.world.getAssetCollection(); DefaultTableModel m = (DefaultTableModel) assetTable.getModel(); @@ -177,14 +135,6 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi } - public void uppdate() { - DefaultTableModel m; - - m = (DefaultTableModel) this.assetTable.getModel(); - m.fireTableDataChanged(); - - } - /** * 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 diff --git a/src/opensesim/world/World.java b/src/opensesim/world/World.java index be30bd9..c38a635 100644 --- a/src/opensesim/world/World.java +++ b/src/opensesim/world/World.java @@ -136,6 +136,10 @@ public class World { public Collection getAssetCollection() { return Collections.unmodifiableCollection(assetsById); } + + public AbstractAsset getAssetBySymbol(String symbol){ + return this.assetsBySymbol.get(symbol); + } public Collection getAssetPairsCollection() { return Collections.unmodifiableCollection(assetPairs);