Search in sources :

Example 46 with IColumn

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

the class OrgUnitAddDeletePopup method initLayout.

public void initLayout(WebMarkupContainer content) {
    List<IColumn<SelectableBeanImpl<ObjectType>, String>> columns = initColumns();
    ObjectQuery query = getDataProviderQuery();
    ObjectDataProvider provider = new ObjectDataProvider(getPageBase(), null) {

        @Override
        public ObjectQuery getQuery() {
            return query;
        }

        @Override
        public Class getType() {
            return OrgType.class;
        }
    };
    TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    content.add(table);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("orgUnitAddDeletePopup.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            cancelPerformed(ajaxRequestTarget);
        }
    };
    content.add(cancelButton);
    AjaxButton actionButton = new AjaxButton(ID_BUTTON_ACTION, createActionButtonStringResource()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            actionPerformed(target);
        }
    };
    actionButton.add(new AttributeAppender("class", getActionButtonClass()));
    content.add(actionButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 47 with IColumn

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

the class ChildCasesPanel method initLayout.

protected void initLayout() {
    setOutputMarkupId(true);
    MainObjectListPanel<CaseType> table = new MainObjectListPanel<CaseType>(ID_CHILD_CASES_PANEL, CaseType.class, Collections.emptyList()) {

        @Override
        protected List<IColumn<SelectableBean<CaseType>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<CaseType>, String>> columns = new ArrayList<IColumn<SelectableBean<CaseType>, String>>();
            IColumn column = new PropertyColumn(createStringResource("pageCases.table.description"), "value.description");
            columns.add(column);
            columns.add(ColumnUtils.createCaseActorsColumn(ChildCasesPanel.this.getPageBase()));
            column = new PropertyColumn<SelectableBeanImpl<CaseType>, String>(createStringResource("pageCases.table.state"), CaseType.F_STATE.getLocalPart(), "value.state") {

                @Override
                public String getCssClass() {
                    return "col-sm-2 col-md-1";
                }
            };
            columns.add(column);
            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-md-2 col-lg-1";
                }
            };
            columns.add(column);
            return (List) columns;
        }

        @Override
        protected boolean isCreateNewObjectEnabled() {
            return false;
        }

        @Override
        protected ISelectableDataProvider<CaseType, SelectableBean<CaseType>> createProvider() {
            return createSelectableBeanObjectDataProvider(() -> getChildCasesQuery(), null);
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.PAGE_CASE_CHILD_CASES_TAB;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return new ArrayList<>();
        }

        @Override
        protected IColumn<SelectableBean<CaseType>, String> createCheckboxColumn() {
            return null;
        }
    };
    table.setOutputMarkupId(true);
    add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) CaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) List(java.util.List) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 48 with IColumn

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

the class AssignmentPanel method initLayout.

private void initLayout() {
    MultivalueContainerListPanelWithDetailsPanel<AssignmentType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_ASSIGNMENTS, AssignmentType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isCreateNewObjectVisible() {
            return isNewObjectButtonVisible(getFocusObject());
        }

        @Override
        protected IModel<PrismContainerWrapper<AssignmentType>> getContainerModel() {
            return AssignmentPanel.this.getModel();
        }

        @Override
        protected void cancelItemDetailsPerformed(AjaxRequestTarget target) {
            AssignmentPanel.this.cancelAssignmentDetailsPerformed(target);
        }

        protected List<IColumn<PrismContainerValueWrapper<AssignmentType>, String>> createDefaultColumns() {
            if (AssignmentPanel.this.getModelObject() == null) {
                return new ArrayList<>();
            }
            return initBasicColumns();
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> bar = new ArrayList<>();
            AjaxIconButton newObjectButton = new AjaxIconButton(idButton, new Model<>(GuiStyleConstants.EVO_ASSIGNMENT_ICON), createStringResource("MainObjectListPanel.newObject")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    newAssignmentClickPerformed(target);
                }
            };
            newObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
            bar.add(newObjectButton);
            newObjectButton.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    return isNewObjectButtonVisible(getFocusObject());
                }

                @Override
                public boolean isEnabled() {
                    return !isAssignmentsLimitReached();
                }
            });
            return bar;
        }

        @Override
        public void deleteItemPerformed(AjaxRequestTarget target, List<PrismContainerValueWrapper<AssignmentType>> toDeleteList) {
            int countAddedAssignments = 0;
            for (PrismContainerValueWrapper<AssignmentType> assignment : toDeleteList) {
                if (ValueStatus.ADDED.equals(assignment.getStatus())) {
                    countAddedAssignments++;
                }
            }
            boolean isLimitReached = isAssignmentsLimitReached(toDeleteList.size() - countAddedAssignments, true);
            if (isLimitReached) {
                warn(getParentPage().getString("AssignmentPanel.assignmentsLimitReachedWarning", assignmentsRequestsLimit));
                target.add(getPageBase().getFeedbackPanel());
                return;
            }
            super.deleteItemPerformed(target, toDeleteList);
        }

        @Override
        protected AssignmentListProvider createProvider() {
            PageStorage pageStorage = getPageStorage(getAssignmentsTabStorageKey());
            return createAssignmentProvider(pageStorage, getSearchModel(), loadValuesModel());
        }

        @Override
        protected MultivalueContainerDetailsPanel<AssignmentType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AssignmentType>> item) {
            return createMultivalueContainerDetailsPanel(item);
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return AssignmentPanel.this.getTableId();
        }

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
            return createSearchableItems(containerDef);
        }

        @Override
        public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
            super.refreshTable(ajaxRequestTarget);
            AssignmentPanel.this.refreshTable(ajaxRequestTarget);
        }

        @Override
        protected boolean isCollectionViewPanel() {
            return config != null && config.getListView() != null;
        }

        @Override
        protected CompiledObjectCollectionView getObjectCollectionView() {
            if (config == null) {
                return super.getObjectCollectionView();
            }
            GuiObjectListViewType listView = config.getListView();
            if (listView == null) {
                return null;
            }
            CollectionRefSpecificationType collectionRefSpecificationType = listView.getCollection();
            if (collectionRefSpecificationType == null) {
                return null;
            }
            Task task = getPageBase().createSimpleTask("Compile collection");
            OperationResult result = task.getResult();
            try {
                return getPageBase().getModelInteractionService().compileObjectCollectionView(collectionRefSpecificationType, AssignmentType.class, task, result);
            } catch (Throwable e) {
                e.printStackTrace();
            }
            return null;
        }
    };
    multivalueContainerListPanel.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) PageStorage(com.evolveum.midpoint.web.session.PageStorage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 49 with IColumn

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

the class PageDebugList method createColumns.

private List<IColumn<DebugObjectItem, String>> createColumns() {
    List<IColumn<DebugObjectItem, String>> columns = new ArrayList<>();
    IColumn<DebugObjectItem, String> column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = new AjaxLinkColumn<>(createStringResource("pageDebugList.name"), DebugObjectItem.F_NAME, DebugObjectItem.F_NAME) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @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(object.getOid(), object.getType());
                }

                @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.equals(getType())) {
        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<>(new Model<>(), null) {

        private static final long serialVersionUID = 1L;

        @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<>(componentId, rowModel) {

                private static final long serialVersionUID = 1L;

                @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);
    columns.add(new InlineMenuHeaderColumn(initInlineMenu()));
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) ArrayList(java.util.ArrayList) PropertyModel(org.apache.wicket.model.PropertyModel) DebugObjectItem(com.evolveum.midpoint.web.page.admin.configuration.dto.DebugObjectItem) AttributeModifier(org.apache.wicket.AttributeModifier) TwoValueLinkPanel(com.evolveum.midpoint.web.component.data.column.TwoValueLinkPanel) 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) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) 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 50 with IColumn

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

the class InternalsLoggedInUsersPanel method initLayout.

private void initLayout() {
    MainObjectListPanel<F> table = new MainObjectListPanel(ID_TABLE, FocusType.class, null) {

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
            if (WebComponentUtil.hasDetailsPage(object.getClass())) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, object.getOid());
                getPageBase().navigateToNext(WebComponentUtil.getObjectDetailsPage(object.getClass()), parameters);
            }
        }

        @Override
        protected List<IColumn<SelectableBean<F>, String>> createDefaultColumns() {
            return InternalsLoggedInUsersPanel.this.initColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return initInlineMenu();
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return null;
        }

        @Override
        protected ISelectableDataProvider<UserSessionManagementType, SelectableBean<F>> createProvider() {
            LoadableModel<List<UserSessionManagementType>> principals = new LoadableModel<List<UserSessionManagementType>>(true) {

                @Override
                protected List<UserSessionManagementType> load() {
                    return loadLoggedInPrincipals();
                }
            };
            return new SelectableListDataProvider<SelectableBean<F>, UserSessionManagementType>(InternalsLoggedInUsersPanel.this, principals) {

                @Override
                protected SelectableBean<F> createObjectWrapper(UserSessionManagementType principal) {
                    SelectableBeanImpl<F> user = new SelectableBeanImpl<>((F) principal.getFocus());
                    user.setActiveSessions(principal.getActiveSessions());
                    user.setNodes(principal.getNode());
                    return user;
                }
            };
        }

        @Override
        protected boolean isCreateNewObjectEnabled() {
            return false;
        }

        @Override
        protected List<Component> createToolbarButtonsList(String buttonId) {
            return new ArrayList<>();
        }

        @Override
        protected boolean enableSavePageSize() {
            return false;
        }
    };
    add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) UserSessionManagementType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.apache.wicket.Component)

Aggregations

IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)131 ArrayList (java.util.ArrayList)80 IModel (org.apache.wicket.model.IModel)73 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)69 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)43 Label (org.apache.wicket.markup.html.basic.Label)43 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)37 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)36 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)31 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)31 Model (org.apache.wicket.model.Model)22 Item (org.apache.wicket.markup.repeater.Item)19 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)18 List (java.util.List)18 Component (org.apache.wicket.Component)18 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)17 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)17 PropertyModel (org.apache.wicket.model.PropertyModel)15 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)14 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)13