Search in sources :

Example 11 with DropDownChoice

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

the class LoggingConfigPanel method initRoot.

private void initRoot() {
    DropDownChoice<LoggingLevelType> rootLevel = new DropDownChoice<>(ID_ROOT_LEVEL, new PropertyModel<LoggingLevelType>(getModel(), LoggingDto.F_ROOT_LEVEL), WebComponentUtil.createReadonlyModelFromEnum(LoggingLevelType.class));
    rootLevel.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(rootLevel);
    DropDownChoice<String> rootAppender = new DropDownChoice<>(ID_ROOT_APPENDER, new PropertyModel<String>(getModel(), LoggingDto.F_ROOT_APPENDER), createAppendersListModel());
    rootAppender.setNullValid(true);
    rootAppender.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            rootAppenderChangePerformed(target);
        }
    });
    rootAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(rootAppender);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LoggingLevelType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingLevelType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior)

Example 12 with DropDownChoice

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

the class ResourceRelatedHandlerPanel method initLayout.

private void initLayout() {
    final VisibleEnableBehaviour visibleIfEdit = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return parentPage.isEdit();
        }
    };
    final VisibleEnableBehaviour visibleIfView = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !parentPage.isEdit();
        }
    };
    enabledIfEdit = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit();
        }
    };
    final VisibleEnableBehaviour visibleForResourceCoordinates = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresResourceCoordinates();
        }
    };
    final WebMarkupContainer resourceRefContainer = new WebMarkupContainer(ID_RESOURCE_REF_CONTAINER);
    resourceRefContainer.add(visibleForResourceCoordinates);
    resourceRefContainer.setOutputMarkupId(true);
    add(resourceRefContainer);
    final DropDownChoice<TaskAddResourcesDto> resourceRef = new DropDownChoice<>(ID_RESOURCE_REF, new PropertyModel<TaskAddResourcesDto>(getModel(), ResourceRelatedHandlerDto.F_RESOURCE_REFERENCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {

        @Override
        public List<TaskAddResourcesDto> getObject() {
            return createResourceList();
        }
    }, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
    resourceRef.setOutputMarkupId(true);
    resourceRef.add(enabledIfEdit);
    resourceRef.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Task task = parentPage.createSimpleTask(OPERATION_LOAD_RESOURCE);
            OperationResult result = task.getResult();
            List<QName> objectClassList = new ArrayList<>();
            TaskAddResourcesDto resourcesDto = getModelObject().getResourceRef();
            if (resourcesDto != null) {
                PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(ResourceType.class, resourcesDto.getOid(), parentPage, task, result);
                try {
                    ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, parentPage.getPrismContext());
                    schema.getObjectClassDefinitions();
                    for (Definition def : schema.getDefinitions()) {
                        objectClassList.add(def.getTypeName());
                    }
                    getModelObject().setObjectClassList(objectClassList);
                } catch (Exception e) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
                    error("Couldn't load object class list from resource.");
                }
            }
            target.add(resourceRefContainer);
        }
    });
    resourceRefContainer.add(resourceRef);
    WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
    kindContainer.add(visibleForResourceCoordinates);
    add(kindContainer);
    final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(getModel(), ResourceRelatedHandlerDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    kind.setOutputMarkupId(true);
    kind.setNullValid(true);
    kindContainer.add(kind);
    WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
    intentContainer.add(visibleForResourceCoordinates);
    add(intentContainer);
    final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_INTENT));
    intentContainer.add(intent);
    intent.setOutputMarkupId(true);
    intent.add(enabledIfEdit);
    WebMarkupContainer objectClassContainer = new WebMarkupContainer(ID_OBJECT_CLASS_CONTAINER);
    objectClassContainer.add(visibleForResourceCoordinates);
    add(objectClassContainer);
    AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
    autoCompleteSettings.setShowListOnEmptyInput(true);
    final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_OBJECT_CLASS), autoCompleteSettings) {

        @Override
        protected Iterator<String> getChoices(String input) {
            return prepareObjectClassChoiceList(input);
        }
    };
    objectClass.add(enabledIfEdit);
    objectClassContainer.add(objectClass);
    WebMarkupContainer optionsContainer = new WebMarkupContainer(ID_OPTIONS_CONTAINER);
    optionsContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresDryRun();
        }
    });
    add(optionsContainer);
    WebMarkupContainer dryRunContainer = new WebMarkupContainer(ID_DRY_RUN_CONTAINER);
    dryRunContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresDryRun();
        }
    });
    optionsContainer.add(dryRunContainer);
    CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(getModel(), ResourceRelatedHandlerDto.F_DRY_RUN));
    dryRun.add(enabledIfEdit);
    dryRunContainer.add(dryRun);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Definition(com.evolveum.midpoint.prism.Definition) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 13 with DropDownChoice

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

the class OrgMemberPanel method createContentQuery.

@Override
protected ObjectQuery createContentQuery() {
    String oid = getModelObject().getOid();
    DropDownChoice<String> searchScopeChoice = (DropDownChoice<String>) get(createComponentPath(ID_FORM, ID_SEARCH_SCOPE));
    String scope = searchScopeChoice.getModelObject();
    ObjectTypes searchType = getSearchType();
    S_FilterEntryOrEmpty q = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext());
    if (!searchType.equals(ObjectTypes.OBJECT)) {
        q = q.type(searchType.getClassDefinition());
    }
    ObjectQuery query;
    if (SEARCH_SCOPE_ONE.equals(scope)) {
        query = q.isDirectChildOf(oid).build();
    } else {
        query = q.isChildOf(oid).build();
    }
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Searching members of org {} with query:\n{}", oid, query.debugDump());
    }
    return query;
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) S_FilterEntryOrEmpty(com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 14 with DropDownChoice

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

the class AjaxEditableChoiceLabel method newEditor.

/**
 * {@inheritDoc}
 */
@Override
protected FormComponent<T> newEditor(final MarkupContainer parent, final String componentId, final IModel<T> model) {
    IModel<List<? extends T>> choiceModel = new IModel<List<? extends T>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<? extends T> getObject() {
            return choices.getObject();
        }
    };
    DropDownChoice<T> editor = new DropDownChoice<T>(componentId, model, choiceModel, renderer) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onModelChanged() {
            AjaxEditableChoiceLabel.this.onModelChanged();
        }

        @Override
        protected void onModelChanging() {
            AjaxEditableChoiceLabel.this.onModelChanging();
        }
    };
    editor.setOutputMarkupId(true);
    editor.setVisible(false);
    editor.add(new EditorAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setEventNames("change", "blur", "keyup");
            CharSequence dynamicExtraParameters = "var result = [], " + "kc=Wicket.Event.keyCode(attrs.event)," + "evtType=attrs.event.type;" + "if (evtType === 'blur' || (evtType === 'keyup' && kc===27)) {" + "  result.push( { name: 'save', value: false } );" + "}" + "else {" + "  result = Wicket.Form.serializeElement(attrs.c);" + "  result.push( { name: 'save', value: true } );" + "}" + "return result;";
            attributes.getDynamicExtraParameters().add(dynamicExtraParameters);
            CharSequence precondition = "var kc=Wicket.Event.keyCode(attrs.event)," + "evtType=attrs.event.type," + "ret=false;" + "if(evtType==='blur' || evtType==='change' || (evtType==='keyup' && kc===27)) ret = true;" + "return ret;";
            AjaxCallListener ajaxCallListener = new AjaxCallListener();
            ajaxCallListener.onPrecondition(precondition);
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
    return editor;
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) IModel(org.apache.wicket.model.IModel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) List(java.util.List) AjaxCallListener(org.apache.wicket.ajax.attributes.AjaxCallListener)

Example 15 with DropDownChoice

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

the class DirectoryPanel method initResultTable.

protected void initResultTable() {
    // ---------------------------
    // Result table initialization
    // ---------------------------
    updateResultTable(false);
    // ---------------------------
    // ---------------------------
    // Rows-per-page selector
    // ---------------------------
    Form<?> paginatorForm = new Form<>("paginator");
    paginatorForm.setOutputMarkupPlaceholderTag(true);
    paginatorForm.setVisible(showPaginator);
    container.add(paginatorForm);
    DropDownChoice<Integer> rowsChooser = new DropDownChoice<>("rowsChooser", new PropertyModel<>(this, "rows"), prefMan.getPaginatorChoices());
    rowsChooser.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            prefMan.set(getRequest(), getResponse(), paginatorRowsKey(), String.valueOf(rows));
            EventDataWrapper data = new EventDataWrapper();
            data.setTarget(target);
            data.setRows(rows);
            send(getParent(), Broadcast.BREADTH, data);
        }
    });
    paginatorForm.add(rowsChooser);
    // ---------------------------
    // ---------------------------
    // Table handling
    // ---------------------------
    container.add(getHeader("tablehandling"));
// ---------------------------
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Form(org.apache.wicket.markup.html.form.Form) IndicatorAjaxFormComponentUpdatingBehavior(org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior)

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