use of com.evolveum.midpoint.gui.api.model.ReadOnlyModel in project midpoint by Evolveum.
the class PrismValueMetadataPanel method createMetadataNavigationPanel.
private void createMetadataNavigationPanel() {
WebMarkupContainer metadataNavigation = new WebMarkupContainer(ID_METADATA_NAVIGATION);
add(metadataNavigation);
metadataNavigation.setOutputMarkupId(true);
ListView<ContainersPopupDto> metadataList = new ListView<ContainersPopupDto>(ID_METADATA_LIST, createMetadataListModel()) {
@Override
protected void populateItem(ListItem<ContainersPopupDto> listItem) {
AjaxButton showMetadataDetails = new AjaxButton(ID_METADATA_QNAME, createStringResource(listItem.getModelObject().getItemName())) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
ContainersPopupDto ccontainerToShow = listItem.getModelObject();
ccontainerToShow.setSelected(true);
setContainersToShow(ccontainerToShow, ajaxRequestTarget);
}
};
showMetadataDetails.add(AttributeAppender.replace("class", createButtonClassModel(listItem)));
showMetadataDetails.setOutputMarkupId(true);
showMetadataDetails.setOutputMarkupPlaceholderTag(true);
listItem.setOutputMarkupId(true);
listItem.add(showMetadataDetails);
}
};
metadataNavigation.add(metadataList);
ReadOnlyModel<String> activeTab = new ReadOnlyModel<>(() -> {
if (getValueMetadata() != null && isAnyMetadataSelected()) {
return "contains-active-tab";
}
return "";
});
metadataNavigation.add(AttributeAppender.replace("class", activeTab));
metadataList.setOutputMarkupId(true);
metadataList.setOutputMarkupPlaceholderTag(true);
}
use of com.evolveum.midpoint.gui.api.model.ReadOnlyModel in project midpoint by Evolveum.
the class StatisticsPanel method initLayout.
protected void initLayout() {
contentsPanel = new WebMarkupContainer(ID_CONTENTS_PANEL);
contentsPanel.setOutputMarkupId(true);
add(contentsPanel);
ListView<ProvisioningStatisticsLineDto> provisioningLines = new ListView<>(ID_PROVISIONING_STATISTICS_LINES, new PropertyModel<>(getModel(), StatisticsDto.F_PROVISIONING_LINES)) {
protected void populateItem(final ListItem<ProvisioningStatisticsLineDto> item) {
ListDataProvider<ProvisioningStatisticsOperationDto> provider = new ListDataProvider<>(StatisticsPanel.this, new PropertyModel<>(item.getModel(), ProvisioningStatisticsLineDto.F_OPERATIONS));
BoxedTablePanel<ProvisioningStatisticsOperationDto> provisioningTable = new BoxedTablePanel<>(ID_PROVISIONING_OPERATIONS, provider, createProvisioningStatisticsColumns()) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new ProvisioningStatisticsHeaderFragment(headerId, ID_PROVISIONING_TITLE, StatisticsPanel.this, item.getModel());
}
@Override
protected Item<ProvisioningStatisticsOperationDto> customizeNewRowItem(Item<ProvisioningStatisticsOperationDto> item, IModel<ProvisioningStatisticsOperationDto> model) {
item.add(AttributeModifier.append("class", new ReadOnlyModel<>(() -> {
if (model.getObject() != null && OperationResultStatusType.FATAL_ERROR == model.getObject().getStatus()) {
return "bg-red disabled color-palette";
}
return null;
})));
return item;
}
@Override
protected boolean hideFooterIfSinglePage() {
return true;
}
};
provisioningTable.setOutputMarkupId(true);
provisioningTable.add(new VisibleBehaviour(() -> hasAnyOperation(item.getModelObject())));
item.add(provisioningTable);
}
};
contentsPanel.add(provisioningLines);
ListDataProvider<MappingsLineDto> mappingsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_MAPPINGS_LINES));
BoxedTablePanel<MappingsLineDto> mappingsLines = new BoxedTablePanel<>(ID_MAPPINGS_STATISTICS_LINES, mappingsProvider, createMappingsColumn()) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new TableHeaderFragment(headerId, ID_MAPPINGS_TITLE, StatisticsPanel.this, createStringResource("Title.MappingsStatistics"));
}
@Override
protected boolean hideFooterIfSinglePage() {
return true;
}
};
mappingsLines.setOutputMarkupId(true);
contentsPanel.add(mappingsLines);
ListDataProvider<NotificationsLineDto> notificationsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_NOTIFICATIONS_LINES));
BoxedTablePanel<NotificationsLineDto> notificationsLines = new BoxedTablePanel<>(ID_NOTIFICATIONS_STATISTICS_LINES, notificationsProvider, createNotificationColumns()) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new TableHeaderFragment(headerId, ID_NOTIFICATIONS_TITLE, StatisticsPanel.this, createStringResource("Title.NotificationsStatistics"));
}
@Override
protected boolean hideFooterIfSinglePage() {
return true;
}
};
notificationsLines.setOutputMarkupId(true);
contentsPanel.add(notificationsLines);
Label lastMessage = new Label(ID_LAST_MESSAGE, new PropertyModel<>(getModel(), StatisticsDto.F_LAST_MESSAGE));
contentsPanel.add(lastMessage);
}
use of com.evolveum.midpoint.gui.api.model.ReadOnlyModel in project midpoint by Evolveum.
the class SideBarMenuPanel method createHeader.
private Component createHeader(IModel<SideBarMenuItem> model) {
WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
header.add(new AjaxEventBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
onMenuClick(model);
}
});
header.add(AttributeAppender.append("class", new ReadOnlyModel<>(() -> isMenuExpanded(model.getObject()) ? "" : "closed")));
Label name = new Label(ID_NAME, new StringResourceModel("${name}", model));
header.add(name);
return header;
}
use of com.evolveum.midpoint.gui.api.model.ReadOnlyModel 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.gui.api.model.ReadOnlyModel in project midpoint by Evolveum.
the class TaskResultTabPanel method initLayout.
private void initLayout() {
IModel<List<OperationResult>> resultModel = new ReadOnlyModel<>(() -> createOperationResultList());
SelectableListDataProvider<SelectableBean<OperationResult>, OperationResult> provider = new SelectableListDataProvider<>(this, resultModel);
BoxedTablePanel<SelectableBean<OperationResult>> resultTablePanel = new BoxedTablePanel<>(ID_OPERATION_RESULT, provider, initResultColumns());
resultTablePanel.setOutputMarkupId(true);
add(resultTablePanel);
AjaxFallbackLink<Void> showResult = new AjaxFallbackLink<Void>(ID_SHOW_RESULT) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(Optional<AjaxRequestTarget> optionalTarget) {
if (!optionalTarget.isPresent()) {
LOGGER.warn("Cannot show result in interactive way, request target not present.");
return;
}
AjaxRequestTarget target = optionalTarget.get();
PrismObjectWrapper<TaskType> taskWrapper = TaskResultTabPanel.this.getModelObject();
TaskType taskType = taskWrapper.getObject().asObjectable();
OperationResult opResult = OperationResult.createOperationResult(taskType.getResult());
OpResult result = opResult != null ? OpResult.getOpResult(getPageBase(), opResult) : null;
OperationResultPanel body = new OperationResultPanel(getPageBase().getMainPopupBodyId(), new Model<>(result));
body.add(new VisibleBehaviour(() -> opResult != null));
body.setOutputMarkupId(true);
getPageBase().showMainPopup(body, target);
}
};
showResult.setOutputMarkupId(true);
add(showResult);
}
Aggregations