|
@@ -58,6 +58,7 @@ import classes.HolonSwitch;
|
|
import classes.HolonTransformer;
|
|
import classes.HolonTransformer;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
|
|
+import ui.view.PropertyTable;;
|
|
|
|
|
|
public class GUI<E> implements CategoryListener {
|
|
public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
@@ -99,7 +100,7 @@ public class GUI<E> implements CategoryListener {
|
|
// HolonObject with consumption/production, name and amount.
|
|
// HolonObject with consumption/production, name and amount.
|
|
|
|
|
|
private JTable tableHolonElement = new JTable();
|
|
private JTable tableHolonElement = new JTable();
|
|
- private DefaultTableModel tableModelHolonElement = new DefaultTableModel();
|
|
|
|
|
|
+ private PropertyTable tableModelHolonElement = new PropertyTable();
|
|
private final JPanel scrollElements = new JPanel();
|
|
private final JPanel scrollElements = new JPanel();
|
|
JScrollPane tableHolonElementScrollPane = new JScrollPane();
|
|
JScrollPane tableHolonElementScrollPane = new JScrollPane();
|
|
|
|
|
|
@@ -164,6 +165,8 @@ public class GUI<E> implements CategoryListener {
|
|
private final JComboBox comboBoxAlgo = new JComboBox();
|
|
private final JComboBox comboBoxAlgo = new JComboBox();
|
|
private int yTHIS;
|
|
private int yTHIS;
|
|
private int xTHIS;
|
|
private int xTHIS;
|
|
|
|
+ private int yBTHIS;
|
|
|
|
+ private int xBTHIS;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Create the application.
|
|
* Create the application.
|
|
@@ -262,7 +265,7 @@ public class GUI<E> implements CategoryListener {
|
|
*/
|
|
*/
|
|
|
|
|
|
// Set up of the HolonElements section
|
|
// Set up of the HolonElements section
|
|
- Object[] columnNames = { "Device", "Energy", "Quantity" };
|
|
|
|
|
|
+ Object[] columnNames = { "Device", "Energy", "Quantity", "Activated" };
|
|
tableModelHolonElement.setColumnIdentifiers(columnNames);
|
|
tableModelHolonElement.setColumnIdentifiers(columnNames);
|
|
tableHolonElement.setBorder(null);
|
|
tableHolonElement.setBorder(null);
|
|
tableHolonElement.setModel(tableModelHolonElement);
|
|
tableHolonElement.setModel(tableModelHolonElement);
|
|
@@ -364,6 +367,10 @@ public class GUI<E> implements CategoryListener {
|
|
yTHIS = e.getY();
|
|
yTHIS = e.getY();
|
|
xTHIS = e.getX();
|
|
xTHIS = e.getX();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ yBTHIS = e.getY();
|
|
|
|
+ xBTHIS = e.getX();
|
|
|
|
+
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -391,21 +398,33 @@ public class GUI<E> implements CategoryListener {
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
try {
|
|
try {
|
|
int yMouse = yTHIS;
|
|
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 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) {
|
|
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);
|
|
|
|
+ }
|
|
|
|
+ tableModelHolonElement.fireTableDataChanged();
|
|
}
|
|
}
|
|
- tableModelHolonElement.fireTableDataChanged();
|
|
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
|
@@ -501,10 +520,12 @@ public class GUI<E> implements CategoryListener {
|
|
CpsObject selected = controller.searchObjInCat(selectedNode.toString(),
|
|
CpsObject selected = controller.searchObjInCat(selectedNode.toString(),
|
|
selectedNode.getParent().toString());
|
|
selectedNode.getParent().toString());
|
|
deleteRows();
|
|
deleteRows();
|
|
-// if (selected instanceof HolonObject && selected != null) {
|
|
|
|
-// selected = (HolonObject) selected;
|
|
|
|
-// fillElementTable(((HolonObject) selected).getElements());
|
|
|
|
-// }
|
|
|
|
|
|
+ // if (selected instanceof HolonObject && selected !=
|
|
|
|
+ // null) {
|
|
|
|
+ // selected = (HolonObject) selected;
|
|
|
|
+ // fillElementTable(((HolonObject)
|
|
|
|
+ // selected).getElements());
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
@@ -929,7 +950,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
public void fillElementTable(ArrayList<HolonElement> elements) {
|
|
public void fillElementTable(ArrayList<HolonElement> elements) {
|
|
for (HolonElement he : 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);
|
|
tableModelHolonElement.addRow(temp);
|
|
}
|
|
}
|
|
}
|
|
}
|