Skip to content

Commit 4c47736

Browse files
committed
Fix an issue with the InfiniteDataTable data source.
1 parent cae4623 commit 4c47736

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

src/main/java/gwt/material/design/demo/client/application/datatable/custom/CustomDataTableView.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,6 @@ interface Binder extends UiBinder<Widget, CustomDataTableView> {
6262
// Setting table title
6363
table.getTableTitle().setText("My Custom Table");
6464

65-
//Adding / removing table toolpanel action buttons / icons
66-
Panel panel = table.getScaffolding().getToolPanel();
67-
panel.clear();
68-
// Add two buttons
69-
panel.add(new MaterialIcon(IconType.FAVORITE));
70-
panel.add(new MaterialIcon(IconType.DELETE));
71-
panel.add(new MaterialIcon(IconType.MESSAGE));
72-
7365
// We will manually add this category otherwise categories
7466
// can be loaded on the fly with HasDataCategory, or a custom
7567
// RowComponentFactory as demonstrated below
@@ -297,4 +289,17 @@ public void run() {
297289
//.log("Row Short Pressed: " + model.getId() + ", x:" + mouseEvent.getPageX() + ", y: " + mouseEvent.getPageY());
298290
});
299291
}
292+
293+
@Override
294+
protected void onAttach() {
295+
super.onAttach();
296+
297+
//Adding / removing table toolpanel action buttons / icons
298+
Panel panel = table.getScaffolding().getToolPanel();
299+
panel.clear();
300+
// Add two buttons
301+
panel.add(new MaterialIcon(IconType.FAVORITE));
302+
panel.add(new MaterialIcon(IconType.DELETE));
303+
panel.add(new MaterialIcon(IconType.MESSAGE));
304+
}
300305
}

src/main/java/gwt/material/design/demo/client/application/datatable/table/datasource/PersonDataSource.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public PersonDataSource(PersonServiceAsync personService) {
4646
@Override
4747
public void load(LoadConfig<Person> loadConfig, LoadCallback<Person> callback) {
4848
List<CategoryComponent> categories = loadConfig.getOpenCategories();
49-
List<String> categoryNames = categories.stream().map(CategoryComponent::getName).collect(Collectors.toList());
49+
50+
List<String> categoryNames = null;
51+
if(categories != null) {
52+
categoryNames = categories.stream().map(CategoryComponent::getName).collect(Collectors.toList());
53+
}
5054

5155
personService.getPeople(loadConfig.getOffset(), loadConfig.getLimit(), categoryNames,
5256
new AsyncCallback<People>() {

src/main/java/gwt/material/design/demo/client/application/datatable/table/service/FakePersonService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class FakePersonService implements PersonServiceAsync {
5858
@Override
5959
public void getPeople(int startIndex, int viewSize, List<String> categories, AsyncCallback<People> async) {
6060
List<Person> flatData = new ArrayList<>();
61-
if(categories == null || categories.isEmpty()) {
61+
if(categories == null) {
6262
// Load all data
6363
for(String category : FakePersonService.categories) {
6464
flatData.addAll(peopleMap.get(category));

src/main/java/gwt/material/design/demo/client/ui/ExternalLibrary.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

0 commit comments

Comments
 (0)