Search in sources :

Example 1 with EntityEditor

use of com.codename1.rad.ui.EntityEditor in project CodeRAD by shannah.

the class FieldEditorFormController method onStartController.

protected void onStartController() {
    super.onStartController();
    Form f = new Form(new BorderLayout());
    f.getToolbar().hideToolbar();
    Container titleBar = new Container(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
    titleBar.setSafeArea(true);
    titleBar.setUIID("TitleArea");
    if (hasBackCommand()) {
        Button back = new Button();
        FontImage.setIcon(back, FontImage.MATERIAL_ARROW_BACK_IOS, -1);
        titleBar.add(BorderLayout.WEST, back);
        back.addActionListener(evt -> {
            evt.consume();
            ActionSupport.dispatchEvent(new FormController.FormBackEvent(back));
        });
    }
    AppSectionController sectionCtl = getSectionController();
    if (sectionCtl != null) {
        Button done = new Button("Done");
        done.addActionListener(evt -> {
            evt.consume();
            ActionSupport.dispatchEvent(new AppSectionController.ExitSectionEvent(done));
        });
        titleBar.add(BorderLayout.EAST, done);
    }
    Label l = field.getLabel(entity.getEntity().getEntityType());
    if (l != null) {
        titleBar.add(BorderLayout.CENTER, new com.codename1.ui.Label(l.getValue(entity.getEntity()), "Title"));
    }
    f.add(BorderLayout.NORTH, titleBar);
    field.setAttributes(new LabelStyleAttribute(LabelStyle.None), new DescriptionStyleAttribute(DescriptionStyle.SpanLabel));
    UI ui = new UI() {

        {
            form(columns(1), field, editable(true));
        }
    };
    EntityEditor editor = new EntityEditor(entity, ui);
    editor.setScrollableY(true);
    f.add(BorderLayout.CENTER, editor);
    setView(f);
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.rad.models.Property.Label) Container(com.codename1.ui.Container) LabelStyleAttribute(com.codename1.rad.ui.EntityEditor.LabelStyleAttribute) DescriptionStyleAttribute(com.codename1.rad.ui.EntityEditor.DescriptionStyleAttribute) BorderLayout(com.codename1.ui.layouts.BorderLayout) UI(com.codename1.rad.ui.UI) Button(com.codename1.ui.Button) EntityEditor(com.codename1.rad.ui.EntityEditor)

Aggregations

Label (com.codename1.rad.models.Property.Label)1 EntityEditor (com.codename1.rad.ui.EntityEditor)1 DescriptionStyleAttribute (com.codename1.rad.ui.EntityEditor.DescriptionStyleAttribute)1 LabelStyleAttribute (com.codename1.rad.ui.EntityEditor.LabelStyleAttribute)1 UI (com.codename1.rad.ui.UI)1 Button (com.codename1.ui.Button)1 Container (com.codename1.ui.Container)1 Form (com.codename1.ui.Form)1 BorderLayout (com.codename1.ui.layouts.BorderLayout)1