Revision 1a4c1ca7
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.registration; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
11 | 12 |
import java.util.EnumSet; |
13 |
import java.util.List; |
|
12 | 14 |
import java.util.Set; |
13 | 15 |
import java.util.UUID; |
14 | 16 |
|
15 | 17 |
import org.apache.commons.lang3.StringUtils; |
16 | 18 |
import org.springframework.beans.factory.annotation.Autowired; |
17 | 19 |
import org.springframework.security.core.Authentication; |
20 |
import org.vaadin.spring.events.EventScope; |
|
18 | 21 |
import org.vaadin.spring.events.annotation.EventBusListenerMethod; |
19 | 22 |
|
23 |
import com.vaadin.navigator.Navigator; |
|
20 | 24 |
import com.vaadin.spring.annotation.SpringComponent; |
21 | 25 |
import com.vaadin.spring.annotation.ViewScope; |
22 | 26 |
import com.vaadin.ui.TextField; |
... | ... | |
30 | 34 |
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory; |
31 | 35 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem; |
32 | 36 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
37 |
import eu.etaxonomy.cdm.vaadin.event.PagingEvent; |
|
33 | 38 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
34 | 39 |
import eu.etaxonomy.cdm.vaadin.event.UpdateResultsEvent; |
35 | 40 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
41 |
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent; |
|
36 | 42 |
|
37 | 43 |
/** |
38 | 44 |
* |
... | ... | |
55 | 61 |
@Autowired |
56 | 62 |
private IRegistrationWorkingSetService workingSetService; |
57 | 63 |
|
64 |
private Integer pageIndex = 0; |
|
65 |
private Integer pageSize = null; |
|
66 |
|
|
58 | 67 |
/** |
59 | 68 |
* @return the workingSetService |
60 | 69 |
*/ |
... | ... | |
66 | 75 |
@Override |
67 | 76 |
public void handleViewEntered() { |
68 | 77 |
|
69 |
if(getNavigationManager().getCurrentViewParameters().get(0).equals(ListView.Mode.inProgress.name())){ |
|
78 |
List<String> viewParameters = getNavigationManager().getCurrentViewParameters(); |
|
79 |
if(viewParameters.get(0).equals(ListView.Mode.inProgress.name())){ |
|
70 | 80 |
getView().setViewMode(ListViewBean.Mode.inProgress); |
71 | 81 |
getView().getStatusFilter().setVisible(false); |
72 | 82 |
} else { |
73 | 83 |
getView().setViewMode(ListViewBean.Mode.all); |
74 | 84 |
} |
85 |
if(viewParameters.size() > 1){ |
|
86 |
// expecting the second param to be the page index |
|
87 |
try { |
|
88 |
pageIndex = Integer.parseInt(viewParameters.get(1)); |
|
89 |
} catch (NumberFormatException e) { |
|
90 |
// only log and display the page 0 |
|
91 |
logger.error("Invalid page index parameter " + viewParameters.get(1) + " in " + ((Navigator)getNavigationManager()).getState()); |
|
92 |
} |
|
93 |
} |
|
75 | 94 |
|
76 | 95 |
CdmBeanItemContainerFactory selectFieldFactory = new CdmBeanItemContainerFactory(getRepo()); |
77 | 96 |
|
... | ... | |
129 | 148 |
includeStatus, |
130 | 149 |
StringUtils.trimToNull(identifierFilter), |
131 | 150 |
StringUtils.trimToNull(nameFilter), |
132 |
null,
|
|
133 |
null);
|
|
151 |
pageSize,
|
|
152 |
pageIndex);
|
|
134 | 153 |
return dtoPager; |
135 | 154 |
} |
136 | 155 |
|
... | ... | |
170 | 189 |
getView().populate(pageRegistrations(event.getField(), event.getNewText())); |
171 | 190 |
} |
172 | 191 |
|
192 |
@EventBusListenerMethod |
|
193 |
public void onPagingEvent(PagingEvent event){ |
|
194 |
|
|
195 |
if(!event.getSourceView().equals(getView())){ |
|
196 |
return; |
|
197 |
} |
|
198 |
String viewName = getNavigationManager().getCurrentViewName(); |
|
199 |
List<String> viewNameParams = new ArrayList(getNavigationManager().getCurrentViewParameters()); |
|
200 |
if(viewNameParams.size() > 1){ |
|
201 |
viewNameParams.set(1, event.getPageIndex().toString()); |
|
202 |
} else { |
|
203 |
viewNameParams.add(event.getPageIndex().toString()); |
|
204 |
} |
|
205 |
viewEventBus.publish(EventScope.UI, this, new NavigationEvent(viewName, viewNameParams.toArray(new String[viewNameParams.size()]))); |
|
206 |
} |
|
207 |
|
|
173 | 208 |
} |
Also available in: Unified diff
fix #7131 pager implemented and added to registration list view