Search in sources :

Example 1 with AbstractWidgetDescription

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;
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) CheckboxDescription(org.eclipse.sirius.components.forms.description.CheckboxDescription) RadioDescription(org.eclipse.sirius.components.forms.description.RadioDescription) LinkDescription(org.eclipse.sirius.components.forms.description.LinkDescription) Element(org.eclipse.sirius.components.representations.Element) MultiSelectDescription(org.eclipse.sirius.components.forms.description.MultiSelectDescription) ListDescription(org.eclipse.sirius.components.forms.description.ListDescription) AbstractWidgetDescription(org.eclipse.sirius.components.forms.description.AbstractWidgetDescription) TextareaDescription(org.eclipse.sirius.components.forms.description.TextareaDescription) TextfieldDescription(org.eclipse.sirius.components.forms.description.TextfieldDescription) SelectDescription(org.eclipse.sirius.components.forms.description.SelectDescription) MultiSelectDescription(org.eclipse.sirius.components.forms.description.MultiSelectDescription)

Example 2 with AbstractWidgetDescription

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
    });
}
Also used : BooleanValueProvider(org.eclipse.sirius.components.compatibility.utils.BooleanValueProvider) AbstractWidgetDescription(org.eclipse.sirius.components.forms.description.AbstractWidgetDescription)

Example 3 with AbstractWidgetDescription

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);
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) GroupElementProps(org.eclipse.sirius.components.forms.elements.GroupElementProps) Element(org.eclipse.sirius.components.representations.Element) ArrayList(java.util.ArrayList) AbstractWidgetDescription(org.eclipse.sirius.components.forms.description.AbstractWidgetDescription) Fragment(org.eclipse.sirius.components.representations.Fragment) GroupDescription(org.eclipse.sirius.components.forms.description.GroupDescription) AbstractControlDescription(org.eclipse.sirius.components.forms.description.AbstractControlDescription) FragmentProps(org.eclipse.sirius.components.representations.FragmentProps) ForDescription(org.eclipse.sirius.components.forms.description.ForDescription)

Example 4 with AbstractWidgetDescription

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);
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) Element(org.eclipse.sirius.components.representations.Element) ArrayList(java.util.ArrayList) FragmentProps(org.eclipse.sirius.components.representations.FragmentProps) AbstractWidgetDescription(org.eclipse.sirius.components.forms.description.AbstractWidgetDescription) UUID(java.util.UUID) Fragment(org.eclipse.sirius.components.representations.Fragment)

Aggregations

AbstractWidgetDescription (org.eclipse.sirius.components.forms.description.AbstractWidgetDescription)4 Element (org.eclipse.sirius.components.representations.Element)3 VariableManager (org.eclipse.sirius.components.representations.VariableManager)3 ArrayList (java.util.ArrayList)2 Fragment (org.eclipse.sirius.components.representations.Fragment)2 FragmentProps (org.eclipse.sirius.components.representations.FragmentProps)2 UUID (java.util.UUID)1 BooleanValueProvider (org.eclipse.sirius.components.compatibility.utils.BooleanValueProvider)1 AbstractControlDescription (org.eclipse.sirius.components.forms.description.AbstractControlDescription)1 CheckboxDescription (org.eclipse.sirius.components.forms.description.CheckboxDescription)1 ForDescription (org.eclipse.sirius.components.forms.description.ForDescription)1 GroupDescription (org.eclipse.sirius.components.forms.description.GroupDescription)1 LinkDescription (org.eclipse.sirius.components.forms.description.LinkDescription)1 ListDescription (org.eclipse.sirius.components.forms.description.ListDescription)1 MultiSelectDescription (org.eclipse.sirius.components.forms.description.MultiSelectDescription)1 RadioDescription (org.eclipse.sirius.components.forms.description.RadioDescription)1 SelectDescription (org.eclipse.sirius.components.forms.description.SelectDescription)1 TextareaDescription (org.eclipse.sirius.components.forms.description.TextareaDescription)1 TextfieldDescription (org.eclipse.sirius.components.forms.description.TextfieldDescription)1 GroupElementProps (org.eclipse.sirius.components.forms.elements.GroupElementProps)1