|
@@ -59,6 +59,7 @@ import classes.HolonSwitch;
|
|
|
import classes.HolonTransformer;
|
|
|
import ui.controller.Control;
|
|
|
import ui.model.Model;
|
|
|
+import ui.view.PropertyTable;;
|
|
|
|
|
|
public class GUI<E> implements CategoryListener {
|
|
|
|
|
@@ -102,7 +103,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
// HolonObject with consumption/production, name and amount.
|
|
|
|
|
|
private JTable tableHolonElement = new JTable();
|
|
|
- private DefaultTableModel tableModelHolonElement = new DefaultTableModel();
|
|
|
+ private PropertyTable tableModelHolonElement = new PropertyTable();
|
|
|
private final JPanel scrollElements = new JPanel();
|
|
|
JScrollPane tableHolonElementScrollPane = new JScrollPane();
|
|
|
|
|
@@ -167,6 +168,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
private final JComboBox comboBoxAlgo = new JComboBox();
|
|
|
private int yTHIS;
|
|
|
private int xTHIS;
|
|
|
+ private int yBTHIS;
|
|
|
+ private int xBTHIS;
|
|
|
|
|
|
/**
|
|
|
* Create the application.
|
|
@@ -264,7 +267,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
* RIGHT CONTAINER (INFORMATION)
|
|
|
**********************/
|
|
|
// Set up of the HolonElements section
|
|
|
- Object[] columnNames = { "Device", "Energy", "Quantity" };
|
|
|
+ Object[] columnNames = { "Device", "Energy", "Quantity", "Activated" };
|
|
|
tableModelHolonElement.setColumnIdentifiers(columnNames);
|
|
|
tableHolonElement.setBorder(null);
|
|
|
tableHolonElement.setModel(tableModelHolonElement);
|
|
@@ -367,6 +370,10 @@ public class GUI<E> implements CategoryListener {
|
|
|
yTHIS = e.getY();
|
|
|
xTHIS = e.getX();
|
|
|
}
|
|
|
+
|
|
|
+ yBTHIS = e.getY();
|
|
|
+ xBTHIS = e.getX();
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
/*
|
|
@@ -378,19 +385,31 @@ public class GUI<E> implements CategoryListener {
|
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
try {
|
|
|
int yMouse = yTHIS;
|
|
|
- int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 3));
|
|
|
+ int yBMouse = yBTHIS;
|
|
|
+ int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 4));
|
|
|
int selectedValueY = (int) Math.floor(yMouse / 16);
|
|
|
+ int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 4));
|
|
|
+ int selectedValueBY = (int) Math.floor(yBMouse / 16);
|
|
|
if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
|
|
|
- HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse);
|
|
|
- String newStuff = tableModelHolonElement.getValueAt(selectedValueY, selectedValueX).toString();
|
|
|
- if (selectedValueX == 0) {
|
|
|
- eleTemp.setEleName(newStuff);
|
|
|
- } else if (selectedValueX == 1) {
|
|
|
- Float ftemp = Float.parseFloat(newStuff);
|
|
|
- eleTemp.setEnergy(ftemp);
|
|
|
- } else if (selectedValueX == 2) {
|
|
|
- Integer iTemp = Integer.parseInt(newStuff);
|
|
|
- eleTemp.setAmount(iTemp);
|
|
|
+ if (selectedValueBX == 3) {
|
|
|
+ HolonElement eleBTemp = getActualHolonElement((HolonObject) getActualCps(), yBMouse);
|
|
|
+ String newBStuff = tableModelHolonElement.getValueAt(selectedValueBY, selectedValueBX)
|
|
|
+ .toString();
|
|
|
+ Boolean bTemp = Boolean.parseBoolean(newBStuff);
|
|
|
+ eleBTemp.setActive(bTemp);
|
|
|
+ } else {
|
|
|
+ HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse);
|
|
|
+ String newStuff = tableModelHolonElement.getValueAt(selectedValueY, selectedValueX)
|
|
|
+ .toString();
|
|
|
+ if (selectedValueX == 0) {
|
|
|
+ eleTemp.setEleName(newStuff);
|
|
|
+ } else if (selectedValueX == 1) {
|
|
|
+ Float ftemp = Float.parseFloat(newStuff);
|
|
|
+ eleTemp.setEnergy(ftemp);
|
|
|
+ } else if (selectedValueX == 2) {
|
|
|
+ Integer iTemp = Integer.parseInt(newStuff);
|
|
|
+ eleTemp.setAmount(iTemp);
|
|
|
+ }
|
|
|
}
|
|
|
refreshTableProperties();
|
|
|
tableModelHolonElement.fireTableDataChanged();
|
|
@@ -983,7 +1002,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
*/
|
|
|
public void fillElementTable(ArrayList<HolonElement> elements) {
|
|
|
for (HolonElement he : elements) {
|
|
|
- Object[] temp = { he.getEleName(), he.getEnergy(), he.getAmount() };
|
|
|
+ Object[] temp = { he.getEleName(), he.getEnergy(), he.getAmount(), he.getActive() };
|
|
|
tableModelHolonElement.addRow(temp);
|
|
|
}
|
|
|
}
|