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 |
*/
|
a4d249
|
16 |
package com.gitblit.wicket.panels;
|
JM |
17 |
|
|
18 |
import java.util.ArrayList;
|
|
19 |
import java.util.Collections;
|
|
20 |
import java.util.Comparator;
|
|
21 |
import java.util.Date;
|
|
22 |
import java.util.HashMap;
|
|
23 |
import java.util.Iterator;
|
|
24 |
import java.util.List;
|
|
25 |
import java.util.Map;
|
|
26 |
|
|
27 |
import org.apache.wicket.PageParameters;
|
|
28 |
import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;
|
|
29 |
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
|
|
30 |
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
|
|
31 |
import org.apache.wicket.markup.html.basic.Label;
|
|
32 |
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
8a2e9c
|
33 |
import org.apache.wicket.markup.html.link.Link;
|
a4d249
|
34 |
import org.apache.wicket.markup.html.panel.Fragment;
|
JM |
35 |
import org.apache.wicket.markup.repeater.Item;
|
|
36 |
import org.apache.wicket.markup.repeater.data.DataView;
|
|
37 |
import org.apache.wicket.markup.repeater.data.IDataProvider;
|
|
38 |
import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
|
39 |
import org.apache.wicket.model.IModel;
|
|
40 |
import org.apache.wicket.model.Model;
|
|
41 |
|
|
42 |
import com.gitblit.Constants.AccessRestrictionType;
|
|
43 |
import com.gitblit.Keys;
|
13a3f5
|
44 |
import com.gitblit.models.ProjectModel;
|
1f9dae
|
45 |
import com.gitblit.models.RepositoryModel;
|
JM |
46 |
import com.gitblit.models.UserModel;
|
661db6
|
47 |
import com.gitblit.utils.ArrayUtils;
|
cb946f
|
48 |
import com.gitblit.utils.ModelUtils;
|
a4d249
|
49 |
import com.gitblit.utils.StringUtils;
|
JM |
50 |
import com.gitblit.wicket.GitBlitWebSession;
|
|
51 |
import com.gitblit.wicket.WicketUtils;
|
82df52
|
52 |
import com.gitblit.wicket.pages.BasePage;
|
13a3f5
|
53 |
import com.gitblit.wicket.pages.ProjectPage;
|
fee060
|
54 |
import com.gitblit.wicket.pages.RepositoriesPage;
|
a4d249
|
55 |
import com.gitblit.wicket.pages.SummaryPage;
|
1e1b85
|
56 |
import com.gitblit.wicket.pages.UserPage;
|
a4d249
|
57 |
|
JM |
58 |
public class RepositoriesPanel extends BasePanel {
|
|
59 |
|
|
60 |
private static final long serialVersionUID = 1L;
|
8a2e9c
|
61 |
|
6662e3
|
62 |
public RepositoriesPanel(String wicketId, final boolean showAdmin, final boolean showManagement,
|
cb57ec
|
63 |
List<RepositoryModel> models, boolean enableLinks,
|
2a7306
|
64 |
final Map<AccessRestrictionType, String> accessRestrictionTranslations) {
|
a4d249
|
65 |
super(wicketId);
|
8a2e9c
|
66 |
|
cb57ec
|
67 |
final boolean linksActive = enableLinks;
|
99d0d4
|
68 |
final boolean showSize = app().settings().getBoolean(Keys.web.showRepositorySizes, true);
|
831469
|
69 |
|
a4d249
|
70 |
final UserModel user = GitBlitWebSession.get().getUser();
|
831469
|
71 |
|
8a2e9c
|
72 |
final IDataProvider<RepositoryModel> dp;
|
JM |
73 |
|
6662e3
|
74 |
Fragment managementLinks;
|
JM |
75 |
if (showAdmin) {
|
|
76 |
// user is admin
|
|
77 |
managementLinks = new Fragment("managementPanel", "adminLinks", this);
|
|
78 |
managementLinks.add(new Link<Void>("clearCache") {
|
fee060
|
79 |
|
6662e3
|
80 |
private static final long serialVersionUID = 1L;
|
fee060
|
81 |
|
6662e3
|
82 |
@Override
|
JM |
83 |
public void onClick() {
|
99d0d4
|
84 |
app().repositories().resetRepositoryListCache();
|
6662e3
|
85 |
setResponsePage(RepositoriesPage.class);
|
JM |
86 |
}
|
99d0d4
|
87 |
}.setVisible(app().settings().getBoolean(Keys.git.cacheRepositoryList, true)));
|
0047fb
|
88 |
managementLinks.add(new BookmarkablePageLink<Void>("newRepository", app().getNewRepositoryPage()));
|
6662e3
|
89 |
add(managementLinks);
|
7f7051
|
90 |
} else if (showManagement && user != null && user.canCreate()) {
|
6662e3
|
91 |
// user can create personal repositories
|
JM |
92 |
managementLinks = new Fragment("managementPanel", "personalLinks", this);
|
0047fb
|
93 |
managementLinks.add(new BookmarkablePageLink<Void>("newRepository", app().getNewRepositoryPage()));
|
6662e3
|
94 |
add(managementLinks);
|
JM |
95 |
} else {
|
|
96 |
// user has no management permissions
|
|
97 |
add (new Label("managementPanel").setVisible(false));
|
|
98 |
}
|
8a2e9c
|
99 |
|
99d0d4
|
100 |
if (app().settings().getString(Keys.web.repositoryListType, "flat").equalsIgnoreCase("grouped")) {
|
5c2841
|
101 |
List<RepositoryModel> rootRepositories = new ArrayList<RepositoryModel>();
|
a4d249
|
102 |
Map<String, List<RepositoryModel>> groups = new HashMap<String, List<RepositoryModel>>();
|
JM |
103 |
for (RepositoryModel model : models) {
|
|
104 |
String rootPath = StringUtils.getRootPath(model.name);
|
88598b
|
105 |
if (StringUtils.isEmpty(rootPath)) {
|
5c2841
|
106 |
// root repository
|
88598b
|
107 |
rootRepositories.add(model);
|
5c2841
|
108 |
} else {
|
JM |
109 |
// non-root, grouped repository
|
|
110 |
if (!groups.containsKey(rootPath)) {
|
|
111 |
groups.put(rootPath, new ArrayList<RepositoryModel>());
|
|
112 |
}
|
|
113 |
groups.get(rootPath).add(model);
|
a4d249
|
114 |
}
|
JM |
115 |
}
|
|
116 |
List<String> roots = new ArrayList<String>(groups.keySet());
|
|
117 |
Collections.sort(roots);
|
88598b
|
118 |
|
5c2841
|
119 |
if (rootRepositories.size() > 0) {
|
JM |
120 |
// inject the root repositories at the top of the page
|
7ec9d3
|
121 |
roots.add(0, "");
|
JM |
122 |
groups.put("", rootRepositories);
|
5c2841
|
123 |
}
|
699e71
|
124 |
|
a4d249
|
125 |
List<RepositoryModel> groupedModels = new ArrayList<RepositoryModel>();
|
JM |
126 |
for (String root : roots) {
|
|
127 |
List<RepositoryModel> subModels = groups.get(root);
|
99d0d4
|
128 |
ProjectModel project = app().projects().getProjectModel(root);
|
d9d467
|
129 |
GroupRepositoryModel group = new GroupRepositoryModel(project == null ? root : project.name, subModels.size());
|
7ec9d3
|
130 |
if (project != null) {
|
JM |
131 |
group.title = project.title;
|
|
132 |
group.description = project.description;
|
13a3f5
|
133 |
}
|
JM |
134 |
groupedModels.add(group);
|
831469
|
135 |
Collections.sort(subModels);
|
a4d249
|
136 |
groupedModels.addAll(subModels);
|
JM |
137 |
}
|
51c923
|
138 |
dp = new ListDataProvider<RepositoryModel>(groupedModels);
|
a4d249
|
139 |
} else {
|
8a2e9c
|
140 |
dp = new SortableRepositoriesProvider(models);
|
a4d249
|
141 |
}
|
72633d
|
142 |
|
99d0d4
|
143 |
final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true);
|
699e71
|
144 |
|
a4d249
|
145 |
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("row", dp) {
|
JM |
146 |
private static final long serialVersionUID = 1L;
|
2a7306
|
147 |
int counter;
|
94750e
|
148 |
String currGroupName;
|
a4d249
|
149 |
|
8a2e9c
|
150 |
@Override
|
JM |
151 |
protected void onBeforeRender() {
|
|
152 |
super.onBeforeRender();
|
|
153 |
counter = 0;
|
|
154 |
}
|
|
155 |
|
699e71
|
156 |
@Override
|
a4d249
|
157 |
public void populateItem(final Item<RepositoryModel> item) {
|
JM |
158 |
final RepositoryModel entry = item.getModelObject();
|
|
159 |
if (entry instanceof GroupRepositoryModel) {
|
f5cbd0
|
160 |
GroupRepositoryModel groupRow = (GroupRepositoryModel) entry;
|
94750e
|
161 |
currGroupName = entry.name;
|
a4d249
|
162 |
Fragment row = new Fragment("rowContent", "groupRepositoryRow", this);
|
JM |
163 |
item.add(row);
|
699e71
|
164 |
|
f5cbd0
|
165 |
String name = groupRow.name;
|
cb946f
|
166 |
if (name.startsWith(ModelUtils.getUserRepoPrefix())) {
|
1e1b85
|
167 |
// user page
|
cb946f
|
168 |
String username = ModelUtils.getUserNameFromRepoPath(name);
|
99d0d4
|
169 |
UserModel user = app().users().getUserModel(username);
|
f5cbd0
|
170 |
row.add(new LinkPanel("groupName", null, (user == null ? username : user.getDisplayName()) + " (" + groupRow.count + ")", UserPage.class, WicketUtils.newUsernameParameter(username)));
|
1e1b85
|
171 |
row.add(new Label("groupDescription", getString("gb.personalRepositories")));
|
JM |
172 |
} else {
|
|
173 |
// project page
|
f5cbd0
|
174 |
row.add(new LinkPanel("groupName", null, groupRow.toString(), ProjectPage.class, WicketUtils.newProjectParameter(entry.name)));
|
1e1b85
|
175 |
row.add(new Label("groupDescription", entry.description == null ? "":entry.description));
|
JM |
176 |
}
|
a4d249
|
177 |
WicketUtils.setCssClass(item, "group");
|
94750e
|
178 |
// reset counter so that first row is light background
|
JM |
179 |
counter = 0;
|
a4d249
|
180 |
return;
|
JM |
181 |
}
|
|
182 |
Fragment row = new Fragment("rowContent", "repositoryRow", this);
|
|
183 |
item.add(row);
|
309c55
|
184 |
|
86bdc2
|
185 |
// show colored repository type icon
|
JM |
186 |
Fragment iconFragment;
|
|
187 |
if (entry.isMirror) {
|
|
188 |
iconFragment = new Fragment("repoIcon", "mirrorIconFragment", this);
|
|
189 |
} else if (entry.isFork()) {
|
|
190 |
iconFragment = new Fragment("repoIcon", "forkIconFragment", this);
|
|
191 |
} else if (entry.isBare) {
|
|
192 |
iconFragment = new Fragment("repoIcon", "repoIconFragment", this);
|
|
193 |
} else {
|
|
194 |
iconFragment = new Fragment("repoIcon", "cloneIconFragment", this);
|
|
195 |
}
|
|
196 |
if (showSwatch) {
|
|
197 |
WicketUtils.setCssStyle(iconFragment, "color:" + StringUtils.getColor(entry.toString()));
|
|
198 |
}
|
|
199 |
row.add(iconFragment);
|
|
200 |
|
94750e
|
201 |
// try to strip group name for less cluttered list
|
6c6fbf
|
202 |
String repoName = entry.toString();
|
94750e
|
203 |
if (!StringUtils.isEmpty(currGroupName) && (repoName.indexOf('/') > -1)) {
|
JM |
204 |
repoName = repoName.substring(currGroupName.length() + 1);
|
|
205 |
}
|
309c55
|
206 |
|
82df52
|
207 |
if (linksActive) {
|
b5e11d
|
208 |
Class<? extends BasePage> linkPage = SummaryPage.class;
|
a4d249
|
209 |
PageParameters pp = WicketUtils.newRepositoryParameter(entry.name);
|
82df52
|
210 |
row.add(new LinkPanel("repositoryName", "list", repoName, linkPage, pp));
|
2a7306
|
211 |
row.add(new LinkPanel("repositoryDescription", "list", entry.description,
|
82df52
|
212 |
linkPage, pp));
|
831469
|
213 |
} else {
|
82df52
|
214 |
// no links like on a federation page
|
94750e
|
215 |
row.add(new Label("repositoryName", repoName));
|
831469
|
216 |
row.add(new Label("repositoryDescription", entry.description));
|
JM |
217 |
}
|
|
218 |
if (entry.hasCommits) {
|
|
219 |
// Existing repository
|
72633d
|
220 |
row.add(new Label("repositorySize", entry.size).setVisible(showSize));
|
a4d249
|
221 |
} else {
|
JM |
222 |
// New repository
|
017749
|
223 |
row.add(new Label("repositorySize", "<span class='empty'>(" + getString("gb.empty") + ")</span>")
|
88598b
|
224 |
.setEscapeModelStrings(false));
|
a4d249
|
225 |
}
|
JM |
226 |
|
e4e682
|
227 |
if (entry.isSparkleshared()) {
|
JM |
228 |
row.add(WicketUtils.newImage("sparkleshareIcon", "star_16x16.png",
|
|
229 |
getString("gb.isSparkleshared")));
|
|
230 |
} else {
|
|
231 |
row.add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));
|
|
232 |
}
|
699e71
|
233 |
|
86bdc2
|
234 |
if (!entry.isMirror && entry.isFrozen) {
|
2a7306
|
235 |
row.add(WicketUtils.newImage("frozenIcon", "cold_16x16.png",
|
JM |
236 |
getString("gb.isFrozen")));
|
a4d249
|
237 |
} else {
|
JM |
238 |
row.add(WicketUtils.newClearPixel("frozenIcon").setVisible(false));
|
831469
|
239 |
}
|
JM |
240 |
|
|
241 |
if (entry.isFederated) {
|
|
242 |
row.add(WicketUtils.newImage("federatedIcon", "federated_16x16.png",
|
|
243 |
getString("gb.isFederated")));
|
|
244 |
} else {
|
|
245 |
row.add(WicketUtils.newClearPixel("federatedIcon").setVisible(false));
|
a4d249
|
246 |
}
|
86bdc2
|
247 |
|
JM |
248 |
if (entry.isMirror) {
|
|
249 |
row.add(WicketUtils.newImage("accessRestrictionIcon", "mirror_16x16.png",
|
|
250 |
getString("gb.isMirror")));
|
|
251 |
} else {
|
|
252 |
switch (entry.accessRestriction) {
|
|
253 |
case NONE:
|
|
254 |
row.add(WicketUtils.newBlankImage("accessRestrictionIcon"));
|
|
255 |
break;
|
|
256 |
case PUSH:
|
|
257 |
row.add(WicketUtils.newImage("accessRestrictionIcon", "lock_go_16x16.png",
|
|
258 |
accessRestrictionTranslations.get(entry.accessRestriction)));
|
|
259 |
break;
|
|
260 |
case CLONE:
|
|
261 |
row.add(WicketUtils.newImage("accessRestrictionIcon", "lock_pull_16x16.png",
|
|
262 |
accessRestrictionTranslations.get(entry.accessRestriction)));
|
|
263 |
break;
|
|
264 |
case VIEW:
|
|
265 |
row.add(WicketUtils.newImage("accessRestrictionIcon", "shield_16x16.png",
|
|
266 |
accessRestrictionTranslations.get(entry.accessRestriction)));
|
|
267 |
break;
|
|
268 |
default:
|
|
269 |
row.add(WicketUtils.newBlankImage("accessRestrictionIcon"));
|
|
270 |
}
|
a4d249
|
271 |
}
|
JM |
272 |
|
661db6
|
273 |
String owner = "";
|
JM |
274 |
if (!ArrayUtils.isEmpty(entry.owners)) {
|
|
275 |
// display first owner
|
|
276 |
for (String username : entry.owners) {
|
99d0d4
|
277 |
UserModel ownerModel = app().users().getUserModel(username);
|
661db6
|
278 |
if (ownerModel != null) {
|
JM |
279 |
owner = ownerModel.getDisplayName();
|
|
280 |
break;
|
|
281 |
}
|
|
282 |
}
|
|
283 |
if (entry.owners.size() > 1) {
|
|
284 |
owner += ", ...";
|
fb6bf3
|
285 |
}
|
JM |
286 |
}
|
661db6
|
287 |
Label ownerLabel = new Label("repositoryOwner", owner);
|
JM |
288 |
WicketUtils.setHtmlTooltip(ownerLabel, ArrayUtils.toString(entry.owners));
|
|
289 |
row.add(ownerLabel);
|
a4d249
|
290 |
|
a2709d
|
291 |
String lastChange;
|
JM |
292 |
if (entry.lastChange.getTime() == 0) {
|
|
293 |
lastChange = "--";
|
|
294 |
} else {
|
9adf62
|
295 |
lastChange = getTimeUtils().timeAgo(entry.lastChange);
|
a2709d
|
296 |
}
|
a4d249
|
297 |
Label lastChangeLabel = new Label("repositoryLastChange", lastChange);
|
JM |
298 |
row.add(lastChangeLabel);
|
9adf62
|
299 |
WicketUtils.setCssClass(lastChangeLabel, getTimeUtils().timeAgoCss(entry.lastChange));
|
5c5b7a
|
300 |
if (!StringUtils.isEmpty(entry.lastChangeAuthor)) {
|
JM |
301 |
WicketUtils.setHtmlTooltip(lastChangeLabel, getString("gb.author") + ": " + entry.lastChangeAuthor);
|
|
302 |
}
|
a4d249
|
303 |
|
JM |
304 |
WicketUtils.setAlternatingBackground(item, counter);
|
|
305 |
counter++;
|
|
306 |
}
|
|
307 |
};
|
|
308 |
add(dataView);
|
|
309 |
|
|
310 |
if (dp instanceof SortableDataProvider<?>) {
|
|
311 |
// add sortable header
|
|
312 |
SortableDataProvider<?> sdp = (SortableDataProvider<?>) dp;
|
|
313 |
Fragment fragment = new Fragment("headerContent", "flatRepositoryHeader", this);
|
|
314 |
fragment.add(newSort("orderByRepository", SortBy.repository, sdp, dataView));
|
|
315 |
fragment.add(newSort("orderByDescription", SortBy.description, sdp, dataView));
|
|
316 |
fragment.add(newSort("orderByOwner", SortBy.owner, sdp, dataView));
|
|
317 |
fragment.add(newSort("orderByDate", SortBy.date, sdp, dataView));
|
|
318 |
add(fragment);
|
|
319 |
} else {
|
|
320 |
// not sortable
|
|
321 |
Fragment fragment = new Fragment("headerContent", "groupRepositoryHeader", this);
|
|
322 |
add(fragment);
|
|
323 |
}
|
|
324 |
}
|
8a2e9c
|
325 |
|
2a7306
|
326 |
private static class GroupRepositoryModel extends RepositoryModel {
|
a4d249
|
327 |
|
JM |
328 |
private static final long serialVersionUID = 1L;
|
|
329 |
|
2a7306
|
330 |
int count;
|
13a3f5
|
331 |
String title;
|
8a2e9c
|
332 |
|
JM |
333 |
GroupRepositoryModel(String name, int count) {
|
a4d249
|
334 |
super(name, "", "", new Date(0));
|
8a2e9c
|
335 |
this.count = count;
|
JM |
336 |
}
|
|
337 |
|
|
338 |
@Override
|
|
339 |
public String toString() {
|
b94059
|
340 |
return (StringUtils.isEmpty(title) ? name : title) + " (" + count + ")";
|
a4d249
|
341 |
}
|
JM |
342 |
}
|
8a2e9c
|
343 |
|
a4d249
|
344 |
protected enum SortBy {
|
JM |
345 |
repository, description, owner, date;
|
|
346 |
}
|
|
347 |
|
2a7306
|
348 |
protected OrderByBorder newSort(String wicketId, SortBy field, SortableDataProvider<?> dp,
|
JM |
349 |
final DataView<?> dataView) {
|
a4d249
|
350 |
return new OrderByBorder(wicketId, field.name(), dp) {
|
JM |
351 |
private static final long serialVersionUID = 1L;
|
|
352 |
|
|
353 |
@Override
|
|
354 |
protected void onSortChanged() {
|
|
355 |
dataView.setCurrentPage(0);
|
|
356 |
}
|
|
357 |
};
|
|
358 |
}
|
|
359 |
|
2a7306
|
360 |
private static class SortableRepositoriesProvider extends SortableDataProvider<RepositoryModel> {
|
JM |
361 |
|
a4d249
|
362 |
private static final long serialVersionUID = 1L;
|
2a7306
|
363 |
|
JM |
364 |
private List<RepositoryModel> list;
|
a4d249
|
365 |
|
8a2e9c
|
366 |
protected SortableRepositoriesProvider(List<RepositoryModel> list) {
|
a4d249
|
367 |
this.list = list;
|
JM |
368 |
setSort(SortBy.date.name(), false);
|
8a2e9c
|
369 |
}
|
JM |
370 |
|
a4d249
|
371 |
@Override
|
JM |
372 |
public int size() {
|
2a7306
|
373 |
if (list == null) {
|
a4d249
|
374 |
return 0;
|
2a7306
|
375 |
}
|
a4d249
|
376 |
return list.size();
|
JM |
377 |
}
|
|
378 |
|
|
379 |
@Override
|
|
380 |
public IModel<RepositoryModel> model(RepositoryModel header) {
|
|
381 |
return new Model<RepositoryModel>(header);
|
|
382 |
}
|
|
383 |
|
|
384 |
@Override
|
|
385 |
public Iterator<RepositoryModel> iterator(int first, int count) {
|
|
386 |
SortParam sp = getSort();
|
|
387 |
String prop = sp.getProperty();
|
|
388 |
final boolean asc = sp.isAscending();
|
|
389 |
|
|
390 |
if (prop == null || prop.equals(SortBy.date.name())) {
|
|
391 |
Collections.sort(list, new Comparator<RepositoryModel>() {
|
|
392 |
@Override
|
|
393 |
public int compare(RepositoryModel o1, RepositoryModel o2) {
|
2a7306
|
394 |
if (asc) {
|
a4d249
|
395 |
return o1.lastChange.compareTo(o2.lastChange);
|
2a7306
|
396 |
}
|
a4d249
|
397 |
return o2.lastChange.compareTo(o1.lastChange);
|
JM |
398 |
}
|
|
399 |
});
|
|
400 |
} else if (prop.equals(SortBy.repository.name())) {
|
|
401 |
Collections.sort(list, new Comparator<RepositoryModel>() {
|
|
402 |
@Override
|
|
403 |
public int compare(RepositoryModel o1, RepositoryModel o2) {
|
2a7306
|
404 |
if (asc) {
|
a4d249
|
405 |
return o1.name.compareTo(o2.name);
|
2a7306
|
406 |
}
|
a4d249
|
407 |
return o2.name.compareTo(o1.name);
|
JM |
408 |
}
|
|
409 |
});
|
|
410 |
} else if (prop.equals(SortBy.owner.name())) {
|
|
411 |
Collections.sort(list, new Comparator<RepositoryModel>() {
|
|
412 |
@Override
|
|
413 |
public int compare(RepositoryModel o1, RepositoryModel o2) {
|
661db6
|
414 |
String own1 = ArrayUtils.toString(o1.owners);
|
JM |
415 |
String own2 = ArrayUtils.toString(o2.owners);
|
2a7306
|
416 |
if (asc) {
|
661db6
|
417 |
return own1.compareTo(own2);
|
2a7306
|
418 |
}
|
661db6
|
419 |
return own2.compareTo(own1);
|
a4d249
|
420 |
}
|
JM |
421 |
});
|
|
422 |
} else if (prop.equals(SortBy.description.name())) {
|
|
423 |
Collections.sort(list, new Comparator<RepositoryModel>() {
|
|
424 |
@Override
|
|
425 |
public int compare(RepositoryModel o1, RepositoryModel o2) {
|
2a7306
|
426 |
if (asc) {
|
a4d249
|
427 |
return o1.description.compareTo(o2.description);
|
2a7306
|
428 |
}
|
a4d249
|
429 |
return o2.description.compareTo(o1.description);
|
JM |
430 |
}
|
|
431 |
});
|
|
432 |
}
|
|
433 |
return list.subList(first, first + count).iterator();
|
|
434 |
}
|
|
435 |
}
|
|
436 |
}
|