Search in sources :

Example 1 with EnumPropertyColumn

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);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SubtasksPanel(com.evolveum.midpoint.web.page.admin.server.subtasks.SubtasksPanel) TextField(org.apache.wicket.markup.html.form.TextField) ResourceModel(org.apache.wicket.model.ResourceModel) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WorkerThreadDto(com.evolveum.midpoint.web.page.admin.server.dto.WorkerThreadDto) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 2 with EnumPropertyColumn

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;
}
Also used : InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Aggregations

EnumPropertyColumn (com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn)2 ArrayList (java.util.ArrayList)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)2 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)1 InlineMenuHeaderColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn)1 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 CertCampaignListItemDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto)1 TaskDto (com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)1 WorkerThreadDto (com.evolveum.midpoint.web.page.admin.server.dto.WorkerThreadDto)1 SubtasksPanel (com.evolveum.midpoint.web.page.admin.server.subtasks.SubtasksPanel)1 AccessCertificationCampaignType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)1 List (java.util.List)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 TextField (org.apache.wicket.markup.html.form.TextField)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1 IModel (org.apache.wicket.model.IModel)1