Search in sources :

Example 1 with SearchItemDefinition

use of com.evolveum.midpoint.web.component.search.SearchItemDefinition 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 2 with SearchItemDefinition

use of com.evolveum.midpoint.web.component.search.SearchItemDefinition in project midpoint by Evolveum.

the class ResourceContentResourcePanel method createAttributeDefinitionList.

private <T extends ObjectType> List<SearchItemDefinition> createAttributeDefinitionList() {
    List<SearchItemDefinition> map = new ArrayList<>();
    ResourceObjectDefinition ocDef = null;
    try {
        if (getKind() != null) {
            ocDef = getDefinitionByKind();
        } else if (getObjectClass() != null) {
            ocDef = getDefinitionByObjectClass();
        }
    } catch (SchemaException e) {
        warn("Could not get determine object class definition");
        return map;
    }
    if (ocDef == null) {
        return map;
    }
    for (ResourceAttributeDefinition def : ocDef.getAttributeDefinitions()) {
        map.add(new SearchItemDefinition(ItemPath.create(ShadowType.F_ATTRIBUTES, getAttributeName(def)), def, null));
    }
    return map;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ArrayList(java.util.ArrayList) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition)

Example 3 with SearchItemDefinition

use of com.evolveum.midpoint.web.component.search.SearchItemDefinition in project midpoint by Evolveum.

the class ResourceContentResourcePanel method createSearch.

@Override
protected Search createSearch() {
    List<SearchItemDefinition> availableDefs = new ArrayList<>();
    availableDefs.addAll(createAttributeDefinitionList());
    return new Search(new ContainerTypeSearchItem(ShadowType.class), availableDefs);
}
Also used : ContainerTypeSearchItem(com.evolveum.midpoint.web.component.search.ContainerTypeSearchItem) Search(com.evolveum.midpoint.web.component.search.Search) ArrayList(java.util.ArrayList) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition)

Example 4 with SearchItemDefinition

use of com.evolveum.midpoint.web.component.search.SearchItemDefinition in project midpoint by Evolveum.

the class LoggingConfigurationTabPanel method initLayout.

protected void initLayout() {
    try {
        ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder();
        builder.visibilityHandler(itemWrapper -> getLoggingVisibility(itemWrapper.getPath()));
        Panel loggingPanel = getPageBase().initItemPanel(ID_LOGGING, LoggingConfigurationType.COMPLEX_TYPE, getModel(), builder.build());
        add(loggingPanel);
    } catch (SchemaException e) {
        LOGGER.error("Cannot create panel for logging: {}", e.getMessage(), e);
        getSession().error("Cannot create panle for logging");
    }
    PrismContainerWrapperModel<LoggingConfigurationType, ClassLoggerConfigurationType> loggerModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_CLASS_LOGGER);
    MultivalueContainerListPanel<ClassLoggerConfigurationType> loggersMultivalueContainerListPanel = new MultivalueContainerListPanel<ClassLoggerConfigurationType>(ID_LOGGERS, ClassLoggerConfigurationType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ClassLoggerConfigurationType> containerDef) {
            List<SearchItemDefinition> defs = new ArrayList<>();
            SearchFactory.addSearchPropertyDef(containerDef, ClassLoggerConfigurationType.F_APPENDER, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ClassLoggerConfigurationType.F_PACKAGE, defs);
            defs.addAll(SearchFactory.createExtensionDefinitionList(containerDef));
            return defs;
        }

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            PrismContainerValue<ClassLoggerConfigurationType> newLogger = loggerModel.getObject().getItem().createNewValue();
            PrismContainerValueWrapper<ClassLoggerConfigurationType> newLoggerWrapper = getLoggersMultivalueContainerListPanel().createNewItemContainerValueWrapper(newLogger, loggerModel.getObject(), target);
            loggerEditPerformed(target, Model.of(newLoggerWrapper), null);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            return true;
        }

        @Override
        protected IModel<PrismContainerWrapper<ClassLoggerConfigurationType>> getContainerModel() {
            return loggerModel;
        }

        @Override
        protected String getStorageKey() {
            return SessionStorage.KEY_LOGGING_TAB_LOGGER_TABLE;
        }

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

        @Override
        protected List<IColumn<PrismContainerValueWrapper<ClassLoggerConfigurationType>, String>> createDefaultColumns() {
            return initLoggersBasicColumns(loggerModel);
        }

        @Override
        protected void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ClassLoggerConfigurationType>> rowModel, List<PrismContainerValueWrapper<ClassLoggerConfigurationType>> listItems) {
            loggerEditPerformed(target, rowModel, listItems);
        }
    };
    add(loggersMultivalueContainerListPanel);
    PrismContainerWrapperModel<LoggingConfigurationType, AppenderConfigurationType> appenderModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_APPENDER);
    MultivalueContainerListPanelWithDetailsPanel<AppenderConfigurationType> appendersMultivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<AppenderConfigurationType>(ID_APPENDERS, AppenderConfigurationType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            newAppendersClickPerformed(target, appenderModel);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            return true;
        }

        @Override
        protected IModel<PrismContainerWrapper<AppenderConfigurationType>> getContainerModel() {
            return appenderModel;
        }

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

        @Override
        protected String getStorageKey() {
            return SessionStorage.KEY_LOGGING_TAB_APPENDER_TABLE;
        }

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

        @Override
        protected List<IColumn<PrismContainerValueWrapper<AppenderConfigurationType>, String>> createDefaultColumns() {
            return initAppendersBasicColumns(appenderModel);
        }

        @Override
        protected MultivalueContainerDetailsPanel<AppenderConfigurationType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AppenderConfigurationType>> item) {
            return LoggingConfigurationTabPanel.this.getAppendersMultivalueContainerDetailsPanel(item);
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> bar = new ArrayList<>();
            // MidpointForm appenderTypeForm = new MidpointForm(ID_CHOICE_APPENDER_TYPE_FORM);
            AjaxSubmitButton newObjectIcon = new AjaxSubmitButton(idButton, new Model<>("<i class=\"fa fa-plus\"></i>")) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    newItemPerformed(target, null);
                }
            };
            newObjectIcon.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return isCreateNewObjectVisible();
                }

                @Override
                public boolean isEnabled() {
                    return isNewObjectButtonEnabled();
                }
            });
            newObjectIcon.add(AttributeModifier.append("class", createStyleClassModelForNewObjectIcon()));
            // appenderTypeForm.add(newObjectIcon);
            bar.add(newObjectIcon);
            List<QName> appendersChoicesList = new ArrayList<>();
            appendersChoicesList.add(FileAppenderConfigurationType.COMPLEX_TYPE);
            appendersChoicesList.add(SyslogAppenderConfigurationType.COMPLEX_TYPE);
            DropDownChoicePanel<QName> appenderChoice = new DropDownChoicePanel<>(idButton, new Model<>(FileAppenderConfigurationType.COMPLEX_TYPE), Model.ofList(appendersChoicesList), new QNameIChoiceRenderer("LoggingConfigurationTabPanel.appendersChoice"));
            appenderChoice.setOutputMarkupId(true);
            LoggingConfigurationTabPanel.this.appenderChoice = appenderChoice;
            bar.add(appenderChoice);
            // bar.add(appenderTypeForm);
            return bar;
        }
    };
    add(appendersMultivalueContainerListPanel);
    IModel<PrismContainerWrapper<LoggingAuditingConfigurationType>> auditModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_AUDITING);
    try {
        Panel auditPanel = getPageBase().initItemPanel(ID_AUDITING, LoggingAuditingConfigurationType.COMPLEX_TYPE, auditModel, new ItemPanelSettingsBuilder().build());
        add(auditPanel);
    } catch (SchemaException e) {
        LOGGER.error("Cannot create panel for auditing: {}", e.getMessage(), e);
        getSession().error("Cannot create panel for auditing.");
    }
    setOutputMarkupId(true);
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QNameIChoiceRenderer(com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer) ArrayList(java.util.ArrayList) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ItemPanelSettingsBuilder(com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder) 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) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) IModel(org.apache.wicket.model.IModel) MultivalueContainerListPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) MultivalueContainerListPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel) DisplayNamePanel(com.evolveum.midpoint.gui.api.component.DisplayNamePanel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

SearchItemDefinition (com.evolveum.midpoint.web.component.search.SearchItemDefinition)4 ArrayList (java.util.ArrayList)4 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)2 MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)2 List (java.util.List)2 Component (org.apache.wicket.Component)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 ListItem (org.apache.wicket.markup.html.list.ListItem)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 DisplayNamePanel (com.evolveum.midpoint.gui.api.component.DisplayNamePanel)1 MultivalueContainerDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel)1 MultivalueContainerListPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel)1 QNameIChoiceRenderer (com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer)1 ItemPanelSettingsBuilder (com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder)1 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)1 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)1