]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Change mapping of elements, not the mapping itself 27/2527/2
authorjsimomaa <jani.simomaa@gmail.com>
Fri, 7 Dec 2018 06:51:47 +0000 (08:51 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Fri, 7 Dec 2018 06:58:05 +0000 (06:58 +0000)
gitlab #22

Change-Id: I93210fdb5c66469c5eb40451435745f23528313f

org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeMappingTypeHandler.java

index 2b3d1888a41b2a0218221444ac8fbf5536f02ce2..1f94833507ad557226f249d02740347d995e6eab 100644 (file)
@@ -245,18 +245,25 @@ public class ChangeMappingTypeHandler {
         
         @Override
         protected void computeResult() {
+            Map<NamedResource, Collection<NamedResource>> currentElements = null;
+            try {
+                currentElements = elements.get();
+            } catch (InterruptedException | ExecutionException e) {
+                LOGGER.error("Could not get currentElements", e);
+                throw new RuntimeException("Could not get currentElements", e);
+            }
             for (Map.Entry<NamedResource, Combo> combos : mappingCombos.entrySet()) {
                 NamedResource resource = combos.getKey();
                 Combo c = combos.getValue();
                 String item = c.getItem(c.getSelectionIndex());
-                
+                Collection<NamedResource> collection = currentElements.get(resource);
                 Map<String, Resource> map = possibleMappings.get(resource);
                 Resource newMapping = map.get(item);
                 results.compute(newMapping, (t, u) -> {
                     if (u == null) {
                         u = new HashSet<>();
                     }
-                    u.add(resource);
+                    u.addAll(collection);
                     return u;
                 });
             }