Browse Source

Edit Elements

Kevin Trometer 8 years ago
parent
commit
85a93a072b
1 changed files with 13 additions and 3 deletions
  1. 13 3
      src/ui/view/GUI.java

+ 13 - 3
src/ui/view/GUI.java

@@ -376,9 +376,10 @@ public class GUI implements CategoryListener {
 							for (int c = 0; c < tableModel.getColumnCount(); c++) {
 								temp.add(table.getValueAt(r, c));
 							}
-							char ch = (char) temp.get(1);
-							float fa = (float)temp.get(2);
-							int i = (int)temp.get(3);
+							float ch;
+							if(temp.get(1).toString().compareTo("-")==0) {ch = -1;} else {ch = 1;}
+							float fa = Float.parseFloat(temp.get(2).toString());
+							int i = Integer.parseInt(temp.get(3).toString());
 							((HolonObject) tempCps).getElements().get(r).setEleName((String) temp.get(0));
 							((HolonObject) tempCps).getElements().get(r).setSign(ch);
 							((HolonObject) tempCps).getElements().get(r).setEnergy(fa);
@@ -386,6 +387,15 @@ public class GUI implements CategoryListener {
 							System.out.println(table.getRowCount() + " " + temp.get(0) + " " + ch + " "
 									+ fa + " " + i);
 						}
+						if (tableModel.getRowCount() > 0) {
+							for (int i = tableModel.getRowCount() - 1; i > -1; i--) {
+								tableModel.removeRow(i);
+							}
+						}
+						for (HolonElement he : canvas.dataSelected) {
+							Object[] temp = { he.getEleName(), he.getSign(), he.getEnergy(), he.getAmount() };
+							tableModel.addRow(temp);
+						}
 					}
 				} catch (Exception e) {
 					e.printStackTrace();