Search in sources :

Example 31 with DropDownChoice

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

the class PageTaskAdd method initAdvanced.

private void initAdvanced(Form mainForm) {
    CheckBox runUntilNodeDown = new CheckBox(ID_RUN_UNTIL_NODW_DOWN, new PropertyModel<Boolean>(model, TaskAddDto.F_RUN_UNTIL_NODW_DOWN));
    mainForm.add(runUntilNodeDown);
    final IModel<Boolean> createSuspendedCheck = new PropertyModel<>(model, TaskAddDto.F_SUSPENDED_STATE);
    CheckBox createSuspended = new CheckBox(ID_CREATE_SUSPENDED, createSuspendedCheck);
    mainForm.add(createSuspended);
    DropDownChoice threadStop = new DropDownChoice<>(ID_THREAD_STOP, new Model<ThreadStopActionType>() {

        @Override
        public ThreadStopActionType getObject() {
            TaskAddDto dto = model.getObject();
            //				}
            return dto.getThreadStop();
        }

        @Override
        public void setObject(ThreadStopActionType object) {
            model.getObject().setThreadStop(object);
        }
    }, WebComponentUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(PageTaskAdd.this));
    mainForm.add(threadStop);
    mainForm.add(new TsaValidator(runUntilNodeDown, threadStop));
    DropDownChoice misfire = new DropDownChoice<>(ID_MISFIRE_ACTION, new PropertyModel<MisfireActionType>(model, TaskAddDto.F_MISFIRE_ACTION), WebComponentUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(PageTaskAdd.this));
    mainForm.add(misfire);
}
Also used : TaskAddDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddDto) PropertyModel(org.apache.wicket.model.PropertyModel) ThreadStopActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ThreadStopActionType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) TsaValidator(com.evolveum.midpoint.web.page.admin.server.dto.TsaValidator) MisfireActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.MisfireActionType)

Example 32 with DropDownChoice

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

the class PageTaskAdd method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_FORM_MAIN);
    add(mainForm);
    final DropDownChoice resource = new DropDownChoice<>(ID_RESOURCE, new PropertyModel<TaskAddResourcesDto>(model, TaskAddDto.F_RESOURCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {

        @Override
        public List<TaskAddResourcesDto> getObject() {
            return createResourceList();
        }
    }, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
    resource.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    resource.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            PageTaskAdd.this.loadResource();
            target.add(get(ID_FORM_MAIN + ":" + ID_OBJECT_CLASS));
        }
    });
    resource.setOutputMarkupId(true);
    mainForm.add(resource);
    final DropDownChoice focusType = new DropDownChoice<>(ID_FOCUS_TYPE, new PropertyModel<QName>(model, TaskAddDto.F_FOCUS_TYPE), new AbstractReadOnlyModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return createFocusTypeList();
        }
    }, new QNameChoiceRenderer());
    focusType.setOutputMarkupId(true);
    focusType.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            return TaskCategory.RECOMPUTATION.equals(dto.getCategory());
        }
    });
    mainForm.add(focusType);
    final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(model, TaskAddDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    kind.setOutputMarkupId(true);
    kind.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    mainForm.add(kind);
    final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(model, TaskAddDto.F_INTENT));
    mainForm.add(intent);
    intent.setOutputMarkupId(true);
    intent.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    if (model.getObject() != null && model.getObject().getResource() != null && model.getObject().getResource().getOid() != null) {
        loadResource();
    }
    AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
    autoCompleteSettings.setShowListOnEmptyInput(true);
    autoCompleteSettings.setMaxHeightInPx(200);
    final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(model, TaskAddDto.F_OBJECT_CLASS), autoCompleteSettings) {

        @Override
        protected Iterator<String> getChoices(String input) {
            return prepareObjectClassChoiceList(input);
        }
    };
    objectClass.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    mainForm.add(objectClass);
    DropDownChoice type = new DropDownChoice<>(ID_CATEGORY, new PropertyModel<String>(model, TaskAddDto.F_CATEGORY), new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            return WebComponentUtil.createTaskCategoryList();
        }
    }, new StringChoiceRenderer("pageTask.category."));
    type.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(resource);
            target.add(intent);
            target.add(kind);
            target.add(objectClass);
            target.add(focusType);
        }
    });
    type.setRequired(true);
    mainForm.add(type);
    TextField<String> name = new TextField<>(ID_NAME, new PropertyModel<String>(model, TaskAddDto.F_NAME));
    name.setRequired(true);
    mainForm.add(name);
    initScheduling(mainForm);
    initAdvanced(mainForm);
    CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(model, TaskAddDto.F_DRY_RUN));
    mainForm.add(dryRun);
    initButtons(mainForm);
}
Also used : TaskAddDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddDto) Form(org.apache.wicket.markup.html.form.Form) 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) DateTextField(org.apache.wicket.datetime.markup.html.form.DateTextField) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 33 with DropDownChoice

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

the class RoleMemberPanel method createDropDown.

private <V> DropDownChoice<V> createDropDown(String id, IModel<V> defaultModel, final List<V> values, IChoiceRenderer<V> renderer) {
    DropDownChoice<V> listSelect = new DropDownChoice<V>(id, defaultModel, new AbstractReadOnlyModel<List<V>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<V> getObject() {
            return values;
        }
    }, renderer);
    listSelect.add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshTable(target);
        }
    });
    return listSelect;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) List(java.util.List) ArrayList(java.util.ArrayList) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior)

Example 34 with DropDownChoice

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

the class RoleMemberPanel method createDirectMemberQuery.

private ObjectQuery createDirectMemberQuery() {
    ObjectQuery query;
    String oid = getModelObject().getOid();
    S_AtomicFilterExit q = QueryBuilder.queryFor(FocusType.class, getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(createReferenceValuesList());
    DropDownChoice<OrgType> tenantChoice = (DropDownChoice) get(createComponentPath(ID_TENANT));
    OrgType tenant = tenantChoice.getModelObject();
    if (tenant != null) {
        q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF).ref(createReference(tenant).asReferenceValue());
    }
    DropDownChoice<OrgType> projectChoice = (DropDownChoice) get(createComponentPath(ID_PROJECT));
    OrgType project = projectChoice.getModelObject();
    if (project != null) {
        q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(createReference(project).asReferenceValue());
    }
    query = q.build();
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Searching members of role {} with query:\n{}", oid, query.debugDump());
    }
    DropDownChoice<QName> objectTypeChoice = (DropDownChoice) get(createComponentPath(ID_OBJECT_TYPE));
    QName objectType = objectTypeChoice.getModelObject();
    if (objectType == null || FocusType.COMPLEX_TYPE.equals(objectType)) {
        return query;
    } else {
        return ObjectQuery.createObjectQuery(TypeFilter.createType(objectType, query.getFilter()));
    }
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) QName(javax.xml.namespace.QName) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 35 with DropDownChoice

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

the class GuiComponents method createTriStateCombo.

public static <T> DropDownChoice createTriStateCombo(String id, IModel<Boolean> model) {
    final IChoiceRenderer<T> renderer = new IChoiceRenderer<T>() {

        @Override
        public T getObject(String id, IModel<? extends List<? extends T>> choices) {
            return id != null ? choices.getObject().get(Integer.parseInt(id)) : null;
        }

        @Override
        public String getDisplayValue(T object) {
            String key;
            if (object == null) {
                key = KEY_BOOLEAN_NULL;
            } else {
                Boolean b = (Boolean) object;
                key = b ? KEY_BOOLEAN_TRUE : KEY_BOOLEAN_FALSE;
            }
            StringResourceModel model = PageBase.createStringResourceStatic(null, key);
            //                
            return model.getString();
        }

        @Override
        public String getIdValue(T object, int index) {
            return Integer.toString(index);
        }
    };
    DropDownChoice dropDown = new DropDownChoice(id, model, createChoices(), renderer) {

        @Override
        protected CharSequence getDefaultChoice(String selectedValue) {
            StringResourceModel model = PageBase.createStringResourceStatic(null, KEY_BOOLEAN_NULL);
            return model.getString();
        }
    };
    dropDown.setNullValid(true);
    return dropDown;
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) IModel(org.apache.wicket.model.IModel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ArrayList(java.util.ArrayList) List(java.util.List) StringResourceModel(org.apache.wicket.model.StringResourceModel)

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