* only visible if an in-memory data provider is used
* {@link DataSource#isInMemory()}.
*/
- public enum SelectAllCheckBoxVisible {
+ public enum SelectAllCheckBoxVisibility {
/**
* Shows the select all checkbox, regardless of data provider used.
* <p>
private Set<T> selection = new LinkedHashSet<>();
- private SelectAllCheckBoxVisible selectAllCheckBoxVisible = SelectAllCheckBoxVisible.DEFAULT;
+ private SelectAllCheckBoxVisibility selectAllCheckBoxVisibility = SelectAllCheckBoxVisibility.DEFAULT;
@Override
protected void init() {
/**
* Sets the select all checkbox visibility mode.
* <p>
- * The default value is {@link SelectAllCheckBoxVisible#DEFAULT}, which
+ * The default value is {@link SelectAllCheckBoxVisibility#DEFAULT}, which
* means that the checkbox is only visible if the grid's data provider is
* in- memory.
*
- * @param selectAllCheckBoxVisible
+ * @param selectAllCheckBoxVisibility
* the visiblity mode to use
- * @see SelectAllCheckBoxVisible
+ * @see SelectAllCheckBoxVisibility
*/
- public void setSelectAllCheckBoxVisible(
- SelectAllCheckBoxVisible selectAllCheckBoxVisible) {
- if (this.selectAllCheckBoxVisible != selectAllCheckBoxVisible) {
- this.selectAllCheckBoxVisible = selectAllCheckBoxVisible;
+ public void setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility selectAllCheckBoxVisibility) {
+ if (this.selectAllCheckBoxVisibility != selectAllCheckBoxVisibility) {
+ this.selectAllCheckBoxVisibility = selectAllCheckBoxVisibility;
markAsDirty();
}
}
* Gets the current mode for the select all checkbox visibility.
*
* @return the select all checkbox visibility mode
- * @see SelectAllCheckBoxVisible
+ * @see SelectAllCheckBoxVisibility
* @see #isSelectAllCheckBoxVisible()
*/
- public SelectAllCheckBoxVisible getSelectAllCheckBoxVisible() {
- return selectAllCheckBoxVisible;
+ public SelectAllCheckBoxVisibility getSelectAllCheckBoxVisibility() {
+ return selectAllCheckBoxVisibility;
}
/**
* Returns whether the select all checkbox will be visible with the current
* setting of
- * {@link #setSelectAllCheckBoxVisible(SelectAllCheckBoxVisible)}.
+ * {@link #setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility)}.
*
* @return {@code true} if the checkbox will be visible with the current
* settings
- * @see SelectAllCheckBoxVisible
- * @see #setSelectAllCheckBoxVisible(SelectAllCheckBoxVisible)
+ * @see SelectAllCheckBoxVisibility
+ * @see #setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility)
*/
public boolean isSelectAllCheckBoxVisible() {
updateCanSelectAll();
* This is updated as a part of {@link #beforeClientResponse(boolean)},
* since the data provider for grid can be changed on the fly.
*
- * @see SelectAllCheckBoxVisible
+ * @see SelectAllCheckBoxVisibility
*/
protected void updateCanSelectAll() {
- switch (selectAllCheckBoxVisible) {
+ switch (selectAllCheckBoxVisibility) {
case VISIBLE:
getState(false).selectAllCheckBoxVisible = true;
break;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.UI;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisible;
+import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
import elemental.json.JsonObject;
ui.setContent(grid);
// no items yet, default data provider is empty not in memory one
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
- Assert.assertEquals(SelectAllCheckBoxVisible.DEFAULT,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT,
+ model.getSelectAllCheckBoxVisibility());
grid.setItems("Foo", "Bar", "Baz");
// in-memory container keeps default
Assert.assertTrue(model.isSelectAllCheckBoxVisible());
- Assert.assertEquals(SelectAllCheckBoxVisible.DEFAULT,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT,
+ model.getSelectAllCheckBoxVisibility());
// change to explicit NO
- model.setSelectAllCheckBoxVisible(SelectAllCheckBoxVisible.HIDDEN);
+ model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.HIDDEN);
- Assert.assertEquals(SelectAllCheckBoxVisible.HIDDEN,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.HIDDEN,
+ model.getSelectAllCheckBoxVisibility());
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
// change to explicit YES
- model.setSelectAllCheckBoxVisible(SelectAllCheckBoxVisible.VISIBLE);
+ model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.VISIBLE);
- Assert.assertEquals(SelectAllCheckBoxVisible.VISIBLE,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.VISIBLE,
+ model.getSelectAllCheckBoxVisibility());
Assert.assertTrue(model.isSelectAllCheckBoxVisible());
}
// no items yet, default data provider is empty not in memory one
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
- Assert.assertEquals(SelectAllCheckBoxVisible.DEFAULT,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT,
+ model.getSelectAllCheckBoxVisibility());
grid.setDataProvider(
new BackEndDataProvider<String, String>(
// not in-memory -> checkbox is hidden
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
- Assert.assertEquals(SelectAllCheckBoxVisible.DEFAULT,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT,
+ model.getSelectAllCheckBoxVisibility());
// change to explicit YES
- model.setSelectAllCheckBoxVisible(SelectAllCheckBoxVisible.VISIBLE);
+ model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.VISIBLE);
- Assert.assertEquals(SelectAllCheckBoxVisible.VISIBLE,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.VISIBLE,
+ model.getSelectAllCheckBoxVisibility());
Assert.assertTrue(model.isSelectAllCheckBoxVisible());
// change to explicit NO
- model.setSelectAllCheckBoxVisible(SelectAllCheckBoxVisible.HIDDEN);
+ model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.HIDDEN);
- Assert.assertEquals(SelectAllCheckBoxVisible.HIDDEN,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.HIDDEN,
+ model.getSelectAllCheckBoxVisibility());
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
// change back to depends on data provider
- model.setSelectAllCheckBoxVisible(SelectAllCheckBoxVisible.DEFAULT);
+ model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.DEFAULT);
Assert.assertFalse(model.isSelectAllCheckBoxVisible());
- Assert.assertEquals(SelectAllCheckBoxVisible.DEFAULT,
- model.getSelectAllCheckBoxVisible());
+ Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT,
+ model.getSelectAllCheckBoxVisibility());
}
}
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.RadioButtonGroup;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisible;
+import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
public class GridMultiSelectionOnInit extends AbstractTestUI {
grid.getSelectionModel().select("Foo 2");
}
- RadioButtonGroup<SelectAllCheckBoxVisible> rbg = new RadioButtonGroup<>(
+ RadioButtonGroup<SelectAllCheckBoxVisibility> rbg = new RadioButtonGroup<>(
"Select All Visible",
- Arrays.asList(SelectAllCheckBoxVisible.VISIBLE,
- SelectAllCheckBoxVisible.HIDDEN,
- SelectAllCheckBoxVisible.DEFAULT));
- rbg.setValue(selectionModel.getSelectAllCheckBoxVisible());
+ Arrays.asList(SelectAllCheckBoxVisibility.VISIBLE,
+ SelectAllCheckBoxVisibility.HIDDEN,
+ SelectAllCheckBoxVisibility.DEFAULT));
+ rbg.setValue(selectionModel.getSelectAllCheckBoxVisibility());
rbg.addValueChangeListener(event -> selectionModel
- .setSelectAllCheckBoxVisible(event.getValue()));
+ .setSelectAllCheckBoxVisibility(event.getValue()));
addComponent(rbg);
}
}
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisible;
+import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
import com.vaadin.ui.components.grid.SingleSelectionModelImpl;
import com.vaadin.ui.renderers.DateRenderer;
import com.vaadin.ui.renderers.HtmlRenderer;
selectionModelItem.addItem("SelectAllCheckbox: Visible", menuItem -> {
switchToMultiSelect();
((MultiSelectionModelImpl<DataObject>) grid.getSelectionModel())
- .setSelectAllCheckBoxVisible(
- SelectAllCheckBoxVisible.VISIBLE);
+ .setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.VISIBLE);
});
selectionModelItem.addItem("SelectAllCheckbox: Hidden", menuItem -> {
switchToMultiSelect();
((MultiSelectionModelImpl<DataObject>) grid.getSelectionModel())
- .setSelectAllCheckBoxVisible(
- SelectAllCheckBoxVisible.HIDDEN);
+ .setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.HIDDEN);
});
selectionModelItem.addItem("SelectAllCheckbox: Default", menuItem -> {
switchToMultiSelect();
((MultiSelectionModelImpl<DataObject>) grid.getSelectionModel())
- .setSelectAllCheckBoxVisible(
- SelectAllCheckBoxVisible.DEFAULT);
+ .setSelectAllCheckBoxVisibility(
+ SelectAllCheckBoxVisibility.DEFAULT);
});
}