use of com.codename1.rad.attributes.IconUIID in project CodeRAD by shannah.
the class DefaultActionViewFactory method initUI.
public static void initUI(Button btn, Entity entity, ActionNode action) {
btn.setBlockLead(true);
boolean text = action.isTextStyle();
boolean includeIcon = action.isIconStyle();
UIID uiid = action.getUIID();
if (uiid != null) {
btn.setUIID(uiid.getValue(entity));
}
IconUIID iconUiid = action.getIconUIID();
if (iconUiid != null) {
btn.setIconUIID(iconUiid.getValue());
}
Button button = btn;
if (action.getLabel() != null && text) {
button.setText(action.getLabel().getValue(entity.getEntity()));
}
if (!text && button.getText().length() > 0) {
button.setText("");
}
if (action.getImageIcon() != null && includeIcon) {
button.setIcon(action.getImageIcon().getValue());
if (action.getSelected() != action && action.getSelected().getImageIcon() != action.getImageIcon()) {
button.setRolloverIcon(action.getSelected().getImageIcon().getValue());
}
if (action.getPressed() != action && action.getPressed().getImageIcon() != action.getImageIcon()) {
button.setPressedIcon(action.getPressed().getImageIcon().getValue());
}
if (action.getDisabled() != action && action.getDisabled().getImageIcon() != action.getImageIcon()) {
button.setDisabledIcon(action.getDisabled().getImageIcon().getValue());
}
}
if (action.getMaterialIcon() != null && includeIcon) {
char unselectedIcon = action.getMaterialIcon().getValue();
char selectedIcon = action.getSelected().getMaterialIcon().getValue();
char pressedIcon = action.getPressed().getMaterialIcon().getValue();
char selectedPressed = pressedIcon;
if (action.getPressed() == action) {
selectedPressed = selectedIcon;
}
char disabledIcon = action.getDisabled().getMaterialIcon().getValue();
// button.setMaterialIcon(action.getMaterialIcon().getValue());
FontImage.setMaterialIcon(btn, new char[] { unselectedIcon, selectedIcon, pressedIcon, selectedPressed, disabledIcon }, -1);
}
if (action.getTextIcon() != null && includeIcon) {
String iconText = action.getTextIcon().getValue(entity);
Button iconLabel = new Button(iconText);
if (btn.getIconStyleComponent() != btn) {
iconLabel.setUIID(btn.getIconStyleComponent().getUIID());
} else {
iconLabel.setUIID(btn.getUIID());
// IF the button has a border and padding set, we don't
// want to to also be applied to the icon.
iconLabel.getAllStyles().stripMarginAndPadding();
}
iconLabel.setWidth(iconLabel.getPreferredW());
iconLabel.setHeight(iconLabel.getPreferredH());
btn.setIcon(new ComponentImage(iconLabel, iconLabel.getWidth(), iconLabel.getHeight()));
}
if (includeIcon && text) {
ActionStyle style = action.getActionStyle();
if (style != null) {
switch(style) {
case IconTop:
button.setTextPosition(BOTTOM);
break;
case IconBottom:
button.setTextPosition(TOP);
break;
case IconLeft:
button.setTextPosition(RIGHT);
break;
case IconRight:
button.setTextPosition(LEFT);
}
}
}
button.addActionListener(evt -> {
action.fireEvent(entity, button);
update(button, entity, action);
});
update(button, entity, action);
action.decorateComponent(btn);
}
use of com.codename1.rad.attributes.IconUIID in project CodeRAD by shannah.
the class DefaultActionViewFactory method initUI.
public static void initUI(MultiButton btn, Entity entity, ActionNode action) {
btn.setBlockLead(true);
boolean text = action.isTextStyle();
boolean includeIcon = action.isIconStyle();
UIID uiid = action.getUIID();
if (uiid != null) {
btn.setUIID(uiid.getValue(entity));
}
IconUIID iconUiid = action.getIconUIID();
if (iconUiid != null) {
btn.setIconUIID(iconUiid.getValue());
}
MultiButton button = btn;
if (action.getLabel() != null && text) {
button.setTextLines(action.getLabel().getValue(entity.getEntity()));
}
if (action.getImageIcon() != null && includeIcon) {
button.setIcon(action.getImageIcon().getValue());
if (action.getSelected() != action && action.getSelected().getImageIcon() != action.getImageIcon()) {
button.setRolloverIcon(action.getSelected().getImageIcon().getValue());
}
if (action.getPressed() != action && action.getPressed().getImageIcon() != action.getImageIcon()) {
button.setPressedIcon(action.getPressed().getImageIcon().getValue());
}
if (action.getDisabled() != action && action.getDisabled().getImageIcon() != action.getImageIcon()) {
button.setDisabledIcon(action.getDisabled().getImageIcon().getValue());
}
}
if (action.getMaterialIcon() != null && includeIcon) {
char unselectedIcon = action.getMaterialIcon().getValue();
char selectedIcon = action.getSelected().getMaterialIcon().getValue();
char pressedIcon = action.getPressed().getMaterialIcon().getValue();
char selectedPressed = pressedIcon;
if (action.getPressed() == action) {
selectedPressed = selectedIcon;
}
char disabledIcon = action.getDisabled().getMaterialIcon().getValue();
// button.setMaterialIcon(action.getMaterialIcon().getValue());
FontImage.setMaterialIcon(btn, new char[] { unselectedIcon, selectedIcon, pressedIcon, selectedPressed, disabledIcon }, -1);
}
if (action.getTextIcon() != null && includeIcon) {
String iconText = action.getTextIcon().getValue(entity);
Button iconLabel = new Button(iconText);
if (btn.getIconStyleComponent() != btn) {
iconLabel.setUIID(btn.getIconStyleComponent().getUIID());
} else {
iconLabel.setUIID(btn.getUIID());
// IF the button has a border and padding set, we don't
// want to to also be applied to the icon.
iconLabel.getAllStyles().stripMarginAndPadding();
}
iconLabel.setWidth(iconLabel.getPreferredW());
iconLabel.setHeight(iconLabel.getPreferredH());
btn.setIcon(new ComponentImage(iconLabel, iconLabel.getWidth(), iconLabel.getHeight()));
}
if (includeIcon && text) {
ActionStyle style = action.getActionStyle();
if (style != null) {
switch(style) {
case IconTop:
button.setTextPosition(BOTTOM);
break;
case IconBottom:
button.setTextPosition(TOP);
break;
case IconLeft:
button.setTextPosition(RIGHT);
break;
case IconRight:
button.setTextPosition(LEFT);
}
}
}
if (!text) {
button.setText("");
}
button.addActionListener(evt -> {
action.fireEvent(entity, button);
update(button, entity, action);
});
update(button, entity, action);
action.decorateComponent(btn);
}
Aggregations