use of org.eclipse.sirius.components.forms.description.AbstractWidgetDescription in project sirius-components by eclipse-sirius.
the class WidgetComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
AbstractWidgetDescription widgetDescription = this.props.getWidgetDescription();
Element element = null;
if (widgetDescription instanceof TextfieldDescription) {
TextfieldComponentProps textfieldProps = new TextfieldComponentProps(variableManager, (TextfieldDescription) widgetDescription);
element = new Element(TextfieldComponent.class, textfieldProps);
} else if (widgetDescription instanceof TextareaDescription) {
TextareaComponentProps textareaProps = new TextareaComponentProps(variableManager, (TextareaDescription) widgetDescription);
element = new Element(TextareaComponent.class, textareaProps);
} else if (widgetDescription instanceof CheckboxDescription) {
CheckboxComponentProps checkboxProps = new CheckboxComponentProps(variableManager, (CheckboxDescription) widgetDescription);
element = new Element(CheckboxComponent.class, checkboxProps);
} else if (widgetDescription instanceof SelectDescription) {
SelectComponentProps selectProps = new SelectComponentProps(variableManager, (SelectDescription) widgetDescription);
element = new Element(SelectComponent.class, selectProps);
} else if (widgetDescription instanceof MultiSelectDescription) {
MultiSelectComponentProps multiSelectProps = new MultiSelectComponentProps(variableManager, (MultiSelectDescription) widgetDescription);
element = new Element(MultiSelectComponent.class, multiSelectProps);
} else if (widgetDescription instanceof RadioDescription) {
RadioComponentProps radioProps = new RadioComponentProps(variableManager, (RadioDescription) widgetDescription);
element = new Element(RadioComponent.class, radioProps);
} else if (widgetDescription instanceof ListDescription) {
ListComponentProps listProps = new ListComponentProps(variableManager, (ListDescription) widgetDescription);
element = new Element(ListComponent.class, listProps);
} else if (widgetDescription instanceof LinkDescription) {
LinkComponentProps linkProps = new LinkComponentProps(variableManager, (LinkDescription) widgetDescription);
element = new Element(LinkComponent.class, linkProps);
} else {
// $NON-NLS-1$
String pattern = "Unsupported widget description: {}";
this.logger.warn(pattern, widgetDescription.getClass().getSimpleName());
}
return element;
}
use of org.eclipse.sirius.components.forms.description.AbstractWidgetDescription in project sirius-components by eclipse-sirius.
the class IfDescriptionConverter method convert.
public Optional<IfDescription> convert(org.eclipse.sirius.properties.DynamicMappingIfDescription siriusIfDescription) {
BooleanValueProvider predicate = new BooleanValueProvider(this.interpreter, siriusIfDescription.getPredicateExpression());
WidgetDescriptionConverter converter = new WidgetDescriptionConverter(this.interpreter, this.objectService, this.identifierProvider, this.modelOperationHandlerSwitchProvider);
Optional<AbstractWidgetDescription> optionalWidgetDescription = converter.convert(siriusIfDescription.getWidget());
return optionalWidgetDescription.map(widgetDescription -> {
// @formatter:off
return IfDescription.newIfDescription(this.identifierProvider.getIdentifier(siriusIfDescription)).predicate(predicate).widgetDescription(widgetDescription).build();
// @formatter:on
});
}
use of org.eclipse.sirius.components.forms.description.AbstractWidgetDescription in project sirius-components by eclipse-sirius.
the class GroupComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
GroupDescription groupDescription = this.props.getGroupDescription();
WidgetIdCounter widgetIdCounter = new WidgetIdCounter();
List<?> semanticElements = groupDescription.getSemanticElementsProvider().apply(variableManager);
List<Element> children = new ArrayList<>(semanticElements.size());
for (Object semanticElement : semanticElements) {
VariableManager groupVariableManager = variableManager.createChild();
groupVariableManager.put(VariableManager.SELF, semanticElement);
groupVariableManager.put(WIDGET_ID_PROVIDER_COUNTER, widgetIdCounter);
String id = groupDescription.getIdProvider().apply(groupVariableManager);
String label = groupDescription.getLabelProvider().apply(groupVariableManager);
// @formatter:off
List<Element> groupChildren = new ArrayList<>();
List<AbstractControlDescription> controlDescriptions = groupDescription.getControlDescriptions();
for (AbstractControlDescription controlDescription : controlDescriptions) {
if (controlDescription instanceof AbstractWidgetDescription) {
AbstractWidgetDescription widgetDescription = (AbstractWidgetDescription) controlDescription;
WidgetComponentProps widgetComponentProps = new WidgetComponentProps(groupVariableManager, widgetDescription);
groupChildren.add(new Element(WidgetComponent.class, widgetComponentProps));
} else if (controlDescription instanceof ForDescription) {
ForDescription forDescription = (ForDescription) controlDescription;
ForComponentProps forComponentProps = new ForComponentProps(groupVariableManager, forDescription);
groupChildren.add(new Element(ForComponent.class, forComponentProps));
}
}
GroupElementProps groupElementProps = GroupElementProps.newGroupElementProps(id).label(label).children(groupChildren).build();
Element groupElement = new Element(GroupElementProps.TYPE, groupElementProps);
// @formatter:on
children.add(groupElement);
}
FragmentProps fragmentProps = new FragmentProps(children);
return new Fragment(fragmentProps);
}
use of org.eclipse.sirius.components.forms.description.AbstractWidgetDescription in project sirius-components by eclipse-sirius.
the class DiagnosticComponent method render.
@Override
public Element render() {
AbstractWidgetDescription widgetDescription = this.props.getWidgetDescription();
VariableManager variableManager = this.props.getVariableManager();
List<?> diagnostics = widgetDescription.getDiagnosticsProvider().apply(variableManager);
List<Element> children = new ArrayList<>(diagnostics.size());
for (Object diagnostic : diagnostics) {
UUID id = UUID.randomUUID();
String kind = widgetDescription.getKindProvider().apply(diagnostic);
String message = widgetDescription.getMessageProvider().apply(diagnostic);
// @formatter:off
DiagnosticElementProps diagnosticElementProps = DiagnosticElementProps.newDiagnosticElementProps(id).kind(kind).message(message).build();
// @formatter:on
children.add(new Element(DiagnosticElementProps.TYPE, diagnosticElementProps));
}
FragmentProps fragmentProps = new FragmentProps(children);
return new Fragment(fragmentProps);
}
Aggregations