Search in sources :

Example 41 with IColumn

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CSVDataExporter(org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter) Form(org.apache.wicket.markup.html.form.Form) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) AutoRefreshPanel(com.evolveum.midpoint.web.component.refresh.AutoRefreshPanel) ResourceLink(org.apache.wicket.markup.html.link.ResourceLink) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TasksStorage(com.evolveum.midpoint.web.session.TasksStorage) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink)

Example 42 with IColumn

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;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PrismObject(com.evolveum.midpoint.prism.PrismObject) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 43 with IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class PageRoles method initColumns.

private List<IColumn<SelectableBean<RoleType>, String>> initColumns() {
    List<IColumn<SelectableBean<RoleType>, String>> columns = new ArrayList<>();
    IColumn column = new PropertyColumn(createStringResource("OrgType.displayName"), "value.displayName");
    columns.add(column);
    column = new PropertyColumn(createStringResource("OrgType.identifier"), "value.identifier");
    columns.add(column);
    column = new PropertyColumn(createStringResource("ObjectType.description"), "value.description");
    columns.add(column);
    return columns;
}
Also used : IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList)

Example 44 with IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class PageAuditLogDetails method initColumns.

private List<IColumn<AuditEventRecordType, String>> initColumns() {
    List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<>();
    PropertyColumn<AuditEventRecordType, String> timeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.timestamp"), AuditEventRecordType.F_TIMESTAMP.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
            item.add(new Label(componentId, WebComponentUtil.getLocalizedDate(time, DateLabelComponent.SHORT_SHORT_STYLE)));
        }
    };
    columns.add(timeColumn);
    PropertyColumn<AuditEventRecordType, String> stageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageShortLabel"), AuditEventRecordType.F_EVENT_STAGE.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventStageType stage = rowModel.getObject().getEventStage();
            String shortStage = "";
            if (AuditEventStageType.EXECUTION.equals(stage)) {
                shortStage = AuditEventStageType.EXECUTION.value().substring(0, 4);
            } else if (AuditEventStageType.REQUEST.equals(stage)) {
                shortStage = AuditEventStageType.REQUEST.value().substring(0, 3);
            }
            item.add(new Label(componentId, shortStage));
        }
    };
    columns.add(stageColumn);
    PropertyColumn<AuditEventRecordType, String> typeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeShortLabel"), AuditEventRecordType.F_EVENT_TYPE.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            //TODO create some proper short values
            AuditEventTypeType type = rowModel.getObject().getEventType();
            String typeVal = type.value().substring(0, 4);
            item.add(new Label(componentId, typeVal));
        }
    };
    columns.add(typeColumn);
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)

Example 45 with IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class AssignmentPreviewDialog method initLayout.

public void initLayout() {
    List<IColumn<AssignmentsPreviewDto, String>> columns = initColumns();
    ListDataProvider provider = new ListDataProvider(pageBase, data);
    WebMarkupContainer content = new WebMarkupContainer(ID_CONTENT);
    content.setOutputMarkupId(true);
    add(content);
    TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    content.add(table);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.selectButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<AssignmentsPreviewDto> previewDtos = data.getObject();
            List<AssignmentsPreviewDto> selectedDtos = new ArrayList<>();
            for (AssignmentsPreviewDto dto : previewDtos) {
                if (dto.isSelected()) {
                    selectedDtos.add(dto);
                }
            }
            AssignmentPreviewDialog.this.addButtonClicked(target, selectedDtos);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    content.add(addButton);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("AssignmentPreviewDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            ((PageBase) getPage()).hideMainPopup(ajaxRequestTarget);
        }
    };
    content.add(cancelButton);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) ArrayList(java.util.ArrayList) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Aggregations

IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)58 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)34 ArrayList (java.util.ArrayList)33 IModel (org.apache.wicket.model.IModel)28 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)21 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)19 Label (org.apache.wicket.markup.html.basic.Label)19 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)14 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)13 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)13 Model (org.apache.wicket.model.Model)12 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)8 Item (org.apache.wicket.markup.repeater.Item)8 PropertyModel (org.apache.wicket.model.PropertyModel)8 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)7 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)7 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)6