+ private static final class HighlightSelectionEventHandler implements EventHandler {
+ @Override
+ public void handleEvent(Event event) {
+ Object data = event.getProperty("org.eclipse.e4.data");
+ if (data instanceof Variable[]) {
+ Variable[] propertyTableComponents = (Variable[]) data;
+ try {
+ // convert components to dh components
+ List<Resource> dnElements = Simantics.getSession().syncRequest(new UniqueRead<List<Resource>>() {
+
+ @Override
+ public List<Resource> perform(ReadGraph graph) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ return Arrays.asList(propertyTableComponents).stream().map(var -> {
+ try {
+ Resource res = var.getRepresents(graph);
+ Resource element = graph.getSingleObject(res, MOD.ComponentToElement);
+ return graph.getSingleObject(element, DN.MappedFromElement);
+ } catch (Exception e) {
+ String varURI = var.toString();
+ try {
+ varURI = var.getURI(graph);
+ } catch (DatabaseException ex) {
+ LOGGER.error("Unable to resole uri for {}", var, ex);
+ }
+ LOGGER.error("Could not get dn element for {}", varURI, e);
+ return null;
+ }
+ }).collect(Collectors.toList());
+ }
+ });
+ DistrictNetworkUIUtil.openDNDiagramWithSelection(Display.getDefault(), dnElements);
+ } catch (DatabaseException e) {
+ LOGGER.error("Could not convert variables to dn elements", propertyTableComponents, e);
+ }
+ }
+ }
+ }
+
+ // This is hard coded for now.. the same value is used for multipropertytable to
+ // send the events we are here listening and interested in
+ private static final String PROPERTY_TABLE_HIGHLIGHT = "PROPERTY_TABLE_HIGHLIGHT";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+