List of usage examples for org.apache.wicket.markup.html.list ListView ListView
public ListView(final String id, final List<T> list)
From source file:com.ttdev.wicketpagetest.sample.spring.PageExtractedByWicketIds.java
License:Open Source License
public PageExtractedByWicketIds() { values = new ArrayList<Integer>(); values.add(3);/*from w w w .java 2 s. c o m*/ values.add(2); values.add(8); ListView<Integer> eachRow = new ListView<Integer>("eachRow", values) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Integer> item) { Form<Void> f = new Form<Void>("f"); f.add(new TextField<Integer>("v", item.getModel(), Integer.class)); f.add(new AjaxButton("ok") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.add(totalLabel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }); item.add(f); } }; add(eachRow); WebMarkupContainer container = new WebMarkupContainer("container"); add(container); totalLabel = new Label("total", new PropertyModel<String>(this, "total")); totalLabel.setOutputMarkupId(true); container.add(totalLabel); add(new Label("id.containing.dots", "xyz")); }
From source file:com.ttdev.wicketpagetest.sample.spring.PageRefreshingTR.java
License:Open Source License
public PageRefreshingTR() { values = Arrays.asList(new Integer[] { 0, 0, 0 }); ListView<Integer> eachRow = new ListView<Integer>("eachRow", values) { private static final long serialVersionUID = 1L; @Override/*from w w w . java 2s . c o m*/ protected void populateItem(final ListItem<Integer> item) { item.setOutputMarkupId(true); item.add(new Label("count", new AbstractReadOnlyModel<Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getObject() { return getRowCount(item); } })); item.add(new Label("sum", new AbstractReadOnlyModel<Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getObject() { Integer c = getRowCount(item); int sum = 0; for (int i = 0; i <= c; i++) { sum += i; } return sum; } })); item.add(new AjaxLink<Void>("inc") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { values.set(item.getIndex(), getRowCount(item) + 1); target.add(item); } }); } }; add(eachRow); }
From source file:com.tysanclan.site.projectewok.components.AccountPanel.java
License:Open Source License
/** * //from w ww. j a v a 2 s . co m */ public AccountPanel(String id, UserGameRealm userGameRealm) { super(id); ugrModel = ModelMaker.wrap(userGameRealm); add(new Label("realmgamename", userGameRealm.getGame().getName() + " on " + userGameRealm.getRealm().getName())); add(new ListView<GameAccount>("accounts", ModelMaker.wrap(userGameRealm.getAccounts())) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<GameAccount> item) { GameAccount account = item.getModelObject(); item.add(new Label("name", account.toString())); item.add(new IconLink.Builder("images/icons/cross.png", new DefaultClickResponder<GameAccount>(ModelMaker.wrap(account)) { private static final long serialVersionUID = 1L; /** * @see com.tysanclan.site.projectewok.components.IconLink.DefaultClickResponder#onClick() */ @Override public void onClick() { gameService.deleteAccount(getModelObject()); setResponsePage(new EditAccountsPage()); } }).newInstance("delete")); } }); add(new ListView<AccountType>("addAccountForms", Arrays.asList(AccountType.values())) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<AccountType> item) { AccountType type = item.getModelObject(); item.add(type.createAddForm("addPanel", ugrModel.getObject())); } }); add(new IconLink.Builder("images/icons/cross.png", new DefaultClickResponder<UserGameRealm>(ModelMaker.wrap(userGameRealm)) { private static final long serialVersionUID = 1L; /** * @see com.tysanclan.site.projectewok.components.IconLink.DefaultClickResponder#onClick() */ @Override public void onClick() { gameService.removePlayedGame(getModelObject()); setResponsePage(new EditAccountsPage()); } }).setText("I no longer play this game on this realm").newInstance("stopplaying")); }
From source file:com.tysanclan.site.projectewok.components.AchievementsPanel.java
License:Open Source License
public AchievementsPanel(String id, User user) { super(id);/*from ww w . j ava2 s.c o m*/ List<Achievement> achievements = new LinkedList<Achievement>(); achievements.addAll(user.getAchievements()); Collections.sort(achievements, AchievementComparator.INSTANCE); add(new ListView<Achievement>("achievements", ModelMaker.wrap(achievements)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Achievement> item) { Achievement a = item.getModelObject(); AchievementIcon icon = a.getIcon(); item.add(new Image("achievement", new ByteArrayResource(ImageUtil.getMimeType(icon.getImage()), icon.getImage()))); item.add(new Label("name", a.getName())); item.add(new Label("group", a.getGroup() != null ? a.getGroup().getName() : "")); Game game = a.getGame(); byte[] gameImage = game != null ? game.getImage() : new byte[0]; item.add(new Image("game", new ByteArrayResource(ImageUtil.getMimeType(gameImage), gameImage)) .setVisible(game != null)); item.add(new BBCodePanel("description", a.getDescription())); } }); }
From source file:com.tysanclan.site.projectewok.components.BasicMemberPanel.java
License:Open Source License
/** * /* ww w .j a va2 s.c o m*/ */ public BasicMemberPanel(String id, User user) { super(id, "Basic Overview"); addKeyRoleLinks(user); addEmailChangeConfirmationPanel(user); addMessagesLink(); addLogLink(); addJoinGroupLink(user); addCreateGroupLink(user); addFinanceLink(); addStatsLink(); addCalendarLink(); addAcceptanceVoteLink(user); addTruthsayerAcceptanceLink(user); addEndorsementLink(user); addRunForSenatorLink(user); addRunForChancellorLink(user); addChancellorElectionLink(user); addSenateElectionLink(user); addPreferencesLink(); addUntenabilityVoteLink(user); addStartTrialLink(user); addPastElectionsLink(); addSkypeOverviewLink(); addNotificationsLink(user); addCreateGamePetitionLink(user); addCreateRealmPetitionLink(user); addSignGamePetitionLink(user); addSignRealmPetitionLink(user); addEditAccountsPage(); addBirthdays(); addAprilFools2010(); addAchievementLinks(user); addBugLink(); addSubscriptionPaymentLink(); add(new ListView<MumbleServer>("servers", ModelMaker.wrap(serverDAO.findAll())) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<MumbleServer> item) { MumbleServer server = item.getModelObject(); Link<MumbleServer> link = new Link<MumbleServer>("link", ModelMaker.wrap(server)) { private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new MumbleServerStatusPage(getModelObject())); } }; link.add(new Label("name", server.getName()).setRenderBodyOnly(true)); item.add(link); } }); }
From source file:com.tysanclan.site.projectewok.components.BasicMemberPanel.java
License:Open Source License
/** * /*w w w. j a v a 2 s . c o m*/ */ private void addBirthdays() { List<Profile> _profiles = profileDAO.findAll(); List<Profile> profiles = new LinkedList<Profile>(); Calendar cal = DateUtil.getCalendarInstance(); String tzName = getUser().getTimezone(); if (tzName == null) { tzName = DateUtil.NEW_YORK.getID(); } for (Profile p : _profiles) { if (p.getBirthDate() != null && MemberUtil.isMember(p.getUser())) { Calendar cal2 = DateUtil.getMidnightCalendarByUnadjustedDate(p.getBirthDate(), TimeZone.getTimeZone(tzName)); if (cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) && cal.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH)) { profiles.add(p); } } } add(new WebMarkupContainer("birthdays").setVisible(!profiles.isEmpty())); add(new ListView<Profile>("users", ModelMaker.wrap(profiles)) { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem) */ @Override protected void populateItem(ListItem<Profile> item) { Profile profile = item.getModelObject(); item.add(new MemberListItem("user", profile.getUser())); } }); }
From source file:com.tysanclan.site.projectewok.components.CalendarPanel.java
License:Open Source License
/** * // w w w . ja v a 2 s . c o m */ public CalendarPanel(String id, final Calendar calendar) { super(id); this.calendar = calendar; SortedMap<Integer, List<Date>> layout = getCalendarLayout(calendar); List<Integer> weeks = new LinkedList<Integer>(); weeks.addAll(layout.keySet()); add(new ListView<Integer>("weeks", weeks) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Integer> item) { SortedMap<Integer, List<Date>> calendarLayout = getCalendarLayout(calendar); List<Date> days = calendarLayout.get(item.getModelObject()); item.add(createDaysListView(days, item.getModelObject())); } }); }
From source file:com.tysanclan.site.projectewok.components.CalendarPanel.java
License:Open Source License
private ListView<Date> createDaysListView(List<Date> days, final int week) { return new ListView<Date>("days", days) { private static final long serialVersionUID = 1L; @Override/* ww w . j a v a 2 s .c om*/ protected void populateItem(ListItem<Date> item) { item.add(getDateComponent("content", item.getModelObject())); if (item.getModelObject() != null) { item.add(AttributeModifier.replace("class", new Model<String>("Calendar"))); } } }; }
From source file:com.tysanclan.site.projectewok.components.ConversationContentPanel.java
License:Open Source License
public ConversationContentPanel(String id, ConversationParticipation participation, final EntityClickListener<ConversationParticipation> listener) { super(id);// ww w . j a va 2s .c om participationId = participation.getId(); for (Message m : participation.getConversation().getMessages()) { if (!participation.getReadMessages().contains(m)) { service.markAsRead(participation, m); } } add(new ListView<Message>("messages", new MessageList(participation.getConversation().getId())) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Message> item) { Message message = item.getModelObject(); item.add(new Label("user", message.getSender() != null ? message.getSender().getUsername() : "System")); item.add(new Label("time", DateUtil.getTimezoneFormattedString(message.getSendTime(), getUser().getTimezone()))); item.add(new BBCodePanel("content", message.getContent())); } }.setOutputMarkupId(true).add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15)))); List<ConversationParticipation> plist = new LinkedList<ConversationParticipation>(); plist.addAll(participation.getConversation().getParticipants()); add(new ListView<ConversationParticipation>("participants", ModelMaker.wrap(plist)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<ConversationParticipation> item) { item.add(new MemberListItem("participant", item.getModelObject().getUser())); } }); Form<ConversationParticipation> respondForm = new Form<ConversationParticipation>("respondForm", ModelMaker.wrap(participation)) { private static final long serialVersionUID = 1L; @SpringBean private MessageService messageService; @Override protected void onSubmit() { String message = getEditorComponent().getModelObject(); ConversationParticipation part = getModelObject(); Message msg = messageService.respondToConversation(part.getConversation(), part.getUser(), message); messageService.markAsRead(part, msg); listener.onEntityClick(null, part); } }; editorVisible = participation.getConversation().getParticipants().size() > 1; add(new WebMarkupContainer("respondheader").setVisible(editorVisible)); respondForm.setVisible(editorVisible); editor = new BBCodeTextArea("messagecontent", ""); editor.setOutputMarkupId(true); editor.setOutputMarkupPlaceholderTag(true); respondForm.add(editor); add(respondForm); }
From source file:com.tysanclan.site.projectewok.components.DebugWindow.java
License:Open Source License
public DebugWindow(String id, Class<? extends Page> page) { super(id);/*from w w w . ja v a2 s . c om*/ add(new Label("page", page.getName())); Form<?> debugLoginForm = new Form<Void>("debugLogin") { private static final long serialVersionUID = 1L; @SpringBean private AuthenticationService authService; @SpringBean private UserDAO userDAO; /** * @see org.apache.wicket.markup.html.form.Form#onSubmit() */ @SuppressWarnings("unchecked") @Override protected void onSubmit() { TextField<String> devUsernameField = (TextField<String>) get("devusername"); TextField<String> usernameField = (TextField<String>) get("username"); PasswordTextField passwordField = (PasswordTextField) get("password"); String devUsername = devUsernameField.getModelObject(); String username = usernameField.getModelObject(); String password = passwordField.getModelObject(); boolean validUser = authService.isValidUser(devUsername, password); boolean validMember = authService.isValidMember(devUsername, password); if (validUser || validMember) { UserFilter filter = new UserFilter(); filter.setUsername(username); List<User> users = userDAO.findByFilter(filter); if (!users.isEmpty()) { User user = users.get(0); TysanSession session = ((TysanPage) getPage()).getTysanSession(); session.setCurrentUserId(user.getId()); if (validMember) { setResponsePage(new com.tysanclan.site.projectewok.pages.member.OverviewPage()); } else { setResponsePage(new com.tysanclan.site.projectewok.pages.forum.OverviewPage()); } } } } }; debugLoginForm.add(new TextField<String>("devusername", new Model<String>(""))); debugLoginForm.add(new TextField<String>("username", new Model<String>(""))); debugLoginForm.add(new PasswordTextField("password", new Model<String>(""))); add(debugLoginForm); add(new ListView<Class<? extends TysanTask>>("taskStarter", TysanScheduler.getScheduler().getScheduledTaskTypes()) { /** * */ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Class<? extends TysanTask>> item) { Link<?> taskLink = new Link<Void>("task") { /** * */ private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public void onClick() { ListItem<Class<?>> li = (ListItem<Class<?>>) getParent(); Class<?> clazz = li.getModelObject(); try { TysanTask task = (TysanTask) clazz.newInstance(); Injector.get().inject(task); task.run(); } catch (InstantiationException e) { error(e.getMessage()); } catch (IllegalAccessException e) { error(e.getMessage()); } } }; taskLink.add(new Label("type", item.getModelObject().getSimpleName())); item.add(taskLink); } }); }