|
@@ -330,7 +330,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
* RIGHT CONTAINER (INFORMATION)
|
|
|
**********************/
|
|
|
// Set up of the HolonElements section
|
|
|
- Object[] columnNames = { "Device", "Energy", "Quantity", "Activated" };
|
|
|
+ Object[] columnNames = { "Object", "Device", "Energy", "Quantity", "Activated" };
|
|
|
tableModelHolonElement.setColumnIdentifiers(columnNames);
|
|
|
tableHolonElement.setBorder(null);
|
|
|
tableHolonElement.setModel(tableModelHolonElement);
|
|
@@ -476,12 +476,12 @@ public class GUI<E> implements CategoryListener {
|
|
|
try {
|
|
|
int yMouse = yTHIS;
|
|
|
int yBMouse = yBTHIS;
|
|
|
- int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 4));
|
|
|
+ int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 5));
|
|
|
int selectedValueY = (int) Math.floor(yMouse / 16);
|
|
|
- int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 4));
|
|
|
+ int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 5));
|
|
|
int selectedValueBY = (int) Math.floor(yBMouse / 16);
|
|
|
if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
|
|
|
- if (selectedValueBX == 3) {
|
|
|
+ if (selectedValueBX == 4) {
|
|
|
HolonElement eleBTemp = getActualHolonElement((HolonObject) getActualCps(), yBMouse);
|
|
|
String newBStuff = tableModelHolonElement.getValueAt(selectedValueBY, selectedValueBX)
|
|
|
.toString();
|
|
@@ -491,12 +491,12 @@ public class GUI<E> implements CategoryListener {
|
|
|
HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse);
|
|
|
String newStuff = tableModelHolonElement.getValueAt(selectedValueY, selectedValueX)
|
|
|
.toString();
|
|
|
- if (selectedValueX == 0) {
|
|
|
+ if (selectedValueX == 1) {
|
|
|
eleTemp.setEleName(newStuff);
|
|
|
- } else if (selectedValueX == 1) {
|
|
|
+ } else if (selectedValueX == 2) {
|
|
|
Float ftemp = Float.parseFloat(newStuff);
|
|
|
eleTemp.setEnergy(ftemp);
|
|
|
- } else if (selectedValueX == 2) {
|
|
|
+ } else if (selectedValueX == 3) {
|
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
|
eleTemp.setAmount(iTemp);
|
|
|
}
|
|
@@ -775,6 +775,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
* the clicked HolonObject
|
|
|
*/
|
|
|
canvas.addMouseListener(new MouseAdapter() {
|
|
|
+
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
if (temp == null || temp.getID() != model.getSelectedObjectID()) {
|
|
@@ -789,6 +790,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
// Update of the Information about the Properties - only for
|
|
|
// CpsObjects
|
|
|
// Erase old data
|
|
|
+ System.out.println(model.getSelectedCpsObjects());
|
|
|
if (tableModelProperties.getRowCount() > 0) {
|
|
|
for (int i = tableModelProperties.getRowCount() - 1; i > -1; i--) {
|
|
|
tableModelProperties.removeRow(i);
|
|
@@ -808,10 +810,10 @@ public class GUI<E> implements CategoryListener {
|
|
|
boolean nothingImportant = true;
|
|
|
for (CpsObject c : model.getSelectedCpsObjects()) {
|
|
|
if (nothingImportant) {
|
|
|
- System.out.println("Elements: " + c.getName());
|
|
|
+ System.out.println("Elements: " + c.getName() + " and ID: " + c.getID());
|
|
|
nothingImportant = false;
|
|
|
} else {
|
|
|
- System.out.println(c.getName());
|
|
|
+ System.out.println(c.getName() + " and ID: " + c.getID());
|
|
|
}
|
|
|
}
|
|
|
// Write new data
|
|
@@ -881,6 +883,12 @@ public class GUI<E> implements CategoryListener {
|
|
|
deleteRows();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void mouseReleased(MouseEvent e) {
|
|
|
+ refreshTableHolonElement();
|
|
|
+ refreshTableProperties();
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
toolBar.add(btnAdd);
|
|
@@ -1236,8 +1244,9 @@ public class GUI<E> implements CategoryListener {
|
|
|
// HolonObjects
|
|
|
|
|
|
deleteRows();
|
|
|
- if (getActualCps() != null) {
|
|
|
- fillElementTable(((HolonObject) getActualCps()).getElements());
|
|
|
+ System.out.println(model.getSelectedCpsObjects());
|
|
|
+ if (model.getSelectedCpsObjects() != null) {
|
|
|
+ fillElementTable(model.getSelectedCpsObjects());
|
|
|
}
|
|
|
tableModelHolonElement.fireTableDataChanged();
|
|
|
}
|
|
@@ -1260,10 +1269,14 @@ public class GUI<E> implements CategoryListener {
|
|
|
* @param elements
|
|
|
* ArrayList to be displayed
|
|
|
*/
|
|
|
- public void fillElementTable(ArrayList<HolonElement> elements) {
|
|
|
- for (HolonElement he : elements) {
|
|
|
- Object[] temp = { he.getEleName(), he.getEnergy(), he.getAmount(), he.getActive() };
|
|
|
- tableModelHolonElement.addRow(temp);
|
|
|
+ public void fillElementTable(ArrayList<CpsObject> objects) {
|
|
|
+ for (CpsObject o : objects) {
|
|
|
+ if (o instanceof HolonObject) {
|
|
|
+ for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
|
+ Object[] temp = { o.getName(), he.getEleName(), he.getEnergy(), he.getAmount(), he.getActive() };
|
|
|
+ tableModelHolonElement.addRow(temp);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|