use of org.uberfire.ext.editor.commons.client.validation.ValidatorCallback in project kie-wb-common by kiegroup.
the class MainDataObjectFieldEditor method doFieldNameChange.
private void doFieldNameChange(final String oldValue, final String newValue) {
final Command afterCloseCommand = new Command() {
@Override
public void execute() {
view.setNameOnError(true);
view.selectAllNameText();
}
};
// In case an invalid name (entered before), was corrected to the original value, don't do anything but reset the label style
if (oldValue.equalsIgnoreCase(view.getName())) {
view.setName(oldValue);
view.setNameOnError(false);
return;
}
validatorService.isValidIdentifier(newValue, new ValidatorCallback() {
@Override
public void onFailure() {
view.showErrorPopup(Constants.INSTANCE.validation_error_invalid_object_attribute_identifier(newValue), null, afterCloseCommand);
}
@Override
public void onSuccess() {
validatorService.isUniqueAttributeName(newValue, getDataObject(), new ValidatorWithReasonCallback() {
@Override
public void onFailure() {
showFailure(ValidatorService.MANAGED_PROPERTY_EXISTS);
}
@Override
public void onFailure(String reason) {
showFailure(reason);
}
private void showFailure(String reason) {
if (ValidatorService.UN_MANAGED_PROPERTY_EXISTS.equals(reason)) {
ObjectProperty unmanagedProperty = getDataObject().getUnManagedProperty(newValue);
view.showErrorPopup(Constants.INSTANCE.validation_error_object_un_managed_attribute_already_exists(unmanagedProperty.getName(), unmanagedProperty.getClassName()));
} else {
view.showErrorPopup(Constants.INSTANCE.validation_error_object_attribute_already_exists(newValue));
}
}
@Override
public void onSuccess() {
view.setNameOnError(false);
objectField.setName(newValue);
notifyChange(createFieldChangeEvent(ChangeType.FIELD_NAME_CHANGE).withOldValue(oldValue).withNewValue(newValue));
}
});
}
});
}
use of org.uberfire.ext.editor.commons.client.validation.ValidatorCallback in project kie-wb-common by kiegroup.
the class NewPackagePopup method onCreatePackage.
@Override
public void onCreatePackage() {
final String[] packageName = { DataModelerUtils.trim(view.getPackageName()) };
packageName[0] = packageName[0] != null ? packageName[0].trim() : null;
validatorService.isValidPackageIdentifier(packageName[0], new ValidatorCallback() {
@Override
public void onFailure() {
view.setErrorMessage(Constants.INSTANCE.validation_error_invalid_package_identifier(packageName[0]));
}
@Override
public void onSuccess() {
setPackageName(packageName[0]);
view.hide();
if (afterAddCommand != null) {
afterAddCommand.execute();
}
}
});
}
Aggregations