|
@@ -14,7 +14,12 @@ import java.util.LinkedList;
|
|
|
|
|
|
import ElementComparator.ElemCompOnEleName;
|
|
|
import ElementComparator.ElemCompOnEnergy;
|
|
|
+import ElementComparator.ElemCompOnFlexible;
|
|
|
import ElementComparator.ElemCompOnId;
|
|
|
+import ElementComparator.ElemCompOnIsActivated;
|
|
|
+import ElementComparator.ElemCompOnIsFlexible;
|
|
|
+import ElementComparator.ElemCompOnObj;
|
|
|
+import ElementComparator.ElemCompOnQuantity;
|
|
|
import ElementComparator.ElementComparator;
|
|
|
|
|
|
/**
|
|
@@ -27,10 +32,12 @@ public class UpdateController {
|
|
|
|
|
|
Model model;
|
|
|
Control controller;
|
|
|
+ private String sortBy;
|
|
|
|
|
|
public UpdateController(Model model, Control control) {
|
|
|
this.model = model;
|
|
|
this.controller = control;
|
|
|
+ sortBy="Nr.";
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -63,17 +70,14 @@ public class UpdateController {
|
|
|
*/
|
|
|
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) {
|
|
|
for (AbstractCpsObject o : objects) {
|
|
|
if (o instanceof HolonObject) {
|
|
|
for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
|
he.setObjName(o.getName() + ", " + o.getId());
|
|
|
elemList.add(he);
|
|
|
- elemList.sort(compEleName);
|
|
|
- elemList.sort(compEnergy);
|
|
|
+ elemList=sortElemList(elemList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -88,9 +92,9 @@ public class UpdateController {
|
|
|
if (o instanceof HolonObject) {
|
|
|
for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
|
elemList.add(he);
|
|
|
- elemList.sort(compEleName);
|
|
|
- elemList.sort(compEnergy);
|
|
|
+ elemList=sortElemList(elemList);
|
|
|
}
|
|
|
+
|
|
|
for (HolonElement e1 : elemList) {
|
|
|
Object[] temp2 = { e1.getId(), e1.getEleName(), e1.getEnergyPerElement(),
|
|
|
e1.getFlexibleEnergyAvailablePerElement(), e1.getAmount(), e1.isActive(), e1.isFlexible() };
|
|
@@ -99,6 +103,39 @@ public class UpdateController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param elemList - HolonElement-List (unsorted)
|
|
|
+ * @return sorted HolonElement-List!
|
|
|
+ */
|
|
|
+ public LinkedList<HolonElement> sortElemList(LinkedList<HolonElement> elemList) {
|
|
|
+ switch(sortBy) {
|
|
|
+ case "Object":
|
|
|
+ elemList.sort(new ElemCompOnObj());
|
|
|
+ break;
|
|
|
+ case "Device":
|
|
|
+ elemList.sort(new ElemCompOnEleName());
|
|
|
+ break;
|
|
|
+ case "Energy": elemList.sort(new ElemCompOnEnergy());
|
|
|
+ break;
|
|
|
+ case "Flexible Energy Available":
|
|
|
+ elemList.sort(new ElemCompOnFlexible());
|
|
|
+ break;
|
|
|
+ case "Quantity":
|
|
|
+ elemList.sort(new ElemCompOnQuantity());
|
|
|
+ break;
|
|
|
+ case "Activated":
|
|
|
+ elemList.sort(new ElemCompOnIsActivated());
|
|
|
+ break;
|
|
|
+ case "Flexible":
|
|
|
+ elemList.sort(new ElemCompOnIsFlexible());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ elemList.sort(new ElemCompOnId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return elemList;
|
|
|
+ };
|
|
|
|
|
|
/**
|
|
|
* Update the HolonElement Table, that means erase all rows and add the new
|
|
@@ -411,4 +448,12 @@ public class UpdateController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public String getSortBy() {
|
|
|
+ return sortBy;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSortBy(String sortBy) {
|
|
|
+ this.sortBy = sortBy;
|
|
|
+ }
|
|
|
}
|