use of com.evolveum.midpoint.gui.impl.prism.panel.PrismReferencePanel in project midpoint by Evolveum.
the class SchrodingerComponentInitListener method handleLocalization.
private void handleLocalization(Component component) {
if (component instanceof PrismPropertyPanel || component instanceof PrismReferencePanel) {
ItemPanel ppp = (ItemPanel) component;
ItemWrapper iw = (ItemWrapper) ppp.getModel().getObject();
String key = iw.getDisplayName();
QName qname = iw.getItemName();
writeDataAttribute(component, ATTR_RESOURCE_KEY, key);
writeDataAttribute(component, ATTR_QNAME, qnameToString(qname));
return;
}
if (component instanceof PrismHeaderPanel) {
PrismHeaderPanel php = (PrismHeaderPanel) component;
String key = php.getLabel();
writeDataAttribute(component, ATTR_RESOURCE_KEY, key);
return;
}
IModel model = null;
if (component.getDefaultModel() instanceof StringResourceModel) {
model = component.getDefaultModel();
} else if (component.getInnermostModel() instanceof StringResourceModel) {
model = component.getInnermostModel();
} else if (component.getDefaultModel() instanceof ReadOnlyModel) {
try {
if (component.getDefaultModelObject() instanceof String) {
model = component.getDefaultModel();
}
} catch (Exception e) {
LOGGER.error("Schrodinger localization handling failed", e);
}
}
if (model == null) {
return;
}
try {
String key = model instanceof StringResourceModel ? (String) FieldUtils.readField(model, "resourceKey", true) : (String) model.getObject();
if (key.startsWith("${")) {
String expression = key.substring(2, key.length() - 1);
key = new PropertyModel<String>(FieldUtils.readField(model, "model", true), expression).getObject();
}
if (key != null) {
writeDataAttribute(component, ATTR_RESOURCE_KEY, key);
}
} catch (Exception ex) {
// we don't care, should be all right, unless selenium tests starts failing
}
}
Aggregations