Search in sources :

Example 1 with QNameIChoiceRenderer

use of com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer in project midpoint by Evolveum.

the class AppendersContentPanel method createNewAppenderChoice.

private Component createNewAppenderChoice(String id) {
    List<QName> choices = Arrays.asList(FileAppenderConfigurationType.COMPLEX_TYPE, SyslogAppenderConfigurationType.COMPLEX_TYPE);
    DropDownChoicePanel<QName> choice = new DropDownChoicePanel<>(id, Model.of(FileAppenderConfigurationType.COMPLEX_TYPE), Model.ofList(choices), new QNameIChoiceRenderer("AppendersContentPanel.appendersChoice"));
    choice.setOutputMarkupId(true);
    this.newAppenderChoice = choice;
    return choice;
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QNameIChoiceRenderer(com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer) QName(javax.xml.namespace.QName)

Example 2 with QNameIChoiceRenderer

use of com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer 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)

Example 3 with QNameIChoiceRenderer

use of com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer in project midpoint by Evolveum.

the class RelationSearchItem method createSpecialSearchPanel.

@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
    return new SearchSpecialItemPanel(id, new PropertyModel<>(searchBoxConfiguration, SearchBoxConfigurationHelper.F_RELATION_ITEM)) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            ReadOnlyModel<List<QName>> availableRelations = new ReadOnlyModel<>(() -> {
                List<QName> choices = new ArrayList();
                IModel<RelationSearchItemConfigurationType> relationItem = getModelValue();
                List<QName> relations = relationItem.getObject().getSupportedRelations();
                if (relations != null && relations.size() > 1) {
                    choices.add(PrismConstants.Q_ANY);
                }
                choices.addAll(relations);
                return choices;
            });
            DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, new PropertyModel(getModelValue(), RelationSearchItemConfigurationType.F_DEFAULT_VALUE.getLocalPart()), availableRelations, new QNameIChoiceRenderer() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(QName relation) {
                    RelationDefinitionType relationDef = WebComponentUtil.getRelationDefinition(relation);
                    if (relationDef != null) {
                        DisplayType display = relationDef.getDisplay();
                        if (display != null) {
                            PolyStringType label = display.getLabel();
                            if (PolyStringUtils.isNotEmpty(label)) {
                                return WebComponentUtil.getTranslatedPolyString(label);
                            }
                        }
                    }
                    if (QNameUtil.match(PrismConstants.Q_ANY, relation)) {
                        return new ResourceModel("RelationTypes.ANY", relation.getLocalPart()).getObject();
                    }
                    return super.getDisplayValue(relation);
                }
            }, false);
            inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
            inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 100px; max-width: 400px !important;"));
            inputPanel.getBaseFormComponent().add(new EnableBehaviour(() -> availableRelations.getObject().size() > 1));
            inputPanel.setOutputMarkupId(true);
            return inputPanel;
        }

        @Override
        protected IModel<String> createLabelModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getLabel()));
        }

        @Override
        protected IModel<String> createHelpModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getHelp()));
        }
    };
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QNameIChoiceRenderer(com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) PropertyModel(org.apache.wicket.model.PropertyModel) RelationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ResourceModel(org.apache.wicket.model.ResourceModel) ArrayList(java.util.ArrayList) List(java.util.List) RelationSearchItemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.RelationSearchItemConfigurationType) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Aggregations

QNameIChoiceRenderer (com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer)3 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)3 QName (javax.xml.namespace.QName)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 DisplayNamePanel (com.evolveum.midpoint.gui.api.component.DisplayNamePanel)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)1 MultivalueContainerDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel)1 MultivalueContainerListPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel)1 MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)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 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 SearchItemDefinition (com.evolveum.midpoint.web.component.search.SearchItemDefinition)1 SearchSpecialItemPanel (com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)1 EnableBehaviour (com.evolveum.midpoint.web.component.util.EnableBehaviour)1