Search in sources :

Example 1 with LoopItem

use of org.apache.wicket.markup.html.list.LoopItem in project wicket-dashboard by decebals.

the class DashboardPanel method addColumnsPanel.

private void addColumnsPanel() {
    final int columnCount = getDashboard().getColumnCount();
    Loop columnsView = new Loop("columns", columnCount) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onBeforeRender() {
            if (!hasBeenRendered()) {
                columnPanels = new ArrayList<DashboardColumnPanel>();
            }
            super.onBeforeRender();
        }

        @Override
        protected void populateItem(LoopItem item) {
            float columnPanelWidth = 100f / columnCount;
            DashboardColumnPanel columnPanel = new DashboardColumnPanel("column", getModel(), item.getIndex());
            columnPanel.setRenderBodyOnly(true);
            columnPanel.getColumnContainer().add(AttributeModifier.replace("style", "width: " + columnPanelWidth + "%;"));
            item.add(columnPanel);
            columnPanels.add(columnPanel);
        }
    };
    add(columnsView);
}
Also used : Loop(org.apache.wicket.markup.html.list.Loop) LoopItem(org.apache.wicket.markup.html.list.LoopItem)

Example 2 with LoopItem

use of org.apache.wicket.markup.html.list.LoopItem in project midpoint by Evolveum.

the class NavigatorPanel method initNavigation.

private void initNavigation() {
    IModel<Integer> model = new AbstractReadOnlyModel<Integer>() {

        @Override
        public Integer getObject() {
            int count = (int) pageable.getPageCount();
            if (count < PAGING_SIZE) {
                return count;
            }
            return PAGING_SIZE;
        }
    };
    Loop navigation = new Loop(ID_NAVIGATION, model) {

        @Override
        protected void populateItem(final LoopItem item) {
            final NavigatorPageLink pageLink = new NavigatorPageLink(ID_PAGE_LINK, computePageNumber(item.getIndex())) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    pageLinkPerformed(target, getPageNumber());
                }
            };
            item.add(pageLink);
            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return pageable.getCurrentPage() == pageLink.getPageNumber() ? "active" : "";
                }
            }));
        }
    };
    navigation.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return BooleanUtils.isTrue(showPageListingModel.getObject());
        }
    });
    add(navigation);
}
Also used : Loop(org.apache.wicket.markup.html.list.Loop) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) LoopItem(org.apache.wicket.markup.html.list.LoopItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier)

Aggregations

Loop (org.apache.wicket.markup.html.list.Loop)2 LoopItem (org.apache.wicket.markup.html.list.LoopItem)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1