List of usage examples for org.apache.wicket.markup.html.form EnumChoiceRenderer EnumChoiceRenderer
public EnumChoiceRenderer(Component resourceSource)
From source file:com.evolveum.midpoint.web.page.admin.server.PageTaskAdd.java
License:Apache License
private void initAdvanced(Form mainForm) { CheckBox runUntilNodeDown = new CheckBox("runUntilNodeDown", new PropertyModel<Boolean>(model, "runUntilNodeDown")); mainForm.add(runUntilNodeDown);//w ww . j a v a 2 s.c o m final IModel<Boolean> createSuspendedCheck = new PropertyModel<Boolean>(model, "suspendedState"); CheckBox createSuspended = new CheckBox("createSuspended", createSuspendedCheck); mainForm.add(createSuspended); DropDownChoice threadStop = new DropDownChoice("threadStop", new Model<ThreadStopActionType>() { @Override public ThreadStopActionType getObject() { TaskAddDto dto = model.getObject(); // if (dto.getThreadStop() == null) { // if (!dto.getRunUntilNodeDown()) { // dto.setThreadStop(ThreadStopActionType.RESTART); // } else { // dto.setThreadStop(ThreadStopActionType.CLOSE); // } // } return dto.getThreadStop(); } @Override public void setObject(ThreadStopActionType object) { model.getObject().setThreadStop(object); } }, WebMiscUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(PageTaskAdd.this)); mainForm.add(threadStop); mainForm.add(new TsaValidator(runUntilNodeDown, threadStop)); DropDownChoice misfire = new DropDownChoice("misfireAction", new PropertyModel<MisfireActionType>(model, "misfireAction"), WebMiscUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(PageTaskAdd.this)); mainForm.add(misfire); }
From source file:com.evolveum.midpoint.web.page.admin.server.PageTaskEdit.java
License:Apache License
private void initLayout() { Form mainForm = new Form(ID_MAIN_FORM); add(mainForm);//from w ww . jav a 2 s .co m initMainInfo(mainForm); initSchedule(mainForm); VisibleEnableBehaviour hiddenWhenEditing = new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !edit; } }; VisibleEnableBehaviour hiddenWhenEditingOrNoSubtasks = new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !edit && !model.getObject().getSubtasks().isEmpty(); } }; Label subtasksLabel = new Label(ID_SUBTASKS_LABEL, new ResourceModel("pageTaskEdit.subtasksLabel")); subtasksLabel.add(hiddenWhenEditingOrNoSubtasks); mainForm.add(subtasksLabel); SubtasksPanel subtasksPanel = new SubtasksPanel(ID_SUBTASKS_PANEL, new PropertyModel<List<TaskDto>>(model, TaskDto.F_SUBTASKS), getWorkflowManager().isEnabled()); subtasksPanel.add(hiddenWhenEditingOrNoSubtasks); mainForm.add(subtasksPanel); VisibleEnableBehaviour hiddenWhenEditingOrNoWorkflowInformation = new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !edit && model.getObject().isWorkflowShadowTask() && getWorkflowManager().isEnabled(); } }; Label workflowInformationLabel = new Label(ID_WORKFLOW_INFORMATION_LABEL, new ResourceModel("pageTaskEdit.workflowInformationLabel")); workflowInformationLabel.add(hiddenWhenEditingOrNoWorkflowInformation); mainForm.add(workflowInformationLabel); WorkflowInformationPanel workflowInformationPanel = new WorkflowInformationPanel( ID_WORKFLOW_INFORMATION_PANEL, model); workflowInformationPanel.add(hiddenWhenEditingOrNoWorkflowInformation); mainForm.add(workflowInformationPanel); VisibleEnableBehaviour modelOpBehaviour = new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !edit && model.getObject().getModelOperationStatus() != null; } }; Label modelOperationStatusLabel = new Label(ID_MODEL_OPERATION_STATUS_LABEL, new ResourceModel("pageTaskEdit.modelOperationStatusLabel")); modelOperationStatusLabel.add(modelOpBehaviour); mainForm.add(modelOperationStatusLabel); ModelOperationStatusPanel panel = new ModelOperationStatusPanel(ID_MODEL_OPERATION_STATUS_PANEL, new PropertyModel<ModelOperationStatusDto>(model, TaskDto.F_MODEL_OPERATION_STATUS)); panel.add(modelOpBehaviour); mainForm.add(panel); SortableDataProvider<OperationResult, String> provider = new ListDataProvider<OperationResult>(this, new PropertyModel<List<OperationResult>>(model, "opResult")); TablePanel result = new TablePanel<OperationResult>("operationResult", provider, initResultColumns()); result.setStyle("padding-top: 0px;"); result.setShowPaging(false); result.setOutputMarkupId(true); result.add(hiddenWhenEditing); mainForm.add(result); DropDownChoice threadStop = new DropDownChoice("threadStop", new Model<ThreadStopActionType>() { @Override public ThreadStopActionType getObject() { return model.getObject().getThreadStop(); } @Override public void setObject(ThreadStopActionType object) { model.getObject().setThreadStop(object); } }, WebMiscUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(PageTaskEdit.this)); threadStop.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit; } }); mainForm.add(threadStop); //mainForm.add(new TsaValidator(runUntilNodeDown, threadStop)); CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(model, TaskDto.F_DRY_RUN)); dryRun.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit; } }); mainForm.add(dryRun); initButtons(mainForm); }
From source file:com.evolveum.midpoint.web.page.admin.server.PageTaskEdit.java
License:Apache License
private void initSchedule(Form mainForm) { //todo probably can be removed, visibility can be updated in children (already components) [lazyman] final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true);//ww w . java 2 s. co m mainForm.add(container); final IModel<Boolean> recurringCheck = new PropertyModel<Boolean>(model, "recurring"); final IModel<Boolean> boundCheck = new PropertyModel<Boolean>(model, "bound"); WebMarkupContainer suspendReqRecurring = new WebMarkupContainer("suspendReqRecurring"); suspendReqRecurring.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return edit && isRunnableOrRunning(); } }); mainForm.add(suspendReqRecurring); final WebMarkupContainer boundContainer = new WebMarkupContainer("boundContainer"); boundContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return recurringCheck.getObject(); } }); boundContainer.setOutputMarkupId(true); container.add(boundContainer); WebMarkupContainer suspendReqBound = new WebMarkupContainer("suspendReqBound"); suspendReqBound.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return edit && isRunnableOrRunning(); } }); boundContainer.add(suspendReqBound); final WebMarkupContainer intervalContainer = new WebMarkupContainer("intervalContainer"); intervalContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return recurringCheck.getObject(); } }); intervalContainer.setOutputMarkupId(true); container.add(intervalContainer); final WebMarkupContainer cronContainer = new WebMarkupContainer("cronContainer"); cronContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return recurringCheck.getObject() && !boundCheck.getObject(); } }); cronContainer.setOutputMarkupId(true); container.add(cronContainer); AjaxCheckBox recurring = new AjaxCheckBox("recurring", recurringCheck) { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(container); target.add(PageTaskEdit.this.get("mainForm:recurring")); } }; recurring.setOutputMarkupId(true); recurring.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit && !isRunnableOrRunning(); } }); mainForm.add(recurring); final AjaxCheckBox bound = new AjaxCheckBox("bound", boundCheck) { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(container); target.add(PageTaskEdit.this.get("mainForm:recurring")); } }; bound.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit && !isRunnableOrRunning(); } }); boundContainer.add(bound); Label boundHelp = new Label("boundHelp"); boundHelp.add(new InfoTooltipBehavior()); boundContainer.add(boundHelp); TextField<Integer> interval = new TextField<Integer>("interval", new PropertyModel<Integer>(model, "interval")); interval.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); interval.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit && (!isRunnableOrRunning() || !boundCheck.getObject()); } }); intervalContainer.add(interval); TextField<String> cron = new TextField<String>("cron", new PropertyModel<String>(model, "cronSpecification")); cron.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); cron.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit && (!isRunnableOrRunning() || !boundCheck.getObject()); } }); cronContainer.add(cron); Label cronHelp = new Label("cronHelp"); cronHelp.add(new InfoTooltipBehavior()); cronContainer.add(cronHelp); DateInput notStartBefore = new DateInput("notStartBeforeField", new PropertyModel<Date>(model, "notStartBefore")); notStartBefore.setOutputMarkupId(true); notStartBefore.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit && !isRunning(); } }); mainForm.add(notStartBefore); DateInput notStartAfter = new DateInput("notStartAfterField", new PropertyModel<Date>(model, "notStartAfter")); notStartAfter.setOutputMarkupId(true); notStartAfter.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit; } }); mainForm.add(notStartAfter); DropDownChoice misfire = new DropDownChoice("misfireAction", new PropertyModel<MisfireActionType>(model, "misfireAction"), WebMiscUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(PageTaskEdit.this)); misfire.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return edit; } }); mainForm.add(misfire); Label lastStart = new Label("lastStarted", new AbstractReadOnlyModel<String>() { @Override public String getObject() { TaskDto dto = model.getObject(); if (dto.getLastRunStartTimestampLong() == null) { return "-"; } Date date = new Date(dto.getLastRunStartTimestampLong()); return WebMiscUtil.formatDate(date); } }); mainForm.add(lastStart); Label lastFinished = new Label("lastFinished", new AbstractReadOnlyModel<String>() { @Override public String getObject() { TaskDto dto = model.getObject(); if (dto.getLastRunFinishTimestampLong() == null) { return "-"; } Date date = new Date(dto.getLastRunFinishTimestampLong()); return WebMiscUtil.formatDate(date); } }); mainForm.add(lastFinished); Label nextRun = new Label("nextRun", new AbstractReadOnlyModel<String>() { @Override public String getObject() { TaskDto dto = model.getObject(); if (dto.getRecurring() && dto.getBound() && isRunning()) { return getString("pageTasks.runsContinually"); } if (dto.getNextRunStartTimeLong() == null) { return "-"; } Date date = new Date(dto.getNextRunStartTimeLong()); return WebMiscUtil.formatDate(date); } }); mainForm.add(nextRun); mainForm.add(new StartEndDateValidator(notStartBefore, notStartAfter)); mainForm.add(new ScheduleValidator(getTaskManager(), recurring, bound, interval, cron)); }
From source file:com.evolveum.midpoint.web.page.admin.server.PageTasks.java
License:Apache License
private void initSearchForm(Form searchForm) { DropDownChoice listSelect = new DropDownChoice(ID_STATE, new PropertyModel(searchModel, TasksSearchDto.F_STATUS), new AbstractReadOnlyModel<List<TaskDtoExecutionStatusFilter>>() { @Override/*from w w w .j a va 2 s .co m*/ public List<TaskDtoExecutionStatusFilter> getObject() { return createTypeList(); } }, new EnumChoiceRenderer(PageTasks.this)); listSelect.add(createFilterAjaxBehaviour()); listSelect.setOutputMarkupId(true); listSelect.setNullValid(false); if (listSelect.getModel().getObject() == null) { listSelect.getModel().setObject(TaskDtoExecutionStatusFilter.ALL); } searchForm.add(listSelect); DropDownChoice categorySelect = new DropDownChoice(ID_CATEGORY, new PropertyModel(searchModel, TasksSearchDto.F_CATEGORY), new AbstractReadOnlyModel<List<String>>() { @Override public List<String> getObject() { return createCategoryList(); } }, new IChoiceRenderer<String>() { @Override public Object getDisplayValue(String object) { if (ALL_CATEGORIES.equals(object)) { object = "AllCategories"; } return PageTasks.this.getString("pageTasks.category." + object); } @Override public String getIdValue(String object, int index) { return Integer.toString(index); } }); categorySelect.setOutputMarkupId(true); categorySelect.setNullValid(false); categorySelect.add(createFilterAjaxBehaviour()); if (categorySelect.getModel().getObject() == null) { categorySelect.getModel().setObject(ALL_CATEGORIES); } searchForm.add(categorySelect); CheckBox showSubtasks = new CheckBox(ID_SHOW_SUBTASKS, new PropertyModel(searchModel, TasksSearchDto.F_SHOW_SUBTASKS)); showSubtasks.add(createFilterAjaxBehaviour()); searchForm.add(showSubtasks); AjaxSubmitButton clearButton = new AjaxSubmitButton(ID_SEARCH_CLEAR) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { clearSearchPerformed(target); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(getFeedbackPanel()); } }; searchForm.add(clearButton); }
From source file:com.evolveum.midpoint.web.page.admin.server.TaskSchedulingTabPanel.java
License:Apache License
private void initLayoutForSchedulingTable() { // models/* w w w. j a va 2 s.c om*/ 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(); // if not removed, the validators will accumulate on the form // 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)); }
From source file:com.francetelecom.clara.cloud.presentation.releases.ReleaseOverrideProfilePanel.java
License:Apache License
private void initComponents() { initContainers();//from w ww.j a v a 2 s. com //Select middlewareProfile choice middlewareProfileSelect = new DropDownChoice<>("middlewareProfileSelect", new Model<MiddlewareProfile>(), getMiddlewareProfileList(), new ProfileChoiceRenderer(this, new EnumChoiceRenderer<MiddlewareProfile.MiddlewareProfileStatus>(this))); middlewareProfileSelect.setNullValid(false); middlewareProfileSelect.setRequired(true); middlewareProfileSelect.setDefaultModelObject(MiddlewareProfile.getDefault()); middlewareProfileContainer.add(middlewareProfileSelect); }
From source file:de.elatexam.editor.components.panels.tasks.correctionmode.CorrectionModePanel.java
License:Open Source License
/** * @param id// w ww .j a v a 2 s. com * @param model */ public CorrectionModePanel(String id, IModel<de.elatexam.model.ComplexTaskDef.Config.CorrectionMode> model) { super(id, model); Config.CorrectionMode modelObject = (Config.CorrectionMode) getDefaultModelObject(); selectedMode = CMode.getCorrectionMode(modelObject); additionalValue = CMode.getValue(modelObject); PropertyModel<CMode> cmodeModel = new PropertyModel<CMode>(this, "selectedMode"); // add correction mode via custom model, ichoicerenderer? final DropDownChoice<CMode> correctionModeDropDown = new DropDownChoice<CMode>("correctionMode", cmodeModel, Arrays.asList(CMode.values()), new EnumChoiceRenderer<CMode>(this)); correctionModeDropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(valueTextfield); target.add(label); } }); add(correctionModeDropDown); valueTextfield = new TextField<Integer>("additionalValue", new PropertyModel<Integer>(this, "additionalValue")) { @Override public boolean isVisible() { return selectedMode != CMode.REGULAR; }; }; valueTextfield.setOutputMarkupId(true); valueTextfield.setOutputMarkupPlaceholderTag(true); // TODO validate correctProcessedOnly:>=1, multipleCorrectos:>=2 valueTextfield.add(new MinimumValidator<Integer>(0)); add(valueTextfield); // use dynamic string key for i18n: ${} means this.toString(). add(label = new Label("selectedMode", new StringResourceModel("label.${}", this, cmodeModel))); label.setOutputMarkupId(true); }
From source file:org.cdlflex.ui.ajax.markup.html.form.AjaxEnumRadioChoice.java
License:Apache License
public AjaxEnumRadioChoice(String id, Class<T> enumType, Component resourceProvider) { this(id, enumType, new EnumChoiceRenderer<T>(resourceProvider)); }
From source file:org.geoserver.taskmanager.web.panel.FrequencyPanel.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/* w w w . j a v a 2 s .c o m*/ public void onInitialize() { super.onInitialize(); add(new DropDownChoice<Type>("type", typeModel, Arrays.asList(Type.values()), new EnumChoiceRenderer<Type>(this)).add(new AjaxFormSubmitBehavior("change") { private static final long serialVersionUID = -7698014209707408962L; @Override protected void onSubmit(AjaxRequestTarget target) { updateVisibility(); target.add(FrequencyPanel.this); } })); add(new WebMarkupContainer("dayOfWeekLabel")); add(new DropDownChoice<DayOfWeek>("dayOfWeek", dayOfWeekModel, Arrays.asList(DayOfWeek.values()), new EnumChoiceRenderer<DayOfWeek>() { private static final long serialVersionUID = 246492731661118407L; @Override public Object getDisplayValue(DayOfWeek object) { return object.getDisplayName(TextStyle.FULL, getLocale()); } })); add(new WebMarkupContainer("dayOfMonthLabel")); add(new DropDownChoice<Integer>("dayOfMonth", dayOfMonthModel, Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28))); add(new WebMarkupContainer("timeLabel")); add(new TextField<String>("time", timeModel).add(new IValidator<String>() { private static final long serialVersionUID = -3170061736947280260L; @Override public void validate(IValidatable<String> validatable) { if (findParent(Form.class).findSubmittingButton() != null) { Matcher matcher = TIME_PATTERN.matcher(validatable.getValue()); if (!(matcher.matches() && Integer.parseInt(matcher.group(1)) < 24 && Integer.parseInt(matcher.group(2)) < 60)) { error(new ParamResourceModel("timeFormatError", FrequencyPanel.this).getString()); } } } })); add(new TextField<String>("custom", (IModel<String>) getDefaultModel()).add(new IValidator<String>() { private static final long serialVersionUID = -3170061736947280260L; @Override public void validate(IValidatable<String> validatable) { if (findParent(Form.class).findSubmittingButton() != null) { try { CronExpression.validateExpression(validatable.getValue()); } catch (ParseException e) { error(e.getLocalizedMessage()); } } } })); setOutputMarkupId(true); updateVisibility(); }
From source file:org.sakaiproject.attendance.tool.pages.EventView.java
License:Educational Community License
private void init() { createHeader();/*from w w w . j a va 2 s. c o m*/ createTable(); createStatsTable(); add(new Label("event-name", attendanceEvent.getName())); add(new Label("event-date", attendanceEvent.getStartDateTime())); add(new Label("take-attendance-header", getString("attendance.event.view.take.attendance"))); final Form<?> setAllForm = new Form<Void>("set-all-form") { @Override protected void onSubmit() { attendanceLogic.updateAttendanceRecordsForEvent(attendanceEvent, setAllStatus.getModelObject(), selectedGroup); String who = selectedGroup == null ? "" : " for " + sakaiProxy.getGroupTitleForCurrentSite(selectedGroup); getSession().info("All attendance records " + who + " for " + attendanceEvent.getName() + " set to " + setAllStatus.getModelObject()); setResponsePage(new EventView(attendanceEvent.getId(), returnPage, selectedGroup)); } @Override public boolean isEnabled() { return !attendanceEvent.getAttendanceSite().getIsSyncing(); } }; List<AttendanceStatus> activeAttendanceStatuses = attendanceLogic.getActiveStatusesForCurrentSite(); Collections.sort(activeAttendanceStatuses, new Comparator<AttendanceStatus>() { @Override public int compare(AttendanceStatus o1, AttendanceStatus o2) { return o1.getSortOrder() - o2.getSortOrder(); } }); List<Status> activeStatuses = new ArrayList<>(); for (AttendanceStatus attendanceStatus : activeAttendanceStatuses) { activeStatuses.add(attendanceStatus.getStatus()); } setAllForm.add(setAllStatus = new DropDownChoice<>("set-all-status", new Model<>(), activeStatuses, new EnumChoiceRenderer<>(this))); setAllStatus.add(new AjaxFormSubmitBehavior("onchange") { @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); } }); add(setAllForm); this.printContainer = new WebMarkupContainer("print-container"); printContainer.setOutputMarkupId(true); this.printPanel = new PrintPanel("print-panel", new Model<>(attendanceEvent)); printContainer.add(printPanel); printContainer.add(AttributeModifier.append("class", "printHidden")); add(printContainer); }