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));
}
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));
}
}
};
}
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);
}
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;
}
});
}
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);
}
Aggregations