import java.util.Optional;
import java.util.Set;
import java.util.UUID;
-import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.jsoup.select.Elements;
import com.vaadin.data.Binder;
-import com.vaadin.data.BinderValidationStatus;
import com.vaadin.data.Listing;
-import com.vaadin.data.SelectionModel;
import com.vaadin.data.ValueProvider;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.data.provider.SortOrder;
import com.vaadin.event.ConnectorEvent;
import com.vaadin.event.ContextClickEvent;
-import com.vaadin.event.SerializableEventListener;
import com.vaadin.event.selection.MultiSelectionListener;
import com.vaadin.event.selection.SelectionListener;
import com.vaadin.event.selection.SingleSelectionListener;
import com.vaadin.shared.ui.grid.GridStaticCellType;
import com.vaadin.shared.ui.grid.HeightMode;
import com.vaadin.shared.ui.grid.SectionState;
-import com.vaadin.ui.Grid.FooterRow;
import com.vaadin.ui.Grid.SelectionMode;
-import com.vaadin.ui.components.grid.AbstractSelectionModel;
+import com.vaadin.ui.components.grid.ColumnReorderListener;
+import com.vaadin.ui.components.grid.ColumnResizeListener;
+import com.vaadin.ui.components.grid.ColumnVisibilityChangeListener;
+import com.vaadin.ui.components.grid.DescriptionGenerator;
+import com.vaadin.ui.components.grid.DetailsGenerator;
+import com.vaadin.ui.components.grid.Editor;
import com.vaadin.ui.components.grid.EditorComponentGenerator;
import com.vaadin.ui.components.grid.EditorImpl;
import com.vaadin.ui.components.grid.Footer;
+import com.vaadin.ui.components.grid.FooterCell;
+import com.vaadin.ui.components.grid.FooterRow;
+import com.vaadin.ui.components.grid.GridSelectionModel;
import com.vaadin.ui.components.grid.Header;
import com.vaadin.ui.components.grid.Header.Row;
+import com.vaadin.ui.components.grid.HeaderCell;
+import com.vaadin.ui.components.grid.HeaderRow;
+import com.vaadin.ui.components.grid.ItemClickListener;
+import com.vaadin.ui.components.grid.MultiSelectionModel;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
import com.vaadin.ui.components.grid.NoSelectionModel;
+import com.vaadin.ui.components.grid.SingleSelectionModel;
import com.vaadin.ui.components.grid.SingleSelectionModelImpl;
+import com.vaadin.ui.components.grid.SortOrderProvider;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignException;
"columnVisibilityChanged",
ColumnVisibilityChangeEvent.class);
- /**
- * An event listener for column reorder events in the Grid.
- */
- @FunctionalInterface
- public interface ColumnReorderListener extends Serializable {
-
- /**
- * Called when the columns of the grid have been reordered.
- *
- * @param event
- * An event providing more information
- */
- void columnReorder(ColumnReorderEvent event);
- }
-
/**
* Selection mode representing the built-in selection models in grid.
* <p>
protected abstract <T> GridSelectionModel<T> createModel();
}
- /**
- * The server-side interface that controls Grid's selection state.
- * SelectionModel should extend {@link AbstractGridExtension}.
- * <p>
- *
- * @param <T>
- * the grid bean type
- * @see AbstractSelectionModel
- * @see SingleSelectionModel
- * @see MultiSelectionModel
- */
- public interface GridSelectionModel<T>
- extends SelectionModel<T>, Extension {
-
- /**
- * Removes this selection model from the grid.
- * <p>
- * Must call super {@link Extension#remove()} to detach the extension,
- * and fire an selection change event for the selection model (with an
- * empty selection).
- */
- @Override
- public void remove();
- }
-
- /**
- * Single selection model interface for Grid.
- *
- * @param <T>
- * the type of items in grid
- */
- public interface SingleSelectionModel<T> extends GridSelectionModel<T>,
- com.vaadin.data.SelectionModel.Single<T> {
-
- /**
- * Gets a wrapper to use this single selection model as a single select
- * in {@link Binder}.
- *
- * @return the single select wrapper
- */
- SingleSelect<T> asSingleSelect();
-
- /**
- * {@inheritDoc}
- * <p>
- * Use {@link #addSingleSelectionListener(SingleSelectionListener)} for
- * more specific single selection event.
- *
- * @see #addSingleSelectionListener(SingleSelectionListener)
- */
- @Override
- public default Registration addSelectionListener(
- SelectionListener<T> listener) {
- return addSingleSelectionListener(e -> listener.selectionChange(e));
- }
-
- /**
- * Adds a single selection listener that is called when the value of
- * this select is changed either by the user or programmatically.
- *
- * @param listener
- * the value change listener, not {@code null}
- * @return a registration for the listener
- */
- public Registration addSingleSelectionListener(
- SingleSelectionListener<T> listener);
- }
-
- /**
- * Multiselection model interface for Grid.
- *
- * @param <T>
- * the type of items in grid
- */
- public interface MultiSelectionModel<T> extends GridSelectionModel<T>,
- com.vaadin.data.SelectionModel.Multi<T> {
-
- /**
- * Gets a wrapper to use this multiselection model as a multiselect in
- * {@link Binder}.
- *
- * @return the multiselect wrapper
- */
- MultiSelect<T> asMultiSelect();
-
- /**
- * {@inheritDoc}
- * <p>
- * Use {@link #addMultiSelectionListener(MultiSelectionListener)} for
- * more specific event on multiselection.
- *
- * @see #addMultiSelectionListener(MultiSelectionListener)
- */
- @Override
- public default Registration addSelectionListener(
- SelectionListener<T> listener) {
- return addMultiSelectionListener(e -> listener.selectionChange(e));
- }
-
- /**
- * Adds a selection listener that will be called when the selection is
- * changed either by the user or programmatically.
- *
- * @param listener
- * the value change listener, not {@code null}
- * @return a registration for the listener
- */
- public Registration addMultiSelectionListener(
- MultiSelectionListener<T> listener);
- }
-
- /**
- * An event listener for column resize events in the Grid.
- */
- @FunctionalInterface
- public interface ColumnResizeListener extends Serializable {
-
- /**
- * Called when the columns of the grid have been resized.
- *
- * @param event
- * An event providing more information
- */
- void columnResize(ColumnResizeEvent event);
- }
-
- /**
- * Generates the sort orders when rows are sorted by a column.
- *
- * @see Column#setSortOrderProvider
- *
- * @since 8.0
- * @author Vaadin Ltd
- */
- @FunctionalInterface
- public interface SortOrderProvider extends
- SerializableFunction<SortDirection, Stream<SortOrder<String>>> {
-
- /**
- * Generates the sort orders when rows are sorted by a column.
- *
- * @param sortDirection
- * desired sort direction
- *
- * @return sort information
- */
- @Override
- public Stream<SortOrder<String>> apply(SortDirection sortDirection);
-
- }
-
/**
* An event that is fired when the columns are reordered.
*/
}
}
- /**
- * A listener for item click events.
- *
- * @param <T>
- * the grid bean type
- *
- * @see ItemClick
- * @see Registration
- */
- @FunctionalInterface
- public interface ItemClickListener<T> extends SerializableEventListener {
- /**
- * Invoked when this listener receives a item click event from a Grid to
- * which it has been added.
- *
- * @param event
- * the received event, not null
- */
- public void itemClick(ItemClick<T> event);
- }
-
/**
* ContextClickEvent for the Grid Component.
*
}
}
- /**
- * An event listener for column visibility change events in the Grid.
- *
- * @since 7.5.0
- */
- @FunctionalInterface
- public interface ColumnVisibilityChangeListener extends Serializable {
-
- /**
- * Called when a column has become hidden or unhidden.
- *
- * @param event
- */
- void columnVisibilityChanged(ColumnVisibilityChangeEvent event);
- }
-
/**
* An event that is fired when a column's visibility changes.
*
}
}
- /**
- * A callback interface for generating description texts for an item.
- *
- * @param <T>
- * the grid bean type
- */
- @FunctionalInterface
- public interface DescriptionGenerator<T>
- extends SerializableFunction<T, String> {
- }
-
- /**
- * A callback interface for generating details for a particular row in Grid.
- *
- * @param <T>
- * the grid bean type
- */
- @FunctionalInterface
- public interface DetailsGenerator<T>
- extends SerializableFunction<T, Component> {
- }
-
/**
* A helper base class for creating extensions for the Grid component.
*
}
}
- /**
- * A header row in a Grid.
- */
- public interface HeaderRow extends Serializable {
-
- /**
- * Returns the cell on this row corresponding to the given column id.
- *
- * @param columnId
- * the id of the column whose header cell to get, not null
- * @return the header cell
- * @throws IllegalArgumentException
- * if there is no such column in the grid
- */
- public HeaderCell getCell(String columnId);
-
- /**
- * Returns the cell on this row corresponding to the given column.
- *
- * @param column
- * the column whose header cell to get, not null
- * @return the header cell
- * @throws IllegalArgumentException
- * if there is no such column in the grid
- */
- public HeaderCell getCell(Column<?, ?> column);
-
- /**
- * Merges column cells in the row. Original cells are hidden, and new
- * merged cell is shown instead. The cell has a width of all merged
- * cells together, inherits styles of the first merged cell but has
- * empty caption.
- *
- * @param cellsToMerge
- * the cells which should be merged. The cells should not be
- * merged to any other cell set.
- * @return the remaining visible cell after the merge
- *
- * @see #join(Grid.HeaderCell...)
- * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
- */
- HeaderCell join(Set<HeaderCell> cellsToMerge);
-
- /**
- * Merges column cells in the row. Original cells are hidden, and new
- * merged cell is shown instead. The cell has a width of all merged
- * cells together, inherits styles of the first merged cell but has
- * empty caption.
- *
- * @param cellsToMerge
- * the cells which should be merged. The cells should not be
- * merged to any other cell set.
- * @return the remaining visible cell after the merge
- *
- * @see #join(Set)
- * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
- */
- HeaderCell join(HeaderCell... cellsToMerge);
-
- }
-
- /**
- * An individual cell on a Grid header row.
- */
- public interface HeaderCell extends Serializable {
-
- /**
- * Returns the textual caption of this cell.
- *
- * @return the header caption
- */
- public String getText();
-
- /**
- * Sets the textual caption of this cell.
- *
- * @param text
- * the header caption to set, not null
- */
- public void setText(String text);
-
- /**
- * Returns the HTML content displayed in this cell.
- *
- * @return the html
- *
- */
- public String getHtml();
-
- /**
- * Sets the HTML content displayed in this cell.
- *
- * @param html
- * the html to set
- */
- public void setHtml(String html);
-
- /**
- * Returns the component displayed in this cell.
- *
- * @return the component
- */
- public Component getComponent();
-
- /**
- * Sets the component displayed in this cell.
- *
- * @param component
- * the component to set
- */
- public void setComponent(Component component);
-
- /**
- * Returns the type of content stored in this cell.
- *
- * @return cell content type
- */
- public GridStaticCellType getCellType();
-
- /**
- * Gets the column id where this cell is.
- *
- * @return column id for this cell
- */
- public String getColumnId();
- }
-
- /**
- * A footer row in a Grid.
- */
- public interface FooterRow extends Serializable {
-
- /**
- * Returns the cell on this row corresponding to the given column id.
- *
- * @param columnId
- * the id of the column whose footer cell to get, not null
- * @return the footer cell
- * @throws IllegalArgumentException
- * if there is no such column in the grid
- */
- public FooterCell getCell(String columnId);
-
- /**
- * Returns the cell on this row corresponding to the given column.
- *
- * @param column
- * the column whose footer cell to get, not null
- * @return the footer cell
- * @throws IllegalArgumentException
- * if there is no such column in the grid
- */
- public FooterCell getCell(Column<?, ?> column);
-
- /**
- * Merges column cells in the row. Original cells are hidden, and new
- * merged cell is shown instead. The cell has a width of all merged
- * cells together, inherits styles of the first merged cell but has
- * empty caption.
- *
- * @param cellsToMerge
- * the cells which should be merged. The cells should not be
- * merged to any other cell set.
- * @return the remaining visible cell after the merge
- *
- * @see #join(Grid.FooterCell...)
- * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
- */
- FooterCell join(Set<FooterCell> cellsToMerge);
-
- /**
- * Merges column cells in the row. Original cells are hidden, and new
- * merged cell is shown instead. The cell has a width of all merged
- * cells together, inherits styles of the first merged cell but has
- * empty caption.
- *
- * @param cellsToMerge
- * the cells which should be merged. The cells should not be
- * merged to any other cell set.
- * @return the remaining visible cell after the merge
- *
- * @see #join(Set)
- * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
- */
- FooterCell join(FooterCell... cellsToMerge);
- }
-
- /**
- * An individual cell on a Grid footer row.
- */
- public interface FooterCell extends Serializable {
-
- /**
- * Returns the textual caption of this cell.
- *
- * @return the footer caption
- */
- public String getText();
-
- /**
- * Sets the textual caption of this cell.
- *
- * @param text
- * the footer caption to set, not null
- */
- public void setText(String text);
-
- /**
- * Returns the HTML content displayed in this cell.
- *
- * @return the html
- *
- */
- public String getHtml();
-
- /**
- * Sets the HTML content displayed in this cell.
- *
- * @param html
- * the html to set
- */
- public void setHtml(String html);
-
- /**
- * Returns the component displayed in this cell.
- *
- * @return the component
- */
- public Component getComponent();
-
- /**
- * Sets the component displayed in this cell.
- *
- * @param component
- * the component to set
- */
- public void setComponent(Component component);
-
- /**
- * Returns the type of content stored in this cell.
- *
- * @return cell content type
- */
- public GridStaticCellType getCellType();
-
- /**
- * Gets the column id where this cell is.
- *
- * @return column id for this cell
- */
- public String getColumnId();
- }
-
- /**
- * Generator for creating editor validation and conversion error messages.
- *
- * @param <T>
- * the bean type
- */
- @FunctionalInterface
- public interface EditorErrorGenerator<T> extends Serializable,
- BiFunction<Map<Component, Column<T, ?>>, BinderValidationStatus<T>, String> {
-
- /**
- * Generates an error message from given validation status object.
- *
- * @param fieldToColumn
- * the map of failed fields and corresponding columns
- * @param status
- * the binder status object with all failures
- *
- * @return error message string
- */
- @Override
- public String apply(Map<Component, Column<T, ?>> fieldToColumn,
- BinderValidationStatus<T> status);
- }
-
- /**
- * An editor in a Grid.
- *
- * @param <T>
- */
- public interface Editor<T> extends Serializable {
-
- /**
- * Sets the underlying Binder to this Editor.
- *
- * @param binder
- * the binder for updating editor fields; not {@code null}
- * @return this editor
- */
- public Editor<T> setBinder(Binder<T> binder);
-
- /**
- * Returns the underlying Binder from Editor.
- *
- * @return the binder; not {@code null}
- */
- public Binder<T> getBinder();
-
- /**
- * Sets the Editor buffered mode. When the editor is in buffered mode,
- * edits are only committed when the user clicks the save button. In
- * unbuffered mode valid changes are automatically committed.
- *
- * @param buffered
- * {@code true} if editor should be buffered; {@code false}
- * if not
- * @return this editor
- */
- public Editor<T> setBuffered(boolean buffered);
-
- /**
- * Enables or disabled the Editor. A disabled editor cannot be opened.
- *
- * @param enabled
- * {@code true} if editor should be enabled; {@code false} if
- * not
- * @return this editor
- */
- public Editor<T> setEnabled(boolean enabled);
-
- /**
- * Returns whether Editor is buffered or not.
- *
- * @see #setBuffered(boolean)
- *
- * @return {@code true} if editor is buffered; {@code false} if not
- */
- public boolean isBuffered();
-
- /**
- * Returns whether Editor is enabled or not.
- *
- * @return {@code true} if editor is enabled; {@code false} if not
- */
- public boolean isEnabled();
-
- /**
- * Returns whether Editor is open or not.
- *
- * @return {@code true} if editor is open; {@code false} if not
- */
- public boolean isOpen();
-
- /**
- * Saves any changes from the Editor fields to the edited bean.
- *
- * @return {@code true} if save succeeded; {@code false} if not
- */
- public boolean save();
-
- /**
- * Close the editor discarding any unsaved changes.
- */
- public void cancel();
-
- /**
- * Sets the caption of the save button in buffered mode.
- *
- * @param saveCaption
- * the save button caption
- * @return this editor
- */
- public Editor<T> setSaveCaption(String saveCaption);
-
- /**
- * Sets the caption of the cancel button in buffered mode.
- *
- * @param cancelCaption
- * the cancel button caption
- * @return this editor
- */
- public Editor<T> setCancelCaption(String cancelCaption);
-
- /**
- * Gets the caption of the save button in buffered mode.
- *
- * @return the save button caption
- */
- public String getSaveCaption();
-
- /**
- * Gets the caption of the cancel button in buffered mode.
- *
- * @return the cancel button caption
- */
- public String getCancelCaption();
-
- /**
- * Sets the error message generator for this editor.
- * <p>
- * The default message is a concatenation of column field validation
- * failures and bean validation failures.
- *
- * @param errorGenerator
- * the function to generate error messages; not {@code null}
- * @return this editor
- *
- * @see EditorErrorGenerator
- */
- public Editor<T> setErrorGenerator(
- EditorErrorGenerator<T> errorGenerator);
-
- /**
- * Gets the error message generator of this editor.
- *
- * @return the function that generates error messages; not {@code null}
- *
- * @see EditorErrorGenerator
- */
- public EditorErrorGenerator<T> getErrorGenerator();
- }
-
private class HeaderImpl extends Header {
@Override
import com.vaadin.ui.AbstractListing;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.AbstractGridExtension;
-import com.vaadin.ui.Grid.GridSelectionModel;
import elemental.json.JsonObject;
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.ui.Grid;
+
+/**
+ * An event listener for column reorder events in the Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+@FunctionalInterface
+public interface ColumnReorderListener extends Serializable {
+
+ /**
+ * Called when the columns of the grid have been reordered.
+ *
+ * @param event
+ * An event providing more information
+ */
+ void columnReorder(Grid.ColumnReorderEvent event);
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.ui.Grid;
+
+/**
+ * An event listener for column resize events in the Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+@FunctionalInterface
+public interface ColumnResizeListener extends Serializable {
+
+ /**
+ * Called when the columns of the grid have been resized.
+ *
+ * @param event
+ * An event providing more information
+ */
+ void columnResize(Grid.ColumnResizeEvent event);
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.ui.Grid;
+
+/**
+ * An event listener for column visibility change events in the Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+@FunctionalInterface
+public interface ColumnVisibilityChangeListener extends Serializable {
+
+ /**
+ * Called when a column has become hidden or unhidden.
+ *
+ * @param event
+ * the event
+ */
+ void columnVisibilityChanged(Grid.ColumnVisibilityChangeEvent event);
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import com.vaadin.server.SerializableFunction;
+
+/**
+ * A callback interface for generating description texts for an item.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ * the grid bean type
+ */
+@FunctionalInterface
+public interface DescriptionGenerator<T>
+ extends SerializableFunction<T, String> {
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import com.vaadin.server.SerializableFunction;
+import com.vaadin.ui.Component;
+
+/**
+ * A callback interface for generating details for a particular row in Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ * the grid bean type
+ */
+@FunctionalInterface
+public interface DetailsGenerator<T>
+ extends SerializableFunction<T, Component> {
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.data.Binder;
+
+/**
+ * An editor in a Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ */
+public interface Editor<T> extends Serializable {
+
+ /**
+ * Sets the underlying Binder to this Editor.
+ *
+ * @param binder
+ * the binder for updating editor fields; not {@code null}
+ * @return this editor
+ */
+ public Editor<T> setBinder(Binder<T> binder);
+
+ /**
+ * Returns the underlying Binder from Editor.
+ *
+ * @return the binder; not {@code null}
+ */
+ public Binder<T> getBinder();
+
+ /**
+ * Sets the Editor buffered mode. When the editor is in buffered mode, edits
+ * are only committed when the user clicks the save button. In unbuffered
+ * mode valid changes are automatically committed.
+ *
+ * @param buffered
+ * {@code true} if editor should be buffered; {@code false} if
+ * not
+ * @return this editor
+ */
+ public Editor<T> setBuffered(boolean buffered);
+
+ /**
+ * Enables or disabled the Editor. A disabled editor cannot be opened.
+ *
+ * @param enabled
+ * {@code true} if editor should be enabled; {@code false} if not
+ * @return this editor
+ */
+ public Editor<T> setEnabled(boolean enabled);
+
+ /**
+ * Returns whether Editor is buffered or not.
+ *
+ * @see #setBuffered(boolean)
+ *
+ * @return {@code true} if editor is buffered; {@code false} if not
+ */
+ public boolean isBuffered();
+
+ /**
+ * Returns whether Editor is enabled or not.
+ *
+ * @return {@code true} if editor is enabled; {@code false} if not
+ */
+ public boolean isEnabled();
+
+ /**
+ * Returns whether Editor is open or not.
+ *
+ * @return {@code true} if editor is open; {@code false} if not
+ */
+ public boolean isOpen();
+
+ /**
+ * Saves any changes from the Editor fields to the edited bean.
+ *
+ * @return {@code true} if save succeeded; {@code false} if not
+ */
+ public boolean save();
+
+ /**
+ * Close the editor discarding any unsaved changes.
+ */
+ public void cancel();
+
+ /**
+ * Sets the caption of the save button in buffered mode.
+ *
+ * @param saveCaption
+ * the save button caption
+ * @return this editor
+ */
+ public Editor<T> setSaveCaption(String saveCaption);
+
+ /**
+ * Sets the caption of the cancel button in buffered mode.
+ *
+ * @param cancelCaption
+ * the cancel button caption
+ * @return this editor
+ */
+ public Editor<T> setCancelCaption(String cancelCaption);
+
+ /**
+ * Gets the caption of the save button in buffered mode.
+ *
+ * @return the save button caption
+ */
+ public String getSaveCaption();
+
+ /**
+ * Gets the caption of the cancel button in buffered mode.
+ *
+ * @return the cancel button caption
+ */
+ public String getCancelCaption();
+
+ /**
+ * Sets the error message generator for this editor.
+ * <p>
+ * The default message is a concatenation of column field validation
+ * failures and bean validation failures.
+ *
+ * @param errorGenerator
+ * the function to generate error messages; not {@code null}
+ * @return this editor
+ *
+ * @see EditorErrorGenerator
+ */
+ public Editor<T> setErrorGenerator(EditorErrorGenerator<T> errorGenerator);
+
+ /**
+ * Gets the error message generator of this editor.
+ *
+ * @return the function that generates error messages; not {@code null}
+ *
+ * @see EditorErrorGenerator
+ */
+ public EditorErrorGenerator<T> getErrorGenerator();
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.function.BiFunction;
+
+import com.vaadin.data.BinderValidationStatus;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Grid;
+
+/**
+ * Generator for creating editor validation and conversion error messages.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ * the bean type
+ */
+@FunctionalInterface
+public interface EditorErrorGenerator<T> extends Serializable,
+ BiFunction<Map<Component, Grid.Column<T, ?>>, BinderValidationStatus<T>, String> {
+
+ /**
+ * Generates an error message from given validation status object.
+ *
+ * @param fieldToColumn
+ * the map of failed fields and corresponding columns
+ * @param status
+ * the binder status object with all failures
+ *
+ * @return error message string
+ */
+ @Override
+ public String apply(Map<Component, Grid.Column<T, ?>> fieldToColumn,
+ BinderValidationStatus<T> status);
+}
import com.vaadin.ui.Component;
import com.vaadin.ui.Grid.AbstractGridExtension;
import com.vaadin.ui.Grid.Column;
-import com.vaadin.ui.Grid.Editor;
-import com.vaadin.ui.Grid.EditorErrorGenerator;
import elemental.json.JsonObject;
import java.util.HashSet;
import java.util.Set;
-import com.vaadin.ui.Grid;
-
/**
* Represents the footer section of a Grid.
*
* A row in a Grid Footer.
*/
public class Row extends StaticSection.StaticRow<Row.Cell>
- implements Grid.FooterRow {
+ implements FooterRow {
/**
* A cell in a Grid footer row.
*/
public class Cell extends StaticSection.StaticCell
- implements Grid.FooterCell {
+ implements FooterCell {
/**
* Creates a new footer cell.
*/
* merged to any other cell set.
* @return the remaining visible cell after the merge
*
- * @see #join(Grid.FooterCell...)
+ * @see #join(FooterCell...)
* @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
*/
@Override
- public Grid.FooterCell join(Set<Grid.FooterCell> cellsToMerge) {
- for (Grid.FooterCell cell : cellsToMerge) {
+ public FooterCell join(Set<FooterCell> cellsToMerge) {
+ for (FooterCell cell : cellsToMerge) {
checkIfAlreadyMerged(cell.getColumnId());
}
Cell newCell = createCell();
Set<String> columnGroup = new HashSet<>();
- for (Grid.FooterCell cell : cellsToMerge) {
+ for (FooterCell cell : cellsToMerge) {
columnGroup.add(cell.getColumnId());
}
addMergedCell(newCell, columnGroup);
* @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
*/
@Override
- public Grid.FooterCell join(Grid.FooterCell... cellsToMerge) {
- Set<Grid.FooterCell> footerCells = new HashSet<>(
+ public FooterCell join(FooterCell... cellsToMerge) {
+ Set<FooterCell> footerCells = new HashSet<>(
Arrays.asList(cellsToMerge));
return join(footerCells);
}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.shared.ui.grid.GridStaticCellType;
+import com.vaadin.ui.Component;
+
+/**
+ * An individual cell on a Grid footer row.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+public interface FooterCell extends Serializable {
+
+ /**
+ * Returns the textual caption of this cell.
+ *
+ * @return the footer caption
+ */
+ public String getText();
+
+ /**
+ * Sets the textual caption of this cell.
+ *
+ * @param text
+ * the footer caption to set, not null
+ */
+ public void setText(String text);
+
+ /**
+ * Returns the HTML content displayed in this cell.
+ *
+ * @return the html
+ *
+ */
+ public String getHtml();
+
+ /**
+ * Sets the HTML content displayed in this cell.
+ *
+ * @param html
+ * the html to set
+ */
+ public void setHtml(String html);
+
+ /**
+ * Returns the component displayed in this cell.
+ *
+ * @return the component
+ */
+ public Component getComponent();
+
+ /**
+ * Sets the component displayed in this cell.
+ *
+ * @param component
+ * the component to set
+ */
+ public void setComponent(Component component);
+
+ /**
+ * Returns the type of content stored in this cell.
+ *
+ * @return cell content type
+ */
+ public GridStaticCellType getCellType();
+
+ /**
+ * Gets the column id where this cell is.
+ *
+ * @return column id for this cell
+ */
+ public String getColumnId();
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import com.vaadin.ui.Grid;
+
+/**
+ * A footer row in a Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+public interface FooterRow extends Serializable {
+
+ /**
+ * Returns the cell on this row corresponding to the given column id.
+ *
+ * @param columnId
+ * the id of the column whose footer cell to get, not null
+ * @return the footer cell
+ * @throws IllegalArgumentException
+ * if there is no such column in the grid
+ */
+ public FooterCell getCell(String columnId);
+
+ /**
+ * Returns the cell on this row corresponding to the given column.
+ *
+ * @param column
+ * the column whose footer cell to get, not null
+ * @return the footer cell
+ * @throws IllegalArgumentException
+ * if there is no such column in the grid
+ */
+ public FooterCell getCell(Grid.Column<?, ?> column);
+
+ /**
+ * Merges column cells in the row. Original cells are hidden, and new merged
+ * cell is shown instead. The cell has a width of all merged cells together,
+ * inherits styles of the first merged cell but has empty caption.
+ *
+ * @param cellsToMerge
+ * the cells which should be merged. The cells should not be
+ * merged to any other cell set.
+ * @return the remaining visible cell after the merge
+ *
+ * @see #join(FooterCell...)
+ * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
+ */
+ FooterCell join(Set<FooterCell> cellsToMerge);
+
+ /**
+ * Merges column cells in the row. Original cells are hidden, and new merged
+ * cell is shown instead. The cell has a width of all merged cells together,
+ * inherits styles of the first merged cell but has empty caption.
+ *
+ * @param cellsToMerge
+ * the cells which should be merged. The cells should not be
+ * merged to any other cell set.
+ * @return the remaining visible cell after the merge
+ *
+ * @see #join(Set)
+ * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
+ */
+ FooterCell join(FooterCell... cellsToMerge);
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import com.vaadin.data.SelectionModel;
+import com.vaadin.server.Extension;
+import com.vaadin.ui.Grid.AbstractGridExtension;
+
+/**
+ * The server-side interface that controls Grid's selection state.
+ * SelectionModel should extend {@link AbstractGridExtension}.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ * the grid bean type
+ * @see AbstractSelectionModel
+ * @see SingleSelectionModel
+ * @see MultiSelectionModel
+ */
+public interface GridSelectionModel<T> extends SelectionModel<T>, Extension {
+
+ /**
+ * Removes this selection model from the grid.
+ * <p>
+ * Must call super {@link Extension#remove()} to detach the extension, and
+ * fire an selection change event for the selection model (with an empty
+ * selection).
+ */
+ @Override
+ public void remove();
+}
import org.jsoup.nodes.Element;
-import com.vaadin.ui.Grid;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
* A row in a Grid header.
*/
public class Row extends StaticSection.StaticRow<Row.Cell>
- implements Grid.HeaderRow {
+ implements HeaderRow {
/**
* A cell in a Grid header row.
*/
public class Cell extends StaticSection.StaticCell
- implements Grid.HeaderCell {
+ implements HeaderCell {
/**
* Creates a new header cell.
*/
* merged to any other cell set.
* @return the remaining visible cell after the merge
*
- * @see #join(Grid.HeaderCell...)
+ * @see #join(HeaderCell...)
* @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
*/
@Override
- public Grid.HeaderCell join(Set<Grid.HeaderCell> cellsToMerge) {
- for (Grid.HeaderCell cell : cellsToMerge) {
+ public HeaderCell join(Set<HeaderCell> cellsToMerge) {
+ for (HeaderCell cell : cellsToMerge) {
checkIfAlreadyMerged(cell.getColumnId());
}
Cell newCell = createCell();
Set<String> columnGroup = new HashSet<>();
- for (Grid.HeaderCell cell : cellsToMerge) {
+ for (HeaderCell cell : cellsToMerge) {
columnGroup.add(cell.getColumnId());
}
addMergedCell(newCell, columnGroup);
* @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
*/
@Override
- public Grid.HeaderCell join(Grid.HeaderCell... cellsToMerge) {
- Set<Grid.HeaderCell> headerCells = new HashSet<>(
+ public HeaderCell join(HeaderCell... cellsToMerge) {
+ Set<HeaderCell> headerCells = new HashSet<>(
Arrays.asList(cellsToMerge));
return join(headerCells);
}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.shared.ui.grid.GridStaticCellType;
+import com.vaadin.ui.Component;
+
+/**
+ * An individual cell on a Grid header row.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+public interface HeaderCell extends Serializable {
+
+ /**
+ * Returns the textual caption of this cell.
+ *
+ * @return the header caption
+ */
+ public String getText();
+
+ /**
+ * Sets the textual caption of this cell.
+ *
+ * @param text
+ * the header caption to set, not null
+ */
+ public void setText(String text);
+
+ /**
+ * Returns the HTML content displayed in this cell.
+ *
+ * @return the html
+ *
+ */
+ public String getHtml();
+
+ /**
+ * Sets the HTML content displayed in this cell.
+ *
+ * @param html
+ * the html to set
+ */
+ public void setHtml(String html);
+
+ /**
+ * Returns the component displayed in this cell.
+ *
+ * @return the component
+ */
+ public Component getComponent();
+
+ /**
+ * Sets the component displayed in this cell.
+ *
+ * @param component
+ * the component to set
+ */
+ public void setComponent(Component component);
+
+ /**
+ * Returns the type of content stored in this cell.
+ *
+ * @return cell content type
+ */
+ public GridStaticCellType getCellType();
+
+ /**
+ * Gets the column id where this cell is.
+ *
+ * @return column id for this cell
+ */
+ public String getColumnId();
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import com.vaadin.ui.Grid;
+
+/**
+ * A header row in a Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+public interface HeaderRow extends Serializable {
+
+ /**
+ * Returns the cell on this row corresponding to the given column id.
+ *
+ * @param columnId
+ * the id of the column whose header cell to get, not null
+ * @return the header cell
+ * @throws IllegalArgumentException
+ * if there is no such column in the grid
+ */
+ public HeaderCell getCell(String columnId);
+
+ /**
+ * Returns the cell on this row corresponding to the given column.
+ *
+ * @param column
+ * the column whose header cell to get, not null
+ * @return the header cell
+ * @throws IllegalArgumentException
+ * if there is no such column in the grid
+ */
+ public HeaderCell getCell(Grid.Column<?, ?> column);
+
+ /**
+ * Merges column cells in the row. Original cells are hidden, and new merged
+ * cell is shown instead. The cell has a width of all merged cells together,
+ * inherits styles of the first merged cell but has empty caption.
+ *
+ * @param cellsToMerge
+ * the cells which should be merged. The cells should not be
+ * merged to any other cell set.
+ * @return the remaining visible cell after the merge
+ *
+ * @see #join(HeaderCell...)
+ * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
+ */
+ HeaderCell join(Set<HeaderCell> cellsToMerge);
+
+ /**
+ * Merges column cells in the row. Original cells are hidden, and new merged
+ * cell is shown instead. The cell has a width of all merged cells together,
+ * inherits styles of the first merged cell but has empty caption.
+ *
+ * @param cellsToMerge
+ * the cells which should be merged. The cells should not be
+ * merged to any other cell set.
+ * @return the remaining visible cell after the merge
+ *
+ * @see #join(Set)
+ * @see com.vaadin.ui.AbstractComponent#setCaption(String) setCaption
+ */
+ HeaderCell join(HeaderCell... cellsToMerge);
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import com.vaadin.event.SerializableEventListener;
+import com.vaadin.shared.Registration;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.ItemClick;
+
+/**
+ * A listener for item click events.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ * the grid bean type
+ *
+ * @see ItemClick
+ * @see Registration
+ */
+@FunctionalInterface
+public interface ItemClickListener<T> extends SerializableEventListener {
+ /**
+ * Invoked when this listener receives a item click event from a Grid to
+ * which it has been added.
+ *
+ * @param event
+ * the received event, not null
+ */
+ public void itemClick(Grid.ItemClick<T> event);
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import com.vaadin.data.Binder;
+import com.vaadin.event.selection.MultiSelectionListener;
+import com.vaadin.event.selection.SelectionListener;
+import com.vaadin.shared.Registration;
+import com.vaadin.ui.MultiSelect;
+
+/**
+ * Multiselection model interface for Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ * the type of items in grid
+ */
+public interface MultiSelectionModel<T>
+ extends GridSelectionModel<T>, com.vaadin.data.SelectionModel.Multi<T> {
+
+ /**
+ * Gets a wrapper to use this multiselection model as a multiselect in
+ * {@link Binder}.
+ *
+ * @return the multiselect wrapper
+ */
+ MultiSelect<T> asMultiSelect();
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Use {@link #addMultiSelectionListener(MultiSelectionListener)} for more
+ * specific event on multiselection.
+ *
+ * @see #addMultiSelectionListener(MultiSelectionListener)
+ */
+ @Override
+ public default Registration addSelectionListener(
+ SelectionListener<T> listener) {
+ return addMultiSelectionListener(e -> listener.selectionChange(e));
+ }
+
+ /**
+ * Adds a selection listener that will be called when the selection is
+ * changed either by the user or programmatically.
+ *
+ * @param listener
+ * the value change listener, not {@code null}
+ * @return a registration for the listener
+ */
+ public Registration addMultiSelectionListener(
+ MultiSelectionListener<T> listener);
+}
import com.vaadin.shared.Registration;
import com.vaadin.shared.data.selection.GridMultiSelectServerRpc;
import com.vaadin.shared.ui.grid.MultiSelectionModelState;
-import com.vaadin.ui.Grid.MultiSelectionModel;
import com.vaadin.ui.MultiSelect;
/**
@Override
public boolean isSelected(T item) {
return isAllSelected()
- || com.vaadin.ui.Grid.MultiSelectionModel.super.isSelected(
+ || com.vaadin.ui.components.grid.MultiSelectionModel.super.isSelected(
item);
}
import com.vaadin.event.selection.SelectionListener;
import com.vaadin.server.AbstractExtension;
import com.vaadin.shared.Registration;
-import com.vaadin.ui.Grid.GridSelectionModel;
/**
* Selection model that doesn't allow selecting anything from the grid.
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import com.vaadin.data.Binder;
+import com.vaadin.event.selection.SelectionListener;
+import com.vaadin.event.selection.SingleSelectionListener;
+import com.vaadin.shared.Registration;
+import com.vaadin.ui.SingleSelect;
+
+/**
+ * Single selection model interface for Grid.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ *
+ * @param <T>
+ * the type of items in grid
+ */
+public interface SingleSelectionModel<T> extends GridSelectionModel<T>,
+ com.vaadin.data.SelectionModel.Single<T> {
+
+ /**
+ * Gets a wrapper to use this single selection model as a single select in
+ * {@link Binder}.
+ *
+ * @return the single select wrapper
+ */
+ SingleSelect<T> asSingleSelect();
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Use {@link #addSingleSelectionListener(SingleSelectionListener)} for more
+ * specific single selection event.
+ *
+ * @see #addSingleSelectionListener(SingleSelectionListener)
+ */
+ @Override
+ public default Registration addSelectionListener(
+ SelectionListener<T> listener) {
+ return addSingleSelectionListener(e -> listener.selectionChange(e));
+ }
+
+ /**
+ * Adds a single selection listener that is called when the value of this
+ * select is changed either by the user or programmatically.
+ *
+ * @param listener
+ * the value change listener, not {@code null}
+ * @return a registration for the listener
+ */
+ public Registration addSingleSelectionListener(
+ SingleSelectionListener<T> listener);
+}
import com.vaadin.shared.data.selection.SelectionServerRpc;
import com.vaadin.shared.ui.grid.SingleSelectionModelState;
import com.vaadin.ui.Component;
-import com.vaadin.ui.Grid.SingleSelectionModel;
import com.vaadin.ui.SingleSelect;
/**
--- /dev/null
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui.components.grid;
+
+import java.util.stream.Stream;
+
+import com.vaadin.server.SerializableFunction;
+import com.vaadin.server.data.SortOrder;
+import com.vaadin.shared.data.sort.SortDirection;
+import com.vaadin.ui.Grid.Column;
+
+/**
+ * Generates the sort orders when rows are sorted by a column.
+ *
+ * @see Column#setSortOrderProvider
+ *
+ * @since 8.0
+ * @author Vaadin Ltd
+ */
+@FunctionalInterface
+public interface SortOrderProvider
+ extends SerializableFunction<SortDirection, Stream<SortOrder<String>>> {
+
+ /**
+ * Generates the sort orders when rows are sorted by a column.
+ *
+ * @param sortDirection
+ * desired sort direction
+ *
+ * @return sort information
+ */
+ @Override
+ public Stream<SortOrder<String>> apply(SortDirection sortDirection);
+
+}
private class GridWithCustomSingleSelectionModel extends Grid<Sex> {
@Override
public void setSelectionModel(
- com.vaadin.ui.Grid.GridSelectionModel<Sex> model) {
+ com.vaadin.ui.components.grid.GridSelectionModel<Sex> model) {
super.setSelectionModel(model);
}
}
import com.vaadin.shared.Registration;
import com.vaadin.tests.util.MockUI;
import com.vaadin.ui.Grid;
-import com.vaadin.ui.Grid.GridSelectionModel;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.UI;
+import com.vaadin.ui.components.grid.GridSelectionModel;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
model.getSelectAllCheckBoxVisibility());
// change to explicit NO
- model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.HIDDEN);
+ model.setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.HIDDEN);
Assert.assertEquals(SelectAllCheckBoxVisibility.HIDDEN,
model.getSelectAllCheckBoxVisibility());
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
// change to explicit YES
- model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.VISIBLE);
+ model.setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.VISIBLE);
Assert.assertEquals(SelectAllCheckBoxVisibility.VISIBLE,
model.getSelectAllCheckBoxVisibility());
model.getSelectAllCheckBoxVisibility());
// change to explicit YES
- model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.VISIBLE);
+ model.setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.VISIBLE);
Assert.assertEquals(SelectAllCheckBoxVisibility.VISIBLE,
model.getSelectAllCheckBoxVisibility());
Assert.assertTrue(model.isSelectAllCheckBoxVisible());
// change to explicit NO
- model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.HIDDEN);
+ model.setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.HIDDEN);
Assert.assertEquals(SelectAllCheckBoxVisibility.HIDDEN,
model.getSelectAllCheckBoxVisibility());
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
// change back to depends on data provider
- model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.DEFAULT);
+ model.setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.DEFAULT);
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT,
import com.vaadin.data.provider.bov.Person;
import com.vaadin.ui.Grid;
-import com.vaadin.ui.Grid.GridSelectionModel;
import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.components.grid.GridSelectionModel;
public class GridNoSelectionModelTest {
import com.vaadin.event.selection.SingleSelectionListener;
import com.vaadin.shared.Registration;
import com.vaadin.ui.Grid;
-import com.vaadin.ui.Grid.GridSelectionModel;
import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.components.grid.GridSelectionModel;
import com.vaadin.ui.components.grid.SingleSelectionModelImpl;
import elemental.json.JsonObject;
import com.vaadin.tests.server.component.abstractlisting.AbstractListingDeclarativeTest;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
-import com.vaadin.ui.Grid.FooterCell;
-import com.vaadin.ui.Grid.FooterRow;
-import com.vaadin.ui.Grid.HeaderCell;
-import com.vaadin.ui.Grid.HeaderRow;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.Label;
+import com.vaadin.ui.components.grid.FooterCell;
+import com.vaadin.ui.components.grid.FooterRow;
+import com.vaadin.ui.components.grid.HeaderCell;
+import com.vaadin.ui.components.grid.HeaderRow;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignException;
import com.vaadin.data.ValueProvider;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
-import com.vaadin.ui.Grid.HeaderRow;
+import com.vaadin.ui.components.grid.HeaderRow;
public class GridDefaultHeaderTest {
private Grid<String> grid;
import com.vaadin.data.ValueProvider;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
-import com.vaadin.ui.Grid.HeaderRow;
+import com.vaadin.ui.components.grid.HeaderRow;
public class GridHeaderFooterTest {
import com.vaadin.ui.Component;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
-import com.vaadin.ui.Grid.DetailsGenerator;
-import com.vaadin.ui.Grid.FooterRow;
-import com.vaadin.ui.Grid.HeaderRow;
-import com.vaadin.ui.Grid.MultiSelectionModel;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.StyleGenerator;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.components.grid.DetailsGenerator;
+import com.vaadin.ui.components.grid.FooterCell;
+import com.vaadin.ui.components.grid.FooterRow;
+import com.vaadin.ui.components.grid.HeaderCell;
+import com.vaadin.ui.components.grid.HeaderRow;
+import com.vaadin.ui.components.grid.MultiSelectionModel;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
import com.vaadin.ui.components.grid.SingleSelectionModelImpl;
int... columnIndexes) {
HeaderRow headerRow = grid.getHeaderRow(rowIndex);
List<Column<DataObject, ?>> columns = grid.getColumns();
- Set<Grid.HeaderCell> toMerge = new HashSet<>();
+ Set<HeaderCell> toMerge = new HashSet<>();
for (int columnIndex : columnIndexes) {
toMerge.add(headerRow.getCell(columns.get(columnIndex)));
}
int... columnIndexes) {
FooterRow footerRow = grid.getFooterRow(rowIndex);
List<Column<DataObject, ?>> columns = grid.getColumns();
- Set<Grid.FooterCell> toMerge = new HashSet<>();
+ Set<FooterCell> toMerge = new HashSet<>();
for (int columnIndex : columnIndexes) {
toMerge.add(footerRow.getCell(columns.get(columnIndex)));
}