Search in sources :

Example 1 with Label

use of com.codename1.rad.models.Property.Label in project CodeRAD by shannah.

the class DefaultTableCellRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(Table table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Label out = new Label();
    String strVal = value == null ? "" : String.valueOf(value);
    out.setText(strVal);
    if (isSelected) {
        $(out).setBgColor(0xff0000).setBgTransparency(0xff);
    }
    $(out).setMargin(0);
    return out;
}
Also used : Label(com.codename1.ui.Label)

Example 2 with Label

use of com.codename1.rad.models.Property.Label 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)

Example 3 with Label

use of com.codename1.rad.models.Property.Label in project CodeRAD by shannah.

the class FormController method setView.

/**
 * Overrides parent setView().  Delegates to {@link #setView(com.codename1.ui.Form) } if cmp is
 * a form.  Throws IllegalArgumentException otherwise.
 * @param cmp
 */
public void setView(Component cmp) {
    if (cmp == null) {
        setView((Form) null);
        return;
    }
    Form currView = getView();
    if (currView != null) {
        currView.removeShowListener(showListener());
    }
    if (cmp instanceof Form) {
        ((Form) cmp).addShowListener(showListener());
        setView((Form) cmp);
    } else {
        Form f = new Form(new BorderLayout()) {

            @Override
            public void setTitle(String title) {
                super.setTitle(title);
                if (titleLbl != null) {
                    titleLbl.setText(title);
                    revalidateLater();
                }
            }

            @Override
            public void layoutContainer() {
                super.layoutContainer();
                if (true)
                    return;
                int maxLeftX = 0;
                ComponentSelector cmps = $(".left-inset", this);
                for (Component c : cmps) {
                    if (!c.isVisible() || c.isHidden() || c.getWidth() == 1 || c.getHeight() == 0) {
                        continue;
                    }
                    Component wrap = $(c).parents(".left-edge").first().asComponent();
                    if (wrap == null) {
                        continue;
                    }
                    int thisLeftX = c.getAbsoluteX() + c.getStyle().getPaddingLeftNoRTL() - wrap.getAbsoluteX();
                    maxLeftX = Math.max(maxLeftX, thisLeftX);
                }
                for (Component c : cmps) {
                    if (!c.isVisible() || c.isHidden() || c.getWidth() == 1 || c.getHeight() == 0) {
                        continue;
                    }
                    Component wrap = $(c).parents(".left-edge").first().asComponent();
                    if (wrap == null) {
                        continue;
                    }
                    int absX = c.getAbsoluteX() + c.getStyle().getPaddingLeftNoRTL() - wrap.getAbsoluteX();
                    if (absX < maxLeftX) {
                        int marginLeft = c.getStyle().getMarginLeftNoRTL();
                        c.getAllStyles().setMarginUnitLeft(Style.UNIT_TYPE_PIXELS);
                        c.getAllStyles().setMarginLeft(marginLeft + maxLeftX - absX);
                    }
                }
            }
        };
        boolean hasTitle = !addTitleBar;
        Component titleBarEast = null;
        Component titleBarWest = null;
        if (!hasTitle) {
            for (Component c : $("*", cmp).add(cmp, true)) {
                if (c instanceof CollapsibleHeaderContainer) {
                    hasTitle = true;
                    break;
                }
                if ("Title".equals(c)) {
                    hasTitle = true;
                    break;
                }
                if ("TitleBarEast".equalsIgnoreCase(c.getName())) {
                    titleBarEast = c;
                } else if ("TitleBarWest".equalsIgnoreCase(c.getName())) {
                    titleBarWest = c;
                }
            }
        }
        if (titleBarEast != null)
            titleBarEast.remove();
        if (titleBarWest != null)
            titleBarWest.remove();
        f.addShowListener(showListener());
        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);
            titleBarWest = titleBarWest == null ? back : BoxLayout.encloseX(back, titleBarWest);
            // 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));
            });
            titleBarEast = titleBarEast == null ? done : BoxLayout.encloseX(titleBarEast, done);
        // titleBar.add(BorderLayout.EAST, done);
        }
        if (titleComponent != null) {
            titleBar.add(BorderLayout.CENTER, titleComponent);
        } else {
            titleLbl = new Label();
            titleLbl.setUIID("Title");
            if (getTitle() != null) {
                titleLbl.setText(getTitle());
            }
            titleBar.add(BorderLayout.CENTER, titleLbl);
        }
        if (titleBarEast != null)
            titleBar.add(BorderLayout.EAST, titleBarEast);
        if (titleBarWest != null)
            titleBar.add(BorderLayout.WEST, titleBarWest);
        if (!hasTitle)
            f.add(BorderLayout.NORTH, titleBar);
        f.add(BorderLayout.CENTER, decorateView(cmp));
        f.revalidateLater();
        setView(f);
    }
}
Also used : Form(com.codename1.ui.Form) ComponentSelector(com.codename1.ui.ComponentSelector) Label(com.codename1.ui.Label) CollapsibleHeaderContainer(ca.weblite.shared.components.CollapsibleHeaderContainer) Container(com.codename1.ui.Container) CollapsibleHeaderContainer(ca.weblite.shared.components.CollapsibleHeaderContainer) BorderLayout(com.codename1.ui.layouts.BorderLayout) Button(com.codename1.ui.Button) Component(com.codename1.ui.Component)

Example 4 with Label

use of com.codename1.rad.models.Property.Label in project CodeRAD by shannah.

the class NodeUtilFunctions method buildActionsBar.

static void buildActionsBar(Node node, Container target, Entity entity, Actions right, Actions left, Actions overflow, Actions middle) {
    Container actionsBar = new Container(new BorderLayout());
    Container actionsBarRight = new Container(new BorderLayout());
    if (middle != null && middle.size() > 0) {
        GridLayout layout = new GridLayout(middle.size());
        Container cnt = new Container(layout);
        middle.addToContainer(cnt, entity);
        actionsBar.add(BorderLayout.CENTER, cnt);
    }
    if (left != null) {
        Container cnt = new Container(BoxLayout.x());
        for (ActionNode action : left) {
            cnt.add(action.getViewFactory().createActionView(entity, action));
        }
        if (actionsBar.getComponentCount() > 0) {
            actionsBar.add(BorderLayout.WEST, cnt);
        } else {
            actionsBar.add(BorderLayout.CENTER, cnt);
        }
    }
    if (right != null) {
        Container cnt = new Container(BoxLayout.x());
        $(cnt).setAlignment(RIGHT);
        for (ActionNode action : right) {
            // System.out.println("right node "+action);
            cnt.add(action.getViewFactory().createActionView(entity, action));
        }
        // System.out.println("Adding to right "+cnt);
        actionsBarRight.add(BorderLayout.CENTER, cnt);
    }
    if (overflow != null && !overflow.isEmpty()) {
        PopupMenu popup = new PopupMenu();
        for (ActionNode action : overflow) {
            Property.Label label = action.getLabel();
            String labelStr = label != null ? label.getValue() : "";
            Command cmd = new Command(labelStr) {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    action.fireEvent(entity, target);
                }
            };
            if (action.getImageIcon() != null) {
                cmd.setIcon(action.getImageIcon().getValue());
            } else if (action.getMaterialIcon() != null) {
                cmd.setMaterialIcon(action.getMaterialIcon().getValue());
            }
            popup.addCommand(cmd);
        }
        actionsBarRight.add(BorderLayout.EAST, new Button(popup.getCommand()));
    }
    if (actionsBarRight.getComponentCount() > 0) {
        actionsBar.add(BorderLayout.EAST, actionsBarRight);
    }
    if (actionsBar.getComponentCount() > 0) {
        target.add(actionsBar);
    }
}
Also used : Container(com.codename1.ui.Container) GridLayout(com.codename1.ui.layouts.GridLayout) BorderLayout(com.codename1.ui.layouts.BorderLayout) Command(com.codename1.ui.Command) Button(com.codename1.ui.Button) ActionEvent(com.codename1.ui.events.ActionEvent) ActionNode(com.codename1.rad.nodes.ActionNode) Property(com.codename1.rad.models.Property) PopupMenu(ca.weblite.shared.components.PopupMenu)

Example 5 with Label

use of com.codename1.rad.models.Property.Label in project CodeRAD by shannah.

the class TextAreaPropertyView method update.

@Override
public void update() {
    super.update();
    String oldVal = getComponent().getText();
    String newVal = ContentType.convert(getProperty().getContentType(), getProperty().getValue(getEntity().getEntity()), ContentType.Text);
    TextFormatterAttribute formatter = (TextFormatterAttribute) getField().findAttribute(TextFormatterAttribute.class);
    if (formatter != null) {
        newVal = formatter.getValue().format(newVal);
    }
    if (!Objects.equals(oldVal, newVal)) {
        getComponent().setText(newVal);
    }
    HintUIID hintUiid = (HintUIID) getField().findAttribute(HintUIID.class);
    if (hintUiid != null) {
        Label hintLabel = getComponent().getHintLabel();
        if (hintLabel != null) {
            String oldUiid = hintLabel.getUIID();
            String newUiidStr = hintUiid.getValue(getEntity());
            if (newUiidStr != null && !Objects.equals(oldUiid, newUiidStr)) {
                hintLabel.setUIID(newUiidStr);
            }
        }
    }
}
Also used : HintUIID(com.codename1.rad.attributes.HintUIID) Label(com.codename1.ui.Label) TextFormatterAttribute(com.codename1.rad.models.TextFormatterAttribute)

Aggregations

Label (com.codename1.ui.Label)129 Form (com.codename1.ui.Form)95 Button (com.codename1.ui.Button)50 BorderLayout (com.codename1.ui.layouts.BorderLayout)50 Container (com.codename1.ui.Container)49 Component (com.codename1.ui.Component)27 SpanLabel (com.codename1.components.SpanLabel)26 Style (com.codename1.ui.plaf.Style)24 BoxLayout (com.codename1.ui.layouts.BoxLayout)19 TextArea (com.codename1.ui.TextArea)18 ActionEvent (com.codename1.ui.events.ActionEvent)18 IOException (java.io.IOException)18 Image (com.codename1.ui.Image)17 Dimension (com.codename1.ui.geom.Dimension)16 TextField (com.codename1.ui.TextField)15 ActionListener (com.codename1.ui.events.ActionListener)15 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)15 Toolbar (com.codename1.ui.Toolbar)13 FlowLayout (com.codename1.ui.layouts.FlowLayout)12 EncodedImage (com.codename1.ui.EncodedImage)11