|
@@ -179,7 +179,7 @@ public class GUI implements CategoryListener {
|
|
|
this.model = control.getModel();
|
|
|
this.canvas = new MyCanvas(model, control);
|
|
|
this.unitGraph = new UnitGraph(model, control);
|
|
|
-
|
|
|
+
|
|
|
control.initListener(this);
|
|
|
initialize();
|
|
|
updateCategories(model.getCategories());
|
|
@@ -578,41 +578,42 @@ public class GUI implements CategoryListener {
|
|
|
}
|
|
|
}
|
|
|
// Write new data
|
|
|
- if (canvas.tempCps != null) {
|
|
|
- Object[] tempName = { "Name", canvas.tempCps.getName() };
|
|
|
+ CpsObject temp = getActualCps();
|
|
|
+ if (temp != null) {
|
|
|
+ Object[] tempName = { "Name", temp.getName() };
|
|
|
tableModelProperties.addRow(tempName);
|
|
|
- Object[] tempId = { "ID", canvas.tempCps.getID() };
|
|
|
+ Object[] tempId = { "ID", temp.getID() };
|
|
|
tableModelProperties.addRow(tempId);
|
|
|
- if (canvas.tempCps.getClass() == HolonObject.class) {
|
|
|
- Object[] tempEnergy = { "Total Energy", ((HolonObject) canvas.tempCps).getCurrentEnergy() };
|
|
|
+ if (temp.getClass() == HolonObject.class) {
|
|
|
+ Object[] tempEnergy = { "Total Energy", ((HolonObject) temp).getCurrentEnergy() };
|
|
|
tableModelProperties.addRow(tempEnergy);
|
|
|
}
|
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
|
tableModelProperties.setCellEditable(2, 1, false);
|
|
|
- ArrayList<CpsEdge> temp_array = canvas.tempCps.getConnectedTo();
|
|
|
+ ArrayList<CpsEdge> temp_array = temp.getConnectedTo();
|
|
|
if (!temp_array.isEmpty()) {
|
|
|
boolean first = true;
|
|
|
- for (CpsEdge temp : temp_array) {
|
|
|
+ for (CpsEdge temp2 : temp_array) {
|
|
|
if (first) {
|
|
|
first = false;
|
|
|
- if (canvas.tempCps.getName().compareTo(temp.getA().getCompareName()) == 0) {
|
|
|
- Object[] tempConnection = { canvas.tempCps.getName() + " is connected to",
|
|
|
- temp.getB().getName() + " with ID: " + temp.getB().getID() };
|
|
|
+ if (temp.getName().compareTo(temp2.getA().getCompareName()) == 0) {
|
|
|
+ Object[] tempConnection = { temp.getName() + " is connected to",
|
|
|
+ temp2.getB().getName() + " with ID: " + temp2.getB().getID() };
|
|
|
tableModelProperties.addRow(tempConnection);
|
|
|
} else {
|
|
|
- Object[] tempConnection = { canvas.tempCps.getName() + " is connected to",
|
|
|
- temp.getA().getName() + " with ID: " + temp.getA().getID() };
|
|
|
+ Object[] tempConnection = { temp.getName() + " is connected to",
|
|
|
+ temp2.getA().getName() + " with ID: " + temp2.getA().getID() };
|
|
|
tableModelProperties.addRow(tempConnection);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- if (canvas.tempCps.getName().compareTo(temp.getA().getCompareName()) == 0) {
|
|
|
+ if (temp.getName().compareTo(temp2.getA().getCompareName()) == 0) {
|
|
|
Object[] tempConnection = { "",
|
|
|
- temp.getB().getName() + " with ID: " + temp.getB().getID() };
|
|
|
+ temp2.getB().getName() + " with ID: " + temp2.getB().getID() };
|
|
|
tableModelProperties.addRow(tempConnection);
|
|
|
} else {
|
|
|
Object[] tempConnection = { "",
|
|
|
- temp.getA().getName() + " with ID: " + temp.getA().getID() };
|
|
|
+ temp2.getA().getName() + " with ID: " + temp2.getA().getID() };
|
|
|
tableModelProperties.addRow(tempConnection);
|
|
|
}
|
|
|
|
|
@@ -725,7 +726,7 @@ public class GUI implements CategoryListener {
|
|
|
@Override
|
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
menuFileExitActionPerformed(evt);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void menuFileExitActionPerformed(java.awt.event.ActionEvent evt) {
|
|
@@ -733,7 +734,7 @@ public class GUI implements CategoryListener {
|
|
|
JFrame test = new JFrame();
|
|
|
if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
|
File file = fileChooser.getSelectedFile();
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
controller.loadFile(file.getAbsolutePath());
|
|
|
} catch (IOException e) {
|
|
@@ -743,13 +744,13 @@ public class GUI implements CategoryListener {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
mntmSave.addActionListener(new java.awt.event.ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
-
|
|
|
+
|
|
|
menuSaveActionPerformed(evt);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void menuSaveActionPerformed(java.awt.event.ActionEvent evt) {
|
|
@@ -757,7 +758,7 @@ public class GUI implements CategoryListener {
|
|
|
JFrame test = new JFrame();
|
|
|
if (fileChooser.showSaveDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
|
File file = fileChooser.getSelectedFile();
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
controller.saveFile(file.getAbsolutePath());
|
|
|
} catch (IOException e) {
|