Search in sources :

Example 11 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class ItemApprovalHistoryPanel method initLayout.

private void initLayout(UserProfileStorage.TableId tableId, int pageSize) {
    add(new DecisionsPanel(ID_DECISIONS_DONE, new AbstractReadOnlyModel<List<DecisionDto>>() {

        @Override
        public List<DecisionDto> getObject() {
            List<DecisionDto> rv = new ArrayList<>();
            WfContextType wfContextType = getModelObject();
            if (wfContextType == null) {
                return rv;
            }
            if (!wfContextType.getEvent().isEmpty()) {
                wfContextType.getEvent().forEach(e -> addIgnoreNull(rv, DecisionDto.create(e, getPageBase())));
            } else {
                ItemApprovalProcessStateType instanceState = WfContextUtil.getItemApprovalProcessInfo(wfContextType);
                if (instanceState != null) {
                    instanceState.getDecisions().forEach(d -> addIgnoreNull(rv, DecisionDto.create(d)));
                }
            }
            return rv;
        }
    }, tableId, pageSize));
}
Also used : DecisionsPanel(com.evolveum.midpoint.web.component.wf.DecisionsPanel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ItemApprovalProcessStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ItemApprovalProcessStateType) DecisionDto(com.evolveum.midpoint.web.page.admin.workflow.dto.DecisionDto) ArrayList(java.util.ArrayList) WfContextType(com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType)

Example 12 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class TaskSummaryPanel method getTitle3Model.

@Override
protected IModel<String> getTitle3Model() {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (parentPage.getTaskDto().isWorkflow()) {
                String stageInfo = getStageInfo();
                if (stageInfo != null) {
                    return getString("TaskSummaryPanel.stage", stageInfo);
                } else {
                    return null;
                }
            }
            TaskType taskType = getModel().getObject();
            if (taskType == null) {
                return null;
            }
            long started = XmlTypeConverter.toMillis(taskType.getLastRunStartTimestamp());
            long finished = XmlTypeConverter.toMillis(taskType.getLastRunFinishTimestamp());
            if (started == 0) {
                return null;
            }
            if ((TaskExecutionStatus.RUNNABLE.equals(taskType.getExecutionStatus()) && taskType.getNodeAsObserved() != null) || finished == 0 || finished < started) {
                PatternDateConverter pdc = new PatternDateConverter(WebComponentUtil.getLocalizedDatePattern(DateLabelComponent.SHORT_MEDIUM_STYLE), true);
                String date = pdc.convertToString(new Date(started), WebComponentUtil.getCurrentLocale());
                return getString("TaskStatePanel.message.executionTime.notFinished", date, DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - started));
            } else {
                PatternDateConverter pdc = new PatternDateConverter(WebComponentUtil.getLocalizedDatePattern(DateLabelComponent.SHORT_MEDIUM_STYLE), true);
                String startedDate = pdc.convertToString(new Date(started), WebComponentUtil.getCurrentLocale());
                String finishedDate = pdc.convertToString(new Date(finished), WebComponentUtil.getCurrentLocale());
                return getString("TaskStatePanel.message.executionTime.finished", startedDate, finishedDate, DurationFormatUtils.formatDurationHMS(finished - started));
            }
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) PatternDateConverter(org.apache.wicket.datetime.PatternDateConverter) Date(java.util.Date)

Example 13 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class TaskWfParentPanel method initLayout.

private void initLayout(final IModel<TaskDto> taskDtoModel) {
    final PropertyModel<List<ProcessInstanceDto>> requestsModel = new PropertyModel<>(taskDtoModel, TaskDto.F_WORKFLOW_REQUESTS);
    final ISortableDataProvider<ProcessInstanceDto, String> requestsProvider = new ListDataProvider<>(this, requestsModel);
    processInstancesPanel = new ProcessInstancesPanel(ID_REQUESTS, requestsProvider, null, 10, ProcessInstancesPanel.View.TASKS_FOR_PROCESS, null);
    processInstancesPanel.setOutputMarkupId(true);
    add(processInstancesPanel);
    add(WebComponentUtil.createHelp(ID_REQUESTS_HELP));
    changesContainer = new WebMarkupContainer(ID_CHANGES_CONTAINER);
    for (int i = 1; i <= CHANGES_NUMBER; i++) {
        final int index = i;
        final String changesId = ID_CHANGES_PREFIX + i;
        final String changesContentId = changesId + ID_CHANGES_CONTENT_SUFFIX;
        final WebMarkupContainer changes = new WebMarkupContainer(changesId);
        final IModel<TaskChangesDto> changesModel = new AbstractReadOnlyModel<TaskChangesDto>() {

            @Override
            public TaskChangesDto getObject() {
                return taskDtoModel.getObject().getChangesForIndex(index);
            }
        };
        final TaskChangesPanel changesPanel = new TaskChangesPanel(changesContentId, changesModel);
        changes.add(changesPanel);
        changes.add(new VisibleEnableBehaviour() {

            @Override
            public boolean isVisible() {
                return changesModel.getObject() != null;
            }
        });
        changesContainer.add(changes);
    }
    changesContainer.setOutputMarkupId(true);
    add(changesContainer);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ProcessInstancesPanel(com.evolveum.midpoint.web.page.admin.workflow.ProcessInstancesPanel) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TaskChangesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskChangesDto)

Example 14 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel 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)

Example 15 with AbstractReadOnlyModel

use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.

the class PageTaskEdit method initLayout.

protected void initLayout() {
    refreshModel = new Model(new AutoRefreshDto());
    refreshModel.getObject().setInterval(getRefreshInterval());
    IModel<PrismObject<TaskType>> prismObjectModel = new AbstractReadOnlyModel<PrismObject<TaskType>>() {

        @Override
        public PrismObject<TaskType> getObject() {
            return objectWrapperModel.getObject().getObject();
        }
    };
    final TaskSummaryPanel summaryPanel = new TaskSummaryPanel(ID_SUMMARY_PANEL, prismObjectModel, refreshModel, this);
    summaryPanel.setOutputMarkupId(true);
    add(summaryPanel);
    mainPanel = new TaskMainPanel(ID_MAIN_PANEL, objectWrapperModel, taskDtoModel, showAdvancedFeaturesModel, this);
    mainPanel.setOutputMarkupId(true);
    add(mainPanel);
    summaryPanel.getRefreshPanel().startRefreshing(this, null);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AutoRefreshDto(com.evolveum.midpoint.web.component.refresh.AutoRefreshDto)

Aggregations

AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)52 ArrayList (java.util.ArrayList)22 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)22 Label (org.apache.wicket.markup.html.basic.Label)21 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)20 List (java.util.List)16 ListItem (org.apache.wicket.markup.html.list.ListItem)12 ListView (org.apache.wicket.markup.html.list.ListView)12 IModel (org.apache.wicket.model.IModel)12 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)10 PropertyModel (org.apache.wicket.model.PropertyModel)8 AttributeModifier (org.apache.wicket.AttributeModifier)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 Model (org.apache.wicket.model.Model)6 Task (com.evolveum.midpoint.task.api.Task)5 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 TooltipBehavior (de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior)4