• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 17544407096

08 Sep 2025 08:19AM UTC coverage: 11.972% (+0.02%) from 11.955%
17544407096

push

github

tkuhn
Improve paging navigation bar

334 of 3876 branches covered (8.62%)

Branch coverage included in aggregate %.

960 of 6933 relevant lines covered (13.85%)

0.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/UserList.java
1
package com.knowledgepixels.nanodash.component;
2

3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Map;
6

7
import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
8
import org.apache.wicket.extensions.markup.html.repeater.data.table.NavigatorLabel;
9
import org.apache.wicket.markup.html.WebMarkupContainer;
10
import org.apache.wicket.markup.html.basic.Label;
11
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
12
import org.apache.wicket.markup.html.panel.Panel;
13
import org.apache.wicket.markup.repeater.Item;
14
import org.apache.wicket.markup.repeater.data.DataView;
15
import org.apache.wicket.markup.repeater.data.ListDataProvider;
16
import org.apache.wicket.request.mapper.parameter.PageParameters;
17
import org.eclipse.rdf4j.model.IRI;
18
import org.nanopub.extra.services.ApiResponse;
19
import org.nanopub.extra.services.ApiResponseEntry;
20

21
import com.knowledgepixels.nanodash.User;
22
import com.knowledgepixels.nanodash.Utils;
23
import com.knowledgepixels.nanodash.page.UserPage;
24

25
/**
26
 * A panel that displays a list of users with links to their user pages.
27
 * Optionally, it can also display notes associated with each user.
28
 */
29
public class UserList extends Panel {
30

31
    private static final long serialVersionUID = 1L;
32

33
    /**
34
     * Constructor for UserList.
35
     *
36
     * @param id    the component id
37
     * @param users a list of user IRI objects
38
     * @param notes a map of user IRI to notes (optional)
39
     */
40
    public UserList(String id, List<IRI> users, Map<IRI, String> notes) {
41
        super(id);
×
42
        setOutputMarkupId(true);
×
43
        init(users, notes);
×
44
    }
×
45

46
    /**
47
     * Constructor for UserList with a list of user IRI objects.
48
     *
49
     * @param id    the component id
50
     * @param users a list of user IRI objects
51
     */
52
    public UserList(String id, List<IRI> users) {
53
        super(id);
×
54
        setOutputMarkupId(true);
×
55
        init(users, null);
×
56
    }
×
57

58
    /**
59
     * Constructor for UserList that initializes from an ApiResponse.
60
     *
61
     * @param id        the component id
62
     * @param resp      the ApiResponse containing user data
63
     * @param userIdKey the key in the ApiResponse entries that contains the user IRI
64
     */
65
    public UserList(String id, ApiResponse resp, String userIdKey) {
66
        super(id);
×
67
        setOutputMarkupId(true);
×
68
        List<IRI> users = new ArrayList<>();
×
69
        for (ApiResponseEntry e : resp.getData()) {
×
70
            users.add(Utils.vf.createIRI(e.get(userIdKey)));
×
71
        }
×
72
        init(users, null);
×
73
    }
×
74

75
    private void init(List<IRI> users, Map<IRI, String> notes) {
76
        DataView<IRI> dataView = new DataView<>("userlist", new ListDataProvider<IRI>(users)) {
×
77

78
            private static final long serialVersionUID = 1L;
79

80
            @Override
81
            protected void populateItem(Item<IRI> item) {
82
                IRI userIri = item.getModelObject();
×
83
                PageParameters params = new PageParameters();
×
84
                params.add("id", userIri);
×
85
                BookmarkablePageLink<Void> l = new BookmarkablePageLink<Void>("userlink", UserPage.class, params);
×
86
                l.add(new Label("linktext", User.getShortDisplayName(userIri)));
×
87
                item.add(l);
×
88
                if (notes != null && notes.containsKey(userIri)) {
×
89
                    item.add(new Label("notes", notes.get(userIri)));
×
90
                } else {
91
                    item.add(new Label("notes"));
×
92
                }
93
            }
×
94

95
        };
96
        dataView.setItemsPerPage(10);
×
97
        dataView.setOutputMarkupId(true);
×
98
        add(dataView);
×
99

100
        WebMarkupContainer navigation = new WebMarkupContainer("navigation");
×
101
        navigation.add(new NavigatorLabel("navigatorLabel", dataView));
×
102
        AjaxPagingNavigator pagingNavigator = new AjaxPagingNavigator("navigator", dataView);
×
103
        navigation.setVisible(dataView.getPageCount() > 1);
×
104
        navigation.add(pagingNavigator);
×
105
        add(navigation);
×
106
    }
×
107

108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc