/** * Returns a label representing the alert type. * * @param alert the alert * @return a label for the alert type */ private Label getAlertType(Alert alert) { Label result = LabelFactory.create(); result.setText(alert.getAlertType().getName()); IMObjectBean bean = new IMObjectBean(alert.getAlertType()); Color value = ColourHelper.getColor(bean.getString("colour")); if (value != null) { TableLayoutData layout = new TableLayoutData(); layout.setBackground(value); result.setForeground(ColourHelper.getTextColour(value)); result.setLayoutData(layout); } return result; }
/** * Sets the background/foreground of the alert type field, if it is a text field. * * @param alertType the alert type * @param component the component to display the alert type */ private void initAlertType(Lookup alertType, Component component) { if (component instanceof TextField) { Color background = AlertHelper.getColour(alertType); Color foreground = ColourHelper.getTextColour(background); component.setBackground(background); component.setForeground(foreground); } }