use of com.codename1.rad.attributes.IconRendererAttribute in project CodeRAD by shannah.
the class MultiButtonEntityView method update.
@Override
public void update() {
EntityType type = getEntity().getEntity().getEntityType();
boolean changed = false;
if (line1PropDirty) {
line1PropDirty = false;
line1Prop = line1Prop == null ? type.findProperty(line1, Thing.name) : line1Prop;
if (line1Prop != null) {
String text = type.getText(line1Prop, entity.getEntity());
if (!Objects.equals(text, getTextLine1())) {
setTextLine1(text);
changed = true;
}
}
}
if (line2PropDirty) {
line2PropDirty = false;
line2Prop = line2Prop == null ? type.findProperty(line2, Thing.description) : line2Prop;
if (line2Prop != null) {
String text = type.getText(line2Prop, entity.getEntity());
if (!Objects.equals(text, getTextLine2())) {
setTextLine2(text);
changed = true;
}
}
}
if (line3PropDirty) {
line3PropDirty = false;
line3Prop = line3Prop == null ? type.findProperty(line3) : line3Prop;
if (line3Prop != null) {
String text = type.getText(line3Prop, entity.getEntity());
if (!Objects.equals(text, getTextLine3())) {
setTextLine3(text);
changed = true;
}
}
}
if (line4PropDirty) {
line4PropDirty = false;
line4Prop = line4Prop == null ? type.findProperty(line4) : line4Prop;
if (line4Prop != null) {
String text = type.getText(line4Prop, entity.getEntity());
if (!Objects.equals(text, getTextLine4())) {
setTextLine4(text);
changed = true;
}
}
}
if (iconDirty) {
iconDirty = false;
Property iconProp = this.iconProp != null ? this.iconProp : type.findProperty(icon);
this.iconProp = iconProp;
if (iconProp != null) {
Object iconData = iconProp.getValue(getEntity().getEntity());
if (iconData != null) {
IconRendererAttribute iconRendererAtt = (IconRendererAttribute) viewNode.findInheritedAttribute(IconRendererAttribute.class);
EntityImageRenderer iconRenderer = iconRendererAtt == null ? new DefaultEntityImageRenderer() : iconRendererAtt.getValue();
iconRenderer.createImage(this, iconProp, 0, false, false).ready(im -> {
setIcon(im);
revalidateLater();
});
}
}
}
if (changed) {
revalidateLater();
}
}
Aggregations