use of com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn in project midpoint by Evolveum.
the class TaskSubtasksAndThreadsTabPanel method initLayout.
private void initLayout(final IModel<TaskDto> taskDtoModel) {
WebMarkupContainer threadsConfigurationPanel = new WebMarkupContainer(ID_THREADS_CONFIGURATION_PANEL);
add(threadsConfigurationPanel);
threadsConfigurationPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return taskDtoModel.getObject().configuresWorkerThreads();
}
});
final TextField<Integer> workerThreads = new TextField<>(ID_WORKER_THREADS, new PropertyModel<Integer>(taskDtoModel, TaskDto.F_WORKER_THREADS));
workerThreads.setOutputMarkupId(true);
workerThreads.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit();
}
});
threadsConfigurationPanel.add(workerThreads);
VisibleEnableBehaviour hiddenWhenEditingOrNoSubtasks = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !parentPage.isEdit() && !taskDtoModel.getObject().getSubtasks().isEmpty();
}
};
Label subtasksLabel = new Label(ID_SUBTASKS_LABEL, new ResourceModel("pageTaskEdit.subtasksLabel"));
subtasksLabel.add(hiddenWhenEditingOrNoSubtasks);
add(subtasksLabel);
SubtasksPanel subtasksPanel = new SubtasksPanel(ID_SUBTASKS_PANEL, new PropertyModel<List<TaskDto>>(taskDtoModel, TaskDto.F_SUBTASKS), parentPage.getWorkflowManager().isEnabled());
subtasksPanel.add(hiddenWhenEditingOrNoSubtasks);
add(subtasksPanel);
VisibleEnableBehaviour hiddenWhenNoSubtasks = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
TaskDto taskDto = taskDtoModel.getObject();
return taskDto != null && !taskDto.getTransientSubtasks().isEmpty();
}
};
Label workerThreadsTableLabel = new Label(ID_WORKER_THREADS_TABLE_LABEL, new ResourceModel("TaskStatePanel.workerThreads"));
workerThreadsTableLabel.add(hiddenWhenNoSubtasks);
add(workerThreadsTableLabel);
List<IColumn<WorkerThreadDto, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn(createStringResourceStatic(this, "TaskStatePanel.subtaskName"), WorkerThreadDto.F_NAME));
columns.add(new EnumPropertyColumn<WorkerThreadDto>(createStringResourceStatic(this, "TaskStatePanel.subtaskState"), WorkerThreadDto.F_EXECUTION_STATUS));
columns.add(new PropertyColumn(createStringResourceStatic(this, "TaskStatePanel.subtaskObjectsProcessed"), WorkerThreadDto.F_PROGRESS));
ISortableDataProvider<WorkerThreadDto, String> threadsProvider = new ListDataProvider<>(this, new AbstractReadOnlyModel<List<WorkerThreadDto>>() {
@Override
public List<WorkerThreadDto> getObject() {
List<WorkerThreadDto> rv = new ArrayList<>();
TaskDto taskDto = taskDtoModel.getObject();
if (taskDto != null) {
for (TaskDto subtaskDto : taskDto.getTransientSubtasks()) {
rv.add(new WorkerThreadDto(subtaskDto));
}
}
return rv;
}
});
TablePanel<WorkerThreadDto> workerThreadsTablePanel = new TablePanel<>(ID_WORKER_THREADS_TABLE, threadsProvider, columns);
workerThreadsTablePanel.add(hiddenWhenNoSubtasks);
add(workerThreadsTablePanel);
}
use of com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn in project midpoint by Evolveum.
the class PageCertCampaigns method initColumns.
private List<IColumn<CertCampaignListItemDto, String>> initColumns() {
List<IColumn<CertCampaignListItemDto, String>> columns = new ArrayList<>();
IColumn column;
column = new CheckBoxHeaderColumn<>();
columns.add(column);
column = new LinkColumn<CertCampaignListItemDto>(createStringResource("PageCertCampaigns.table.name"), AccessCertificationCampaignType.F_NAME.getLocalPart(), CertCampaignListItemDto.F_NAME) {
@Override
public void onClick(AjaxRequestTarget target, IModel<CertCampaignListItemDto> rowModel) {
campaignDetailsPerformed(target, rowModel.getObject().getOid());
}
};
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.description"), CertCampaignListItemDto.F_DESCRIPTION);
columns.add(column);
column = new EnumPropertyColumn(createStringResource("PageCertCampaigns.table.state"), CertCampaignListItemDto.F_STATE) {
@Override
protected String translate(Enum en) {
return createStringResourceStatic(getPage(), en).getString();
}
};
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stage"), CertCampaignListItemDto.F_CURRENT_STAGE_NUMBER);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.escalationLevel"), CertCampaignListItemDto.F_ESCALATION_LEVEL_NUMBER);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stages"), CertCampaignListItemDto.F_NUMBER_OF_STAGES);
columns.add(column);
column = new PropertyColumn(createStringResource("PageCertCampaigns.table.deadline"), CertCampaignListItemDto.F_DEADLINE_AS_STRING);
columns.add(column);
column = new SingleButtonColumn<CertCampaignListItemDto>(new Model(), null) {
@Override
public boolean isButtonEnabled(IModel<CertCampaignListItemDto> model) {
final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
String button = determineAction(campaign);
return button != null;
}
@Override
public boolean isButtonVisible(IModel<CertCampaignListItemDto> model) {
final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
return campaign.getState() != AccessCertificationCampaignStateType.IN_REMEDIATION && campaign.getState() != AccessCertificationCampaignStateType.CLOSED;
}
@Override
public String getCaption() {
AccessCertificationCampaignType campaign = getRowModel().getObject().getCampaign();
String button = determineAction(campaign);
if (button != null) {
return PageCertCampaigns.this.createStringResource(button).getString();
} else {
return "";
}
}
@Override
public String getButtonCssColorClass() {
return DoubleButtonColumn.BUTTON_COLOR_CLASS.PRIMARY.toString();
}
@Override
public String getButtonCssSizeClass() {
return DoubleButtonColumn.BUTTON_SIZE_CLASS.SMALL.toString();
}
@Override
public void clickPerformed(AjaxRequestTarget target, IModel<CertCampaignListItemDto> model) {
AccessCertificationCampaignType campaign = model.getObject().getCampaign();
String action = determineAction(campaign);
switch(action) {
case OP_START_CAMPAIGN:
case OP_OPEN_NEXT_STAGE:
openNextStagePerformed(target, campaign);
break;
case OP_CLOSE_STAGE:
closeStageConfirmation(target, model.getObject());
break;
case OP_START_REMEDIATION:
startRemediationPerformed(target, campaign);
break;
// not used
case OP_CLOSE_CAMPAIGN:
default:
throw new IllegalStateException("Unknown action: " + action);
}
}
};
columns.add(column);
columns.add(new InlineMenuHeaderColumn(createInlineMenu()));
return columns;
}
Aggregations