From 6bf51de1941aa1dc5ee0a3aa8c50d53168b0c068 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Thu, 22 Mar 2018 18:00:37 +0200 Subject: [PATCH] Allow client-logic in component type interface property name editing refs #7838 Change-Id: I17cebd2f303b2713444eeba5b4480657e3fba057 --- .../ComponentTypeViewerData.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewerData.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewerData.java index d6b312426..e1f179965 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewerData.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewerData.java @@ -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 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 nameValidator) + { + editName(table, editor, propertyInfo, selectedItem, column, nameValidator, null); } public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column, - Function2 nameValidator) { + Function2 nameValidator, DbConsumer 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); } }); } -- 2.43.2