Search in sources :

Example 46 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class ObjectBrowserPanel method initLayout.

private void initLayout() {
    MessagePanel warningMessage = new MessagePanel(ID_WARNING_MESSAGE, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
    warningMessage.setOutputMarkupId(true);
    warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
    add(warningMessage);
    List<ObjectTypes> supported = new ArrayList<>();
    for (QName qname : supportedTypes) {
        supported.add(ObjectTypes.getObjectTypeFromTypeQName(qname));
    }
    WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL);
    typePanel.setOutputMarkupId(true);
    typePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return supportedTypes.size() != 1;
        }
    });
    add(typePanel);
    DropDownChoice<ObjectTypes> typeSelect = new DropDownChoice<>(ID_TYPE, typeModel, new ListModel<>(supported), new EnumChoiceRenderer<>(this));
    typeSelect.add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            ObjectListPanel<O> listPanel = (ObjectListPanel<O>) get(ID_TABLE);
            listPanel = createObjectListPanel(typeModel.getObject(), multiselect);
            addOrReplace(listPanel);
            target.add(listPanel);
        }
    });
    typePanel.add(typeSelect);
    ObjectTypes objType = defaultType != null ? ObjectTypes.getObjectType(defaultType) : null;
    ObjectListPanel<O> listPanel = createObjectListPanel(objType, multiselect);
    add(listPanel);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<O> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedRealObjects();
            ObjectTypes type = ObjectBrowserPanel.this.typeModel.getObject();
            QName qname = type != null ? type.getTypeQName() : null;
            ObjectBrowserPanel.this.addPerformed(target, qname, selected);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    add(addButton);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("Button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            getPageBase().hideMainPopup(ajaxRequestTarget);
        }
    };
    add(cancelButton);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) MessagePanel(com.evolveum.midpoint.gui.api.component.result.MessagePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 47 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class AttributeEditorUtils method addMatchingRuleFields.

static void addMatchingRuleFields(final BasePanel<? extends ResourceItemDefinitionType> editor, final NonEmptyModel<Boolean> readOnlyModel) {
    // normalizes unqualified QNames
    final IModel<QName> matchingRuleModel = new IModel<QName>() {

        @Override
        public QName getObject() {
            QName rawRuleName = editor.getModelObject().getMatchingRule();
            if (rawRuleName == null) {
                return null;
            }
            try {
                MatchingRule<?> rule = editor.getPageBase().getMatchingRuleRegistry().getMatchingRule(rawRuleName, null);
                return rule.getName();
            } catch (SchemaException e) {
                // we could get here if invalid QName is specified - but we don't want to throw an exception in that case
                LoggingUtils.logUnexpectedException(LOGGER, "Invalid matching rule name encountered in resource wizard: {} -- continuing", e, rawRuleName);
                return rawRuleName;
            }
        }

        @Override
        public void setObject(QName value) {
            editor.getModelObject().setMatchingRule(value);
        }

        @Override
        public void detach() {
        }
    };
    final List<QName> matchingRuleList = WebComponentUtil.getMatchingRuleList();
    DropDownChoice matchingRule = new DropDownChoice<>(ID_MATCHING_RULE, matchingRuleModel, new IModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return matchingRuleList;
        }
    }, new QNameChoiceRenderer());
    matchingRule.setNullValid(true);
    matchingRule.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            QName ruleName = matchingRuleModel.getObject();
            return ruleName == null || WebComponentUtil.getMatchingRuleList().contains(ruleName);
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    editor.add(matchingRule);
    Label unknownMatchingRule = new Label(ID_UNKNOWN_MATCHING_RULE, new IModel<String>() {

        @Override
        public String getObject() {
            return editor.getString("ResourceAttributeEditor.label.unknownMatchingRule", matchingRuleModel.getObject());
        }
    });
    unknownMatchingRule.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            QName ruleName = matchingRuleModel.getObject();
            return ruleName != null && !WebComponentUtil.getMatchingRuleList().contains(ruleName);
        }
    });
    editor.add(unknownMatchingRule);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) Label(org.apache.wicket.markup.html.basic.Label) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 48 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class SynchronizationActionEditorDialog method initLayout.

private void initLayout(WebMarkupContainer content) {
    Form form = new MidpointForm(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    content.add(form);
    TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".name"), createStringResource("SynchronizationActionEditorDialog.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(name);
    TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".description"), createStringResource("SynchronizationActionEditorDialog.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(description);
    DropDownFormGroup<SynchronizationActionTypeDto.HandlerUriActions> handlerUri = new DropDownFormGroup<SynchronizationActionTypeDto.HandlerUriActions>(ID_HANDLER_URI, new PropertyModel<>(model, SynchronizationActionTypeDto.F_HANDLER_URI), WebComponentUtil.createReadonlyModelFromEnum(SynchronizationActionTypeDto.HandlerUriActions.class), new EnumChoiceRenderer<>(this), createStringResource("SynchronizationActionEditorDialog.label.handlerUri"), createStringResource("SynchronizationStep.action.tooltip.handlerUri", WebComponentUtil.getMidpointCustomSystemName((PageResourceWizard) getPage(), "midpoint.default.system.name")), ID_LABEL_SIZE, ID_INPUT_SIZE, false, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<SynchronizationActionTypeDto.HandlerUriActions>> choices, IChoiceRenderer<SynchronizationActionTypeDto.HandlerUriActions> renderer, boolean required) {
            DropDownChoice choice = new DropDownChoice<>(id, getModel(), choices, renderer);
            choice.setNullValid(true);
            return choice;
        }
    };
    form.add(handlerUri);
    DropDownFormGroup<BeforeAfterType> order = new DropDownFormGroup<BeforeAfterType>(ID_ORDER, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".order"), WebComponentUtil.createReadonlyModelFromEnum(BeforeAfterType.class), new EnumChoiceRenderer<>(this), createStringResource("SynchronizationActionEditorDialog.label.order"), createStringResource("SynchronizationStep.action.tooltip.order", WebComponentUtil.getMidpointCustomSystemName((PageResourceWizard) getPage(), "midpoint.default.system.name")), ID_LABEL_SIZE, ID_INPUT_SIZE, false, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<BeforeAfterType>> choices, IChoiceRenderer<BeforeAfterType> renderer, boolean required) {
            DropDownChoice choice = new DropDownChoice<>(id, getModel(), choices, renderer);
            choice.setNullValid(true);
            return choice;
        }
    };
    form.add(order);
    initButtons(form);
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) SynchronizationActionTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.SynchronizationActionTypeDto) TextFormGroup(com.evolveum.midpoint.web.component.form.TextFormGroup) IModel(org.apache.wicket.model.IModel) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) BeforeAfterType(com.evolveum.midpoint.xml.ns._public.common.common_3.BeforeAfterType) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) TextAreaFormGroup(com.evolveum.midpoint.web.component.form.TextAreaFormGroup) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice)

Example 49 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class ResourceActivationEditor method prepareActivationPanelBody.

private void prepareActivationPanelBody(String containerValue, String fetchStrategyId, String outboundId, String inboundId, NonEmptyModel<Boolean> readOnlyModel) {
    DropDownChoice fetchStrategy = new DropDownChoice<>(fetchStrategyId, new PropertyModel<>(getModel(), containerValue + ".fetchStrategy"), WebComponentUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class), new EnumChoiceRenderer<>(this));
    fetchStrategy.setNullValid(true);
    fetchStrategy.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(fetchStrategy);
    MultiValueTextEditPanel outbound = new MultiValueTextEditPanel<MappingType>(outboundId, new PropertyModel<>(getModel(), containerValue + ".outbound"), null, false, true, readOnlyModel) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            mappingEditPerformed(target, object, false);
        }
    };
    add(outbound);
    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(inboundId, new PropertyModel<>(getModel(), containerValue + ".inbound"), null, false, true, readOnlyModel) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            mappingEditPerformed(target, object, true);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);
}
Also used : MultiValueTextEditPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) StringResourceModel(org.apache.wicket.model.StringResourceModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) NonEmptyModel(com.evolveum.midpoint.gui.api.model.NonEmptyModel) IModel(org.apache.wicket.model.IModel)

Example 50 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class ExecuteChangeOptionsPanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    createContainer(ID_FORCE_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_FORCE), FORCE_LABEL, FORCE_HELP, true);
    createContainer(ID_RECONCILE_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_RECONCILE), RECONCILE_LABEL, RECONCILE_HELP, showReconcile);
    createContainer(ID_RECONCILE_AFFECTED_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_RECONCILE_AFFECTED), RECONCILE_AFFECTED_LABEL, RECONCILE_AFFECTED_HELP, showReconcileAffected);
    createContainer(ID_EXECUTE_AFTER_ALL_APPROVALS_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_EXECUTE_AFTER_ALL_APPROVALS), EXECUTE_AFTER_ALL_APPROVALS_LABEL, EXECUTE_AFTER_ALL_APPROVALS_HELP, true);
    createContainer(ID_KEEP_DISPLAYING_RESULTS_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_KEEP_DISPLAYING_RESULTS), KEEP_DISPLAYING_RESULTS_LABEL, KEEP_DISPLAYING_RESULTS_HELP, showKeepDisplayingResults, true);
    createContainer(ID_SAVE_IN_BACKGROUND_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_SAVE_IN_BACKGROUND), SAVE_IN_BACKGROUND_LABEL, SAVE_IN_BACKGROUND_HELP, showKeepDisplayingResults, true);
    boolean canRecordTrace;
    try {
        canRecordTrace = getPageBase().isAuthorized(ModelAuthorizationAction.RECORD_TRACE.getUrl());
    } catch (Throwable t) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't check trace recording authorization", t);
        canRecordTrace = false;
    }
    WebMarkupContainer tracingContainer = new WebMarkupContainer(ID_TRACING_CONTAINER);
    tracingContainer.setVisible(canRecordTrace && WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()));
    add(tracingContainer);
    DropDownChoice tracing = new DropDownChoice<>(ID_TRACING, PropertyModel.of(getModel(), ExecuteChangeOptionsDto.F_TRACING), PropertyModel.of(getModel(), ExecuteChangeOptionsDto.F_TRACING_CHOICES), new IChoiceRenderer<TracingProfileType>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(TracingProfileType profile) {
            if (profile == null) {
                return "(none)";
            } else if (profile.getDisplayName() != null) {
                return profile.getDisplayName();
            } else if (profile.getName() != null) {
                return profile.getName();
            } else {
                return "(unnamed profile)";
            }
        }

        @Override
        public String getIdValue(TracingProfileType object, int index) {
            return String.valueOf(index);
        }

        @Override
        public TracingProfileType getObject(String id, IModel<? extends List<? extends TracingProfileType>> choices) {
            return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
        }
    });
    tracing.setNullValid(true);
    tracingContainer.add(tracing);
}
Also used : TracingProfileType(com.evolveum.midpoint.xml.ns._public.common.common_3.TracingProfileType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice)

Aggregations

DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)52 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)30 List (java.util.List)18 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)17 Label (org.apache.wicket.markup.html.basic.Label)17 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)16 CheckBox (org.apache.wicket.markup.html.form.CheckBox)14 IModel (org.apache.wicket.model.IModel)14 ArrayList (java.util.ArrayList)12 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)11 Form (org.apache.wicket.markup.html.form.Form)11 TextField (org.apache.wicket.markup.html.form.TextField)11 PropertyModel (org.apache.wicket.model.PropertyModel)11 QName (javax.xml.namespace.QName)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)8 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)7 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)6 ListItem (org.apache.wicket.markup.html.list.ListItem)6 ListView (org.apache.wicket.markup.html.list.ListView)6 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)5