Search in sources :

Example 26 with PropertyColumn

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

the class PageConnectorHosts method initColumns.

private List<IColumn<SelectableBean<ConnectorHostType>, String>> initColumns() {
    List<IColumn<SelectableBean<ConnectorHostType>, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.hostname"), "value.hostname"));
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.port"), "value.port"));
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.timeout"), "value.timeout"));
    columns.add(new CheckBoxColumn(createStringResource("pageResources.connector.protectConnection"), "value.protectConnection"));
    return columns;
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn)

Example 27 with PropertyColumn

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

the class ResourceDetailsTabPanel method initLayout.

protected void initLayout() {
    PrismObject<ResourceType> resourceObject = getModelObject();
    ResourceType resource = resourceObject.asObjectable();
    add(createLastAvailabilityStatusInfo(resource));
    add(createSourceTargetInfo(resource));
    add(createSchemaStatusInfo(resource));
    CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
    add(capabilities);
    List<ResourceConfigurationDto> resourceConfigList = createResourceConfigList(resource);
    ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<>(ResourceDetailsTabPanel.this, new ListModel<>(resourceConfigList));
    List<IColumn<SelectableBeanImpl<ResourceType>, String>> tableColumns = new ArrayList<>();
    tableColumns.add(ColumnUtils.createPropertyColumn(new ColumnTypeDto<>("ShadowType.kind", "objectTypeDefinition.kind", ShadowType.F_KIND.getLocalPart())));
    tableColumns.add(new PropertyColumn<>(createStringResource("ShadowType.objectClass"), "objectTypeDefinition.objectClass") {

        @Override
        public IModel<?> getDataModel(IModel<SelectableBeanImpl<ResourceType>> rowModel) {
            IModel<QName> model = (IModel<QName>) super.getDataModel(rowModel);
            if (model.getObject() != null) {
                return () -> model.getObject().getLocalPart();
            }
            return model;
        }
    });
    List<ColumnTypeDto<String>> columns = Arrays.asList(new ColumnTypeDto<>("ShadowType.intent", "objectTypeDefinition.intent", ShadowType.F_INTENT.getLocalPart()), new ColumnTypeDto<>("ResourceType.isSync", "sync", null));
    tableColumns.addAll(ColumnUtils.createColumns(columns));
    PropertyColumn tasksColumn = new PropertyColumn(PageBase.createStringResourceStatic(this, "ResourceType.tasks"), "definedTasks") {

        @Override
        public void populateItem(Item item, String componentId, final IModel rowModel) {
            ResourceConfigurationDto conf = (ResourceConfigurationDto) rowModel.getObject();
            RepeatingView repeater = new RepeatingView(componentId);
            for (final TaskType task : conf.getDefinedTasks()) {
                repeater.add(new AjaxLinkPanel(repeater.newChildId(), new Model<>(task.getName().getOrig())) {

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        ResourceDetailsTabPanel.this.taskDetailsPerformed(target, task.getOid());
                    }
                });
            }
            item.add(repeater);
        }
    };
    tableColumns.add(tasksColumn);
    BoxedTablePanel<ResourceConfigurationDto> resourceConfig = new BoxedTablePanel("resourceConfig", resourceConfigProvider, tableColumns);
    resourceConfig.setAdditionalBoxCssClasses("box-success");
    add(resourceConfig);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto) ColumnTypeDto(com.evolveum.midpoint.web.component.data.column.ColumnTypeDto) Item(org.apache.wicket.markup.repeater.Item) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 28 with PropertyColumn

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

the class ColumnUtils method getDefaultCaseColumns.

public static List<IColumn<SelectableBean<CaseType>, String>> getDefaultCaseColumns(PageBase pageBase, boolean isDashboard) {
    List<IColumn<SelectableBean<CaseType>, String>> columns = new ArrayList<>();
    IColumn column = new PropertyColumn(createStringResource("pageCases.table.description"), "value.description");
    columns.add(column);
    column = new AbstractColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.objectRef")) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> item, String componentId, IModel<SelectableBean<CaseType>> rowModel) {
            item.add(new Label(componentId, new IModel<String>() {

                @Override
                public String getObject() {
                    CaseType caseModelObject = rowModel.getObject().getValue();
                    if (caseModelObject == null) {
                        return "";
                    }
                    AssignmentHolderType objectRef = WebComponentUtil.getObjectFromAddDeltyForCase(caseModelObject);
                    if (objectRef != null) {
                        return WebComponentUtil.getEffectiveName(objectRef, AbstractRoleType.F_DISPLAY_NAME);
                    } else if (caseModelObject.getObjectRef() != null && StringUtils.isNotEmpty(caseModelObject.getObjectRef().getOid())) {
                        if (caseModelObject.getObjectRef().getObject() != null) {
                            return WebComponentUtil.getEffectiveName(caseModelObject.getObjectRef().getObject(), AbstractRoleType.F_DISPLAY_NAME);
                        } else {
                            try {
                                return WebComponentUtil.getEffectiveName(caseModelObject.getObjectRef(), AbstractRoleType.F_DISPLAY_NAME, pageBase, pageBase.getClass().getSimpleName() + "." + "loadCaseObjectRefName");
                            } catch (Exception ex) {
                                LOGGER.error("Unable find the object for reference: {}", caseModelObject.getObjectRef());
                            }
                        }
                    }
                    return "";
                }
            }));
        }
    };
    columns.add(column);
    if (!isDashboard) {
        columns.add(createCaseActorsColumn(pageBase));
    }
    column = new AbstractColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.openTimestamp"), MetadataType.F_CREATE_TIMESTAMP.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, final IModel<SelectableBean<CaseType>> rowModel) {
            CaseType object = rowModel.getObject().getValue();
            MetadataType metadata = object != null ? object.getMetadata() : null;
            XMLGregorianCalendar createdCal = metadata != null ? metadata.getCreateTimestamp() : null;
            final Date created;
            if (createdCal != null) {
                created = createdCal.toGregorianCalendar().getTime();
            // cellItem.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(created, DateLabelComponent.LONG_MEDIUM_STYLE)));
            // cellItem.add(new TooltipBehavior());
            } else {
                created = null;
            }
            cellItem.add(new Label(componentId, new IModel<String>() {

                @Override
                public String getObject() {
                    return WebComponentUtil.getShortDateTimeFormattedValue(created, pageBase);
                }
            }));
        }

        @Override
        public String getCssClass() {
            return isDashboard ? "col-sm-2 col-lg-1" : super.getCssClass();
        }
    };
    columns.add(column);
    if (!isDashboard) {
        column = new PropertyColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.closeTimestamp"), CaseType.F_CLOSE_TIMESTAMP.getLocalPart(), "value.closeTimestamp") {

            @Override
            public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, final IModel<SelectableBean<CaseType>> rowModel) {
                CaseType object = rowModel.getObject().getValue();
                XMLGregorianCalendar closedCal = object != null ? object.getCloseTimestamp() : null;
                final Date closed;
                if (closedCal != null) {
                    closed = closedCal.toGregorianCalendar().getTime();
                    cellItem.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(closed, DateLabelComponent.LONG_MEDIUM_STYLE)));
                    cellItem.add(new TooltipBehavior());
                } else {
                    closed = null;
                }
                cellItem.add(new Label(componentId, new IModel<String>() {

                    @Override
                    public String getObject() {
                        return WebComponentUtil.getShortDateTimeFormattedValue(closed, pageBase);
                    }
                }));
            }

            @Override
            public String getCssClass() {
                return isDashboard ? "col-sm-2 col-lg-1" : super.getCssClass();
            }
        };
        columns.add(column);
    }
    column = new CountIconColumn<SelectableBean<CaseType>>(createStringResource("CaseType.outcome")) {

        @Override
        protected Map<DisplayType, Integer> getIconDisplayType(IModel<SelectableBean<CaseType>> rowModel) {
            Map<DisplayType, Integer> map = new HashMap<>();
            CaseType caseType = rowModel.getObject().getValue();
            if (ObjectTypeUtil.hasArchetype(caseType, SystemObjectsType.ARCHETYPE_OPERATION_REQUEST.value())) {
                ObjectQuery queryFilter = pageBase.getPrismContext().queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(caseType.getOid()).build();
                List<PrismObject<CaseType>> childs = WebModelServiceUtils.searchObjects(CaseType.class, queryFilter, new OperationResult("search_case_child"), pageBase);
                for (PrismObject<CaseType> child : childs) {
                    processCaseOutcome(child.asObjectable(), map, false);
                }
            } else {
                processCaseOutcome(caseType, map, true);
            }
            return map;
        }

        @Override
        public String getCssClass() {
            return "col-lg-1";
        }
    };
    columns.add(column);
    column = new PropertyColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.state"), CaseType.F_STATE.getLocalPart(), "value.state") {

        @Override
        public String getCssClass() {
            return "col-lg-1";
        }

        @Override
        public IModel<?> getDataModel(IModel<SelectableBean<CaseType>> rowModel) {
            IModel<String> dataModel = (IModel<String>) super.getDataModel(rowModel);
            if (StringUtils.isNotBlank(dataModel.getObject())) {
                String key = CaseType.COMPLEX_TYPE.getLocalPart() + "." + CaseType.F_STATE.getLocalPart() + "." + dataModel.getObject();
                return new StringResourceModel(key, pageBase).setModel(new Model<String>()).setDefaultValue(dataModel.getObject());
            }
            return dataModel;
        }
    };
    columns.add(column);
    if (!isDashboard) {
        column = new AbstractExportableColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.workitems")) {

            @Override
            public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, IModel<SelectableBean<CaseType>> model) {
                cellItem.add(new Label(componentId, model.getObject().getValue() != null && model.getObject().getValue().getWorkItem() != null ? model.getObject().getValue().getWorkItem().size() : null));
            }

            @Override
            public IModel<String> getDataModel(IModel<SelectableBean<CaseType>> rowModel) {
                return Model.of(rowModel.getObject().getValue() != null && rowModel.getObject().getValue().getWorkItem() != null ? Integer.toString(rowModel.getObject().getValue().getWorkItem().size()) : "");
            }

            @Override
            public String getCssClass() {
                return "col-lg-1";
            }
        };
        columns.add(column);
    }
    return columns;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) StringResourceModel(org.apache.wicket.model.StringResourceModel) IModel(org.apache.wicket.model.IModel) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)

Example 29 with PropertyColumn

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

the class PageValuePolicies method initValuePoliciesColumns.

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

Example 30 with PropertyColumn

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

the class ResourceDetailsTabPanel method initLayout.

protected void initLayout() {
    // PrismObject<ResourceType> resourceObject = getObjectWrapper().getObject();
    // ResourceType resource = resourceObject.asObjectable();
    add(createLastAvailabilityStatusInfo());
    add(createSourceTargetInfo());
    add(createSchemaStatusInfo());
    CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
    add(capabilities);
    ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<>(ResourceDetailsTabPanel.this, createResourceConfigListModel());
    List<IColumn<SelectableBeanImpl<ResourceType>, String>> tableColumns = new ArrayList<>();
    tableColumns.add(ColumnUtils.createPropertyColumn(new ColumnTypeDto<>("ShadowType.kind", "objectTypeDefinition.kind", ShadowType.F_KIND.getLocalPart())));
    tableColumns.add(new PropertyColumn<>(createStringResource("ShadowType.objectClass"), "objectTypeDefinition.objectClass") {

        @Override
        public IModel<?> getDataModel(IModel<SelectableBeanImpl<ResourceType>> rowModel) {
            IModel<QName> model = (IModel<QName>) super.getDataModel(rowModel);
            if (model.getObject() != null) {
                return () -> model.getObject().getLocalPart();
            }
            return model;
        }
    });
    List<ColumnTypeDto<String>> columns = Arrays.asList(new ColumnTypeDto<>("ShadowType.intent", "objectTypeDefinition.intent", ShadowType.F_INTENT.getLocalPart()), new ColumnTypeDto<>("ResourceType.isSync", "sync", null));
    tableColumns.addAll(ColumnUtils.createColumns(columns));
    PropertyColumn tasksColumn = new PropertyColumn(PageBase.createStringResourceStatic(this, "ResourceType.tasks"), "definedTasks") {

        @Override
        public void populateItem(Item item, String componentId, final IModel rowModel) {
            ResourceConfigurationDto conf = (ResourceConfigurationDto) rowModel.getObject();
            RepeatingView repeater = new RepeatingView(componentId);
            for (final TaskType task : conf.getDefinedTasks()) {
                repeater.add(new AjaxLinkPanel(repeater.newChildId(), new Model<>(task.getName().getOrig())) {

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        ResourceDetailsTabPanel.this.taskDetailsPerformed(target, task.getOid());
                    }
                });
            }
            item.add(repeater);
        }
    };
    tableColumns.add(tasksColumn);
    BoxedTablePanel<ResourceConfigurationDto> resourceConfig = new BoxedTablePanel("resourceConfig", resourceConfigProvider, tableColumns);
    resourceConfig.setAdditionalBoxCssClasses("box-success");
    add(resourceConfig);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto) ColumnTypeDto(com.evolveum.midpoint.web.component.data.column.ColumnTypeDto) Item(org.apache.wicket.markup.repeater.Item) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) CapabilitiesPanel(com.evolveum.midpoint.web.page.admin.resources.CapabilitiesPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Model(org.apache.wicket.model.Model) ResourceDetailsModel(com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Aggregations

PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)31 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)30 ArrayList (java.util.ArrayList)23 IModel (org.apache.wicket.model.IModel)21 Label (org.apache.wicket.markup.html.basic.Label)13 Model (org.apache.wicket.model.Model)13 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)12 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)10 Item (org.apache.wicket.markup.repeater.Item)9 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)7 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)6 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)5 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)4 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)4 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)4 List (java.util.List)4 QName (javax.xml.namespace.QName)4