Search in sources :

Example 1 with ActionsExecutedInformationDto

use of com.evolveum.midpoint.web.page.admin.server.dto.ActionsExecutedInformationDto in project midpoint by Evolveum.

the class ActionsExecutedInformationPanel method initLayout.

protected void initLayout() {
    WebMarkupContainer tableLinesContainer = new WebMarkupContainer(ID_OBJECTS_TABLE_LINES_CONTAINER);
    ListView tableLines = new ListView<ActionsExecutedObjectsTableLineDto>(ID_OBJECTS_TABLE_LINES, new AbstractReadOnlyModel<List<ActionsExecutedObjectsTableLineDto>>() {

        @Override
        public List<ActionsExecutedObjectsTableLineDto> getObject() {
            final ActionsExecutedInformationDto modelObject = getModelObject();
            if (modelObject == null) {
                return new ArrayList<>();
            }
            if (showResultingActionsOnly) {
                return modelObject.getUniqueObjectsTableLines();
            } else {
                return modelObject.getObjectsTableLines();
            }
        }
    }) {

        protected void populateItem(final ListItem<ActionsExecutedObjectsTableLineDto> item) {
            item.add(new Label(ID_OBJECT_TYPE, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    String key = item.getModelObject().getObjectTypeLocalizationKey();
                    if (key != null) {
                        return createStringResource(key).getString();
                    } else {
                        return item.getModelObject().getObjectType().getLocalPart();
                    }
                }
            }));
            item.add(new Label(ID_OPERATION, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return createStringResource(item.getModelObject().getOperation()).getString();
                }
            }));
            item.add(new Label(ID_CHANNEL, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    String channel = item.getModelObject().getChannel();
                    if (channel != null && !channel.isEmpty()) {
                        String key = "Channel." + channel;
                        return createStringResource(key).getString();
                    } else {
                        return "";
                    }
                }
            }));
            item.add(new Label(ID_SUCCESS_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_SUCCESS_COUNT)));
            item.add(new Label(ID_LAST_SUCCESS_OBJECT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_OBJECT)));
            item.add(new Label(ID_LAST_SUCCESS_TIMESTAMP, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_TIMESTAMP)));
            item.add(new Label(ID_FAILURE_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_FAILURE_COUNT)));
        }
    };
    tableLinesContainer.add(tableLines);
    tableLinesContainer.setOutputMarkupId(true);
    add(tableLinesContainer);
    final Label showResultingActionsOnlyLabel = new Label(ID_SHOW_RESULTING_ACTIONS_ONLY_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return showResultingActionsOnly ? createStringResource("ActionsExecutedInformationPanel.showingResultingActionsOnly").getString() : createStringResource("ActionsExecutedInformationPanel.showingAllActions").getString();
        }
    });
    showResultingActionsOnlyLabel.setOutputMarkupId(true);
    add(showResultingActionsOnlyLabel);
    add(new AjaxFallbackLink<String>(ID_SHOW_RESULTING_ACTIONS_ONLY_LINK) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            showResultingActionsOnly = !showResultingActionsOnly;
            ajaxRequestTarget.add(ActionsExecutedInformationPanel.this);
        }
    });
    add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject() != null;
        }
    });
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ActionsExecutedInformationDto(com.evolveum.midpoint.web.page.admin.server.dto.ActionsExecutedInformationDto) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 ActionsExecutedInformationDto (com.evolveum.midpoint.web.page.admin.server.dto.ActionsExecutedInformationDto)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1 PropertyModel (org.apache.wicket.model.PropertyModel)1