use of com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType in project midpoint by Evolveum.
the class LinkedReferencePanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
IModel<DisplayType> displayModel = new ReadOnlyModel<>(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return null;
}
DisplayType displayType = GuiDisplayTypeUtil.getDisplayTypeForObject(ref.getObject(), null, getPageBase());
if (displayType == null) {
displayType = new DisplayType();
}
if (displayType.getIcon() == null) {
displayType.setIcon(WebComponentUtil.createIconType(WebComponentUtil.createDefaultBlackIcon(ref.getTargetType())));
}
return displayType;
});
ImagePanel imagePanel = new ImagePanel(ID_ICON, displayModel);
imagePanel.setOutputMarkupId(true);
add(imagePanel);
AjaxLink<PrismReferenceValue> nameLink = new AjaxLink<PrismReferenceValue>(ID_NAME, referenceModel) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
WebComponentUtil.dispatchToObjectDetailsPage(referenceModel.getObject(), LinkedReferencePanel.this, false);
}
};
nameLink.add(new EnableBehaviour(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return false;
}
return ref.getObject() != null;
}));
nameLink.setOutputMarkupId(true);
add(nameLink);
Label nameLinkText = new Label(ID_NAME_TEXT, new ReadOnlyModel<>(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return "";
}
return WebComponentUtil.getReferencedObjectDisplayNameAndName(ref.asReferencable(), false, getPageBase());
}));
nameLinkText.setOutputMarkupId(true);
nameLink.add(nameLinkText);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType in project midpoint by Evolveum.
the class CountIconPanel method initLayout.
private void initLayout() {
getModelObject().sort((d1, d2) -> {
if (d1 == null || d1.getIcon() == null || d1.getIcon().getCssClass() == null || d2 == null || d2.getIcon() == null || d2.getIcon().getCssClass() == null) {
return 0;
}
return d1.getIcon().getCssClass().compareTo(d2.getIcon().getCssClass());
});
ListView<DisplayType> iconsPanel = new ListView<DisplayType>(ID_ICONS, getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<DisplayType> item) {
Label icon = new Label(ID_ICON);
icon.add(AttributeModifier.replace("class", new PropertyModel<>(item.getModel(), "icon.cssClass")));
if (item.getModelObject() != null && item.getModelObject().getTooltip() != null) {
icon.add(AttributeModifier.replace("title", getPageBase().createStringResource(item.getModelObject().getTooltip().getOrig())));
}
icon.add(AttributeAppender.append("style", new ReadOnlyModel<>(() -> StringUtils.isNotBlank(getColor(item.getModelObject())) ? "color: " + getColor(item.getModelObject()) + ";" : "")));
icon.setOutputMarkupId(true);
icon.add(new VisibleBehaviour(() -> item.getModelObject() != null && item.getModelObject().getIcon() != null && StringUtils.isNotEmpty(item.getModelObject().getIcon().getCssClass())));
item.add(icon);
Integer count = icons.get(item.getModelObject());
Label countPanel = new Label(ID_COUNT, Model.of(count));
item.add(countPanel);
}
};
add(iconsPanel);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType 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);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType in project midpoint by Evolveum.
the class RelationSearchItem method createSpecialSearchPanel.
@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
return new SearchSpecialItemPanel(id, new PropertyModel<>(searchBoxConfiguration, SearchBoxConfigurationHelper.F_RELATION_ITEM)) {
@Override
protected WebMarkupContainer initSearchItemField(String id) {
ReadOnlyModel<List<QName>> availableRelations = new ReadOnlyModel<>(() -> {
List<QName> choices = new ArrayList();
IModel<RelationSearchItemConfigurationType> relationItem = getModelValue();
List<QName> relations = relationItem.getObject().getSupportedRelations();
if (relations != null && relations.size() > 1) {
choices.add(PrismConstants.Q_ANY);
}
choices.addAll(relations);
return choices;
});
DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, new PropertyModel(getModelValue(), RelationSearchItemConfigurationType.F_DEFAULT_VALUE.getLocalPart()), availableRelations, new QNameIChoiceRenderer() {
private static final long serialVersionUID = 1L;
@Override
public Object getDisplayValue(QName relation) {
RelationDefinitionType relationDef = WebComponentUtil.getRelationDefinition(relation);
if (relationDef != null) {
DisplayType display = relationDef.getDisplay();
if (display != null) {
PolyStringType label = display.getLabel();
if (PolyStringUtils.isNotEmpty(label)) {
return WebComponentUtil.getTranslatedPolyString(label);
}
}
}
if (QNameUtil.match(PrismConstants.Q_ANY, relation)) {
return new ResourceModel("RelationTypes.ANY", relation.getLocalPart()).getObject();
}
return super.getDisplayValue(relation);
}
}, false);
inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 100px; max-width: 400px !important;"));
inputPanel.getBaseFormComponent().add(new EnableBehaviour(() -> availableRelations.getObject().size() > 1));
inputPanel.setOutputMarkupId(true);
return inputPanel;
}
@Override
protected IModel<String> createLabelModel() {
return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getLabel()));
}
@Override
protected IModel<String> createHelpModel() {
return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getHelp()));
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType in project midpoint by Evolveum.
the class UserInterfaceFeatureFinder method getLabel.
// private RA find(Predicate<F> filter) {
// List<VirtualContainersSpecificationType> foundVirtualContainers = virtualContainersAsserter.getVirtualContainers()
// .stream()
// .filter(filter)
// .collect(Collectors.toList());
// Assertions.assertThat(foundVirtualContainers).hasSize(1);
// return new VirtualContainerSpecificationAsserter<>(foundVirtualContainers.iterator().next(), virtualContainersAsserter, "from list of virtual containers " + virtualContainersAsserter.getVirtualContainers());
// }
private PolyString getLabel(F container) {
DisplayType display = container.getDisplay();
if (display == null) {
return null;
}
PolyStringType label = display.getLabel();
if (label == null) {
return null;
}
return label.toPolyString();
}
Aggregations