Example usage for org.apache.wicket.markup.repeater.data DataView DataView

List of usage examples for org.apache.wicket.markup.repeater.data DataView DataView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.repeater.data DataView DataView.

Prototype

protected DataView(String id, IDataProvider<T> dataProvider, long itemsPerPage) 

Source Link

Usage

From source file:com.socialsite.friend.AllFriendsPanel.java

License:Open Source License

public AllFriendsPanel(final String id) {
    super(id);/*from   w w w.  j av a  2  s  .co  m*/
    // friends data provider
    final FriendsDataProvider friendsDataProvider = new FriendsDataProvider(
            SocialSiteSession.get().getUserId());

    final DataView<User> friendList = new DataView<User>("friends", friendsDataProvider, 12) {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<User> item) {
            final User user = item.getModelObject();
            UserLink<User> userImageLink;
            item.add(userImageLink = new UserLink<User>("imagelink", item.getModel()));
            userImageLink.add(
                    new ImagePanel("user", user.getId(), ImageType.USER, user.getLastModified(), false, false));
            Link<User> name;
            item.add(name = new UserLink<User>("home", item.getModel()));
            name.add(new Label("username", item.getModelObject().getUserName()));

            item.add(new Label("city", user.getProfile().getCurrentCity().getValue()));
            item.add(new Label("sex", user.getProfile().getSex()));

        }

    };

    add(new PagingNavigator("paging", friendList));
    add(friendList);
}

From source file:com.socialsite.search.SearchPage.java

License:Open Source License

/**
 * constructor//w ww  . j  a v  a  2s.c  o  m
 * 
 * @param searchText
 *            search text
 */
@SuppressWarnings("unchecked")
public SearchPage(final StringWrapper filter, final SearchOption searchOption) {
    // intialize the filter
    this.filter = filter;

    // add the user info panel
    add(new UserInfoPanel("userinfo"));

    final SearchDataProvider searchDataProvider = new SearchDataProvider(this.filter, searchOption);

    final DataView searchList = new DataView("searchlist", searchDataProvider, 9) {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item item) {
            switch (searchOption) {
            case USER:
                item.add(new SearchUserInfoPanel("details", item.getModel()));
                break;
            case UNIVERSITY:
                item.add(new SearchUniversityInfo("details", item.getModel()));
                break;
            case COURSE:
                item.add(new SearchCourseInfoPanel("details", item.getModel()));
            }
        }
    };

    add(new PagingNavigator("searchpagination", searchList));
    add(searchList);
}

From source file:com.socialsite.staff.StaffsPanel.java

License:Open Source License

public StaffsPanel(final String id, final University university) {
    super(id);//from w  w  w . j  a va2  s .com
    // friends data provider
    final StaffDataProvider staffDataProvider = new StaffDataProvider(university);

    final DataView<User> staffList = new DataView<User>("staffs", staffDataProvider, 9) {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<User> item) {
            final User staff = item.getModelObject();
            UserLink<User> userImageLink;
            item.add(userImageLink = new UserLink<User>("imagelink", item.getModel()));
            userImageLink.add(
                    new ImagePanel("userthumb", staff.getId(), ImageType.USER, staff.getLastModified(), true));
            Link<User> name;
            item.add(name = new UserLink<User>("home", item.getModel()));
            name.add(new Label("username", item.getModelObject().getUserName()));
        }

    };
    add(new ShowAllLink("showall", staffList.getDataProvider()));
    add(staffList);

}

From source file:com.socialsite.user.AllUsersPanel.java

License:Open Source License

public AllUsersPanel(String id, IDataProvider<User> dataProvider) {
    super(id);//ww w .java  2  s.c o  m
    final DataView<User> userList = new DataView<User>("friends", dataProvider, 12) {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<User> item) {
            final User user = item.getModelObject();
            UserLink<User> userImageLink;
            item.add(userImageLink = new UserLink<User>("imagelink", item.getModel()));
            userImageLink.add(
                    new ImagePanel("user", user.getId(), ImageType.USER, user.getLastModified(), false, false));
            Link<User> name;
            item.add(name = new UserLink<User>("home", item.getModel()));
            name.add(new Label("username", item.getModelObject().getUserName()));

            item.add(new Label("city", user.getProfile().getCurrentCity().getValue()));
            item.add(new Label("sex", user.getProfile().getSex()));

        }

    };

    add(new PagingNavigator("paging", userList));
    add(userList);
}

From source file:com.socialsite.user.UsersPanel.java

License:Open Source License

public UsersPanel(String id, IDataProvider<User> dataProvider, Class<? extends Page> showAllPage) {
    super(id);/* w  w w . j a v  a 2 s .  c  o  m*/

    final DataView<User> userList = new DataView<User>("users", dataProvider, 9) {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<User> item) {
            final User user = item.getModelObject();
            UserLink<User> userImageLink;
            item.add(userImageLink = new UserLink<User>("imagelink", item.getModel()));
            userImageLink.add(
                    new ImagePanel("userthumb", user.getId(), ImageType.USER, user.getLastModified(), true));
            Link<User> name;
            item.add(name = new UserLink<User>("home", item.getModel()));
            name.add(new Label("username", item.getModelObject().getUserName()));
        }

    };
    add(new ShowAllLink("showall", userList.getDataProvider()));
    add(userList);
}

From source file:com.tysanclan.site.projectewok.components.ForumPanel.java

License:Open Source License

public ForumPanel(String id, final Forum forum, final long pageId, final boolean publicView) {
    super(id);// ww w.j a va2  s .com

    DataView<ForumThread> threads = new DataView<ForumThread>("threads",
            ForumDataProvider.of(forum, forumThreadDAO), 10) {
        private static final long serialVersionUID = 1L;

        @SpringBean
        private EventDAO eventDAO;

        @SpringBean
        private TrialDAO trialDAO;

        @SpringBean
        private JoinApplicationDAO joinApplicationDAO;

        @SpringBean
        private ForumPostDAO forumPostDAO;

        @Override
        protected void populateItem(Item<ForumThread> item) {

            ForumThread current = item.getModelObject();
            TysanSession session = (TysanSession) Session.get();

            int unreadCount = (session != null && session.getUser() != null)
                    ? forumService.getForumThreadUnreadCount(session.getUser(), current)
                    : 0;

            Event ev = current.getEvent();
            Trial tr = current.getTrial();
            JoinApplication ja = current.getApplication();

            if (ev != null) {
                item.add(new ContextImage("thread", "images/icons/clock.png")
                        .add(AttributeModifier.replace("alt", new Model<String>("Event")))
                        .add(AttributeModifier.replace("title", new Model<String>("Event"))));
            } else if (ja != null) {
                item.add(new ContextImage("thread", "images/icons/user_add.png")
                        .add(AttributeModifier.replace("alt", new Model<String>("Join Application")))
                        .add(AttributeModifier.replace("title", new Model<String>("Join Application"))));
            } else if (tr != null) {
                item.add(new ContextImage("thread", "images/icons/bell.png")
                        .add(new AttributeModifier("alt", new Model<String>("User Trial")))
                        .add(AttributeModifier.replace("title", new Model<String>("User Trial"))));
            } else {
                item.add(new ContextImage("thread", "images/icons/page_white.png"));

            }

            item.add(new ContextImage("sticky", "images/icons/link.png").setVisible(current.isPostSticky()));
            item.add(new ContextImage("locked", "images/icons/lock.png").setVisible(current.isLocked()));
            item.add(new ContextImage("new", "images/icons/new.png").setVisible(unreadCount > 0));

            item.add(new AutoThreadLink("postlink", current));

            item.add(new LastPostLink("last", current));

            TimeZone ny = TimeZone.getTimeZone("America/New_York");

            Calendar cal = Calendar.getInstance(ny);
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);

            Calendar cal2 = (Calendar) cal.clone();
            cal2.add(Calendar.DAY_OF_MONTH, 1);

            SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd, yyyy h:mma zzz", Locale.US);
            sdf.setTimeZone(ny);

            SimpleDateFormat sdfToday = new SimpleDateFormat("'Today' h:mma zzz", Locale.US);
            sdfToday.setTimeZone(ny);

            item.add(new Label("poster",
                    current.getPoster() != null ? current.getPoster().getUsername() : "System"));
            item.add(new Label("postcount",
                    new Model<Long>(ForumDataProvider.of(current, forumPostDAO).size())));

            Date lastPost = current.getLastPost();
            if (lastPost != null) {
                item.add(new DateTimeLabel("lastresponse", current.getLastPost()));
            } else {
                item.add(new Label("lastresponse", "Never"));
            }

            if (current.getPosts().size() > 0) {
                ForumPost last = null;
                for (int i = current.getPosts().size() - 1; i >= 0; i--) {
                    ForumPost cp = current.getPosts().get(i);
                    if (cp.isShadow())
                        continue;

                    last = cp;
                    break;
                }

                if (last != null) {
                    item.add(new Label("lastposter",
                            last.getPoster() != null ? last.getPoster().getUsername() : "System"));
                } else {
                    item.add(new Label("lastposter", "Nobody"));
                }

            } else {
                item.add(new Label("lastposter", "Nobody"));
            }

        }

    };

    threads.setItemsPerPage(10);

    Link<Forum> markAsReadLink = new Link<Forum>("markasread", ModelMaker.wrap(forum)) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            TysanSession session = (TysanSession) TysanSession.get();

            if (session != null && session.getUser() != null) {
                forumService.clearUnreadPosts(session.getUser(), getModelObject());

            }

        }

    };

    markAsReadLink.add(new ContextImage("icon", "images/icons/eye.png"));

    TysanSession session = (TysanSession) TysanSession.get();
    User user = null;

    if (session != null) {
        user = session.getUser();
    }

    markAsReadLink.setVisible(user != null);

    add(markAsReadLink);

    add(threads);

    Link<Forum> createThread = new Link<Forum>("threadlink", ModelMaker.wrap(forum)) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(new CreateThreadPage(getModelObject()));
        }
    };

    createThread.setVisible(!publicView && forum.canCreateThread(user));

    add(createThread);

    add(new PagingNavigator("navigation", threads));
}

From source file:eu.uqasar.web.dashboard.DashboardSharePage.java

License:Apache License

public DashboardSharePage(final PageParameters pageParameters) {
    super(pageParameters);

    // Load the dashboard to be shared
    loadDashboard(pageParameters.get("id"));

    UserFilterPanel filter = new UserFilterPanel("filter") {

        /**//from  w  ww. j av  a  2 s.c om
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void applyClicked(AjaxRequestTarget target, Form<?> form) {
            userProvider.setFilter(this.getFilter());
            target.add(usersContainer);
        }

        @Override
        public void resetClicked(AjaxRequestTarget target, Form<?> form) {
            userProvider.setFilter(new UserFilterStructure());
            target.add(usersContainer);
        }
    };
    add(filter);
    userProvider = new UserEntityProvider(filter.getFilter());

    Form<Void> form = new Form("form");
    usersContainer = new WebMarkupContainer("usersContainer");
    form.add(userGroup = newCheckGroup());
    userGroup.add(usersContainer.setOutputMarkupId(true));
    CheckGroupSelector checkGroupSelector = new CheckGroupSelector("userGroupSelector", userGroup);
    usersContainer.add(checkGroupSelector);
    usersContainer.add(shareToSelectedButton = newShareToSelectedButton(userGroup));
    usersContainer.add(cancelShareButton = newCancelButton());
    DataView<User> usersView = new DataView<User>("users", userProvider, itemsPerPage) {
        @Override
        protected void populateItem(Item<User> item) {
            final User user = item.getModelObject();
            Check<User> check = newShareCheck(item);
            item.add(check);
            Link userEditPictureLink = new BookmarkablePageLink("link.picture.edit.user", UserEditPage.class,
                    new PageParameters().add("id", user.getId()));

            WebMarkupContainer picture = new WebMarkupContainer("td.picture");
            picture.add(new UserProfilePictureBackgroundBehaviour(user, User.PictureDimensions.Badge));
            item.add(userEditPictureLink.add(picture));
            item.add(new Label("td.username", new PropertyModel<>(user, "fullNameWithUserName")));
            item.add(new Label("td.role", new PropertyModel<>(user, "role")));
            item.setOutputMarkupId(true);
        }
    };

    // add links for table pagination
    usersContainer.add(navigator = new BootstrapAjaxPagingNavigator("navigatorFoot", usersView));
    usersContainer.add(usersView);

    // add confirmation modal for sharing dashboard
    add(shareConfirmationModal = newShareConfirmationModal());

    add(form);

}

From source file:eu.uqasar.web.pages.adapterdata.AdapterManagementPage.java

License:Apache License

/**
 * Constructor building the page/*  w  w w .jav  a2  s.co m*/
 *
 * @param parameters
 */
public AdapterManagementPage(final PageParameters parameters) {

    super(parameters);

    final Form<AdapterSettings> deleteForm = new Form<>("deleteForm");
    add(deleteForm);

    // add checkgroup for selecting multiple products
    deleteForm.add(adapterGroup = newAdapterSettingsCheckGroup());

    // add the container holding list of existing products
    adapterGroup.add(adapterContainer.setOutputMarkupId(true));

    adapterContainer.add(new CheckGroupSelector("adapterGroupSelector", adapterGroup));

    DataView<AdapterSettings> adapterSettings = new DataView<AdapterSettings>("adapters", new AdapterProvider(),
            itemsPerPage) {

        /**
         * 
         */
        private static final long serialVersionUID = 5487182988227539575L;

        @Override
        protected void populateItem(final Item<AdapterSettings> item) {
            final AdapterSettings adapterSettings = item.getModelObject();

            item.add(new Check<>("adapterCheck", item.getModel(), adapterGroup));

            item.add(new Label("name", new PropertyModel<String>(adapterSettings, "name")));

            item.add(new Label("metricSource", new PropertyModel<String>(adapterSettings, "metricSource")));

            item.add(new Label("url", new PropertyModel<String>(adapterSettings, "url")));

            item.add(new Label("project", new PropertyModel<Project>(adapterSettings, "project")));

            item.add(new Label("latestUpdate", new PropertyModel<Date>(adapterSettings, "latestUpdate")));

            item.add(new IndicatingAjaxLink<Object>("updateAdapterData") {

                private static final long serialVersionUID = 6245494998390009999L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    logger.info("AdapterManagementPage::updateAdapterData()::onClick()");
                    adapterSettings.updateAdapterData();
                    viewUpdateSuccessful(target);
                    target.add(adapterContainer);
                }
            });

            // add button to show AddEditPage
            item.add(new BookmarkablePageLink<AdapterAddEditPage>("edit", AdapterAddEditPage.class,
                    forAdapter(adapterSettings)));

            // Depending on the adapter type add a link to the page 
            // where the adapter data can be managed.
            if (adapterSettings.getMetricSource() == MetricSource.IssueTracker) {
                item.add(new BookmarkablePageLink<IssueTrackerDataManagementPage>("manage",
                        IssueTrackerDataManagementPage.class, forAdapter(adapterSettings)));
            } else if (adapterSettings.getMetricSource() == MetricSource.StaticAnalysis) {
                item.add(new BookmarkablePageLink<StaticAnalysisDataManagementPage>("manage",
                        StaticAnalysisDataManagementPage.class, forAdapter(adapterSettings)));
            } else if (adapterSettings.getMetricSource() == MetricSource.TestingFramework) {
                item.add(new BookmarkablePageLink<TestFrameworkDataManagementPage>("manage",
                        TestFrameworkDataManagementPage.class, forAdapter(adapterSettings)));
            } else if (adapterSettings.getMetricSource() == MetricSource.CubeAnalysis) {
                item.add(new BookmarkablePageLink<CubeAnalysisDataManagementPage>("manage",
                        CubeAnalysisDataManagementPage.class, forAdapter(adapterSettings)));
            } else if (adapterSettings.getMetricSource() == MetricSource.VersionControl) {
                item.add(new BookmarkablePageLink<GitlabDataManagementPage>("manage",
                        GitlabDataManagementPage.class, forAdapter(adapterSettings)));
            } else if (adapterSettings.getMetricSource() == MetricSource.ContinuousIntegration) {
                item.add(new BookmarkablePageLink<JenkinsDataManagementPage>("manage",
                        JenkinsDataManagementPage.class, forAdapter(adapterSettings)));

            } else {
                item.add(new WebMarkupContainer("manage").setVisible(false));
            }
        }
    };
    // add list of adapters to container
    adapterContainer.add(adapterSettings);

    // add button to new adapter settings
    adapterContainer
            .add(new BookmarkablePageLink<AdapterAddEditPage>("addAdapterLink", AdapterAddEditPage.class));

    // add links for table pagination
    adapterContainer.add(new BootstrapAjaxPagingNavigator("navigatorHead", adapterSettings));
    adapterContainer.add(new BootstrapAjaxPagingNavigator("navigatorFoot", adapterSettings));

    // add button to delete selected adapters
    adapterContainer.add(deleteSelectedButton = newDeleteSelectedButton(adapterGroup));

    // add confirmation modal for deleting settings
    add(deleteConfirmationModal = newDeleteConfirmationModal());
}

From source file:eu.uqasar.web.pages.adapterdata.CubeAnalysisDataManagementPage.java

License:Apache License

/**
 * Constructor building the page//from  w  w  w . j  a v  a 2  s  . com
 *
 * @param parameters
 */
public CubeAnalysisDataManagementPage(final PageParameters parameters) {

    super(parameters);

    Long adapterId = parameters.get("id").toLongObject();

    final Form<CubesMetricMeasurement> deleteForm = new Form<>("deleteForm");
    add(deleteForm);

    // add checkgroup for selecting multiple measurements
    deleteForm.add(cubesGroup = newCubesCheckGroup());

    // add the container holding list of existing measurements
    cubesGroup.add(cubesContainer.setOutputMarkupId(true));

    cubesContainer.add(new CheckGroupSelector("cubesGroupSelector", cubesGroup));

    DataView<CubesMetricMeasurement> cubesMeasurements = new DataView<CubesMetricMeasurement>(
            "cubesMeasurements", new CubesProvider(adapterId), itemsPerPage) {

        private static final long serialVersionUID = 7687248000895943825L;

        @Override
        protected void populateItem(final Item<CubesMetricMeasurement> item) {
            final CubesMetricMeasurement cubesMetricMeasurement = item.getModelObject();

            item.add(new Check<>("cubesCheck", item.getModel(), cubesGroup));

            item.add(linkCubesQuery(cubesMetricMeasurement));

            item.add(new Label("value", new PropertyModel<String>(cubesMetricMeasurement, "value")));

            item.add(
                    new Label("jsonContent", new PropertyModel<String>(cubesMetricMeasurement, "jsonContent")));

            item.add(new Label("timeStamp", new PropertyModel<Date>(cubesMetricMeasurement, "timeStamp")));

            // add button to show AddEditPage
            item.add(new BookmarkablePageLink<CubeAnalysisDataManagementEditPage>("edit",
                    CubeAnalysisDataManagementEditPage.class,
                    forTableEntity(cubesMetricMeasurement, parameters)));
        }
    };
    cubesContainer.add(cubesMeasurements);

    // add links for table pagination
    cubesContainer.add(new BootstrapAjaxPagingNavigator("navigatorHead", cubesMeasurements));
    cubesContainer.add(new BootstrapAjaxPagingNavigator("navigatorFoot", cubesMeasurements));

    // add button to delete selected items
    cubesContainer.add(deleteSelectedButton = newDeleteSelectedButton(cubesGroup));

    // add confirmation modal for deleting items
    add(deleteConfirmationModal = newDeleteConfirmationModal());
}

From source file:eu.uqasar.web.pages.adapterdata.GitlabDataManagementPage.java

License:Apache License

/**
 * Constructor building the page/*from   ww w  . ja  v a 2s .co m*/
 *
 * @param parameters
 */
public GitlabDataManagementPage(final PageParameters parameters) {

    super(parameters);

    Long adapterId = parameters.get("id").toLongObject();

    final Form<GitlabMetricMeasurement> deleteForm = new Form<>("deleteForm");
    add(deleteForm);

    // add checkgroup for selecting multiple products
    deleteForm.add(gitlabGroup = newGitlabCheckGroup());

    // add the container holding list of existing products
    gitlabGroup.add(gitlabContainer.setOutputMarkupId(true));

    gitlabContainer.add(new CheckGroupSelector("gitlabGroupSelector", gitlabGroup));

    DataView<GitlabMetricMeasurement> gitlabMeasurements = new DataView<GitlabMetricMeasurement>(
            "gitlabMeasurements", new GitlabProvider(adapterId), itemsPerPage) {

        @Override
        protected void populateItem(final Item<GitlabMetricMeasurement> item) {
            final GitlabMetricMeasurement gitlabMetricMeasurement = item.getModelObject();

            item.add(new Check<>("gitlabCheck", item.getModel(), gitlabGroup));

            item.add(new Label("name", new PropertyModel<String>(gitlabMetricMeasurement, "name")));

            item.add(new Label("metric", new PropertyModel<String>(gitlabMetricMeasurement, "gitlabMetric")));

            item.add(new Label("value", new PropertyModel<String>(gitlabMetricMeasurement, "value")));

            item.add(new Label("timeStamp", new PropertyModel<Date>(gitlabMetricMeasurement, "timeStamp")));
        }
    };
    gitlabContainer.add(gitlabMeasurements);

    // add links for table pagination
    gitlabContainer.add(new BootstrapAjaxPagingNavigator("navigatorHead", gitlabMeasurements));
    gitlabContainer.add(new BootstrapAjaxPagingNavigator("navigatorFoot", gitlabMeasurements));

    // add button to delete selected items
    gitlabContainer.add(deleteSelectedButton = newDeleteSelectedButton(gitlabGroup));

    // add confirmation modal for deleting products
    add(deleteConfirmationModal = newDeleteConfirmationModal());
}