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;
}
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);
}
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);
}
}
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);
}
}
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);
}
}
}
}
Aggregations