X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FcomponentTypeEditor%2FComponentTypeViewerData.java;h=ea3f61e80fe0904251ac2cd4af2a44581717f392;hb=b825d7a7aff95002f355878ec2767352411b5a43;hp=d6b312426253fa33226aeb13f36505455ddea238;hpb=0d0f89ee7fdf9fa2315ba4d797de202992ae7158;p=simantics%2Fplatform.git 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..ea3f61e80 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); } }); } @@ -219,7 +235,7 @@ public class ComponentTypeViewerData { combo.addListener(SWT.Traverse, listener); } - protected void editUnit(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column) { + public void editUnit(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column) { // Disallow unit editing for non-numeric configuration properties if (propertyInfo.numberType == null && propertyInfo.sectionSpecificData == null) return;