use of org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps in project sirius-components by eclipse-sirius.
the class MultiSelectComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
MultiSelectDescription multiSelectDescription = this.props.getMultiSelectDescription();
String id = multiSelectDescription.getIdProvider().apply(variableManager);
String label = multiSelectDescription.getLabelProvider().apply(variableManager);
List<?> optionCandidates = multiSelectDescription.getOptionsProvider().apply(variableManager);
List<String> values = multiSelectDescription.getValuesProvider().apply(variableManager);
List<Element> children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(multiSelectDescription, variableManager)));
List<SelectOption> options = new ArrayList<>(optionCandidates.size());
for (Object candidate : optionCandidates) {
VariableManager optionVariableManager = variableManager.createChild();
optionVariableManager.put(CANDIDATE_VARIABLE, candidate);
String optionId = multiSelectDescription.getOptionIdProvider().apply(optionVariableManager);
String optionLabel = multiSelectDescription.getOptionLabelProvider().apply(optionVariableManager);
// @formatter:off
SelectOption option = SelectOption.newSelectOption(optionId).label(optionLabel).build();
// @formatter:on
options.add(option);
}
Function<List<String>, IStatus> newValuesHandler = newValues -> {
return multiSelectDescription.getNewValuesHandler().apply(variableManager, newValues);
};
// @formatter:off
MultiSelectElementProps selectElementProps = MultiSelectElementProps.newMultiSelectElementProps(id).label(label).options(options).values(values).newValuesHandler(newValuesHandler).children(children).build();
return new Element(MultiSelectElementProps.TYPE, selectElementProps);
// @formatter:on
}
use of org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps in project sirius-components by eclipse-sirius.
the class LinkComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
LinkDescription linkDescription = this.props.getLinkDescription();
String id = linkDescription.getIdProvider().apply(variableManager);
String label = linkDescription.getLabelProvider().apply(variableManager);
String url = linkDescription.getUrlProvider().apply(variableManager);
List<Element> children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(linkDescription, variableManager)));
// @formatter:off
LinkElementProps linkElementProps = LinkElementProps.newLinkElementProps(id).label(label).url(url).children(children).build();
return new Element(LinkElementProps.TYPE, linkElementProps);
// @formatter:on
}
use of org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps in project sirius-components by eclipse-sirius.
the class TextfieldComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
TextfieldDescription textfieldDescription = this.props.getTextfieldDescription();
String id = textfieldDescription.getIdProvider().apply(variableManager);
String label = textfieldDescription.getLabelProvider().apply(variableManager);
String value = textfieldDescription.getValueProvider().apply(variableManager);
BiFunction<VariableManager, String, IStatus> genericHandler = textfieldDescription.getNewValueHandler();
Function<String, IStatus> specializedHandler = newValue -> {
return genericHandler.apply(variableManager, newValue);
};
List<Element> children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(textfieldDescription, variableManager)));
// @formatter:off
TextfieldElementProps textfieldElementProps = TextfieldElementProps.newTextfieldElementProps(id).label(label).value(value).newValueHandler(specializedHandler).children(children).build();
return new Element(TextfieldElementProps.TYPE, textfieldElementProps);
// @formatter:on
}
use of org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps in project sirius-components by eclipse-sirius.
the class RadioComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
RadioDescription radioDescription = this.props.getRadioDescription();
String id = radioDescription.getIdProvider().apply(variableManager);
String label = radioDescription.getLabelProvider().apply(variableManager);
List<?> optionCandidates = radioDescription.getOptionsProvider().apply(variableManager);
List<Element> children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(radioDescription, variableManager)));
List<RadioOption> options = new ArrayList<>(optionCandidates.size());
for (Object candidate : optionCandidates) {
VariableManager optionVariableManager = variableManager.createChild();
optionVariableManager.put(CANDIDATE_VARIABLE, candidate);
String optionId = radioDescription.getOptionIdProvider().apply(optionVariableManager);
String optionLabel = radioDescription.getOptionLabelProvider().apply(optionVariableManager);
Boolean optionSelected = radioDescription.getOptionSelectedProvider().apply(optionVariableManager);
// @formatter:off
RadioOption option = RadioOption.newRadioOption(optionId).label(optionLabel).selected(optionSelected).build();
// @formatter:on
options.add(option);
}
BiFunction<VariableManager, String, IStatus> genericHandler = radioDescription.getNewValueHandler();
Function<String, IStatus> specializedHandler = newValue -> {
return genericHandler.apply(variableManager, newValue);
};
// @formatter:off
RadioElementProps radioElementProps = RadioElementProps.newRadioElementProps(id).label(label).options(options).newValueHandler(specializedHandler).children(children).build();
return new Element(RadioElementProps.TYPE, radioElementProps);
// @formatter:on
}
use of org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps in project sirius-components by eclipse-sirius.
the class SelectComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
SelectDescription selectDescription = this.props.getSelectDescription();
String id = selectDescription.getIdProvider().apply(variableManager);
String label = selectDescription.getLabelProvider().apply(variableManager);
List<?> optionCandidates = selectDescription.getOptionsProvider().apply(variableManager);
String value = selectDescription.getValueProvider().apply(variableManager);
List<Element> children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(selectDescription, variableManager)));
List<SelectOption> options = new ArrayList<>(optionCandidates.size());
for (Object candidate : optionCandidates) {
VariableManager optionVariableManager = variableManager.createChild();
optionVariableManager.put(CANDIDATE_VARIABLE, candidate);
String optionId = selectDescription.getOptionIdProvider().apply(optionVariableManager);
String optionLabel = selectDescription.getOptionLabelProvider().apply(optionVariableManager);
// @formatter:off
SelectOption option = SelectOption.newSelectOption(optionId).label(optionLabel).build();
// @formatter:on
options.add(option);
}
Function<String, IStatus> specializedHandler = newValue -> {
return selectDescription.getNewValueHandler().apply(variableManager, newValue);
};
// @formatter:off
SelectElementProps selectElementProps = SelectElementProps.newSelectElementProps(id).label(label).options(options).value(value).newValueHandler(specializedHandler).children(children).build();
return new Element(SelectElementProps.TYPE, selectElementProps);
// @formatter:on
}
Aggregations