Search in sources :

Example 1 with DropDownChoice

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

the class ObjectBrowserPanel method initLayout.

private void initLayout(Class<? extends O> type, final List<QName> supportedTypes, final boolean multiselect) {
    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<QName> typeSelect = new DropDownChoice<QName>(ID_TYPE, typeModel, new ListModel<QName>(supportedTypes), new QNameChoiceRenderer());
    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(qnameToCompileTimeClass(typeModel.getObject()), multiselect);
            addOrReplace(listPanel);
            target.add(listPanel);
        }
    });
    typePanel.add(typeSelect);
    ObjectListPanel<O> listPanel = createObjectListPanel(type, 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)).getSelectedObjects();
            QName type = ObjectBrowserPanel.this.typeModel.getObject();
            ObjectBrowserPanel.this.addPerformed(target, type, selected);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    add(addButton);
}
Also used : QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) QName(javax.xml.namespace.QName) 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) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 2 with DropDownChoice

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

the class OrgMemberPanel method initSearch.

@Override
protected void initSearch(Form form) {
    /// TODO: move to utils class??
    List<ObjectTypes> objectTypes = Arrays.asList(ObjectTypes.values());
    Collections.sort(objectTypes, new Comparator<ObjectTypes>() {

        @Override
        public int compare(ObjectTypes o1, ObjectTypes o2) {
            Validate.notNull(o1);
            Validate.notNull(o2);
            String type1 = o1.getValue();
            String type2 = o2.getValue();
            return String.CASE_INSENSITIVE_ORDER.compare(type1, type2);
        }
    });
    DropDownChoice<ObjectTypes> objectType = new DropDownChoice<ObjectTypes>(ID_SEARCH_BY_TYPE, Model.of(OBJECT_TYPES_DEFAULT), objectTypes, new EnumChoiceRenderer<ObjectTypes>());
    objectType.add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshTable(target);
        }
    });
    objectType.setOutputMarkupId(true);
    form.add(objectType);
    DropDownChoice<String> seachScrope = new DropDownChoice<String>(ID_SEARCH_SCOPE, Model.of(SEARCH_SCOPE_SUBTREE), SEARCH_SCOPE_VALUES, new StringResourceChoiceRenderer("TreeTablePanel.search.scope"));
    seachScrope.add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshTable(target);
        }
    });
    seachScrope.setOutputMarkupId(true);
    form.add(seachScrope);
}
Also used : StringResourceChoiceRenderer(com.evolveum.midpoint.web.util.StringResourceChoiceRenderer) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice)

Example 3 with DropDownChoice

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

the class DropDownFormGroup method createDropDown.

protected DropDownChoice<T> createDropDown(String id, IModel<List<T>> choices, IChoiceRenderer<T> renderer, boolean required) {
    DropDownChoice choice = new DropDownChoice<T>(id, getModel(), choices, renderer) {

        @Override
        protected String getNullValidDisplayValue() {
            return getString("DropDownChoicePanel.empty");
        }
    };
    choice.setNullValid(!required);
    choice.setRequired(required);
    return choice;
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice)

Example 4 with DropDownChoice

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

the class TaskSchedulingTabPanel method initLayoutForSchedulingTable.

private void initLayoutForSchedulingTable() {
    // models
    final IModel<Boolean> recurringCheckModel = new PropertyModel<>(taskDtoModel, TaskDto.F_RECURRING);
    final IModel<Boolean> boundCheckModel = new PropertyModel<Boolean>(taskDtoModel, TaskDto.F_BOUND);
    // behaviors
    final VisibleEnableBehaviour visibleIfEditAndRunnableOrRunning = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return parentPage.isEdit() && parentPage.getTaskDto().isRunnableOrRunning();
        }
    };
    final VisibleEnableBehaviour visibleIfRecurringAndScheduleIsAccessible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheckModel.getObject() && !boundCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && (!parentPage.getTaskDto().isRunnableOrRunning() || !boundCheckModel.getObject()) && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndNotRunningAndScheduleIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && !parentPage.getTaskDto().isRunning() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndScheduleIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndThreadStopIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_THREAD_STOP_ACTION));
        }
    };
    // components
    final WebMarkupContainer schedulingTable = new WebMarkupContainer(ID_SCHEDULING_TABLE);
    schedulingTable.setOutputMarkupId(true);
    add(schedulingTable);
    WebMarkupContainer recurringContainer = new WebMarkupContainer(ID_RECURRING_CONTAINER);
    AjaxCheckBox recurringCheck = new AjaxCheckBox(ID_RECURRING_CHECK, recurringCheckModel) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(schedulingTable);
        }
    };
    recurringCheck.setOutputMarkupId(true);
    recurringCheck.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_RECURRENCE);
        }
    });
    recurringContainer.add(recurringCheck);
    WebMarkupContainer suspendReqRecurring = new WebMarkupContainer(ID_SUSPEND_REQ_RECURRING);
    suspendReqRecurring.add(visibleIfEditAndRunnableOrRunning);
    recurringContainer.add(suspendReqRecurring);
    recurringContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_RECURRENCE));
    schedulingTable.add(recurringContainer);
    final WebMarkupContainer boundContainer = new WebMarkupContainer(ID_BOUND_CONTAINER);
    boundContainer.setOutputMarkupId(true);
    final AjaxCheckBox bound = new AjaxCheckBox(ID_BOUND_CHECK, boundCheckModel) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(schedulingTable);
        }
    };
    bound.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_BINDING);
        }
    });
    boundContainer.add(bound);
    WebMarkupContainer suspendReqBound = new WebMarkupContainer(ID_SUSPEND_REQ_BOUND);
    suspendReqBound.add(visibleIfEditAndRunnableOrRunning);
    boundContainer.add(suspendReqBound);
    boundContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_BINDING));
        }
    });
    Label boundHelp = new Label(ID_BOUND_HELP);
    boundHelp.add(new InfoTooltipBehavior());
    boundContainer.add(boundHelp);
    schedulingTable.add(boundContainer);
    WebMarkupContainer intervalContainer = new WebMarkupContainer(ID_INTERVAL_CONTAINER);
    intervalContainer.add(visibleIfRecurringAndScheduleIsAccessible);
    intervalContainer.setOutputMarkupId(true);
    schedulingTable.add(intervalContainer);
    TextField<Integer> interval = new TextField<>(ID_INTERVAL, new PropertyModel<Integer>(taskDtoModel, TaskDto.F_INTERVAL));
    interval.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    interval.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
    intervalContainer.add(interval);
    WebMarkupContainer cronContainer = new WebMarkupContainer(ID_CRON_CONTAINER);
    cronContainer.add(visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible);
    cronContainer.setOutputMarkupId(true);
    schedulingTable.add(cronContainer);
    TextField<String> cron = new TextField<>(ID_CRON, new PropertyModel<String>(taskDtoModel, TaskDto.F_CRON_SPECIFICATION));
    cron.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    cron.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
    cronContainer.add(cron);
    Label cronHelp = new Label(ID_CRON_HELP);
    cronHelp.add(new InfoTooltipBehavior());
    cronContainer.add(cronHelp);
    WebMarkupContainer notStartBeforeContainer = new WebMarkupContainer(ID_NOT_START_BEFORE_CONTAINER);
    DateInput notStartBefore = new DateInput(ID_NOT_START_BEFORE_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_BEFORE));
    notStartBefore.setOutputMarkupId(true);
    notStartBefore.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
    notStartBeforeContainer.add(notStartBefore);
    notStartBeforeContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
    schedulingTable.add(notStartBeforeContainer);
    WebMarkupContainer notStartAfterContainer = new WebMarkupContainer(ID_NOT_START_AFTER_CONTAINER);
    DateInput notStartAfter = new DateInput(ID_NOT_START_AFTER_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_AFTER));
    notStartAfter.setOutputMarkupId(true);
    notStartAfter.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
    notStartAfterContainer.add(notStartAfter);
    notStartAfterContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
    schedulingTable.add(notStartAfterContainer);
    WebMarkupContainer misfireActionContainer = new WebMarkupContainer(ID_MISFIRE_ACTION_CONTAINER);
    DropDownChoice misfire = new DropDownChoice(ID_MISFIRE_ACTION, new PropertyModel<MisfireActionType>(taskDtoModel, TaskDto.F_MISFIRE_ACTION), WebComponentUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(parentPage));
    misfire.add(enabledIfEditAndScheduleIsEditable);
    misfireActionContainer.add(misfire);
    misfireActionContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
    schedulingTable.add(misfireActionContainer);
    WebMarkupContainer threadStopContainer = new WebMarkupContainer(ID_THREAD_STOP_CONTAINER);
    DropDownChoice threadStop = new DropDownChoice<>(ID_THREAD_STOP, new Model<ThreadStopActionType>() {

        @Override
        public ThreadStopActionType getObject() {
            return taskDtoModel.getObject().getThreadStopActionType();
        }

        @Override
        public void setObject(ThreadStopActionType object) {
            taskDtoModel.getObject().setThreadStopActionType(object);
        }
    }, WebComponentUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(parentPage));
    threadStop.add(enabledIfEditAndThreadStopIsEditable);
    threadStopContainer.add(threadStop);
    threadStopContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_THREAD_STOP_ACTION));
    schedulingTable.add(threadStopContainer);
    org.apache.wicket.markup.html.form.Form<?> form = parentPage.getForm();
    // TODO implement more intelligently when other tabs have validators as well
    for (IFormValidator validator : form.getFormValidators()) {
        form.remove(validator);
    }
    form.add(new StartEndDateValidator(notStartBefore, notStartAfter));
    form.add(new ScheduleValidator(parentPage.getTaskManager(), recurringCheck, bound, interval, cron));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) StartEndDateValidator(com.evolveum.midpoint.web.page.admin.server.dto.StartEndDateValidator) IFormValidator(org.apache.wicket.markup.html.form.validation.IFormValidator) ScheduleValidator(com.evolveum.midpoint.web.page.admin.server.dto.ScheduleValidator) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) ThreadStopActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ThreadStopActionType) Date(java.util.Date) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) DateInput(com.evolveum.midpoint.web.component.DateInput) MisfireActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.MisfireActionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 5 with DropDownChoice

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

the class RoleMemberPanel method createMemberAssignmentToModify.

private AssignmentType createMemberAssignmentToModify(QName relation) throws SchemaException {
    AssignmentType assignmentToModify = createAssignmentToModify(relation);
    DropDownChoice<OrgType> tenantChoice = (DropDownChoice<OrgType>) get(ID_TENANT);
    OrgType tenant = tenantChoice.getModelObject();
    if (tenant != null) {
        assignmentToModify.setTenantRef(ObjectTypeUtil.createObjectRef(tenant.getOid(), ObjectTypes.ORG));
    }
    DropDownChoice<OrgType> projectChoice = (DropDownChoice<OrgType>) get(ID_PROJECT);
    OrgType project = projectChoice.getModelObject();
    if (project != null) {
        assignmentToModify.setOrgRef(ObjectTypeUtil.createObjectRef(project.getOid(), ObjectTypes.ORG));
    }
    return assignmentToModify;
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

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