Search in sources :

Example 1 with WidgetType

use of com.codename1.rad.attributes.WidgetType in project CodeRAD by shannah.

the class FieldEditor method build.

void build() {
    if (built) {
        return;
    }
    built = true;
    setLayout(BoxLayout.y());
    Property.Label lbl = field.getLabel(entity.getEntity().getEntityType());
    LabelStyle labelStyle = field.getLabelStyle(LabelStyle.Default);
    Property.Description description = field.getDescription(entity.getEntity().getEntityType());
    DescriptionStyle descriptionStyle = field.getDescriptionStyle(DescriptionStyle.HelpButton);
    Container above = new Container(new FlowLayout());
    above.stripMarginAndPadding();
    Container wrap = new Container(new BorderLayout());
    wrap.stripMarginAndPadding();
    if (lbl != null && labelStyle != LabelStyle.None) {
        above.add(new SpanLabel(lbl.getValue()));
        if (description != null) {
            switch(descriptionStyle) {
                case HelpButton:
                    above.add(new HelpButton(description.getValue()));
                    break;
                case SpanLabel:
                    SpanLabel descriptionSpanLabel = new SpanLabel(description.getValue(), "FieldDescriptionText");
                    above.add(descriptionSpanLabel);
                    break;
            }
        }
    } else {
        if (description != null) {
            Component descCmp = null;
            switch(descriptionStyle) {
                case HelpButton:
                    descCmp = new HelpButton(description.getValue());
                    wrap.add(BorderLayout.EAST, descCmp);
                    break;
                case SpanLabel:
                    descCmp = new SpanLabel(description.getValue(), "FieldDescriptionText");
                    above.add(descCmp);
                    break;
            }
            if (descCmp != null) {
            }
        }
    }
    WidgetType widgetType = field.getWidgetType(entity.getEntity().getEntityType());
    if (widgetType != null) {
        component = field.getViewFactory().createPropertyView(entity, field);
        wrap.add(BorderLayout.CENTER, component);
    } else {
        throw new IllegalStateException("Field " + field + " has not widget type");
    }
    Container topBar = new Container(BoxLayout.y());
    NodeUtilFunctions.buildTopActionsBar(field, topBar, entity);
    if (above.getComponentCount() > 0) {
        if (topBar.getComponentCount() > 0) {
            above = BorderLayout.centerEastWest(above, topBar, null);
        }
        add(above);
    } else {
        if (topBar.getComponentCount() > 0) {
            add(topBar);
        }
    }
    add(wrap);
    NodeUtilFunctions.buildBottomActionsBar(field, this, entity);
}
Also used : DescriptionStyle(com.codename1.rad.ui.EntityEditor.DescriptionStyle) FlowLayout(com.codename1.ui.layouts.FlowLayout) LabelStyle(com.codename1.rad.ui.EntityEditor.LabelStyle) SpanLabel(com.codename1.components.SpanLabel) Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) HelpButton(ca.weblite.shared.components.HelpButton) Component(com.codename1.ui.Component) WidgetType(com.codename1.rad.attributes.WidgetType) Property(com.codename1.rad.models.Property)

Aggregations

HelpButton (ca.weblite.shared.components.HelpButton)1 SpanLabel (com.codename1.components.SpanLabel)1 WidgetType (com.codename1.rad.attributes.WidgetType)1 Property (com.codename1.rad.models.Property)1 DescriptionStyle (com.codename1.rad.ui.EntityEditor.DescriptionStyle)1 LabelStyle (com.codename1.rad.ui.EntityEditor.LabelStyle)1 Component (com.codename1.ui.Component)1 Container (com.codename1.ui.Container)1 BorderLayout (com.codename1.ui.layouts.BorderLayout)1 FlowLayout (com.codename1.ui.layouts.FlowLayout)1