本文整理汇总了Java中org.apache.wicket.markup.html.form.IChoiceRenderer类的典型用法代码示例。如果您正苦于以下问题:Java IChoiceRenderer类的具体用法?Java IChoiceRenderer怎么用?Java IChoiceRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IChoiceRenderer类属于org.apache.wicket.markup.html.form包,在下文中一共展示了IChoiceRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChoiceModel
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
private IModel<List<ObjectTypes>> createChoiceModel(final IChoiceRenderer<ObjectTypes> renderer) {
return new LoadableModel<List<ObjectTypes>>(false) {
@Override
protected List<ObjectTypes> load() {
List<ObjectTypes> choices = new ArrayList<>();
Collections.addAll(choices, ObjectTypes.values());
choices.remove(ObjectTypes.OBJECT);
Collections.sort(choices, new Comparator<ObjectTypes>() {
@Override
public int compare(ObjectTypes o1, ObjectTypes o2) {
String str1 = (String) renderer.getDisplayValue(o1);
String str2 = (String) renderer.getDisplayValue(o2);
return String.CASE_INSENSITIVE_ORDER.compare(str1, str2);
}
});
return choices;
}
};
}
示例2: initLayout
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
private void initLayout(final Component component){
TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<String>(getModel(), UserReportDto.F_NAME),
createStringResource("ObjectType.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
add(name);
TextFormGroup description = new TextFormGroup(ID_DESCRIPTION, new PropertyModel<String>(getModel(), UserReportDto.F_DESCRIPTION),
createStringResource("ObjectType.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
add(description);
IModel choices = WebComponentUtil.createReadonlyModelFromEnum(ExportType.class);
IChoiceRenderer renderer = new EnumChoiceRenderer();
DropDownFormGroup exportType = new DropDownFormGroup(ID_EXPORT_TYPE, new
PropertyModel<ExportType>(getModel(), UserReportDto.F_EXPORT_TYPE), choices, renderer,
createStringResource("UserReportConfigPanel.exportFileType"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
add(exportType);
DateFormGroup dateFrom = new DateFormGroup(ID_DATE_FROM, new PropertyModel<XMLGregorianCalendar>(getModel(), UserReportDto.F_FROM_GREG),
createStringResource("UserReportConfigPanel.dateFrom"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
add(dateFrom);
DateFormGroup dateTo = new DateFormGroup(ID_DATE_TO, new PropertyModel<XMLGregorianCalendar>(getModel(), UserReportDto.F_TO_GREG),
createStringResource("UserReportConfigPanel.dateTo"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
add(dateTo);
}
示例3: createDropDown
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
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;
}
示例4: GenericSelect2DropDownMultipleChoice
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
/**
* @param id The wicket ID.
* @param collectionModel The model containing the selected elements.
* @param collectionSupplier A factory for new, empty collections to be put in <code>collectionModel</code>
* @param choicesModel The model containing the selectable elements.
* @param renderer The choice renderer.
*/
protected <C extends Collection<T>> GenericSelect2DropDownMultipleChoice(
String id, IModel<C> collectionModel, Supplier<? extends C> collectionSupplier,
IModel<? extends Collection<? extends T>> choicesModel, IChoiceRenderer<? super T> renderer) {
super(id);
setModel(new ConcreteCollectionToCollectionWrapperModel<T, C>(collectionModel, collectionSupplier));
choicesWrapperModel = new MultipleChoicesWrapperModel<T>(collectionModel, choicesModel);
setChoices(choicesWrapperModel);
setSelectedObjectForcedInChoices(true);
setChoiceRenderer(renderer);
select2Behavior = Select2Behavior.forChoice(this);
fillSelect2Settings(select2Behavior.getSettings());
add(select2Behavior);
}
示例5: AbstractOptGroupDropDownChoice
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
protected AbstractOptGroupDropDownChoice(String id, IModel<E> model, final IModel<? extends List<? extends E>> choicesModel,
IChoiceRenderer<? super E> renderer, final Comparator<E> sorter) {
super(id, model, choicesModel, renderer);
setChoices(new LoadableDetachableModel<List<? extends E>>() {
private static final long serialVersionUID = 1L;
@Override
protected List<? extends E> load() {
List<? extends E> result = choicesModel.getObject();
Collections.sort(result, sorter);
return result;
};
@Override
public void detach() {
super.detach();
choicesModel.detach();
}
});
}
示例6: createPalette
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
private Palette<T> createPalette(
final String id,
final IModel<List<T>> model,
final ListModel<T> choices,
final IChoiceRenderer renderer) {
final Palette<T> palette = new Palette(
"paletteField",
model,
choices,
renderer,
8,
false);
return palette;
}
示例7: initIds
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
/**
* Synchronize ids collection from the palette's model
*/
private void initIds() {
// construct the model string based on selection collection
final IChoiceRenderer<T> renderer = getPalette().getChoiceRenderer();
final StringBuilder modelStringBuffer = new StringBuilder();
final 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");
}
final 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
final String modelString = modelStringBuffer.toString();
setDefaultModel(new Model<String>(modelString));
updateIds(modelString);
}
示例8: getUnselectedList
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
/**
* @return list over unselected choices
*/
protected List<T> getUnselectedList() {
final Collection<? extends T> choices = getPalette().getChoices();
if (choices.size() - getSelectedIds().size() == 0) {
return Collections.<T> emptyList();
}
final IChoiceRenderer<T> renderer = getPalette().getChoiceRenderer();
final List<T> unselected = new ArrayList<T>(Math.max(1, choices.size() - getSelectedIds().size()));
for (final T choice : choices) {
final String choiceId = renderer.getIdValue(choice, 0);
if (!getSelectedIds().contains(choiceId)) {
unselected.add(choice);
}
}
return unselected;
}
示例9: makeUserChoiceRenderer
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
private IChoiceRenderer<User> makeUserChoiceRenderer()
{
return new ChoiceRenderer<User>()
{
private static final long serialVersionUID = 4607720784161484145L;
@Override
public Object getDisplayValue(User aObject)
{
List<ProjectPermission> projectPermissions = projectRepository
.listProjectPermissionLevel(aObject, projectModel.getObject());
List<String> permissionLevels = new ArrayList<>();
for (ProjectPermission projectPermission : projectPermissions) {
permissionLevels.add(projectPermission.getLevel().getName());
}
return aObject.getUsername() + " " + permissionLevels
+ (aObject.isEnabled() ? "" : " (login disabled)");
}
};
}
示例10: profile_renderer_render_default_label_only_on_default_profile
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
@Test
public void profile_renderer_render_default_label_only_on_default_profile() throws Exception {
IChoiceRenderer<MiddlewareProfileStatus> statusRenderer = mock(IChoiceRenderer.class);
when(statusRenderer.getDisplayValue(any(MiddlewareProfileStatus.class))).thenReturn("mockedstatus");
ProfileChoiceRenderer renderer = spy(new ReleaseOverrideProfilePanel.ProfileChoiceRenderer(null, statusRenderer));
doReturn("default, ").when(renderer).getDefaultLabel();
for (MiddlewareProfile profile : MiddlewareProfile.values()) {
if(MiddlewareProfile.getDefault() == profile){
assertThat(renderer.getDisplayValue(profile)).contains("default, ");
}else{
assertThat(renderer.getDisplayValue(profile)).doesNotContain("default, ");
}
}
}
示例11: DeletableLabelGroup
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
public DeletableLabelGroup(String id, IModel<Collection<T>> collectionModel, IChoiceRenderer<T> renderer) {
super(id, collectionModel);
setRenderer(renderer);
setOutputMarkupId(true);
dataView = new DataView<T>("item", new LabelsDataProvider()) {
@Override
protected void populateItem(Item<T> item) {
final T value = item.getModelObject();
String itemText = getDisplayValue(value);
item.add(newLabel(value, itemText));
}
};
add(dataView);
add(new MoreIndicator("more"));
}
示例12: GroupSizeCache
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
public GroupSizeCache(Collection<T> collection, IChoiceRenderer<T> renderer) {
indicesList = new ArrayList<>();
int index = 0;
int beginIndex = 0;
String prevId = null;
for (T element : collection) {
String id = renderer.getIdValue(element, index);
if (prevId != null && !prevId.equals(id)) {
indicesList.add(new GroupMetaData(beginIndex, index));
beginIndex = index;
}
prevId = id;
index++;
}
indicesList.add(new GroupMetaData(beginIndex, index));
}
示例13: DropDownChoicePanel
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
public DropDownChoicePanel(String id, IModel<T> model, IModel<? extends List<? extends T>> choices, IChoiceRenderer<T> renderer,
boolean allowNull) {
super(id);
DropDownChoice<T> input = new DropDownChoice<T>(ID_INPUT, model, choices, renderer) {
private static final long serialVersionUID = 1L;
@Override
protected String getNullValidDisplayValue() {
return getString("DropDownChoicePanel.notDefined");
}
};
input.setNullValid(allowNull);
add(input);
}
示例14: createChoiceModel
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
private IModel<List<ObjectTypes>> createChoiceModel(final IChoiceRenderer<ObjectTypes> renderer) {
return new LoadableModel<List<ObjectTypes>>(false) {
@Override
protected List<ObjectTypes> load() {
List<ObjectTypes> choices = new ArrayList<>();
Collections.addAll(choices, ObjectTypes.values());
choices.remove(ObjectTypes.OBJECT);
choices.sort((o1, o2) -> {
String str1 = (String) renderer.getDisplayValue(o1);
String str2 = (String) renderer.getDisplayValue(o2);
return String.CASE_INSENSITIVE_ORDER.compare(str1, str2);
});
return choices;
}
};
}
示例15: initIds
import org.apache.wicket.markup.html.form.IChoiceRenderer; //导入依赖的package包/类
/**
* 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);
}