use of com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor in project midpoint by Evolveum.
the class SceneItemValuePanel method initLayout.
private void initLayout() {
final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return hasValidReferenceValue(object);
}
};
final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return !hasValidReferenceValue(object);
}
};
IModel<DisplayType> displayModel = (IModel) () -> {
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor();
String cssClass = ObjectTypeGuiDescriptor.ERROR_ICON;
String title = null;
if (guiDescriptor != null) {
cssClass = guiDescriptor.getBlackIcon();
title = createStringResource(guiDescriptor.getLocalizationKey()).getObject();
}
return GuiDisplayTypeUtil.createDisplayType(cssClass, "", title);
};
final ImagePanel icon = new ImagePanel(ID_ICON, displayModel);
icon.add(visibleIfReference);
add(icon);
final Label label = new Label(ID_LABEL, new LabelModel());
label.add(visibleIfNotReference);
add(label);
final AjaxLinkPanel link = new AjaxLinkPanel(ID_LINK, new LabelModel()) {
@Override
public void onClick(AjaxRequestTarget target) {
if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
return;
}
PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
if (refValue == null) {
return;
}
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue(refValue);
WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);
}
};
link.add(visibleIfReference);
add(link);
final Label additionalText = new Label(ID_ADDITIONAL_TEXT, new IModel<String>() {
@Override
public String getObject() {
return getModelObject() != null ? getModelObject().getAdditionalText() : null;
}
});
add(additionalText);
}
Aggregations