use of com.codename1.rad.ui.EntityEditor.DescriptionStyle 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);
}
Aggregations