]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Allow client-logic in component type interface property name editing 34/1634/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 22 Mar 2018 16:00:37 +0000 (18:00 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 22 Mar 2018 17:43:23 +0000 (19:43 +0200)
refs #7838

Change-Id: I17cebd2f303b2713444eeba5b4480657e3fba057
(cherry picked from commit 6bf51de1941aa1dc5ee0a3aa8c50d53168b0c068)

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewerData.java

index d6b312426253fa33226aeb13f36505455ddea238..e1f17996505f6d34ec2131f489f97552f0743327 100644 (file)
@@ -40,6 +40,7 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.NamedResource;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.function.DbConsumer;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.userComponent.ComponentTypeCommands;
 import org.simantics.scl.runtime.function.Function2;
@@ -90,12 +91,24 @@ public class ComponentTypeViewerData {
 
     public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
             Pattern namePattern) {
+        editName(table, editor, propertyInfo, selectedItem, column, namePattern, null);
+    }
+
+    public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
+            Pattern namePattern, DbConsumer<WriteGraph> extraWriter) {
         editName(table, editor, propertyInfo, selectedItem, column,
-                (pInfo, name) -> validatePropertyName(pInfo, name, namePattern));
+                (pInfo, name) -> validatePropertyName(pInfo, name, namePattern),
+                extraWriter);
+    }
+
+    public void editName(Table table, TableEditor editor, ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
+            Function2<ComponentTypeViewerPropertyInfo, String, String> nameValidator)
+    {
+        editName(table, editor, propertyInfo, selectedItem, column, nameValidator, null);
     }
 
     public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
-            Function2<ComponentTypeViewerPropertyInfo, String, String> nameValidator) {
+            Function2<ComponentTypeViewerPropertyInfo, String, String> nameValidator, DbConsumer<WriteGraph> extraWriter) {
         int extraStyle = propertyInfo.immutable ? SWT.READ_ONLY : 0;
         final Text text = new Text(table, SWT.NONE | extraStyle);
         org.eclipse.swt.widgets.Listener listener = 
@@ -157,6 +170,9 @@ public class ComponentTypeViewerData {
                         ComponentTypeCommands.rename(graph, propertyInfo.resource, newValue);
                         if (setLabel)
                             ComponentTypeCommands.setLabel(graph, propertyInfo.resource, ComponentTypeCommands.camelCaseNameToLabel(newValue));
+
+                        if (extraWriter != null)
+                            extraWriter.accept(graph);
                     }
                 });
             }