List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table IColumn getHeader
Component getHeader(String componentId);
From source file:net.unbewaff.wicketcrudr.components.StyledHeadersToolbar.java
License:Apache License
/** * Constructor//from w ww . j a va 2 s .co 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.ajaxtable.IsisAjaxHeadersToolbar.java
License:Apache License
/** * Constructor/* w w w . j a v a 2s . co 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> IsisAjaxHeadersToolbar(final DataTable<T, S> table, final ISortStateLocator<S> stateLocator) { super(table); RefreshingView<IColumn<T, S>> headers = new RefreshingView<IColumn<T, S>>("headers") { private static final long serialVersionUID = 1L; @Override protected Iterator<IModel<IColumn<T, S>>> getItemModels() { List<IModel<IColumn<T, S>>> columnsModels = new LinkedList<IModel<IColumn<T, S>>>(); for (IColumn<T, S> column : table.getColumns()) { columnsModels.add(Model.of(column)); } return columnsModels.iterator(); } @Override protected void populateItem(Item<IColumn<T, S>> item) { final IColumn<T, S> column = item.getModelObject(); WebMarkupContainer header; if (column.isSortable()) { header = newSortableHeader("header", column.getSortProperty(), stateLocator); if (column instanceof IStyledColumn) { CssAttributeBehavior cssAttributeBehavior = new CssAttributeBehavior() { private static final long serialVersionUID = 1L; @Override protected String getCssClass() { return ((IStyledColumn<?, S>) column).getCssClass(); } }; header.add(cssAttributeBehavior); } } else { header = new WebMarkupContainer("header"); } item.add(header); item.setRenderBodyOnly(true); Component label = column.getHeader("label"); Component sortIcon = newSortIcon("sortIcon", column, stateLocator); header.add(label, sortIcon); if (column instanceof ObjectAdapterTitleColumn) { header.add(new CssClassAppender("title-column")); } } }; add(headers); }
From source file:org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.MyHeadersToolbar.java
License:Apache License
/** * Constructor/*w w w . j ava 2s. 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> MyHeadersToolbar(final DataTable<T, S> table, final ISortStateLocator<S> stateLocator) { super(table); RefreshingView<IColumn<T, S>> headers = new RefreshingView<IColumn<T, S>>("headers") { private static final long serialVersionUID = 1L; @Override protected Iterator<IModel<IColumn<T, S>>> getItemModels() { List<IModel<IColumn<T, S>>> columnsModels = new LinkedList<IModel<IColumn<T, S>>>(); for (IColumn<T, S> column : table.getColumns()) { columnsModels.add(Model.of(column)); } return columnsModels.iterator(); } @Override protected void populateItem(Item<IColumn<T, S>> item) { final IColumn<T, S> column = item.getModelObject(); WebMarkupContainer header = null; if (column.isSortable()) { header = newSortableHeader("header", column.getSortProperty(), stateLocator); } else { header = new WebMarkupContainer("header"); } if (column instanceof IStyledColumn) { CssAttributeBehavior cssAttributeBehavior = new CssAttributeBehavior() { private static final long serialVersionUID = 1L; @Override protected String getCssClass() { return ((IStyledColumn<?, S>) column).getCssClass(); } }; header.add(cssAttributeBehavior); } item.add(header); item.setRenderBodyOnly(true); Component label; //Component checkBox; //if(column instanceof ObjectAdapterToggleboxColumn) { label = new Label("label"); // checkBox = column.getHeader("checkbox"); // label.setVisible(false); //} else { label = column.getHeader("label"); // checkBox = new CheckBox("checkbox"); // checkBox.setVisible(false); // } header.add(label); //header.add(checkBox); } }; add(headers); }
From source file:org.artifactory.common.wicket.component.table.groupable.header.AjaxGroupableHeadersToolbar.java
License:Open Source License
public AjaxGroupableHeadersToolbar(final DataTable table, final ISortStateLocator stateLocator) { super(table); // alas, copied from HeadersToolbar RepeatingView headers = new RepeatingView("headers"); add(headers);/* w w w . ja v a 2 s. c o m*/ final List<IColumn> columns = table.getColumns(); int i = 0; for (final IColumn column : columns) { WebMarkupContainer item = new WebMarkupContainer(headers.newChildId()); item.setRenderBodyOnly(true); headers.add(item); WebMarkupContainer header; if (column.isSortable()) { if (column instanceof IGroupableColumn) { final IGroupableColumn groupableColumn = (IGroupableColumn) column; header = newSortableHeader("header", groupableColumn.getSortProperty(), groupableColumn.getGroupProperty(), stateLocator); } else { header = newSortableHeader("header", column.getSortProperty(), column.getSortProperty(), stateLocator); } } else { header = new UnsortableBorder("header"); } // add IStyledColumn style if (column instanceof IStyledColumn) { header.add(new CssClass(new AbstractReadOnlyModel() { @Override public Object getObject() { return ((IStyledColumn) column).getCssClass(); } })); } // add first/last style if (i == 0) { header.add(new CssClass("first-cell")); } else if (i == columns.size() - 1) { header.add(new CssClass("last-cell")); } item.add(header); // add label header.add(column.getHeader("label")); // add groupByLink Component groupByLink; WebMarkupContainer groupByText = new WebMarkupContainer("groupByText"); if (column instanceof IGroupableColumn) { IGroupableColumn groupableColumn = (IGroupableColumn) column; String property = groupableColumn.getGroupProperty(); groupByLink = newGroupByLink("groupByLink", stateLocator, property); header.add(new CssClass(new HeaderCssModel(stateLocator, property))); } else { groupByLink = new WebMarkupContainer("groupByLink").setVisible(false); groupByText.setVisible(false); } header.add(groupByLink); header.add(groupByText); i++; } }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.array.AbstractQuestionArray.java
License:Open Source License
/** * Constructor building the headers from the given column headers, and call building cells content. * @param id/*from w ww . j a v a 2s. c om*/ * @param questionModel * @param columns * @param rows */ public AbstractQuestionArray(String id, IModel questionModel, List<IColumn> columns, IDataProvider rows) { super(id, questionModel); RepeatingView headers = new RepeatingView("headers"); for (IColumn column : columns) { WebMarkupContainer item = new WebMarkupContainer(headers.newChildId()); headers.add(item); WebMarkupContainer header = new WebMarkupContainer("header"); if (column instanceof IStyledColumn && ((IStyledColumn) column).getCssClass() != null) { header.add(new AttributeAppender("class", new PropertyModel(column, "cssClass"), " ")); } item.add(header); item.setRenderBodyOnly(true); header.add(column.getHeader("label")); } add(headers); add(getRowsContent("rows", columns, rows)); }
From source file:org.onexus.website.api.widgets.tableviewer.HeadersToolbar.java
License:Apache License
/** * Constructor// ww w . j ava2 s .c o m * * @param table data table this toolbar will be attached to * @param stateLocator locator for the ISortState implementation used by sortable * headers */ public <T, S> HeadersToolbar(final DataTable<T, S> table, final ISortStateLocator stateLocator) { super(table); table.setOutputMarkupId(true); RepeatingView headersGrandParents = new RepeatingView("headersGrandParents"); RepeatingView headersParents = new RepeatingView("headersParents"); RepeatingView headers = new RepeatingView("headers"); //TODO Show optionally headers headersGrandParents.setVisible(false); headersParents.setVisible(false); add(headersGrandParents); add(headersParents); add(headers); final List<? extends IColumn<T, S>> columns = table.getColumns(); WebMarkupContainer secondHeaderContainer = null; String lastSecondHeaderTitle = null; int lastSecondHeaderColspan = 0; WebMarkupContainer thirdHeaderContainer = null; String lastThirdHeaderTitle = null; int lastThirdHeaderColspan = 0; int col = 0; for (final IColumn<T, S> c : columns) { String placement = col == 0 ? "right" : (col + 1 == columns.size() ? "left" : "top"); // Process only Track columns CollectionColumn column = null; if (c instanceof CollectionColumn) { column = (CollectionColumn) c; } else { if (c instanceof AbstractColumn) { WebMarkupContainer item = new WebMarkupContainer(headers.newChildId()); item.setRenderBodyOnly(true); WebMarkupContainer parentItem = new WebMarkupContainer(headersParents.newChildId()); parentItem.setRenderBodyOnly(true); WebMarkupContainer grandParentItem = new WebMarkupContainer(headersGrandParents.newChildId()); grandParentItem.setRenderBodyOnly(true); headers.add(item); headersParents.add(parentItem); headersGrandParents.add(grandParentItem); WebMarkupContainer firstHeaderContainer = new WebMarkupContainer("header"); WebMarkupContainer innerHeader = new WebMarkupContainer("filter"); innerHeader.add(c.getHeader("label")); firstHeaderContainer.add(innerHeader); firstHeaderContainer.add(new AttributeModifier("style", new Model<String>("font-size:12px; font-family:sans-serif;"))); item.add(firstHeaderContainer); secondHeaderContainer = new WebMarkupContainer("header"); decorateSecondParentHeader(secondHeaderContainer, null, column); secondHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty"))); parentItem.add(secondHeaderContainer); secondHeaderContainer = null; thirdHeaderContainer = new WebMarkupContainer("header"); thirdHeaderContainer.add(new EmptyPanel("label")); thirdHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty"))); grandParentItem.add(thirdHeaderContainer); thirdHeaderContainer = null; } continue; } IHeader firstHeader = column.getHeaderDecorator(); IHeader secondHeader = firstHeader == null ? null : firstHeader.getParentHeader(); IHeader thirdHeader = secondHeader == null ? null : secondHeader.getParentHeader(); WebMarkupContainer item = new WebMarkupContainer(headers.newChildId()); headers.add(item); WebMarkupContainer firstHeaderContainer = null; if (column.isFilterable()) { firstHeaderContainer = new FilteredHeader("header", (FieldHeader) column.getHeaderDecorator()); } else { firstHeaderContainer = new WebMarkupContainer("header"); } WebMarkupContainer innerHeader; if (column.isSortable()) { innerHeader = newSortableHeader("filter", column.getSortProperty(), stateLocator); } else { innerHeader = new WebMarkupContainer("filter"); } firstHeaderContainer.add(innerHeader); item.add(firstHeaderContainer); item.setRenderBodyOnly(true); innerHeader.add(firstHeader.getHeader("label")); if (firstHeader.getLabel() == null) { firstHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty"))); } // Add parent and grand parent headers String secondTitle = null; String thirdTitle = null; firstHeaderContainer.add(new AttributeModifier("title", new Model<String>(firstHeader.getTitle()))); firstHeaderContainer.add(new AttributeModifier("rel", Model.of("tooltip"))); firstHeaderContainer.add(new AttributeModifier("data-placement", Model.of(placement))); firstHeaderContainer.add( new AttributeModifier("style", new Model<String>("font-size:12px; font-family:sans-serif;"))); if (secondHeader != null) { secondTitle = secondHeader.getLabel(); } if (thirdHeader != null) { thirdTitle = thirdHeader.getLabel(); } if (secondHeaderContainer != null && ((lastSecondHeaderTitle == null && secondTitle == null) || (lastSecondHeaderTitle != null && secondTitle != null && lastSecondHeaderTitle.equals(secondTitle)))) { lastSecondHeaderColspan += 1; secondHeaderContainer.add(new AttributeModifier("colspan", new Model<String>(Integer.toString(lastSecondHeaderColspan)))); } else { // Add parentItem WebMarkupContainer parentItem = new WebMarkupContainer(headersParents.newChildId()); headersParents.add(parentItem); secondHeaderContainer = new WebMarkupContainer("header"); decorateSecondParentHeader(secondHeaderContainer, secondHeader, column); if (secondTitle == null) { secondHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty"))); } if (secondHeader != null && secondHeader.getLabel() != null) { secondHeaderContainer .add(new AttributeModifier("title", new Model<String>(secondHeader.getTitle()))); secondHeaderContainer.add(new AttributeModifier("rel", Model.of("tooltip"))); secondHeaderContainer.add(new AttributeModifier("data-placement", Model.of(placement))); } secondHeaderContainer.add(new AttributeModifier("style", new Model<String>("font-size:12px; font-family:sans-serif;"))); parentItem.add(secondHeaderContainer); parentItem.setRenderBodyOnly(true); lastSecondHeaderTitle = secondTitle; lastSecondHeaderColspan = 1; } // GrandParents if (thirdHeaderContainer != null && ((lastThirdHeaderTitle == null && thirdTitle == null) || (lastThirdHeaderTitle != null && thirdTitle != null && lastThirdHeaderTitle.equals(thirdTitle)))) { lastThirdHeaderColspan += 1; thirdHeaderContainer.add(new AttributeModifier("colspan", new Model<String>(Integer.toString(lastThirdHeaderColspan)))); } else { // Add grandParentItem WebMarkupContainer grandParentItem = new WebMarkupContainer(headersGrandParents.newChildId()); headersGrandParents.add(grandParentItem); thirdHeaderContainer = new WebMarkupContainer("header"); if (thirdTitle == null) { thirdHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty"))); } if (thirdHeader != null) { thirdHeaderContainer.add(thirdHeader.getHeader("label")); if (thirdHeader.getLabel() != null) { thirdHeaderContainer .add(new AttributeModifier("title", new Model<String>(thirdHeader.getTitle()))); thirdHeaderContainer.add(new AttributeModifier("rel", Model.of("tooltip"))); thirdHeaderContainer.add(new AttributeModifier("data-placement", Model.of(placement))); } } else { thirdHeaderContainer.add(new EmptyPanel("label")); } thirdHeaderContainer.add(new AttributeModifier("style", new Model<String>("font-size:12px; font-family:sans-serif;"))); grandParentItem.add(thirdHeaderContainer); grandParentItem.setRenderBodyOnly(true); lastThirdHeaderTitle = thirdTitle; lastThirdHeaderColspan = 1; } col++; } }
From source file:org.sakaiproject.sitestats.tool.wicket.components.paging.infinite.InfinitePagingDataTableHeadersToolbar.java
License:Educational Community License
public <T> InfinitePagingDataTableHeadersToolbar(final InfinitePagingDataTable<T, S> table, final ISortStateLocator<S> stateLocator) { super(null, table); RefreshingView<IColumn<T, S>> headers = new RefreshingView<IColumn<T, S>>("headers") { private static final long serialVersionUID = 1L; @Override//from w ww. ja v a 2s . c o m protected Iterator<IModel<IColumn<T, S>>> getItemModels() { List<IModel<IColumn<T, S>>> columnsModels = new LinkedList<>(); for (IColumn<T, S> column : table.getColumns()) { columnsModels.add(Model.of(column)); } return columnsModels.iterator(); } @Override protected void populateItem(Item<IColumn<T, S>> item) { final IColumn<T, S> column = item.getModelObject(); WebMarkupContainer header; if (column.isSortable()) { header = newSortableHeader("header", column.getSortProperty(), stateLocator); } else { header = new WebMarkupContainer("header"); } if (column instanceof IStyledColumn) { InfinitePagingDataTable.CssAttributeBehavior cssAttributeBehavior = new InfinitePagingDataTable.CssAttributeBehavior() { private static final long serialVersionUID = 1L; @Override protected String getCssClass() { return ((IStyledColumn<?, S>) column).getCssClass(); } }; header.add(cssAttributeBehavior); } item.add(header); item.setRenderBodyOnly(true); header.add(column.getHeader("label")); } }; add(headers); WebMarkupContainer sortToggle = new WebMarkupContainer("sortToggle"); sortToggle.setVisible(table.getColumns().stream().anyMatch(IColumn::isSortable)); add(sortToggle); table.setOutputMarkupId(true); }
From source file:org.sakaiproject.wicket.markup.html.repeater.data.table.BasicHeadersToolbar.java
License:Educational Community License
public BasicHeadersToolbar(DataTable table, ISortStateLocator stateLocator) { super(table); setRenderBodyOnly(true);/* w ww.jav a2 s. co m*/ RepeatingView headers = new RepeatingView("headers"); add(headers); final IColumn[] columns = table.getColumns(); for (int i = 0; i < columns.length; i++) { final IColumn column = columns[i]; WebMarkupContainer item = new WebMarkupContainer(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 PropertyColumn) { String expression = ((PropertyColumn) column).getPropertyExpression(); if (expression != null) header.setMarkupId(expression); } if (column instanceof IStyledColumn) { header.add(new CssAttributeBehavior() { private static final long serialVersionUID = 1L; protected String getCssClass() { return ((IStyledColumn) column).getCssClass(); } }); } final ISortState state = stateLocator.getSortState(); Image indicatorImage = new Image("indicator") { private static final long serialVersionUID = 1L; protected ResourceReference getImageResourceReference() { int sortOrder = ISortState.NONE; if (column.isSortable() && column.getSortProperty() != null) sortOrder = state.getPropertySortOrder(column.getSortProperty()); if (sortOrder == ISortState.DESCENDING) return upArrowReference; else if (sortOrder == ISortState.ASCENDING) return downArrowReference; return noArrowReference; } }; header.add(indicatorImage); indicatorImage.setVisible(column.isSortable() && column.getSortProperty() != null); item.add(header); item.setRenderBodyOnly(true); header.add(column.getHeader("label")); } }
From source file:org.wicketstuff.datatables.columns.SpanHeadersToolbar.java
License:Apache License
/** * Constructor/*from w ww. j a v a 2 s.c o m*/ * * @param table * data table this toolbar will be attached to * @param columns */ public <T> SpanHeadersToolbar(final DataTable<T, S> table, final IDataTablesColumn<T, S>... columns) { super(table); RefreshingView<IColumn<T, S>> headers = new RefreshingView<IColumn<T, S>>("headers") { private static final long serialVersionUID = 1L; @Override protected Iterator<IModel<IColumn<T, S>>> getItemModels() { List<IModel<IColumn<T, S>>> columnsModels = new LinkedList<>(); List<? extends IColumn<T, S>> tableColumns = (columns != null && columns.length > 0) ? Arrays.asList(columns) : table.getColumns(); for (IColumn<T, S> column : tableColumns) { columnsModels.add(Model.of(column)); } return columnsModels.iterator(); } @Override protected void populateItem(Item<IColumn<T, S>> item) { final IColumn<T, S> column = item.getModelObject(); WebMarkupContainer header = new WebMarkupContainer("header"); if (column instanceof IDataTablesColumn) { IDataTablesColumn<T, S> dtColumn = (IDataTablesColumn<T, S>) column; if (dtColumn.getColspan() > 0) { header.add(AttributeModifier.replace("colspan", dtColumn.getColspan())); } if (dtColumn.getRowspan() > 0) { header.add(AttributeModifier.replace("rowspan", dtColumn.getRowspan() - 1)); } } if (column instanceof IStyledColumn) { Behavior cssAttributeBehavior = new Behavior() { private static final long serialVersionUID = 1L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { super.onComponentTag(component, tag); String cssClass = ((IStyledColumn<?, S>) column).getCssClass(); if (!Strings.isEmpty(cssClass)) { tag.append("class", cssClass, " "); } } }; header.add(cssAttributeBehavior); } item.add(header); item.setRenderBodyOnly(true); header.add(column.getHeader("label")); } }; add(headers); }
From source file:table.headercolumndatatable.TwinHeadersToolbar.java
License:Apache License
private void populateHeaders(ISortStateLocator stateLocator, RepeatingView headers, String headerId, String labelId, IColumn<?>[] tableColumns) { for (final IColumn column : tableColumns) { WebMarkupContainer item = new WebMarkupContainer(headers.newChildId()); headers.add(item);/*from w ww .j a v a 2s .com*/ WebMarkupContainer header; if (column.isSortable()) { header = newSortableHeader(headerId, column.getSortProperty(), stateLocator); } else { header = new WebMarkupContainer(headerId); } if (column instanceof IStyledColumn) { header.add(new CssAttributeBehavior() { private static final long serialVersionUID = 1L; @Override protected String getCssClass() { return ((IStyledColumn<?>) column).getCssClass(); } }); } item.add(header); item.setRenderBodyOnly(true); header.add(column.getHeader(labelId)); } }