public void run(ReadGraph graph) throws DatabaseException {
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
Resource componentType = graph.getPossibleObject(table, DN.TechType_TechTypeTable_HasComponentType);
-
- TechTypeTableView.table.getDisplay().asyncExec(() -> {
- TechTypeTableView.table.setComponentType(componentType);
- });
+ if (componentType != null) {
+ TechTypeTableView.table.getDisplay().asyncExec(() -> {
+ TechTypeTableView.table.setComponentType(componentType);
+ });
+ } else {
+ String data = graph.getRelatedValue2(table, DN.TechType_TechTypeTable_HasData);
+ int[] enabled = graph.getPossibleRelatedValue2(table, DN.TechType_TechTypeTable_HasEnabledItems);
+ TechTypeTableView.table.getDisplay().asyncExec(() -> {
+ TechTypeTableView.table.setComponentType(null);
+ TechTypeTableView.table.setTechTypeData(data, enabled);
+ });
+ }
}
});
} catch (DatabaseException e) {
LOGGER.error("Failed to read possible tech type key name for {}", componentType, e);
}
}
- return keyName.startsWith("_") ? keyName.substring(1) : keyName;
+ return keyName != null && keyName.startsWith("_") ? keyName.substring(1) : keyName;
}
@Override
this.componentType = componentType;
this.keyName = getKeyColumnName(componentType);
-
- Simantics.getSession().asyncRequest(new TableDataRequest(componentType), new TableDataListener(componentType));
+
+ if (componentType != null) {
+ Simantics.getSession().asyncRequest(new TableDataRequest(componentType), new TableDataListener(componentType));
+ }
}
private final class TableDataListener implements Listener<Triple<Resource, String, List<Integer>>> {
@Override
public void execute(Triple<Resource, String, List<Integer>> result) {
TechTypeTable.this.getDisplay().asyncExec(() -> {
+ if (isDisposed() || result == null)
+ return;
+
TechTypeTable.this.tableResource = result.first;
String data = result.second;
int[] enabled = result.third.stream().mapToInt(Integer::intValue).toArray();