use of com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses in project midpoint by Evolveum.
the class PageCertDecisions method initColumns.
// private void addVisibleOnWarningBehavior(Component c) {
// c.add(new VisibleEnableBehaviour() {
// @Override
// public boolean isVisible() {
// return PageCertDecisions.this.getFeedbackMessages().hasMessage(FeedbackMessage.WARNING);
// }
// });
// }
private List<IColumn<CertWorkItemDto, String>> initColumns() {
List<IColumn<CertWorkItemDto, String>> columns = new ArrayList<>();
IColumn<CertWorkItemDto, String> column;
column = new CheckBoxHeaderColumn<>();
columns.add(column);
column = helper.createTypeColumn(OBJECT, this);
columns.add(column);
column = helper.createObjectNameColumn(this, "PageCertDecisions.table.objectName");
columns.add(column);
column = helper.createTypeColumn(TARGET, this);
columns.add(column);
column = helper.createTargetNameColumn(this, "PageCertDecisions.table.targetName");
columns.add(column);
if (isDisplayingAllItems()) {
column = helper.createReviewerNameColumn(this, "PageCertDecisions.table.reviewer");
columns.add(column);
}
column = helper.createDetailedInfoColumn(this);
columns.add(column);
column = helper.createConflictingNameColumn(this, "PageCertDecisions.table.conflictingTargetName");
columns.add(column);
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_CERTIFICATION_ALL_URL, AuthorizationConstants.AUTZ_UI_CERTIFICATION_CAMPAIGN_URL)) {
column = new AjaxLinkColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME, CertWorkItemDto.F_CAMPAIGN_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
super.populateItem(item, componentId, rowModel);
AccessCertificationCampaignType campaign = rowModel.getObject().getCampaign();
if (campaign != null && campaign.getDescription() != null) {
item.add(AttributeModifier.replace("title", campaign.getDescription()));
item.add(new TooltipBehavior());
}
}
@Override
public void onClick(AjaxRequestTarget target, IModel<CertWorkItemDto> rowModel) {
CertWorkItemDto dto = rowModel.getObject();
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, dto.getCampaignRef().getOid());
navigateToNext(PageCertCampaign.class, parameters);
}
};
} else {
column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
item.add(new Label(componentId, new IModel<Object>() {
@Override
public Object getObject() {
return rowModel.getObject().getCampaignName();
}
}));
}
};
}
columns.add(column);
column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.iteration"), CertCaseOrWorkItemDto.F_ITERATION) {
private static final long serialVersionUID = 1L;
@Override
public String getCssClass() {
return "countLabel";
}
};
columns.add(column);
column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignStage")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
item.add(new Label(componentId, new IModel<String>() {
@Override
public String getObject() {
CertWorkItemDto dto = rowModel.getObject();
return dto.getCampaignStageNumber() + "/" + dto.getCampaignStageCount();
}
}));
String stageName = rowModel.getObject().getCurrentStageName();
if (stageName != null) {
item.add(AttributeModifier.replace("title", stageName));
item.add(new TooltipBehavior());
}
}
@Override
public String getCssClass() {
return "countLabel";
}
};
columns.add(column);
column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.escalation")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
item.add(new Label(componentId, new IModel<String>() {
@Override
public String getObject() {
CertWorkItemDto dto = rowModel.getObject();
Integer n = dto.getEscalationLevelNumber();
return n != null ? String.valueOf(n) : null;
}
}));
String info = rowModel.getObject().getEscalationLevelInfo();
if (info != null) {
item.add(AttributeModifier.replace("title", info));
item.add(new TooltipBehavior());
}
}
@Override
public String getCssClass() {
return "countLabel";
}
};
columns.add(column);
column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.requested"), SearchingUtils.CURRENT_REVIEW_REQUESTED_TIMESTAMP, CertWorkItemDto.F_REVIEW_REQUESTED) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
super.populateItem(item, componentId, rowModel);
CertWorkItemDto dto = rowModel.getObject();
Date started = dto.getStageStarted();
if (started != null) {
item.add(AttributeModifier.replace("title", WebComponentUtil.getShortDateTimeFormattedValue(started, PageCertDecisions.this)));
item.add(new TooltipBehavior());
}
}
};
columns.add(column);
column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.deadline"), SearchingUtils.CURRENT_REVIEW_DEADLINE, CertWorkItemDto.F_DEADLINE_AS_STRING) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
super.populateItem(item, componentId, rowModel);
XMLGregorianCalendar deadline = rowModel.getObject().getCertCase().getCurrentStageDeadline();
if (deadline != null) {
item.add(AttributeModifier.replace("title", WebComponentUtil.formatDate(deadline)));
item.add(new TooltipBehavior());
}
}
};
columns.add(column);
final AvailableResponses availableResponses = new AvailableResponses(this);
final int responses = availableResponses.getResponseKeys().size();
column = new AbstractColumn<CertWorkItemDto, String>(new Model<>()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertWorkItemDto>> cellItem, String componentId, IModel<CertWorkItemDto> rowModel) {
cellItem.add(new MultiButtonPanel<CertWorkItemDto>(componentId, rowModel, responses + 1) {
private static final long serialVersionUID = 1L;
@Override
protected Component createButton(int index, String componentId, IModel<CertWorkItemDto> model) {
AjaxIconButton btn;
if (index < responses) {
btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + getDecisionButtonColor(model, availableResponses.getResponseValues().get(index))), target -> recordActionPerformed(target, model.getObject(), availableResponses.getResponseValues().get(index)));
btn.add(new EnableBehaviour(() -> !decisionEquals(model, availableResponses.getResponseValues().get(index))));
} else {
btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + ButtonColorClass.DANGER), null);
btn.setEnabled(false);
btn.add(new VisibleBehaviour(() -> !availableResponses.isAvailable(model.getObject().getResponse())));
}
return btn;
}
});
}
};
columns.add(column);
column = new DirectlyEditablePropertyColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.comment"), CertWorkItemDto.F_COMMENT) {
private static final long serialVersionUID = 1L;
@Override
public void onBlur(AjaxRequestTarget target, IModel model) {
// TODO determine somehow if the model.comment was really changed
recordActionPerformed(target, (CertWorkItemDto) model.getObject(), null);
}
};
columns.add(column);
columns.add(new InlineMenuHeaderColumn(createInlineMenu(availableResponses)));
return columns;
}
use of com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses in project midpoint by Evolveum.
the class PageCertCampaign method initColumns.
private List<IColumn<CertCaseDto, String>> initColumns() {
List<IColumn<CertCaseDto, String>> columns = new ArrayList<>();
IColumn column;
column = helper.createTypeColumn(OBJECT, this);
columns.add(column);
column = helper.createObjectNameColumn(this, "PageCertCampaign.table.objectName");
columns.add(column);
column = helper.createTypeColumn(TARGET, this);
columns.add(column);
column = helper.createTargetNameColumn(this, "PageCertCampaign.table.targetName");
columns.add(column);
column = helper.createDetailedInfoColumn(this);
columns.add(column);
if (AccessCertificationApiConstants.EXCLUSION_HANDLER_URI.equals(campaignModel.getObject().getHandlerUri())) {
column = helper.createConflictingNameColumn(this, "PageCertCampaign.table.conflictingTargetName");
columns.add(column);
}
column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewers"), CertCaseDto.F_CURRENT_REVIEWERS);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewedAt"), CertCaseDto.F_REVIEWED_AT);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewedBy"), CertCaseDto.F_REVIEWED_BY);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewedInStage"), CertCaseDto.F_CURRENT_RESPONSE_STAGE_NUMBER);
columns.add(column);
final AvailableResponses availableResponses = new AvailableResponses(this);
final int responses = availableResponses.getCount();
column = new AbstractColumn<CertCaseDto, String>(new Model<>()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<CertCaseDto>> cellItem, String componentId, IModel<CertCaseDto> rowModel) {
cellItem.add(new MultiButtonPanel<CertCaseDto>(componentId, rowModel, responses + 1) {
private static final long serialVersionUID = 1L;
@Override
protected Component createButton(int index, String componentId, IModel<CertCaseDto> model) {
AjaxIconButton btn = null;
if (index < responses) {
btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + getDecisionButtonColor(model, availableResponses.getResponseValues().get(index))), null);
} else {
btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + ButtonColorClass.DANGER), null);
btn.add(new VisibleBehaviour(() -> !availableResponses.isAvailable(model.getObject().getOverallOutcome())));
}
btn.setEnabled(false);
return btn;
}
});
}
};
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaign.table.comments"), CertCaseDto.F_COMMENTS);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaign.table.remediedAt"), CertCaseDto.F_REMEDIED_AT);
columns.add(column);
return columns;
}
Aggregations