commit | author | age
|
f13c4c
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
98ce17
|
16 |
package com.gitblit.wicket.pages;
|
JM |
17 |
|
|
18 |
import org.apache.wicket.PageParameters;
|
|
19 |
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
|
20 |
|
|
21 |
import com.gitblit.utils.JGitUtils.SearchType;
|
|
22 |
import com.gitblit.wicket.WicketUtils;
|
|
23 |
import com.gitblit.wicket.panels.SearchPanel;
|
|
24 |
|
|
25 |
public class SearchPage extends RepositoryPage {
|
2a7306
|
26 |
|
98ce17
|
27 |
public SearchPage(PageParameters params) {
|
JM |
28 |
super(params);
|
|
29 |
|
|
30 |
String value = WicketUtils.getSearchString(params);
|
|
31 |
String type = WicketUtils.getSearchType(params);
|
|
32 |
SearchType searchType = SearchType.forName(type);
|
2a7306
|
33 |
|
98ce17
|
34 |
int pageNumber = WicketUtils.getPage(params);
|
JM |
35 |
int prevPage = Math.max(0, pageNumber - 1);
|
|
36 |
int nextPage = pageNumber + 1;
|
|
37 |
|
2a7306
|
38 |
SearchPanel search = new SearchPanel("searchPanel", repositoryName, objectId, value,
|
JM |
39 |
searchType, getRepository(), -1, pageNumber - 1);
|
98ce17
|
40 |
boolean hasMore = search.hasMore();
|
JM |
41 |
add(search);
|
|
42 |
|
2a7306
|
43 |
add(new BookmarkablePageLink<Void>("firstPageTop", SearchPage.class,
|
JM |
44 |
WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType))
|
|
45 |
.setEnabled(pageNumber > 1));
|
|
46 |
add(new BookmarkablePageLink<Void>("prevPageTop", SearchPage.class,
|
|
47 |
WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,
|
|
48 |
prevPage)).setEnabled(pageNumber > 1));
|
|
49 |
add(new BookmarkablePageLink<Void>("nextPageTop", SearchPage.class,
|
|
50 |
WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,
|
|
51 |
nextPage)).setEnabled(hasMore));
|
98ce17
|
52 |
|
2a7306
|
53 |
add(new BookmarkablePageLink<Void>("firstPageBottom", SearchPage.class,
|
JM |
54 |
WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType))
|
|
55 |
.setEnabled(pageNumber > 1));
|
|
56 |
add(new BookmarkablePageLink<Void>("prevPageBottom", SearchPage.class,
|
|
57 |
WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,
|
|
58 |
prevPage)).setEnabled(pageNumber > 1));
|
|
59 |
add(new BookmarkablePageLink<Void>("nextPageBottom", SearchPage.class,
|
|
60 |
WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,
|
|
61 |
nextPage)).setEnabled(hasMore));
|
98ce17
|
62 |
|
JM |
63 |
}
|
|
64 |
|
|
65 |
@Override
|
|
66 |
protected String getPageName() {
|
|
67 |
return getString("gb.search");
|
|
68 |
}
|
|
69 |
}
|