|
@@ -8,7 +8,14 @@ import ui.view.PropertyTable;
|
|
import ui.view.UpperNodeCanvas;
|
|
import ui.view.UpperNodeCanvas;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.LinkedList;
|
|
|
|
+
|
|
|
|
+import ElementComparator.ElemCompOnEleName;
|
|
|
|
+import ElementComparator.ElemCompOnEnergy;
|
|
|
|
+import ElementComparator.ElemCompOnId;
|
|
|
|
+import ElementComparator.ElementComparator;
|
|
|
|
|
|
/**
|
|
/**
|
|
* This class is for all update methods and more ;)
|
|
* This class is for all update methods and more ;)
|
|
@@ -46,6 +53,7 @@ public class UpdateController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Add the Information of the given ArrayList in the HolonElement Model as
|
|
* Add the Information of the given ArrayList in the HolonElement Model as
|
|
* Name,Energy and Amount.
|
|
* Name,Energy and Amount.
|
|
@@ -54,23 +62,39 @@ public class UpdateController {
|
|
* ArrayList to be displayed
|
|
* ArrayList to be displayed
|
|
*/
|
|
*/
|
|
public void fillElementTable(ArrayList<AbstractCpsObject> objects, PropertyTable table) {
|
|
public void fillElementTable(ArrayList<AbstractCpsObject> objects, PropertyTable table) {
|
|
|
|
+ LinkedList<HolonElement> elemList = new LinkedList<HolonElement>();
|
|
|
|
+ ElementComparator compEnergy = new ElemCompOnEnergy();
|
|
|
|
+ //ElementComparator compId = new ElemCompOnId();
|
|
|
|
+ ElementComparator compEleName = new ElemCompOnEleName();
|
|
if (objects.size() > 1) {
|
|
if (objects.size() > 1) {
|
|
for (AbstractCpsObject o : objects) {
|
|
for (AbstractCpsObject o : objects) {
|
|
if (o instanceof HolonObject) {
|
|
if (o instanceof HolonObject) {
|
|
for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
- Object[] temp = {o.getName() + ", " + o.getId(), he.getId(), he.getEleName(), he.getEnergyPerElement(),
|
|
|
|
- he.getFlexibleEnergyAvailablePerElement(), he.getAmount(), he.isActive(), he.isFlexible()};
|
|
|
|
- table.addRow(temp);
|
|
|
|
|
|
+ he.setObjName(o.getName() + ", " + o.getId());
|
|
|
|
+ elemList.add(he);
|
|
|
|
+ elemList.sort(compEleName);
|
|
|
|
+ elemList.sort(compEnergy);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ for (HolonElement e1 : elemList) {
|
|
|
|
+ Object[] temp2 = { e1.getObjName(), e1.getId(), e1.getEleName(), e1.getEnergyPerElement(),
|
|
|
|
+ e1.getFlexibleEnergyAvailablePerElement(), e1.getAmount(), e1.isActive(), e1.isFlexible() };
|
|
|
|
+ table.addRow(temp2);
|
|
|
|
+ }
|
|
|
|
+
|
|
} else if (objects.size() == 1) {
|
|
} else if (objects.size() == 1) {
|
|
AbstractCpsObject o = objects.get(0);
|
|
AbstractCpsObject o = objects.get(0);
|
|
if (o instanceof HolonObject) {
|
|
if (o instanceof HolonObject) {
|
|
for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
- Object[] temp = {he.getId(), he.getEleName(), he.getEnergyPerElement(), he.getFlexibleEnergyAvailablePerElement(), he.getAmount(),
|
|
|
|
- he.isActive(), he.isFlexible()};
|
|
|
|
- table.addRow(temp);
|
|
|
|
|
|
+ elemList.add(he);
|
|
|
|
+ elemList.sort(compEleName);
|
|
|
|
+ elemList.sort(compEnergy);
|
|
|
|
+ }
|
|
|
|
+ for (HolonElement e1 : elemList) {
|
|
|
|
+ Object[] temp2 = { e1.getId(), e1.getEleName(), e1.getEnergyPerElement(),
|
|
|
|
+ e1.getFlexibleEnergyAvailablePerElement(), e1.getAmount(), e1.isActive(), e1.isFlexible() };
|
|
|
|
+ table.addRow(temp2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|