use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class MyAccountsPanel method initLayout.
protected void initLayout() {
List<IColumn<SimpleAccountDto, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn(createStringResource("MyAccountsPanel.account.name"), "accountName"));
columns.add(new PropertyColumn(createStringResource("MyAccountsPanel.account.resource"), "resourceName"));
ISortableDataProvider provider = new ListDataProvider(this, getModel());
TablePanel accountsTable = new TablePanel<>(ID_ACCOUNTS_TABLE, provider, columns);
accountsTable.setShowPaging(false);
add(accountsTable);
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn 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;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class PageTasks method initTaskColumns.
private List<IColumn<TaskDto, String>> initTaskColumns() {
List<IColumn<TaskDto, String>> columns = new ArrayList<IColumn<TaskDto, String>>();
IColumn column = new CheckBoxHeaderColumn<>();
columns.add(column);
column = createTaskNameColumn(this, "pageTasks.task.name");
columns.add(column);
columns.add(createTaskCategoryColumn(this, "pageTasks.task.category"));
columns.add(new IconColumn<TaskDto>(createStringResource("")) {
@Override
protected IModel<String> createIconModel(IModel<TaskDto> rowModel) {
ObjectReferenceType ref = rowModel.getObject().getObjectRef();
if (ref == null || ref.getType() == null) {
return Model.of("");
}
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
String icon = guiDescriptor != null ? guiDescriptor.getBlackIcon() : ObjectTypeGuiDescriptor.ERROR_ICON;
return new Model<>(icon);
}
private ObjectTypeGuiDescriptor getObjectTypeDescriptor(QName type) {
return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(type));
}
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, IModel<TaskDto> rowModel) {
super.populateItem(item, componentId, rowModel);
ObjectReferenceType ref = rowModel.getObject().getObjectRef();
if (ref != null && ref.getType() != null) {
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
if (guiDescriptor != null) {
item.add(AttributeModifier.replace("title", createStringResource(guiDescriptor.getLocalizationKey())));
item.add(new TooltipBehavior());
}
}
}
});
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.objectRef")) {
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return createObjectRef(rowModel);
}
}));
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
return Model.of(createObjectRef(rowModel));
}
});
columns.add(createTaskExecutionStatusColumn(this, "pageTasks.task.execution"));
columns.add(new PropertyColumn<TaskDto, String>(createStringResource("pageTasks.task.executingAt"), "executingAt"));
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.progress")) {
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> cellItem, String componentId, final IModel<TaskDto> rowModel) {
cellItem.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return createProgress(rowModel);
}
}));
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
return Model.of(createProgress(rowModel));
}
});
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.currentRunTime")) {
@Override
public void populateItem(final Item<ICellPopulator<TaskDto>> item, final String componentId, final IModel<TaskDto> rowModel) {
DateLabelComponent dateLabel = new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
Date date = createCurrentRuntime(rowModel);
TaskDto task = rowModel.getObject();
if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
((DateLabelComponent) item.get(componentId)).setBefore("closed at ");
} else if (date != null) {
((DateLabelComponent) item.get(componentId)).setBefore(DurationFormatUtils.formatDurationWords(date.getTime(), true, true));
}
return date;
}
}, DateLabelComponent.MEDIUM_MEDIUM_STYLE);
item.add(dateLabel);
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
TaskDto task = rowModel.getObject();
Date date = createCurrentRuntime(rowModel);
String displayValue = "";
if (date != null) {
if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
displayValue = "closed at " + WebComponentUtil.getLocalizedDate(date, DateLabelComponent.LONG_MEDIUM_STYLE);
} else {
displayValue = DurationFormatUtils.formatDurationWords(date.getTime(), true, true);
}
}
return Model.of(displayValue);
}
});
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.scheduledToRunAgain")) {
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return createScheduledToRunAgain(rowModel);
}
}));
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
return Model.of(createScheduledToRunAgain(rowModel));
}
});
columns.add(new IconColumn<TaskDto>(createStringResource("pageTasks.task.status")) {
@Override
protected IModel<String> createTitleModel(final IModel<TaskDto> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDto dto = rowModel.getObject();
if (dto != null && dto.getStatus() != null) {
return createStringResourceStatic(PageTasks.this, dto.getStatus()).getString();
} else {
return createStringResourceStatic(PageTasks.this, OperationResultStatus.UNKNOWN).getString();
}
}
};
}
@Override
protected IModel<String> createIconModel(final IModel<TaskDto> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getStatus() != null) {
return OperationResultStatusPresentationProperties.parseOperationalResultStatus(rowModel.getObject().getStatus().createStatusType()).getIcon() + " fa-lg";
} else
return OperationResultStatusPresentationProperties.UNKNOWN.getIcon() + " fa-lg";
}
};
}
});
IColumn<TaskDto, String> menuColumn = new InlineMenuButtonColumn<TaskDto>(createTasksInlineMenu(false), 2, PageTasks.this) {
@Override
protected int getHeaderNumberOfButtons() {
return 2;
}
@Override
protected List<InlineMenuItem> getHeaderMenuItems() {
return createTasksInlineMenu(true);
}
};
columns.add(menuColumn);
return columns;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class PageTasks method initLayout.
private void initLayout() {
refreshPanel = new AutoRefreshPanel(ID_REFRESH_PANEL, refreshModel, this, false);
add(refreshPanel);
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
List<IColumn<TaskDto, String>> taskColumns = initTaskColumns();
TaskDtoProviderOptions options = TaskDtoProviderOptions.minimalOptions();
options.setGetNextRunStartTime(true);
options.setUseClusterInformation(true);
options.setResolveObjectRef(true);
TaskDtoProvider provider = new TaskDtoProvider(PageTasks.this, options) {
@Override
protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
TasksStorage storage = getSessionStorage().getTasks();
storage.setPaging(paging);
}
@Override
public TaskDto createTaskDto(PrismObject<TaskType> task, Task opTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
TaskDto dto = super.createTaskDto(task, opTask, result);
addInlineMenuToTaskRow(dto);
return dto;
}
};
provider.setQuery(createTaskQuery());
BoxedTablePanel<TaskDto> taskTable = new BoxedTablePanel(ID_TASK_TABLE, provider, taskColumns, UserProfileStorage.TableId.PAGE_TASKS_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_PANEL)) {
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new SearchFragment(headerId, ID_TABLE_HEADER, PageTasks.this, searchModel);
}
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
String fileName = "TaskType_" + createStringResource("MainObjectListPanel.exportFileName").getString();
CSVDataExporter csvDataExporter = new CSVDataExporter();
ResourceStreamResource resource = (new ResourceStreamResource() {
protected IResourceStream getResourceStream() {
return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getTaskTable().getDataTable());
}
}).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
return exportDataLink;
}
};
taskTable.setOutputMarkupId(true);
TasksStorage storage = getSessionStorage().getTasks();
taskTable.setCurrentPage(storage.getPaging());
mainForm.add(taskTable);
List<IColumn<NodeDto, String>> nodeColumns = initNodeColumns();
BoxedTablePanel nodeTable = new BoxedTablePanel(ID_NODE_TABLE, new NodeDtoProvider(PageTasks.this) {
@Override
public NodeDto createNodeDto(PrismObject<NodeType> node) {
NodeDto dto = super.createNodeDto(node);
addInlineMenuToNodeRow(dto);
return dto;
}
}, nodeColumns, UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL));
nodeTable.setOutputMarkupId(true);
nodeTable.setShowPaging(false);
mainForm.add(nodeTable);
initDiagnosticButtons();
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class PageTasks method initNodeColumns.
private List<IColumn<NodeDto, String>> initNodeColumns() {
List<IColumn<NodeDto, String>> columns = new ArrayList<>();
IColumn column = new CheckBoxHeaderColumn<>();
columns.add(column);
column = new PropertyColumn<>(createStringResource("pageTasks.node.name"), "name", "name");
columns.add(column);
columns.add(new EnumPropertyColumn<NodeDto>(createStringResource("pageTasks.node.executionStatus"), "executionStatus") {
@Override
protected String translate(Enum en) {
return createStringResource(en).getString();
}
});
columns.add(new PropertyColumn(createStringResource("pageTasks.node.managementPort"), "managementPort"));
columns.add(new AbstractColumn<NodeDto, String>(createStringResource("pageTasks.node.lastCheckInTime")) {
@Override
public void populateItem(Item<ICellPopulator<NodeDto>> item, String componentId, final IModel<NodeDto> rowModel) {
item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return createLastCheckInTime(rowModel);
}
}));
}
});
CheckBoxColumn check = new CheckBoxColumn(createStringResource("pageTasks.node.clustered"), "clustered");
check.setEnabled(false);
columns.add(check);
columns.add(new PropertyColumn(createStringResource("pageTasks.node.statusMessage"), "statusMessage"));
IColumn<NodeDto, String> menuColumn = new InlineMenuButtonColumn<NodeDto>(createNodesInlineMenu(false), 2, PageTasks.this) {
@Override
protected int getHeaderNumberOfButtons() {
return 2;
}
@Override
protected List<InlineMenuItem> getHeaderMenuItems() {
return createNodesInlineMenu(true);
}
};
columns.add(menuColumn);
return columns;
}
Aggregations