, P extends Entity> TitledPane createEditableEntityPane(
- final P parentEntity,
- final C childEntity,
- final Query childQuery,
+ public static TitledPane createEditableEntityPane(
+ final Entity parentEntity,
+ final Entity childEntity,
+ final Query childQuery,
String orderby,
- final ChildSetter setter) throws IOException {
+ final ChildSetter setter) throws IOException {
- EntityType type = EntityType.singleForClass(childQuery.getEntityType().getType());
+ EntityType type = childQuery.getEntityType();
String paneTitle;
if (childEntity == null) {
- paneTitle = type.getName() + ": None selected";
+ paneTitle = type.getEntityName() + ": None selected";
} else {
- paneTitle = childEntity.getType().getName() + ": " + childEntity.toString();
+ paneTitle = childEntity.getEntityType().getEntityName() + ": " + childEntity.toString();
}
Node pane = FactoryEntityPanel.getPane(childQuery.getService(), type, childEntity, false);
TitledPane tp = new TitledPane(paneTitle, pane);
Button edit = new Button("🔧");
tp.setGraphic(edit);
edit.setOnAction((ActionEvent event) -> {
- Optional> result = entitySearchDialog(childQuery, false, orderby);
+ Optional> result = entitySearchDialog(childQuery, false, orderby);
if (result.isPresent() && !result.get().isEmpty()) {
- C newChild = result.get().get(0);
+ Entity newChild = result.get().get(0);
setter.setChild(newChild);
try {
tp.setContent(FactoryEntityPanel.getPane(childQuery.getService(), type, childEntity, false));
} catch (IOException ex) {
LoggerFactory.getLogger(EntityGuiController.class).error("Failed to load Collection Pane.", ex);
}
- tp.setText(newChild.getType().getName() + ": " + newChild.toString());
+ tp.setText(newChild.getEntityType().getEntityName() + ": " + newChild.toString());
}
});
@@ -1086,11 +383,11 @@ public static T addFieldTo(GridPane gp, int row, String title,
return node;
}
- public static > Pane createCollectionPaneFor(Query query, String orderBy) {
+ public static Pane createCollectionPaneFor(Query query, String orderBy) {
return createCollectionPaneFor(query, orderBy, false, null);
}
- public static > Pane createCollectionPaneFor(Query query, String orderBy, boolean canLinkNew, ChildSetter childSetter) {
+ public static Pane createCollectionPaneFor(Query query, String orderBy, boolean canLinkNew, ChildSetter childSetter) {
try {
FXMLLoader loader = new FXMLLoader(EntityGuiController.class.getResource("/fxml/Collection.fxml"));
AnchorPane content = (AnchorPane) loader.load();
@@ -1106,19 +403,19 @@ public static > Pane createCollectionPaneFor(Query query,
return null;
}
- public static > Optional> entitySearchDialog(Query query, boolean multiSelect, String orderBy) {
+ public static Optional> entitySearchDialog(Query query, boolean multiSelect, String orderBy) {
try {
FXMLLoader loader = new FXMLLoader(EntityGuiController.class.getResource("/fxml/Collection.fxml"));
AnchorPane content = (AnchorPane) loader.load();
- final ControllerCollection controller = loader.>getController();
+ final ControllerCollection controller = loader.getController();
controller.setQuery(query, false, false, false, multiSelect, orderBy);
- Dialog> dialog = new Dialog<>();
+ Dialog> dialog = new Dialog<>();
dialog.setHeight(800);
if (multiSelect) {
- dialog.setTitle("Choose one or more " + EntityType.singleForClass(query.getEntityType().getType()).getName());
+ dialog.setTitle("Choose one or more " + query.getEntityType().getEntityName());
} else {
- dialog.setTitle("Choose a " + EntityType.singleForClass(query.getEntityType().getType()).getName());
+ dialog.setTitle("Choose a " + query.getEntityType().getEntityName());
}
dialog.setResizable(true);
dialog.getDialogPane().setContent(content);
@@ -1131,7 +428,7 @@ public static > Optional> entitySearchDialog(Query list = new ArrayList<>();
+ List list = new ArrayList<>();
list.add(controller.getSelectedEntity());
return list;
}
diff --git a/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/EntityListEntry.java b/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/EntityListEntry.java
index 02778db..48b12c4 100644
--- a/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/EntityListEntry.java
+++ b/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/EntityListEntry.java
@@ -1,15 +1,14 @@
package de.fraunhofer.iosb.ilt.sensorthingsmanager.controller;
-import de.fraunhofer.iosb.ilt.sta.model.Entity;
+import de.fraunhofer.iosb.ilt.frostclient.model.Entity;
/**
*
* @author scf
- * @param The entity type.
*/
-public class EntityListEntry> {
+public class EntityListEntry {
- private T entity;
+ private Entity entity;
private boolean changed = false;
@Override
@@ -20,7 +19,7 @@ public String toString() {
/**
* @return the entity
*/
- public T getEntity() {
+ public Entity getEntity() {
return entity;
}
@@ -28,7 +27,7 @@ public T getEntity() {
* @param entity the entity to set.
* @return this EntityListEntry.
*/
- public EntityListEntry setEntity(T entity) {
+ public EntityListEntry setEntity(Entity entity) {
this.entity = entity;
return this;
}
@@ -44,7 +43,7 @@ public boolean isChanged() {
* @param changed the changed to set.
* @return this EntityListEntry.
*/
- public EntityListEntry setChanged(boolean changed) {
+ public EntityListEntry setChanged(boolean changed) {
this.changed = changed;
return this;
}
diff --git a/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/FactoryEntityPanel.java b/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/FactoryEntityPanel.java
index 2c1d058..7ec703d 100644
--- a/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/FactoryEntityPanel.java
+++ b/src/main/java/de/fraunhofer/iosb/ilt/sensorthingsmanager/controller/FactoryEntityPanel.java
@@ -1,21 +1,10 @@
package de.fraunhofer.iosb.ilt.sensorthingsmanager.controller;
-import de.fraunhofer.iosb.ilt.sensorthingsmanager.controller.EntityGuiController;
-import de.fraunhofer.iosb.ilt.sensorthingsmanager.controller.ControllerEntity;
+import de.fraunhofer.iosb.ilt.frostclient.SensorThingsService;
+import de.fraunhofer.iosb.ilt.frostclient.model.Entity;
+import de.fraunhofer.iosb.ilt.frostclient.model.EntityType;
import java.io.IOException;
-import de.fraunhofer.iosb.ilt.sta.model.Datastream;
-import de.fraunhofer.iosb.ilt.sta.model.Entity;
-import de.fraunhofer.iosb.ilt.sta.model.EntityType;
-import de.fraunhofer.iosb.ilt.sta.model.FeatureOfInterest;
-import de.fraunhofer.iosb.ilt.sta.model.HistoricalLocation;
-import de.fraunhofer.iosb.ilt.sta.model.Location;
-import de.fraunhofer.iosb.ilt.sta.model.MultiDatastream;
-import de.fraunhofer.iosb.ilt.sta.model.Observation;
-import de.fraunhofer.iosb.ilt.sta.model.ObservedProperty;
-import de.fraunhofer.iosb.ilt.sta.model.Sensor;
-import de.fraunhofer.iosb.ilt.sta.model.Thing;
-import de.fraunhofer.iosb.ilt.sta.service.SensorThingsService;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.control.Label;
@@ -29,117 +18,17 @@ public class FactoryEntityPanel {
private static final String ENTITY_PANE_FXML = "/fxml/PaneEntity.fxml";
- public static > Node getPane(SensorThingsService service, EntityType type, T entity, boolean showNavProps) throws IOException {
- if (entity != null && entity.getType() != type) {
+ public static Node getPane(SensorThingsService service, EntityType type, Entity entity, boolean showNavProps) throws IOException {
+ if (entity != null && entity.getEntityType() != type) {
throw new IllegalArgumentException("Entity must have given type or be null.");
}
- switch (type) {
- case DATASTREAM:
- return getDatastreamPane(service, (Datastream) entity, showNavProps);
-
- case FEATURE_OF_INTEREST:
- return getFeatureOfInterestPane(service, (FeatureOfInterest) entity, showNavProps);
-
- case HISTORICAL_LOCATION:
- return getHistoricalLocationPane(service, (HistoricalLocation) entity, showNavProps);
-
- case LOCATION:
- return getLocationPane(service, (Location) entity, showNavProps);
-
- case MULTIDATASTREAM:
- return getMultiDatastreamPane(service, (MultiDatastream) entity, showNavProps);
-
- case OBSERVATION:
- return getObservationPane(service, (Observation) entity, showNavProps);
-
- case OBSERVED_PROPERTY:
- return getObsPropPane(service, (ObservedProperty) entity, showNavProps);
-
- case SENSOR:
- return getSensorPane(service, (Sensor) entity, showNavProps);
-
- case THING:
- return getThingPane(service, (Thing) entity, showNavProps);
-
- }
- return null;
- }
-
- public static Node getDatastreamPane(SensorThingsService service, Datastream entity, boolean showNavProps) throws IOException {
if (entity == null) {
- return new Label("No Datastream.");
+ return new Label("No " + type.entityName + ".");
}
FXMLLoader loader = new FXMLLoader(FactoryEntityPanel.class.getResource(ENTITY_PANE_FXML));
Node content = (Pane) loader.load();
- ControllerEntity controller = loader.>getController();
- controller.setEntity(service, entity, new EntityGuiController.GuiControllerDatastream(), showNavProps);
- return content;
- }
-
- public static Node getFeatureOfInterestPane(SensorThingsService service, FeatureOfInterest entity, boolean showNavProps) throws IOException {
- FXMLLoader loader = new FXMLLoader(FactoryEntityPanel.class.getResource(ENTITY_PANE_FXML));
- Pane content = (Pane) loader.load();
- ControllerEntity controller = loader.>getController();
- controller.setEntity(service, entity, new EntityGuiController.GuiControllerFeatureOfInterest(), showNavProps);
- return content;
- }
-
- public static Node getHistoricalLocationPane(SensorThingsService service, HistoricalLocation entity, boolean showNavProps) throws IOException {
- FXMLLoader loader = new FXMLLoader(FactoryEntityPanel.class.getResource(ENTITY_PANE_FXML));
- Pane content = (Pane) loader.load();
- ControllerEntity controller = loader.>getController();
- controller.setEntity(service, entity, new EntityGuiController.GuiControllerHistoricalLocation(), showNavProps);
- return content;
- }
-
- public static Node getLocationPane(SensorThingsService service, Location entity, boolean showNavProps) throws IOException {
- FXMLLoader loader = new FXMLLoader(FactoryEntityPanel.class.getResource(ENTITY_PANE_FXML));
- Pane content = (Pane) loader.load();
- ControllerEntity controller = loader.>getController();
- controller.setEntity(service, entity, new EntityGuiController.GuiControllerLocation(), showNavProps);
- return content;
- }
-
- public static Node getMultiDatastreamPane(SensorThingsService service, MultiDatastream entity, boolean showNavProps) throws IOException {
- if (entity == null) {
- return new Label("No MultiDatastream.");
- }
- FXMLLoader loader = new FXMLLoader(FactoryEntityPanel.class.getResource(ENTITY_PANE_FXML));
- Pane content = (Pane) loader.load();
- ControllerEntity controller = loader.