]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/renaming/ComponentsRenamingModel.java
Merge commit 'd1a82fe'
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagram / renaming / ComponentsRenamingModel.java
index 23d2ffa83d723de2f76642d06d1fdbdb3d3ffb30..4df5d4ec0a54be0a1558491b19bb36c4827626eb 100644 (file)
@@ -2,7 +2,9 @@ package org.simantics.modeling.ui.diagram.renaming;
 \r
 import java.util.ArrayList;\r
 import java.util.Collections;\r
+import java.util.HashSet;\r
 import java.util.List;\r
+import java.util.Set;\r
 \r
 import org.eclipse.core.runtime.IStatus;\r
 import org.eclipse.core.runtime.Status;\r
@@ -31,6 +33,7 @@ import org.simantics.structural.stubs.StructuralResource2;
  */\r
 public class ComponentsRenamingModel {\r
     public ArrayList<NameEntry> entries = new ArrayList<NameEntry>();\r
+    public Set<NameEntry> selectedEntries = new HashSet<>();\r
     public String oldNamePrefix;\r
     public String newNamePrefix;\r
     public boolean reset;\r
@@ -41,7 +44,7 @@ public class ComponentsRenamingModel {
     private Resource configuration;\r
     private ComponentNamingStrategy namingStrategy;\r
 \r
-    public void read(ReadGraph g, Resource composite) throws DatabaseException {\r
+    public ComponentsRenamingModel read(ReadGraph g, Resource composite) throws DatabaseException {\r
         this.session = g.getSession();\r
         this.compositeVariable = Variables.getVariable(g, composite);\r
         this.configuration = g.syncRequest(new Configuration(composite));\r
@@ -68,6 +71,11 @@ public class ComponentsRenamingModel {
             prefixValidator = displayValue.getPossiblePropertyValue(g, Variables.INPUT_VALIDATOR);\r
 \r
         this.namingStrategy = ComponentNamingUtil.findNamingStrategy(g, null, composite);\r
+\r
+        // By default, select all entries.\r
+        this.selectedEntries.addAll(entries);\r
+\r
+        return this;\r
     }\r
 \r
     public void computeNewNames() {\r
@@ -125,7 +133,7 @@ public class ComponentsRenamingModel {
         Layer0 L0 = Layer0.getInstance(g);\r
         Layer0X L0X = Layer0X.getInstance(g);\r
         for(NameEntry entry : entries)\r
-            if(!entry.oldName.equals(entry.newName))\r
+            if(!entry.oldName.equals(entry.newName) && selectedEntries.contains(entry))\r
                 g.claimLiteral(entry.resource, L0.HasName, entry.newName, Bindings.STRING);\r
         if(!oldNamePrefix.equals(newNamePrefix))\r
             compositeVariable.setPropertyValue(g, L0X.HasGeneratedNamePrefix, newNamePrefix, Bindings.STRING);\r