Search in sources :

Example 11 with PropertyColumn

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

the class PageDebugList method initColumns.

private List<IColumn> initColumns(final Class<? extends ObjectType> type) {
    List<IColumn> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<ObjectType>();
    columns.add(column);
    column = new LinkColumn<DebugObjectItem>(createStringResource("pageDebugList.name"), DebugObjectItem.F_NAME, DebugObjectItem.F_NAME) {

        @Override
        public void populateItem(Item<ICellPopulator<DebugObjectItem>> cellItem, String componentId, final IModel<DebugObjectItem> rowModel) {
            TwoValueLinkPanel panel = new TwoValueLinkPanel(componentId, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    DebugObjectItem object = rowModel.getObject();
                    if (object == null) {
                        return null;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(object.getName());
                    if (object.getStatus() != null && object.getStatus() != OperationResultStatusType.SUCCESS && object.getStatus() != OperationResultStatusType.HANDLED_ERROR) {
                        sb.append(" (");
                        sb.append(object.getStatus());
                        sb.append(")");
                    }
                    return sb.toString();
                }
            }, new PropertyModel<String>(rowModel, DebugObjectItem.F_OID)) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    DebugObjectItem object = rowModel.getObject();
                    objectEditPerformed(target, object.getOid(), type);
                }

                @Override
                public boolean isEnabled() {
                    return rowModel.getObject().getOid() != null;
                }
            };
            cellItem.add(panel);
            cellItem.add(new AttributeModifier("class", "col-md-3"));
        }
    };
    columns.add(column);
    columns.add(new PropertyColumn(createStringResource("pageDebugList.description"), DebugObjectItem.F_DESCRIPTION));
    if (ShadowType.class.isAssignableFrom(type)) {
        columns.add(new PropertyColumn(createStringResource("pageDebugList.resourceName"), DebugObjectItem.F_RESOURCE_NAME));
        columns.add(new PropertyColumn(createStringResource("pageDebugList.resourceType"), DebugObjectItem.F_RESOURCE_TYPE));
    }
    column = new AbstractColumn<DebugObjectItem, String>(new Model(), null) {

        @Override
        public String getCssClass() {
            return "debug-list-buttons";
        }

        @Override
        public void populateItem(Item<ICellPopulator<DebugObjectItem>> cellItem, String componentId, IModel<DebugObjectItem> rowModel) {
            cellItem.add(new DebugButtonPanel<DebugObjectItem>(componentId, rowModel) {

                @Override
                public void deletePerformed(AjaxRequestTarget target, IModel<DebugObjectItem> model) {
                    deleteSelected(target, model.getObject());
                }

                @Override
                public void exportPerformed(AjaxRequestTarget target, IModel<DebugObjectItem> model) {
                    exportSelected(target, model.getObject());
                }
            });
        }
    };
    columns.add(column);
    column = new InlineMenuHeaderColumn<InlineMenuable>(initInlineMenu()) {

        @Override
        public void populateItem(Item<ICellPopulator<InlineMenuable>> cellItem, String componentId, IModel<InlineMenuable> rowModel) {
            // we don't need row inline menu
            cellItem.add(new Label(componentId));
        }
    };
    columns.add(column);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) DebugObjectItem(com.evolveum.midpoint.web.page.admin.configuration.dto.DebugObjectItem) TwoValueLinkPanel(com.evolveum.midpoint.web.component.data.column.TwoValueLinkPanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) IModel(org.apache.wicket.model.IModel) PropertyModel(org.apache.wicket.model.PropertyModel) AttributeModifier(org.apache.wicket.AttributeModifier) InlineMenuable(com.evolveum.midpoint.web.component.data.column.InlineMenuable) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) DebugButtonPanel(com.evolveum.midpoint.web.page.admin.configuration.component.DebugButtonPanel)

Example 12 with PropertyColumn

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

the class ChangePasswordPanel method initColumns.

private List<IColumn<PasswordAccountDto, String>> initColumns() {
    List<IColumn<PasswordAccountDto, String>> columns = new ArrayList<IColumn<PasswordAccountDto, String>>();
    IColumn column = new IconColumn<PasswordAccountDto>(new Model<String>()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createIconModel(final IModel<PasswordAccountDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    PasswordAccountDto item = rowModel.getObject();
                    if (item.getCssClass() == null || item.getCssClass().trim().equals("")) {
                        if (item.isMidpoint()) {
                            item.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        } else if (item.isPasswordOutbound()) {
                            item.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                        } else {
                            item.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        }
                    }
                    return item.getCssClass();
                }
            };
        }

        @Override
        public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId, final IModel<PasswordAccountDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            final ImagePanel imagePanel = (ImagePanel) item.get(0);
            final PasswordAccountDto passwordAccountDto = rowModel.getObject();
            imagePanel.add(new AjaxEventBehavior("click") {

                private static final long serialVersionUID = 1L;

                protected void onEvent(final AjaxRequestTarget target) {
                    if (!passwordAccountDto.isMidpoint()) {
                        if (passwordAccountDto.getCssClass().equals(PROPAGATED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS) && passwordAccountDto.isPasswordOutbound() && midpointAccountSelected) {
                            passwordAccountDto.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        }
                        target.add(imagePanel);
                    } else {
                        midpointAccountSelected = !midpointAccountSelected;
                        if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                            updatePropagatedAccountIconsCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                            target.add(imagePanel.findParent(SelectableDataTable.class));
                        } else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                            updatePropagatedAccountIconsCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                            target.add(imagePanel.findParent(SelectableDataTable.class));
                        }
                    }
                }
            });
        }
    };
    columns.add(column);
    columns.add(new AbstractColumn<PasswordAccountDto, String>(createStringResource("ChangePasswordPanel.name")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId, final IModel<PasswordAccountDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getObject() {
                    PasswordAccountDto dto = rowModel.getObject();
                    return dto.getDisplayName();
                }
            }));
        }
    });
    column = new PropertyColumn(createStringResource("ChangePasswordPanel.resourceName"), PasswordAccountDto.F_RESOURCE_NAME);
    columns.add(column);
    CheckBoxColumn enabled = new CheckBoxColumn(createStringResource("ChangePasswordPanel.enabled"), PasswordAccountDto.F_ENABLED);
    enabled.setEnabled(false);
    columns.add(enabled);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) Item(org.apache.wicket.markup.repeater.Item) IconColumn(com.evolveum.midpoint.web.component.data.column.IconColumn) PasswordAccountDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordAccountDto) IModel(org.apache.wicket.model.IModel) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableDataTable(com.evolveum.midpoint.web.component.data.SelectableDataTable) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 13 with PropertyColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn 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)

Example 14 with PropertyColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn 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 15 with PropertyColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn 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)

Aggregations

PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)21 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)19 ArrayList (java.util.ArrayList)15 IModel (org.apache.wicket.model.IModel)14 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 Label (org.apache.wicket.markup.html.basic.Label)9 Model (org.apache.wicket.model.Model)8 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)7 PropertyModel (org.apache.wicket.model.PropertyModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)5 Item (org.apache.wicket.markup.repeater.Item)5 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)3 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)2 CheckBoxColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxColumn)2 EnumPropertyColumn (com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn)2 InlineMenuHeaderColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn)2