org.apache.wicket.markup.html.form.IChoiceRenderer Java Examples
The following examples show how to use
org.apache.wicket.markup.html.form.IChoiceRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelectableRecorder.java From syncope with Apache License 2.0 | 6 votes |
@Override public List<T> getUnselectedList() { IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer(); Collection<? extends T> choices = getPalette().getChoices(); if (choices.size() - ids.length == 0) { return List.of(); } List<T> unselected = new ArrayList<>(Math.max(1, choices.size() - ids.length)); for (T choice : choices) { final String choiceId = renderer.getIdValue(choice, 0); boolean selected = false; for (String id : ids) { if (id.equals(choiceId)) { selected = true; break; } } if (!selected) { unselected.add(choice); } } return unselected; }
Example #2
Source File: SelectableRecorder.java From syncope with Apache License 2.0 | 6 votes |
@Override public List<T> getSelectedList() { IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer(); if (ids.length == 0) { return List.of(); } List<T> selected = new ArrayList<>(ids.length); for (String id : ids) { for (T choice : getPalette().getChoices()) { if (renderer.getIdValue(choice, 0).equals(id)) { selected.add(choice); break; } } } return selected; }
Example #3
Source File: SelectableRecorder.java From syncope with Apache License 2.0 | 6 votes |
public T getSelectedItem() { if (selectedId == null) { return null; } IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer(); T selected = null; for (T choice : getPalette().getChoices()) { if (renderer.getIdValue(choice, 0).equals(selectedId)) { selected = choice; break; } } return selected; }
Example #4
Source File: SelectableRecorder.java From syncope with Apache License 2.0 | 6 votes |
/** * Synchronize ids collection from the palette's model */ private void initIds() { // construct the model string based on selection collection IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer(); StringBuilder modelStringBuffer = new StringBuilder(); Collection<T> modelCollection = getPalette().getModelCollection(); if (modelCollection == null) { throw new WicketRuntimeException("Expected getPalette().getModelCollection() to return a non-null value." + " Please make sure you have model object assigned to the palette"); } Iterator<T> selection = modelCollection.iterator(); int i = 0; while (selection.hasNext()) { modelStringBuffer.append(renderer.getIdValue(selection.next(), i++)); if (selection.hasNext()) { modelStringBuffer.append(','); } } // set model and update ids array String modelString = modelStringBuffer.toString(); setDefaultModel(new Model<>(modelString)); updateIds(modelString); }
Example #5
Source File: UserSelectionPanel.java From webanno with Apache License 2.0 | 6 votes |
private IChoiceRenderer<User> makeUserChoiceRenderer() { return new org.apache.wicket.markup.html.form.ChoiceRenderer<User>() { private static final long serialVersionUID = 4607720784161484145L; @Override public Object getDisplayValue(User aUser) { String permissionLevels = projectRepository .getProjectPermissionLevels(aUser, projectModel.getObject()).stream() .map(PermissionLevel::getName).collect(joining(", ", "[", "]")); return aUser.getUsername() + " " + permissionLevels + (aUser.isEnabled() ? "" : " (login disabled)"); } }; }
Example #6
Source File: AjaxPalettePanel.java From syncope with Apache License 2.0 | 6 votes |
protected List<T> getFilteredList(final Collection<T> choices, final String filter) { IChoiceRenderer<? super T> renderer = palette.getChoiceRenderer(); Map<T, String> idForChoice = choices.stream().collect(Collectors.toMap( Function.identity(), choice -> renderer.getIdValue(choice, 0), (c1, c2) -> c1)); Pattern pattern = Pattern.compile(filter, Pattern.CASE_INSENSITIVE); List<T> filtered = new ArrayList<>(choices.size()); choices.forEach(choice -> { if (pattern.matcher(idForChoice.get(choice)).matches()) { filtered.add(choice); } }); return filtered; }
Example #7
Source File: NonI18nPalette.java From syncope with Apache License 2.0 | 5 votes |
public NonI18nPalette(final String id, final IModel<? extends Collection<T>> model, final IModel<? extends Collection<? extends T>> choicesModel, final IChoiceRenderer<? super T> choiceRenderer, final int rows, final boolean allowOrder, final boolean allowMoveAll) { super(id, model, choicesModel, choiceRenderer, rows, allowOrder, allowMoveAll); }
Example #8
Source File: GenericSelect2DropDownMultipleChoice.java From artifact-listener with Apache License 2.0 | 5 votes |
protected GenericSelect2DropDownMultipleChoice(String id, IModel<? extends Collection<T>> collectionModel, IModel<? extends List<? extends T>> choicesModel, IChoiceRenderer<? super T> renderer) { super(id, collectionModel, choicesModel, renderer); Select2Behavior<T, T> select2Behavior = Select2Behavior.forChoice(this); fillSelect2Settings(select2Behavior.getSettings()); add(select2Behavior); }
Example #9
Source File: ExtendedPalette.java From nextreports-server with Apache License 2.0 | 5 votes |
/** * @param id Component id * @param model Model representing collection of user's selections * @param choicesModel Model representing collection of all available choices * @param choiceRenderer Render used to render choices. This must use unique IDs for the objects, not the * index. * @param rows Number of choices to be visible on the screen with out scrolling * @param allowOrder Allow user to move selections up and down * @param allowMoveAll Allow user to add or remove all items at once */ public ExtendedPalette(String id, IModel<List<T>> model, IModel<? extends Collection<? extends T>> choicesModel, IChoiceRenderer<T> choiceRenderer, int rows, boolean allowOrder, boolean allowMoveAll) { super(id, model, choicesModel, choiceRenderer, rows, allowOrder, allowMoveAll); this.choicesModel = choicesModel; this.choiceRenderer = choiceRenderer; this.rows = rows; this.allowOrder = allowOrder; this.allowMoveAll = allowMoveAll; }
Example #10
Source File: SakaiSpinnerDropDownChoice.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Constructor * @param id the wicket id * @param choiceModel the model to hold the selected choice * @param choices the available choices * @param renderer how to render each choice * @param labelModel the model for the <label> tag * @param behavior behaviour invoked when the selection changes */ public SakaiSpinnerDropDownChoice(String id, IModel<T> choiceModel, List<T> choices, IChoiceRenderer<T> renderer, IModel<String> labelModel, SakaiSpinningSelectOnChangeBehavior behavior) { super(id, choiceModel); select = new DropDownChoice<>("spinnerSelect", choiceModel, choices, renderer); select.setLabel(labelModel); select.add(behavior); add(select); setRenderBodyOnly(true); }
Example #11
Source File: AjaxOntopolyDropDownChoice.java From ontopia with Apache License 2.0 | 5 votes |
public AjaxOntopolyDropDownChoice(String id, IModel<T> model, IModel<List<T>> choices, IChoiceRenderer<? super T> renderer) { super(id, model, choices, renderer); setOutputMarkupId(true); add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { AjaxOntopolyDropDownChoice.this.onUpdate(target); } }); }
Example #12
Source File: SakaiSpinnerDropDownChoice.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Constructor * @param id the wicket id * @param choiceModel the model to hold the selected choice * @param choices the available choices * @param renderer how to render each choice * @param labelModel the model for the <label> tag * @param behavior behaviour invoked when the selection changes */ public SakaiSpinnerDropDownChoice(String id, IModel<T> choiceModel, List<T> choices, IChoiceRenderer<T> renderer, IModel<String> labelModel, SakaiSpinningSelectOnChangeBehavior behavior) { super(id, choiceModel); select = new DropDownChoice<>("spinnerSelect", choiceModel, choices, renderer); select.setLabel(labelModel); select.add(behavior); add(select); setRenderBodyOnly(true); }
Example #13
Source File: TopicDropDownChoice.java From ontopia with Apache License 2.0 | 4 votes |
public TopicDropDownChoice(String id, IModel<T> model, IModel<List<T>> choices, IChoiceRenderer<T> renderer) { super(id, model, choices, renderer); }
Example #14
Source File: OverviewListChoice.java From webanno with Apache License 2.0 | 4 votes |
public OverviewListChoice(String aId, IModel<? extends List<? extends T>> aChoices, IChoiceRenderer<? super T> aRenderer) { super(aId, aChoices, aRenderer); }
Example #15
Source File: ArtifactSelect2AjaxAdapter.java From artifact-listener with Apache License 2.0 | 4 votes |
public ArtifactSelect2AjaxAdapter(IChoiceRenderer<Artifact> choiceRenderer) { super(Artifact.class, choiceRenderer); }
Example #16
Source File: ProjectArtifactsPanel.java From artifact-listener with Apache License 2.0 | 4 votes |
public ProjectArtifactSelect2AjaxAdapter(IChoiceRenderer<Artifact> choiceRenderer) { super(Artifact.class, choiceRenderer); }
Example #17
Source File: ProjectSelect2AjaxAdapter.java From artifact-listener with Apache License 2.0 | 4 votes |
public ProjectSelect2AjaxAdapter(IChoiceRenderer<Project> choiceRenderer) { super(Project.class, choiceRenderer); }
Example #18
Source File: ExtendedPalette.java From nextreports-server with Apache License 2.0 | 4 votes |
public IChoiceRenderer<T> getChoiceRenderer() { return choiceRenderer; }
Example #19
Source File: OverviewListChoice.java From webanno with Apache License 2.0 | 4 votes |
public OverviewListChoice(String aId, IModel<T> aModel, IModel<? extends List<? extends T>> aChoices, IChoiceRenderer<? super T> aRenderer, int aMaxRows) { super(aId, aModel, aChoices, aRenderer, aMaxRows); }
Example #20
Source File: ExtendedPalette.java From nextreports-server with Apache License 2.0 | 4 votes |
public ExtendedPalette(String id, IModel<List<T>> model, IModel<? extends Collection<? extends T>> choicesModel, IChoiceRenderer<T> choiceRenderer, int rows, boolean allowOrder) { this(id, model, choicesModel, choiceRenderer, rows, allowOrder, false); }
Example #21
Source File: DestinationsPanel.java From nextreports-server with Apache License 2.0 | 4 votes |
private void addDestinationType() { Label type = new Label("type", getString("ActionContributor.Run.destination.type")); add(type); List<String> types = new ArrayList<String>(); boolean supportsAlert = schedulerJob.getReport().isAlarmType() || schedulerJob.getReport().isIndicatorType() || schedulerJob.getReport().isDisplayType(); if (supportsAlert) { types.add(DestinationType.ALERT.toString()); } else { for (DestinationType dt : DestinationType.values()) { if (!DestinationType.ALERT.toString().equals(dt.toString())) { types.add(dt.toString()); } } } IChoiceRenderer<String> typeRenderer = new ChoiceRenderer<String>() { @Override public Object getDisplayValue(String object) { return getString("DestinationsPanel.type." + object); } }; typeChoice = new DropDownChoice<String>("typeChoice", new Model<String>(), types, typeRenderer) { private static final long serialVersionUID = 1L; @Override protected CharSequence getDefaultChoice(String selectedValue) { return "<option value=\"\">" + getString("nullValid") + "</option>"; } }; add(typeChoice); typeChoice.setNullValid(true); typeChoice.setOutputMarkupId(true); typeChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { showNewDestination(target); } }); }
Example #22
Source File: TeamEventReminderComponent.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
/** * @see org.apache.wicket.Component#onInitialize() */ @SuppressWarnings({ "unchecked", "serial"}) @Override protected void onInitialize() { super.onInitialize(); final boolean reminderOptionVisibility = data.getReminderActionType() != null; // ### unchecked reminderDurationTypeList = (List<ReminderDurationUnit>) getTypeList(ReminderDurationUnit.class); reminderActionTypeList = (List<ReminderActionType>) getTypeList(ReminderActionType.class); final IChoiceRenderer<ReminderDurationUnit> reminderDurationTypeRenderer = (IChoiceRenderer<ReminderDurationUnit>) getChoiceRenderer(ReminderDurationUnit.class); // final IChoiceRenderer<ReminderActionType> reminderActionTypeRenderer = (IChoiceRenderer<ReminderActionType>) getChoiceRenderer(ReminderActionType.class); // // ### final MinMaxNumberField<Integer> reminderDuration = new MinMaxNumberField<Integer>(reminderPanel.getTextFieldId(), new PropertyModel<Integer>(data, "reminderDuration"), 0, DURATION_MAX); WicketUtils.setSize(reminderDuration, 3); setComponentProperties(reminderDuration, reminderOptionVisibility, true); // reminder duration dropDown final IModel<List<ReminderDurationUnit>> reminderDurationChoicesModel = new PropertyModel<List<ReminderDurationUnit>>(this, "reminderDurationTypeList"); final IModel<ReminderDurationUnit> reminderDurationActiveModel = new PropertyModel<ReminderDurationUnit>(data, "reminderDurationType"); final DropDownChoicePanel<ReminderDurationUnit> reminderDurationTypeChoice = new DropDownChoicePanel<ReminderDurationUnit>( reminderPanel.newChildId(), reminderDurationActiveModel, reminderDurationChoicesModel, reminderDurationTypeRenderer, false); setComponentProperties(reminderDurationTypeChoice.getDropDownChoice(), reminderOptionVisibility, true); // reminder action dropDown final IModel<List<ReminderActionType>> reminderActionTypeChoiceModel = new PropertyModel<List<ReminderActionType>>(this, "reminderActionTypeList"); final IModel<ReminderActionType> reminderActionActiveModel = new PropertyModel<ReminderActionType>(data, "reminderActionType"); final DropDownChoicePanel<ReminderActionType> reminderActionTypeChoice = new DropDownChoicePanel<ReminderActionType>( reminderPanel.newChildId(), new DropDownChoice<ReminderActionType>(DropDownChoicePanel.WICKET_ID, reminderActionActiveModel, reminderActionTypeChoiceModel, reminderActionTypeRenderer) { /** * @see org.apache.wicket.markup.html.form.AbstractSingleSelectChoice#getNullKey() */ @Override protected String getNullValidKey() { return "plugins.teamcal.event.reminder.NONE"; } }); reminderActionTypeChoice.setNullValid(true); reminderActionTypeChoice.getDropDownChoice().add(new AjaxFormComponentUpdatingBehavior("onChange") { @Override protected void onUpdate(final AjaxRequestTarget target) { final boolean isVisible = data.getReminderActionType() != null; if (isVisible == true) { // Pre-set default values if the user selects a reminder action: if (NumberHelper.greaterZero(data.getReminderDuration()) == false) { data.setReminderDuration(15); } if (data.getReminderDurationUnit() == null) { data.setReminderDurationUnit(ReminderDurationUnit.MINUTES); } } reminderDuration.setVisible(isVisible); reminderDurationTypeChoice.getDropDownChoice().setVisible(isVisible); reminderDurationTypeChoice.setRequired(isVisible); target.add(reminderDurationTypeChoice.getDropDownChoice(), reminderDuration); } }); reminderPanel.add(reminderActionTypeChoice); reminderPanel.add(reminderDuration); reminderPanel.add(reminderDurationTypeChoice); }
Example #23
Source File: IndicatingAjaxDropDownChoice.java From sakai with Educational Community License v2.0 | 4 votes |
public IndicatingAjaxDropDownChoice(String id, IModel<T> model, IModel<? extends List<? extends T>> choices, IChoiceRenderer<? super T> renderer) { super(id, model, choices, renderer); add(indicatorAppender); }
Example #24
Source File: IndicatingAjaxDropDownChoice.java From sakai with Educational Community License v2.0 | 4 votes |
public IndicatingAjaxDropDownChoice(String id, List<T> data, IChoiceRenderer<? super T> renderer) { super(id, data, renderer); add(indicatorAppender); }
Example #25
Source File: OverviewListChoice.java From webanno with Apache License 2.0 | 4 votes |
public OverviewListChoice(String aId, IModel<T> aModel, IModel<? extends List<? extends T>> aChoices, IChoiceRenderer<? super T> aRenderer) { super(aId, aModel, aChoices, aRenderer); }
Example #26
Source File: OverviewListChoice.java From webanno with Apache License 2.0 | 4 votes |
public OverviewListChoice(String aId, IModel<T> aModel, List<? extends T> aChoices, IChoiceRenderer<? super T> aRenderer, int aMaxRows) { super(aId, aModel, aChoices, aRenderer, aMaxRows); }
Example #27
Source File: OverviewListChoice.java From webanno with Apache License 2.0 | 4 votes |
public OverviewListChoice(String aId, IModel<T> aModel, List<? extends T> aChoices, IChoiceRenderer<? super T> aRenderer) { super(aId, aModel, aChoices, aRenderer); }
Example #28
Source File: IndicatingAjaxDropDownChoice.java From sakai with Educational Community License v2.0 | 4 votes |
public IndicatingAjaxDropDownChoice(String id, IModel<T> model, IModel<? extends List<? extends T>> choices, IChoiceRenderer<? super T> renderer) { super(id, model, choices, renderer); add(indicatorAppender); }
Example #29
Source File: SearchClausePanel.java From syncope with Apache License 2.0 | 4 votes |
default IChoiceRenderer<SearchClause.Type> typeRenderer() { return new ChoiceRenderer<>(); }
Example #30
Source File: OverviewListChoice.java From webanno with Apache License 2.0 | 4 votes |
public OverviewListChoice(String aId, List<? extends T> aChoices, IChoiceRenderer<? super T> aRenderer) { super(aId, aChoices, aRenderer); }