Java Code Examples for com.vaadin.data.Result#ok()

The following examples show how to use com.vaadin.data.Result#ok() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CssColorToColorPickerConverter.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public Result<Color> convertToModel(String value, ValueContext context) {
    if (value == null || value.trim().isEmpty()) {
        return Result.ok(Color.WHITE);
    }
    value = value.trim();
    if (!value.startsWith("#") && !value.startsWith("0x")) {
        value = "#" + value;
    }
    try {
        java.awt.Color c = java.awt.Color.decode(value);
        return Result.ok(new Color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()));
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
    return Result.ok(Color.WHITE);
}
 
Example 2
Source File: CubaDateField.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected Result<LocalDate> handleUnparsableDateString(String dateString) {
    if (Objects.equals(dateString, StringUtils.replaceChars(getState(false).dateMask, "#U", "__"))) {
        return Result.ok(null);
    }

    return Result.error(getParseErrorMessage());
}
 
Example 3
Source File: UserProjectListSelect.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Result<Collection<Integer>> convertToModel(Collection<SimpleProject> value, ValueContext context) {
    if (value == null) {
        return Result.ok(null);
    } else {
        return Result.ok(value.stream().map(project -> project.getId()).collect(Collectors.toSet()));
    }
}
 
Example 4
Source File: StringToEnumConverter.java    From cia with Apache License 2.0 4 votes vote down vote up
@Override
public Result<Enum> convertToModel(final String value, final ValueContext context) {
	return Result.ok(null);
}
 
Example 5
Source File: ListPropertyConverter.java    From cia with Apache License 2.0 4 votes vote down vote up
@Override
public Result<List<?>> convertToModel(final String value, final ValueContext context) {
	return Result.ok(new ArrayList<>());
}
 
Example 6
Source File: MilestoneComboBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<Integer> convertToModel(SimpleMilestone value, ValueContext context) {
    return (value != null)? Result.ok(value.getId()) : Result.ok(null);
}
 
Example 7
Source File: ProjectRoleComboBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<Integer> convertToModel(SimpleProjectRole role, ValueContext valueContext) {
    return (role != null)? Result.ok(role.getId()) : Result.ok(null);
}
 
Example 8
Source File: ProjectMemberSelectionBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<String> convertToModel(SimpleProjectMember projectMember, ValueContext valueContext) {
    return Result.ok(projectMember.getUsername());
}
 
Example 9
Source File: RoleComboBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<Integer> convertToModel(SimpleRole simpleRole, ValueContext valueContext) {
    return Result.ok(simpleRole.getId());
}
 
Example 10
Source File: ActiveUserComboBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<String> convertToModel(SimpleUser value, ValueContext context) {
    return (value != null) ? Result.ok(value.getUsername()) : Result.ok(null);
}
 
Example 11
Source File: I18nValueComboBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<String> convertToModel(T value, ValueContext context) {
    return (value != null) ? Result.ok(value.name()) : Result.ok(null);
}
 
Example 12
Source File: KeyCaptionComboBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<Integer> convertToModel(Entry entry, ValueContext valueContext) {
    return Result.ok(entry.key);
}
 
Example 13
Source File: AbstractOptionValComboBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<String> convertToModel(OptionVal value, ValueContext context) {
    return (value != null) ? Result.ok(value.getTypeval()) : Result.ok(null);
}
 
Example 14
Source File: CurrencyComboBoxField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Result<String> convertToModel(Currency value, ValueContext context) {
    return (value != null) ? Result.ok(value.getCurrencyCode()) : Result.ok(null);
}