use of org.apache.wicket.markup.html.list.ListItem in project ocvn by devgateway.
the class FileInputBootstrapFormComponentWrapper method addPendingFilesComponent.
/**
* pending files section
*/
private void addPendingFilesComponent() {
pendingFiles = new WebMarkupContainer("pendingFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onConfigure() {
if (filesModel != null && filesModel.size() > 0) {
for (FileMetadata file : filesModel) {
if (file.isNew()) {
setVisibilityAllowed(true);
return;
}
}
}
setVisibilityAllowed(false);
}
};
pendingFiles.setOutputMarkupPlaceholderTag(true);
pendingFiles.setOutputMarkupId(true);
add(pendingFiles);
pendingFiles.add(new Label("pendingFilesTitle", new StringResourceModel("pendingFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> pendingFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// upload)
for (FileMetadata file : filesModel) {
if (file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", pendingFilesModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
item.add(new Label("fileTitle", item.getModelObject().getName()));
IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public void onClick(final AjaxRequestTarget target) {
filesModel.remove(item.getModelObject());
FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
target.add(pendingFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
}
};
pendingFiles.add(list);
}
use of org.apache.wicket.markup.html.list.ListItem in project openmeetings by apache.
the class RoomForm method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
RequiredTextField<String> name = new RequiredTextField<>("name");
name.setLabel(new Model<>(getString("165")));
add(name);
add(new //
DropDownChoice<>(//
"capacity", //
DROPDOWN_NUMBER_OF_PARTICIPANTS, new ChoiceRenderer<Long>() {
private static final long serialVersionUID = 1L;
@Override
public Object getDisplayValue(Long id) {
return id;
}
@Override
public String getIdValue(Long id, int index) {
return "" + id;
}
}));
add(new RoomTypeDropDown("type").setRequired(true).setLabel(Model.of(getString("45"))));
add(new TextArea<String>("comment"));
boolean isGroupAdmin = hasGroupAdminLevel(getRights());
add(new CheckBox("appointment").setEnabled(false));
add(new CheckBox("ispublic").setEnabled(!isGroupAdmin));
List<Group> orgList = isGroupAdmin ? groupDao.get(null, getUserId(), 0, Integer.MAX_VALUE, null) : groupDao.get(0, Integer.MAX_VALUE);
final List<RoomGroup> orgRooms = new ArrayList<>(orgList.size());
for (Group org : orgList) {
orgRooms.add(new RoomGroup(org, getModelObject()));
}
add(new Select2MultiChoice<>("groups", null, new RestrictiveChoiceProvider<RoomGroup>() {
private static final long serialVersionUID = 1L;
@Override
public String getDisplayValue(RoomGroup choice) {
String name = choice.getGroup().getName();
return name == null ? "" : name;
}
@Override
public String toId(RoomGroup choice) {
Long id = choice.getGroup().getId();
return id == null ? null : "" + id;
}
@Override
public void query(String term, int page, Response<RoomGroup> response) {
response.addAll(orgRooms.stream().filter(rg -> Strings.isEmpty(term) || rg.getGroup().getName().contains(term)).collect(Collectors.toList()));
}
@Override
public RoomGroup fromId(String _id) {
Long id = Long.valueOf(_id);
if (!orgList.stream().filter(g -> g.getId().equals(id)).findFirst().isPresent()) {
// seems to be hacked
return null;
}
Group g = groupDao.get(id);
return new RoomGroup(g, RoomForm.this.getModelObject());
}
}).setLabel(Model.of(getString("828"))).setRequired(isGroupAdmin));
add(new CheckBox("isDemoRoom"));
TextField<Integer> demoTime = new TextField<>("demoTime");
demoTime.setLabel(new Model<>(getString("637")));
add(demoTime);
add(new CheckBox("allowUserQuestions"));
add(new CheckBox("audioOnly"));
add(new CheckBox("closed"));
add(new TextField<String>("redirectURL"));
add(new CheckBox("waitForRecording"));
add(new CheckBox("allowRecording"));
add(new CheckBox("chatModerated"));
add(new Select2MultiChoice<>("hiddenElements", null, new ChoiceProvider<RoomElement>() {
private static final long serialVersionUID = 1L;
@Override
public String getDisplayValue(RoomElement choice) {
return choice.name();
}
@Override
public String getIdValue(RoomElement choice) {
return choice.name();
}
@Override
public void query(String term, int page, Response<RoomElement> response) {
for (RoomElement r : RoomElement.values()) {
if (Strings.isEmpty(term) || r.name().contains(term)) {
response.add(r);
}
}
}
@Override
public Collection<RoomElement> toChoices(Collection<String> ids) {
Collection<RoomElement> rights = new ArrayList<>(ids.size());
for (String id : ids) {
rights.add(RoomElement.valueOf(id));
}
return rights;
}
}));
add(new CheckBox("chatOpened"));
add(new CheckBox("filesOpened"));
add(new CheckBox("autoVideoSelect"));
// Moderators
final Select2Choice<User> moderatorChoice = new Select2Choice<>("moderator2add", moderator2add, new AdminUserChoiceProvider() {
private static final long serialVersionUID = 1L;
@Override
public void query(String term, int page, Response<User> response) {
response.addAll(userDao.get(term, false, page * PAGE_SIZE, PAGE_SIZE));
response.setHasMore(PAGE_SIZE == response.getResults().size());
}
@Override
public String getDisplayValue(User choice) {
Address a = choice.getAddress();
return String.format("\"%s %s\" <%s>", choice.getFirstname(), choice.getLastname(), a == null ? "" : a.getEmail());
}
});
moderatorChoice.getSettings().setCloseOnSelect(true);
add(moderatorChoice.add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
Room r = RoomForm.this.getModelObject();
User u = moderator2add.getObject();
boolean found = false;
if (u != null) {
if (r.getModerators() == null) {
r.setModerators(new ArrayList<RoomModerator>());
}
for (RoomModerator rm : r.getModerators()) {
if (rm.getUser().getId().equals(u.getId())) {
found = true;
break;
}
}
if (!found) {
RoomModerator rm = new RoomModerator();
rm.setRoomId(r.getId());
rm.setUser(u);
r.getModerators().add(0, rm);
moderator2add.setObject(null);
target.add(moderatorContainer, moderatorChoice);
}
}
}
}).setOutputMarkupId(true));
add(moderatorContainer.add(new ListView<RoomModerator>("moderators") {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<RoomModerator> item) {
RoomModerator moderator = item.getModelObject();
Label name = new Label("uName", moderator.getUser().getFirstname() + " " + moderator.getUser().getLastname());
if (moderator.getId() == null) {
name.add(AttributeModifier.append(ATTR_CLASS, "newItem"));
}
item.add(new CheckBox("superModerator", new PropertyModel<Boolean>(moderator, "superModerator"))).add(new Label("userId", "" + moderator.getUser().getId())).add(name).add(new Label("email", moderator.getUser().getAddress().getEmail())).add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
RoomForm.this.getModelObject().getModerators().remove(item.getIndex());
target.add(moderatorContainer);
}
});
}
}).setOutputMarkupId(true));
add(new CheckBox("moderated"));
// Files
Form<Void> filesForm = new Form<>("filesForm");
add(filesForm.add(new Select2MultiChoice<>("files2add", files2add, new ChoiceProvider<BaseFileItem>() {
private static final long serialVersionUID = 1L;
@Override
public String getDisplayValue(BaseFileItem f) {
return f.getName();
}
@Override
public String getIdValue(BaseFileItem f) {
return "" + f.getId();
}
@Override
public void query(String term, int page, Response<BaseFileItem> response) {
response.addAll(fileDao.getAllRoomFiles(term, page * PAGE_SIZE, PAGE_SIZE, RoomForm.this.getModelObject().getId(), orgList));
response.setHasMore(PAGE_SIZE == response.getResults().size());
}
@Override
public Collection<BaseFileItem> toChoices(Collection<String> ids) {
return fileDao.get(ids);
}
}).setLabel(Model.of(getString("245")))).add(new TextField<Long>("wbidx", wbIdx) {
private static final long serialVersionUID = 1L;
@Override
protected String[] getInputTypes() {
return new String[] { "number" };
}
}).add(new AjaxButton("addFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
Room r = RoomForm.this.getModelObject();
if (r.getFiles() == null) {
r.setFiles(new ArrayList<>());
}
for (BaseFileItem f : files2add.getObject()) {
r.getFiles().add(new RoomFile(r.getId(), f, wbIdx.getObject()));
}
target.add(filesContainer, filesForm);
}
@Override
protected String getIcon() {
return JQueryIcon.PLUSTHICK;
}
}).setOutputMarkupId(true));
add(filesContainer.add(new ListView<RoomFile>("files") {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<RoomFile> item) {
final RoomFile rf = item.getModelObject();
item.add(new Label("name", new PropertyModel<>(rf.getFile(), "name"))).add(new Label("wbIdx", new PropertyModel<>(rf, "wbIdx"))).add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
Room r = RoomForm.this.getModelObject();
for (Iterator<RoomFile> iter = r.getFiles().iterator(); iter.hasNext(); ) {
RoomFile _rf = iter.next();
if (_rf.getFile().getId().equals(rf.getFile().getId())) {
iter.remove();
break;
}
}
target.add(filesContainer);
}
});
}
}).setOutputMarkupId(true));
// Users in this Room
add(clientsContainer.add(clients.setOutputMarkupId(true)).setOutputMarkupId(true));
add(new TextField<String>("confno").setEnabled(false));
add(pin);
pin.setEnabled(getModelObject().isSipEnabled());
add(new TextField<String>("ownerId").setEnabled(false));
add(new AjaxCheckBox("sipEnabled") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateView(target);
}
}.setOutputMarkupId(true));
// attach an ajax validation behavior to all form component's keydown
// event and throttle it down to once per second
add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class CompositedIconPanel method initLayout.
private void initLayout() {
WebMarkupContainer layeredIcon = new WebMarkupContainer(ID_LAYERED_ICON);
layeredIcon.add(AttributeAppender.append("title", (IModel<String>) () -> {
if (getModelObject() != null && org.apache.commons.lang3.StringUtils.isNotBlank(getModelObject().getTitle())) {
return getModelObject().getTitle();
}
return null;
}));
add(layeredIcon);
WebComponent basicIcon = new WebComponent(ID_BASIC_ICON);
basicIcon.add(AttributeAppender.append("class", (IModel<String>) () -> {
if (getModelObject() != null && getModelObject().hasBasicIcon()) {
return getModelObject().getBasicIcon();
}
return null;
}));
basicIcon.add(AttributeAppender.append("style", (IModel<String>) () -> {
if (getModelObject() != null && getModelObject().hasBasicIcon() && getModelObject().hasBasicIconHtmlColor()) {
return "color:" + getModelObject().getBasicIconHtmlColor();
}
return null;
}));
layeredIcon.add(basicIcon);
ListView<LayerIcon> validationItems = new ListView<LayerIcon>(ID_LAYER_ICONS, new PropertyModel(getModel(), CompositedIcon.F_LAYER_ICONS)) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<LayerIcon> item) {
if (item.getModelObject() == null) {
return;
}
if (StringUtils.isNotEmpty(item.getModelObject().getIconType().getCssClass())) {
WebComponent icon = new WebComponent(ID_LAYER_ICON);
icon.add(AttributeAppender.append("class", item.getModelObject().getIconType().getCssClass()));
if (StringUtils.isNotEmpty(item.getModelObject().getIconType().getColor())) {
icon.add(AttributeAppender.append("style", "color: " + item.getModelObject().getIconType().getColor()));
}
item.add(icon);
}
}
};
layeredIcon.add(validationItems);
add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject() != null;
}
});
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class MultiValueTextFormGroup method initLayout.
private void initLayout(final IModel<String> label, final String labelSize, final String textSize, final boolean required) {
Label l = new Label(ID_LABEL, label);
if (StringUtils.isNotEmpty(labelSize)) {
l.add(AttributeAppender.prepend("class", labelSize));
}
add(l);
ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {
@Override
protected void populateItem(final ListItem<T> item) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.add(AttributeAppender.prepend("class", new IModel<String>() {
@Override
public String getObject() {
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(textSize)) {
sb.append(textSize).append(' ');
}
if (item.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) {
sb.append(getOffsetClass()).append(' ');
sb.append(CLASS_MULTI_VALUE);
}
return sb.toString();
}
}));
item.add(textWrapper);
TextField<?> text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
text.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
text.setRequired(required);
text.add(AttributeAppender.replace("placeholder", label));
text.setLabel(label);
textWrapper.add(text);
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
textWrapper.add(feedback);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
buttonGroup.add(AttributeAppender.append("class", new IModel<String>() {
@Override
public String getObject() {
if (item.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) {
return CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(buttonGroup);
initButtons(buttonGroup, item);
}
};
add(repeater);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class GenericMultiValueLabelEditPanel method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
Label l = new Label(ID_LABEL, label);
l.setVisible(getLabelVisibility());
if (StringUtils.isNotEmpty(labelSize)) {
l.add(AttributeAppender.prepend("class", labelSize));
}
add(l);
WebMarkupContainer addFirstContainer = new WebMarkupContainer(ID_ADD_FIRST_CONTAINER);
addFirstContainer.setOutputMarkupId(true);
addFirstContainer.setOutputMarkupPlaceholderTag(true);
addFirstContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().isEmpty();
}
});
add(addFirstContainer);
AjaxLink<Void> addFirst = new AjaxLink<Void>(ID_ADD_FIRST) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addFirstPerformed(target);
}
};
addFirstContainer.add(addFirst);
ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<T> listItem) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.add(AttributeAppender.prepend("class", new IModel<String>() {
@Override
public String getObject() {
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(textSize)) {
sb.append(textSize).append(' ');
}
if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) {
sb.append(getOffsetClass()).append(' ');
sb.append(CLASS_MULTI_VALUE);
}
return sb.toString();
}
}));
listItem.add(textWrapper);
TextField text = new TextField<>(ID_TEXT, createTextModel(listItem.getModel()));
text.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
}
});
text.setEnabled(false);
text.add(AttributeAppender.replace("placeholder", label));
text.setLabel(label);
textWrapper.add(text);
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
textWrapper.add(feedback);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
buttonGroup.add(AttributeAppender.append("class", new IModel<String>() {
@Override
public String getObject() {
if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) {
return CLASS_MULTI_VALUE;
}
return null;
}
}));
AjaxLink<Void> edit = new AjaxLink<Void>(ID_EDIT) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editValuePerformed(target, listItem.getModel());
}
};
edit.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return GenericMultiValueLabelEditPanel.this.isEditButtonEnabled();
}
});
textWrapper.add(edit);
listItem.add(buttonGroup);
initButtons(buttonGroup, listItem);
}
};
add(repeater);
}
Aggregations