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,
+ null,
+ (pInfo, name) -> validatePropertyName(pInfo, name, namePattern),
+ extraWriter);
+ }
+
+ public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
+ Function2<ComponentTypeViewerPropertyInfo, String, String> nameFilter, Pattern namePattern, DbConsumer<WriteGraph> extraWriter) {
+ editName(table, editor, propertyInfo, selectedItem, column, nameFilter,
(pInfo, name) -> validatePropertyName(pInfo, name, namePattern),
extraWriter);
}
public void editName(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column,
Function2<ComponentTypeViewerPropertyInfo, String, String> nameValidator, DbConsumer<WriteGraph> extraWriter) {
+ editName(table, editor, propertyInfo, selectedItem, column, null, nameValidator, extraWriter);
+ }
+
+ public void editName(
+ Table table,
+ TableEditor editor,
+ final ComponentTypeViewerPropertyInfo propertyInfo,
+ TableItem selectedItem,
+ int column,
+ Function2<ComponentTypeViewerPropertyInfo, String, String> nameFilter,
+ 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 =
if (e.type == SWT.Dispose) {
form.setMessage(null);
return;
- }
-
- if (e.type == SWT.Modify) {
+ } else if (e.type == SWT.Verify) {
+ // Filter input if necessary
+ e.text = nameFilter != null ? nameFilter.apply(propertyInfo, e.text) : e.text;
+ return;
+ } else if (e.type == SWT.Modify) {
// validate current name
String error = nameValidator.apply(propertyInfo, text.getText());
if (error != null) {
form.setMessage(null);
}
return;
- }
-
- if (e.type == SWT.Traverse) {
+ } else if (e.type == SWT.Traverse) {
if (e.detail == SWT.TRAVERSE_ESCAPE) {
text.dispose();
e.doit = false;
});
}
};
+ if (nameFilter != null)
+ text.addListener(SWT.Verify, listener);
text.addListener(SWT.Modify, listener);
text.addListener(SWT.Deactivate, listener);
text.addListener(SWT.Traverse, listener);
shell.open();
}
- protected void editMultilineText(Table table, TableEditor editor,
+ public void editMultilineText(Table table, TableEditor editor,
final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem,
Rectangle selectedItemBounds, int column, final StringWriter writer)
{