Example usage for org.apache.wicket.markup.html.list AbstractItem AbstractItem

List of usage examples for org.apache.wicket.markup.html.list AbstractItem AbstractItem

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list AbstractItem AbstractItem.

Prototype

public AbstractItem(final long id) 

Source Link

Document

Constructor

Usage

From source file:com.cubeia.network.shared.web.wicket.navigation.Breadcrumbs.java

License:Open Source License

private void addBreadCrumb(PageNode node, RepeatingView rv) {
    if (node.getParent() != null) {
        addBreadCrumb(node.getParent(), rv);
    }/*from  w  w  w .j a v  a 2s  .  c o  m*/
    AbstractItem ai = new AbstractItem(rv.newChildId());
    WebMarkupContainer link = null;
    if (node.isLinkable()) {
        link = new BookmarkablePageLink("link", node.getPageClass());
    } else {
        link = new WebMarkupContainer("link");
    }
    ai.add(link);
    link.add(new Label("title", node.getTitle()));
    WebMarkupContainer icon = new WebMarkupContainer("icon");
    if (node.hasIcon()) {
        icon.add(AttributeModifier.replace("class", node.getIcon()));
    } else {
        icon.add(AttributeModifier.replace("class", "hide"));
    }
    link.add(icon);
    rv.add(ai);
}

From source file:com.cubeia.network.shared.web.wicket.navigation.MenuPanel.java

License:Open Source License

private void createMenuItems(List<PageNode> pages, Class<? extends Page> currentPageClass, RepeatingView rv) {
    for (PageNode n : pages) {
        if (!n.isLinkable()) {
            continue;
        }//from ww w . j a  v  a  2 s .  com
        AbstractItem item = new AbstractItem(rv.newChildId());
        item.add(createMenuItem(n));
        boolean linkableChildren = n.hasLinkableChildren();
        if (n.isRelatedTo(currentPageClass)) {

            if (linkableChildren) {
                item.add(AttributeModifier.append("class", "open"));
            }
            if (n.getPageClass() != null) {
                item.add(AttributeModifier.append("class", "active"));
            }
        }
        if (linkableChildren) {
            item.add(AttributeModifier.append("class", "submenu"));
            item.add(new MenuPanel("children", n.getChildren(), currentPageClass));
        } else {
            item.add(new WebMarkupContainer("children"));
        }
        rv.add(item);
    }
}

From source file:de.tudarmstadt.ukp.csniper.webapp.support.wicket.ExpandableList.java

License:Apache License

private void initialize() {
    expandableList = new RepeatingView("expandableList");
    AbstractItem item;//from   ww  w.jav a  2 s  . c  om
    for (Entry<String, String> entry : items.entrySet()) {
        item = new AbstractItem(expandableList.newChildId());

        final Label body = new Label("body", entry.getValue());
        body.setOutputMarkupPlaceholderTag(true).setVisible(false).setEscapeModelStrings(false);
        item.add(body);

        item.add(new AjaxLink<String>("caption", new Model<String>(entry.getKey())) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
                replaceComponentTagBody(markupStream, openTag, getModelObject());
            }

            @Override
            public void onClick(AjaxRequestTarget aTarget) {
                body.setVisible(!body.isVisible());
                aTarget.add(body);
            }
        }.add(new AttributeModifier("class", new Model<String>("clickableElement"))));
        expandableList.add(item);
    }
    add(expandableList);
}

From source file:net.unbewaff.wicketcrudr.components.StyledHeadersToolbar.java

License:Apache License

/**
 * Constructor// ww  w .j  a v  a2  s.c  o m
 *
 * @param <T>
 *            the column data type
 * @param table
 *            data table this toolbar will be attached to
 * @param stateLocator
 *            locator for the ISortState implementation used by sortable
 *            headers
 */
public <T> StyledHeadersToolbar(final DataTable<T> table, final ISortStateLocator stateLocator) {
    super(table);

    RepeatingView headers = new RepeatingView("headers");
    add(headers);

    final List<IColumn<T>> columns = table.getColumns();
    for (final IColumn<T> column : columns) {
        AbstractItem item = new AbstractItem(headers.newChildId());
        headers.add(item);

        WebMarkupContainer header = null;
        if (column.isSortable()) {
            header = newSortableHeader("header", column.getSortProperty(), stateLocator);
        } else {
            header = new WebMarkupContainer("header");
        }

        if (column instanceof IMultipleStyledColumn) {
            AttributeAppender classAppender = new AttributeAppender("class",
                    ((IMultipleStyledColumn<?>) column).getCssClassForHeader()).setSeparator(" ");

            header.add(classAppender);
        } else if (column instanceof IStyledColumn) {
            AttributeAppender classAppender = new AttributeAppender("class",
                    ((IStyledColumn<?>) column).getCssClass()).setSeparator(" ");

            header.add(classAppender);
        }

        item.add(header);
        item.setRenderBodyOnly(true);
        header.add(column.getHeader("label"));
    }
}

From source file:org.apache.isis.viewer.wicket.ui.components.collectioncontents.summary.CollectionContentsAsSummary.java

License:Apache License

private void buildGui() {

    final EntityCollectionModel model = getModel();

    final ObjectSpecification elementSpec = model.getTypeOfSpecification();

    final NotificationPanel feedback = new NotificationPanel(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);/*from   w  ww.  j av  a 2  s  . c o  m*/
    addOrReplace(feedback);

    List<ObjectAssociation> numberAssociations = elementSpec.getAssociations(Contributed.EXCLUDED,
            CollectionContentsAsSummaryFactory.OF_TYPE_BIGDECIMAL);

    RepeatingView repeating = new RepeatingView(ID_REPEATING_SUMMARY);
    addOrReplace(repeating);

    for (ObjectAssociation numberAssociation : numberAssociations) {
        AbstractItem item = new AbstractItem(repeating.newChildId());

        repeating.add(item);

        String propertyName = numberAssociation.getName();
        item.add(new Label(ID_PROPERTY_NAME, new Model<String>(propertyName)));

        List<ObjectAdapter> adapters = model.getObject();
        Summary summary = new Summary(propertyName, adapters, numberAssociation);
        addItem(item, ID_SUM, summary.getTotal());
        addItem(item, ID_AVG, summary.getAverage());
        addItem(item, ID_MIN, summary.getMin());
        addItem(item, ID_MAX, summary.getMax());
    }
}

From source file:org.isisaddons.wicket.wickedcharts.cpt.ui.summarycharts.CollectionContentsAsSummaryCharts.java

License:Apache License

private void buildGui() {

    final EntityCollectionModel model = getModel();

    final ObjectSpecification elementSpec = model.getTypeOfSpecification();

    final NotificationPanel feedback = new NotificationPanel(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);//from   ww  w  .  j a  v  a 2  s. c o  m
    addOrReplace(feedback);

    RepeatingView repeating = new RepeatingView(ID_REPEATING_SUMMARY_CHARTS);
    addOrReplace(repeating);

    List<ObjectAssociation> numberAssociations = elementSpec
            .getAssociations(CollectionContentsAsSummaryChartsFactory.OF_TYPE_BIGDECIMAL);
    for (ObjectAssociation numberAssociation : numberAssociations) {
        AbstractItem item = new AbstractItem(repeating.newChildId());

        repeating.add(item);

        String propertyName = numberAssociation.getName();
        item.add(new Label(ID_PROPERTY_NAME, new Model<String>(propertyName)));

        List<ObjectAdapter> adapters = model.getObject();

        CollectionContentsAsSummary.Summary summary = new CollectionContentsAsSummary.Summary(propertyName,
                adapters, numberAssociation);

        BigDecimal min = summary.getMin();
        BigDecimal max = summary.getMax();

        addItem(item, ID_SUM, summary.getTotal());
        addItem(item, ID_AVG, summary.getAverage());
        addItem(item, ID_MIN, min);
        addItem(item, ID_MAX, max);

        if (model.isStandalone()) {
            final BigDecimal minElseZero = min != null
                    ? (min.compareTo(BigDecimal.ZERO) < 0 ? min : BigDecimal.ZERO)
                    : null;
            final BigDecimal maxElseZero = max != null
                    ? (max.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : max)
                    : null;
            final WickedChart chartValue = createChartValue(propertyName, summary.getTitles(),
                    summary.getValuesAsNumbers(), minElseZero, maxElseZero);
            final StandaloneValueAsWickedChart wickedChart = new StandaloneValueAsWickedChart(ID_CHART,
                    asValueModel(chartValue));
            item.add(wickedChart);
        } else {
            item.add(new Label(ID_CHART, ""));
        }
    }
}