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.tysanclan.site.projectewok.pages.MemberPage.java
License:Open Source License
private void initComponents(User u) { super.setPageTitle(u.getUsername() + " - Member"); TimeZone tz = TimeZone.getTimeZone("America/New_York"); SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy", Locale.US); sdf.setTimeZone(tz);//www . j ava 2 s . co m add(new Label("membersince", new Model<String>(sdf.format(u.getJoinDate())))); add(new Label("lastlogin", new Model<String>(u.getLastAction() != null ? sdf.format(u.getLastAction()) : null))); Profile profile = u.getProfile(); add(new Label("realname", profile != null && profile.getRealName() != null ? profile.getRealName() : "") .setVisible(profile != null && profile.getRealName() != null && getUser() != null && MemberUtil.isMember(getUser()))); WebMarkupContainer photo = new WebMarkupContainer("photo"); photo.setVisible(false); add(photo); if (profile != null && profile.getPhotoURL() != null) { photo.add(AttributeModifier.replace("src", profile.getPhotoURL())); photo.setVisible(profile.isPhotoPublic() || (getUser() != null && MemberUtil.isMember(getUser()))); } add(new Label("age", profile != null && profile.getBirthDate() != null ? Integer.toString(DateUtil.calculateAge(profile.getBirthDate())) : "Unknown").setVisible( profile != null && profile.getBirthDate() != null && u.getRank() != Rank.HERO)); add(new Label("username", u.getUsername())); WebMarkupContainer aboutMe = new WebMarkupContainer("aboutme"); aboutMe.add(new Label("publicDescription", profile != null && profile.getPublicDescription() != null ? profile.getPublicDescription() : "") .setEscapeModelStrings(false) .setVisible(profile != null && profile.getPublicDescription() != null)); aboutMe.add(new Label("privateDescription", profile != null && profile.getPrivateDescription() != null ? profile.getPrivateDescription() : "") .setEscapeModelStrings(false) .setVisible(profile != null && profile.getPrivateDescription() != null && getUser() != null && MemberUtil.isMember(getUser()))); add(aboutMe.setVisible(profile != null && (profile.getPublicDescription() != null || (profile.getPrivateDescription() != null && getUser() != null && MemberUtil.isMember(getUser()))))); GroupFilter gfilter = new GroupFilter(); gfilter.addIncludedMember(u); List<Group> groups = groupDAO.findByFilter(gfilter); add(new ListView<Group>("groups", ModelMaker.wrap(groups)) { 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<Group> item) { Group group = item.getModelObject(); item.add(new AutoGroupLink("name", group)); } }.setVisible(!groups.isEmpty())); RoleFilter rfilter = new RoleFilter(); rfilter.setUser(u); add(new Label("usernameroles", u.getUsername())); List<Role> roles = roleDAO.findByFilter(rfilter); add(new ListView<Role>("roles", ModelMaker.wrap(roles)) { 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<Role> item) { Role role = item.getModelObject(); item.add(new Label("name", role.getName())); item.add(new Label("description", role.getDescription()).setEscapeModelStrings(false)); } }.setVisible(!roles.isEmpty())); add(new RankIcon("rank", u.getRank())); add(new Label("rankName", u.getRank().toString())); if (u.getRank() == Rank.CHANCELLOR || u.getRank() == Rank.SENATOR) { if (u.getRank() == Rank.CHANCELLOR) { add(new ChancellorElectedSincePanel("electionDatePanel", u)); } else { add(new SenateElectedSincePanel("electionDatePanel", u)); } } else { add(new WebMarkupContainer("electionDatePanel").setVisible(false)); } ForumPostFilter filter = new ForumPostFilter(); filter.setShadow(false); filter.setUser(u); filter.addOrderBy("time", false); List<ForumPost> posts = forumPostDAO.findByFilter(filter); posts = forumService.filterPosts(getUser(), true, posts); List<ForumPost> topPosts = new LinkedList<ForumPost>(); for (int i = 0; i < Math.min(posts.size(), 5); i++) { topPosts.add(posts.get(i)); } ListView<ForumPost> lastPosts = new ListView<ForumPost>("lastposts", ModelMaker.wrap(topPosts)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<ForumPost> item) { ForumPost post = item.getModelObject(); item.add(new AutoThreadLink("thread", post.getThread())); item.add(new DateTimeLabel("time", post.getTime())); } }; add(lastPosts.setVisible(!topPosts.isEmpty())); WebMarkupContainer container = new WebMarkupContainer("gamescontainer"); List<UserGameRealm> played = new LinkedList<UserGameRealm>(); played.addAll(u.getPlayedGames()); Collections.sort(played, new Comparator<UserGameRealm>() { /** * @see java.util.Comparator#compare(java.lang.Object, * java.lang.Object) */ @Override public int compare(UserGameRealm o1, UserGameRealm o2) { return o1.getGame().getName().compareToIgnoreCase(o2.getGame().getName()); } }); container.add(new ListView<UserGameRealm>("games", ModelMaker.wrap(played)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<UserGameRealm> item) { UserGameRealm ugr = item.getModelObject(); item.add(new Label("game", ugr.getGame().getName())); item.add(new Label("realm", ugr.getRealm().getName())); StringBuilder builder = new StringBuilder(); for (GameAccount account : ugr.getAccounts()) { if (builder.length() > 0) { builder.append(", "); } builder.append(account.getName()); } if (builder.length() == 0) { builder.append('-'); } item.add(new Label("accounts", builder.toString())); } }); add(container); boolean twitviz = profile != null && profile.getTwitterUID() != null; add(new Label("twitterhead", u.getUsername() + " on Twitter").setVisible(twitviz)); String url = "http://twitter.com/" + (twitviz && profile != null ? profile.getTwitterUID() : ""); add(new Label("twitterprofile", url).add(AttributeModifier.replace("href", url))); add(new AchievementsPanel("achievements", u)); add(new IconLink.Builder("images/icons/email_add.png", new DefaultClickResponder<User>(ModelMaker.wrap(u)) { private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new MessageListPage(getModelObject())); } }).setText("Send Message").newInstance("sendMessage") .setVisible(getUser() != null && MemberUtil.isMember(getUser()))); }
From source file:com.tysanclan.site.projectewok.pages.RealmPage.java
License:Open Source License
public void init(Realm realm) { setPageTitle("Realm overview - " + realm.getName()); add(new BookmarkablePageLink<Void>("back", AboutPage.class)); realmModel = ModelMaker.wrap(realm); add(new Label("name", realm.getName())); if (realm.getOverseer() != null) { add(new MemberListItem("supervisor", realm.getOverseer())); } else {/*from w w w. ja v a 2s .co m*/ add(new Label("supervisor", "-")); } add(new Label("playercount", new Model<Integer>(realmService.countActivePlayers(realm)))); add(new ListView<Game>("games", ModelMaker.wrap(realm.getGames())) { 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<Game> item) { Game game = item.getModelObject(); Realm rlm = getRealm(); item.add(new RealmGamePanel("game", rlm, game)); } }); }
From source file:com.tysanclan.site.projectewok.pages.RegulationPage.java
License:Open Source License
public RegulationPage() { super("Regulations"); add(new ListView<Regulation>("regulations", ModelMaker.wrap(dao.findAll())) { private static final long serialVersionUID = 1L; @Override/*w w w .ja v a 2 s. co m*/ protected void populateItem(ListItem<Regulation> item) { Regulation rel = item.getModelObject(); item.add(new Label("name", rel.getName())); item.add(new Label("contents", rel.getContents()).setEscapeModelStrings(false)); } }); }
From source file:com.untitleddoc.cadencecalc.web.wicket.SpeedDataPanel.java
License:Apache License
public SpeedDataPanel(final String id, final IModel<Crankset> modelCrank, final IModel<Sproket> modelSproket, final IModel<Perimeter> modelPerimeter, final IModel<Integer> modelCadence) { super(id);//from w w w .j a v a2 s . co m this.modelCrank = modelCrank; this.modelSproket = modelSproket; this.modelPerimeter = modelPerimeter; this.modelCadence = modelCadence; headers = new ListView<Integer>("headers", modelSproketTooths) { private static final long serialVersionUID = SpeedDataPanel.serialVersionUID; @Override protected void populateItem(final ListItem<Integer> item) { item.add(new Label("header", item.getModelObject()).setOutputMarkupId(true)); } }; headers.setOutputMarkupId(true); add(headers); dataList = new ListView<AbstractMap.SimpleEntry<Integer, List<Double>>>("dataBodyRow", modelDataTable) { private static final long serialVersionUID = SpeedDataPanel.serialVersionUID; @Override protected void populateItem(final ListItem<AbstractMap.SimpleEntry<Integer, List<Double>>> item) { final AbstractMap.SimpleEntry<Integer, List<Double>> i = item.getModelObject(); item.add(new Label("dataBodyRowHeader", i.getKey())); item.add(new ListView<Double>("dataBodyColum", i.getValue()) { private static final long serialVersionUID = SpeedDataPanel.serialVersionUID; @Override protected void populateItem(final ListItem<Double> item) { item.add(new Label("dataBodyItem", item.getModelObject())); } }); } }; dataList.setOutputMarkupId(true); add(dataList); }
From source file:com.userweave.components.bar.BarListPanel.java
License:Open Source License
private void init(List<Integer> barValues, final int maxBarValue, final List<String> cssClassNames) { add(new ListView("ratingBars", barValues) { private static final long serialVersionUID = 1L; @Override//from w w w. j a va 2s.c o m protected void populateItem(ListItem item) { Integer rating = (Integer) item.getModelObject(); String cssClassName = null; int index = item.getIndex(); if ((cssClassNames != null) && (cssClassNames.size() > index)) { cssClassName = cssClassNames.get(index); } item.add(new BarPanel("bar", maxBarValue, rating.intValue(), cssClassName)); } }); }
From source file:com.userweave.module.methoden.iconunderstandability.page.report.bmi.IconReportListPanel.java
License:Open Source License
public IconReportListPanel(String id, TermReport theTermReport, Locale aStudyLocale) { super(id);/*from ww w . j a v a2 s . com*/ this.termReport = theTermReport; this.studyLocale = aStudyLocale; setOutputMarkupId(true); WildcardListModel<IconReport> iconModel = new WildcardListModel<IconReport>() { private static final long serialVersionUID = 1L; @Override public List<IconReport> getObject() { if (detailsAreShown()) { return termReport.getBestMatchingIconReports(); } else { return termReport.getBestMatchingIconReports(MAX_ICON_REPORTS); } } }; add(new ListView<IconReport>("icons", iconModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<IconReport> item) { item.add(new IconReportPanel("iconDetails", item.getModelObject(), studyLocale, item.getIndex()) { private static final long serialVersionUID = 1L; @Override protected void onModalWindowClose(AjaxRequestTarget target) { target.add(IconReportListPanel.this); } }); } }); }
From source file:com.userweave.module.methoden.iconunderstandability.page.report.bmi.SelectableItemList.java
License:Open Source License
/** * attention: propertyExpression will be used on a LocalizedString!! * // ww w . j a va 2 s .c o m * @param id * @param listModel * @param propertyExpression */ public SelectableItemList(String id, IModel listModel, final String propertyExpression) { super(id); itemListView = new ListView("items", listModel) { boolean isOdd = true; @Override protected void populateItem(final ListItem item) { isOdd = !isOdd; EntityBase entity = (EntityBase) item.getModelObject(); final int entityId = entity.getId(); item.add(new IndicatingAjaxLink("link") { @Override public void onClick(AjaxRequestTarget target) { onSelect(target, item, entityId); } }.add(new Label("name", new LocalizedPropertyModel(item.getModel(), propertyExpression, getLocale())))); // add css class "odd" to odd lines if (isOdd) { item.add(new SimpleAttributeModifier("class", "odd")); } // add css class "odd" to even lines else { item.add(new SimpleAttributeModifier("class", "even")); } // add css classes "even_first" to 1st line if (item.getIndex() == 0) item.add(new AttributeModifier("class", true, new Model("even_first"))); } }; add(itemListView); // create no item available label with empty list message as default noItemsAvailableLabel = new Label("emptyListMessage", new StringResourceModel("empty_list_message", this, null)); // add label to QuestionsConfigurationPanel add(noItemsAvailableLabel); // set visibility of no items available label updateNoItemsAvailableLabelVisibility(); }
From source file:com.userweave.module.methoden.iconunderstandability.page.report.ITMReportPanel.java
License:Open Source License
private void addTermReports(final ObjectCategorization objectCategorization, final int categorizationCount, final CategoryObjectDisplay displayObject) { ArrayList terms = new ArrayList(objectCategorization.getCategories()); add(new ListView("categories", terms) { @Override// w ww. j a va 2s. com protected void populateItem(ListItem item) { final String category = (String) item.getModelObject(); displayObject.displayCategory(item, "category", category); final int objectCountForCategorySum = objectCategorization.getObjectCountForCategory(category); // how many times the object was not categorized final int missing = categorizationCount - objectCountForCategorySum; item.add(new Label("missing", Integer.toString(missing))); item.add(new Label("sum", Integer.toString(objectCountForCategorySum))); // create list of report models ArrayList<ReportModel> reportModels = new ArrayList<ReportModel>(); for (String object : objectCategorization.getObjectsForCategory(category)) { reportModels.add(new ReportModel(object, objectCategorization.getCountForCategoryAndObject(category, object))); } // add line for missing-categorizations if (missing > 0) { reportModels.add(new ReportModel(null, missing)); } // sort by count java.util.Collections.sort(reportModels, new Comparator<ReportModel>() { public int compare(ReportModel reportModel1, ReportModel reportModel2) { return new Integer(reportModel2.getCount()).compareTo(reportModel1.getCount()); } }); item.add(new ListView("objects", reportModels) { @Override protected void populateItem(ListItem item) { final ReportModel reportModel = (ReportModel) item.getModelObject(); // display object on the left if (reportModel.getObject() != null) { displayObject.displayObject(item, "object", reportModel); } else { displayObject.displayMissingObject(item, "object"); } // percent this object was classified for current category String percent = Double.toString(reportModel.getCount() * 100 / categorizationCount); addBar(item, percent, reportModel.getObject() != null); item.add(new Label("percent", percent)); String iconCount = Integer.toString(reportModel.getCount()); item.add(new Label("count", iconCount)); } private void addBar(ListItem item, String percent, boolean missing) { Label bar = new Label("bar", ""); if (missing) { bar.add(new AttributeModifier("class", true, new Model("color"))); } else { bar.add(new AttributeModifier("class", true, new Model("color-missing"))); } bar.add(new AttributeModifier("style", true, new Model("width: " + percent + "%"))); item.add(bar); } }); } }); }
From source file:com.userweave.module.methoden.questionnaire.page.grouping.multiplepossibleanswers.MultiplePossibleAnswersGroupingPanel.java
License:Open Source License
public MultiplePossibleAnswersGroupingPanel(String id, QuestionWithMultiplePossibleAnswers question, T group, final Locale locale, GroupAddedCallback groupAddedCallback) { super(id, group, locale, groupAddedCallback); questionId = question.getId();//w w w.j ava 2s .co m CheckGroup answers = new CheckGroup("answers", new PropertyModel(MultiplePossibleAnswersGroupingPanel.this, "answers")); if (isOnChangeAjaxBehaviorNeeded()) { answers.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { MultiplePossibleAnswersGroupingPanel.this.onUpdate(target); } }); } add(answers); IModel possibleAnswersModel = new LoadableDetachableModel() { @Override protected Object load() { QuestionWithMultiplePossibleAnswers question = (QuestionWithMultiplePossibleAnswers) questionDao .findById(questionId); return question.getPossibleAnswers(); } }; answers.add(new ListView("values", possibleAnswersModel) { @Override protected void populateItem(ListItem item) { item.add(new Check("check", item.getModel())); item.add(new Label("content", new LocalizedModel((Serializable) item.getModelObject(), locale))); }; }); }
From source file:com.userweave.module.methoden.questionnaire.page.grouping.QuestionnaireGroupingPanel.java
License:Open Source License
public QuestionnaireGroupingPanel(String id, final QuestionnaireConfigurationEntity configuration) { super(id);/* w w w .j ava 2 s . c o m*/ setOutputMarkupId(true); //final int configurationId = configuration.getId(); final Locale locale = configuration.getStudy().getLocale(); setDefaultModel(new SpringLoadableDetachableModel(questionnaireConfigurationDao, configuration)); add(new ListView("moduleGroups", new PropertyModel(getDefaultModel(), "groups")) { @Override protected void populateItem(ListItem item) { if (item.getIndex() % 2 == 1) { item.add(new AttributeModifier("class", true, new Model("oddRow"))); } Panel groupingDescriptionPanel = new QuestionnaireGroupingPanelFactoryImpl() .getGroupingDescriptionPanel(item.getModel(), locale); if (groupingDescriptionPanel != null) { item.add(groupingDescriptionPanel); } else { item.add(new Label("group", "EMPTY !")); } Form form = new Form("deleteForm"); item.add(form); QuestionnaireGroup group = (QuestionnaireGroup) item.getModelObject(); final Class<? extends QuestionnaireGroup> class1 = group.getClass(); final Integer groupId = group.getId(); form.add(new AjaxButton("delete", form) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { QuestionnaireConfigurationEntity configuration = getConfiguration(); QuestionnaireGroup group = questionnaireGroupDao.findById(class1, groupId); configuration.removeFromGroups(group); questionnaireGroupDao.delete(group); target.addComponent(QuestionnaireGroupingPanel.this); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }); } }); add(new ListView("studyGroups", new PropertyModel(getDefaultModel(), "study.groups")) { @Override protected void populateItem(ListItem item) { if (item.getIndex() % 2 == 1) { item.add(new AttributeModifier("class", true, new Model("oddRow"))); } Panel groupingDescriptionPanel = new StudyGroupingFactoryImpl() .getGroupingDescriptionPanel(item.getModel(), locale); if (groupingDescriptionPanel != null) { item.add(groupingDescriptionPanel); } else { item.add(new Label("group", "EMPTY !")); } Form form = new Form("deleteForm"); item.add(form); StudyGroup group = (StudyGroup) item.getModelObject(); final Class<? extends StudyGroup> class1 = group.getClass(); final Integer groupId = group.getId(); form.add(new AjaxButton("delete", form) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { StudyGroup group = studyGroupDao.findById(class1, groupId); getConfiguration().getStudy().removeFromGroups(group); studyGroupDao.delete(group); target.add(QuestionnaireGroupingPanel.this); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }); } }); Form form = new Form("form") { }; add(form); AuthOnlyDropDownChoice choice = new AuthOnlyDropDownChoice("groupTypes", new PropertyModel(this, "selectedGroupType"), getSelectionObjects(configuration, locale), new IChoiceRenderer() { @Override public Object getDisplayValue(Object object) { return ((GroupType) object).getName().getObject(); } @Override public String getIdValue(Object object, int index) { return Integer.toString(index); } }); choice.setRequired(true); choice.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (selectedGroupType instanceof QuestionnaireGroupType) { replaceGroupingPanel(target, new QuestionnaireGroupingPanelFactoryImpl().createGroupingPanel("addGroupPanel", (QuestionnaireGroupType) selectedGroupType, locale, new GroupAddedCallback<QuestionnaireGroup>() { @Override public void onAdd(AjaxRequestTarget target, QuestionnaireGroup group) { addGroupAndSaveConfiguration(group); removeGroupingPanel(target); } })); } else if (selectedGroupType instanceof StudyGroupType) { replaceGroupingPanel(target, new StudyGroupingFactoryImpl().createGroupingPanel("addGroupPanel", (StudyGroupType) selectedGroupType, locale, new GroupAddedCallback<StudyGroup>() { @Override public void onAdd(AjaxRequestTarget target, StudyGroup group) { addGroupAndSaveStudy(group); removeGroupingPanel(target); } })); } } }); form.add(choice); addGroupPanel = new WebMarkupContainer("addGroupPanel"); add(addGroupPanel); addGroupPanel.setOutputMarkupId(true); }