| | |
| | | import com.gitblit.models.ProjectModel;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | |
| | |
|
| | | if (rootRepositories.size() > 0) {
|
| | | // inject the root repositories at the top of the page
|
| | | String rootPath = GitBlit.getString(Keys.web.repositoryRootGroupName, " ");
|
| | | roots.add(0, rootPath);
|
| | | groups.put(rootPath, rootRepositories);
|
| | | roots.add(0, "");
|
| | | groups.put("", rootRepositories);
|
| | | }
|
| | |
|
| | | Map<String, ProjectModel> projects = new HashMap<String, ProjectModel>();
|
| | | for (ProjectModel project : GitBlit.self().getProjectModels(user, true)) {
|
| | | projects.put(project.name, project);
|
| | | }
|
| | | List<RepositoryModel> groupedModels = new ArrayList<RepositoryModel>();
|
| | | for (String root : roots) {
|
| | | List<RepositoryModel> subModels = groups.get(root);
|
| | | GroupRepositoryModel group = new GroupRepositoryModel(root, subModels.size());
|
| | | if (projects.containsKey(root)) {
|
| | | group.title = projects.get(root).title;
|
| | | group.description = projects.get(root).description;
|
| | | ProjectModel project = GitBlit.self().getProjectModel(root);
|
| | | GroupRepositoryModel group = new GroupRepositoryModel(project.name, subModels.size());
|
| | | if (project != null) {
|
| | | group.title = project.title;
|
| | | group.description = project.description;
|
| | | }
|
| | | groupedModels.add(group);
|
| | | Collections.sort(subModels);
|
| | |
| | | public void populateItem(final Item<RepositoryModel> item) {
|
| | | final RepositoryModel entry = item.getModelObject();
|
| | | if (entry instanceof GroupRepositoryModel) {
|
| | | GroupRepositoryModel groupRow = (GroupRepositoryModel) entry;
|
| | | currGroupName = entry.name;
|
| | | Fragment row = new Fragment("rowContent", "groupRepositoryRow", this);
|
| | | item.add(row);
|
| | |
|
| | | String name = entry.toString();
|
| | | String name = groupRow.name;
|
| | | if (name.charAt(0) == '~') {
|
| | | // user page
|
| | | String username = name.substring(1);
|
| | | UserModel user = GitBlit.self().getUserModel(username);
|
| | | row.add(new LinkPanel("groupName", null, user == null ? username : user.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(username)));
|
| | | row.add(new LinkPanel("groupName", null, (user == null ? username : user.getDisplayName()) + " (" + groupRow.count + ")", UserPage.class, WicketUtils.newUsernameParameter(username)));
|
| | | row.add(new Label("groupDescription", getString("gb.personalRepositories")));
|
| | | } else {
|
| | | // project page
|
| | | row.add(new LinkPanel("groupName", null, name, ProjectPage.class, WicketUtils.newProjectParameter(entry.name)));
|
| | | row.add(new LinkPanel("groupName", null, groupRow.toString(), ProjectPage.class, WicketUtils.newProjectParameter(entry.name)));
|
| | | row.add(new Label("groupDescription", entry.description == null ? "":entry.description));
|
| | | }
|
| | | WicketUtils.setCssClass(item, "group");
|
| | |
| | | .setEscapeModelStrings(false));
|
| | | }
|
| | |
|
| | | if (entry.isSparkleshared()) {
|
| | | row.add(WicketUtils.newImage("sparkleshareIcon", "star_16x16.png",
|
| | | getString("gb.isSparkleshared")));
|
| | | } else {
|
| | | row.add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));
|
| | | }
|
| | | |
| | | if (entry.isFork()) {
|
| | | row.add(WicketUtils.newImage("forkIcon", "commit_divide_16x16.png",
|
| | | getString("gb.isFork")));
|
| | |
| | | row.add(WicketUtils.newBlankImage("accessRestrictionIcon"));
|
| | | }
|
| | |
|
| | | String owner = entry.owner;
|
| | | if (!StringUtils.isEmpty(owner)) {
|
| | | UserModel ownerModel = GitBlit.self().getUserModel(owner);
|
| | | if (ownerModel != null) {
|
| | | owner = ownerModel.getDisplayName();
|
| | | String owner = "";
|
| | | if (!ArrayUtils.isEmpty(entry.owners)) {
|
| | | // display first owner
|
| | | for (String username : entry.owners) {
|
| | | UserModel ownerModel = GitBlit.self().getUserModel(username);
|
| | | if (ownerModel != null) {
|
| | | owner = ownerModel.getDisplayName();
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (entry.owners.size() > 1) {
|
| | | owner += ", ...";
|
| | | }
|
| | | }
|
| | | row.add(new Label("repositoryOwner", owner));
|
| | | Label ownerLabel = new Label("repositoryOwner", owner);
|
| | | WicketUtils.setHtmlTooltip(ownerLabel, ArrayUtils.toString(entry.owners));
|
| | | row.add(ownerLabel);
|
| | |
|
| | | String lastChange;
|
| | | if (entry.lastChange.getTime() == 0) {
|
| | |
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return StringUtils.isEmpty(title) ? name : title + " (" + count + ")";
|
| | | return (StringUtils.isEmpty(title) ? name : title) + " (" + count + ")";
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | Collections.sort(list, new Comparator<RepositoryModel>() {
|
| | | @Override
|
| | | public int compare(RepositoryModel o1, RepositoryModel o2) {
|
| | | String own1 = ArrayUtils.toString(o1.owners);
|
| | | String own2 = ArrayUtils.toString(o2.owners);
|
| | | if (asc) {
|
| | | return o1.owner.compareTo(o2.owner);
|
| | | return own1.compareTo(own2);
|
| | | }
|
| | | return o2.owner.compareTo(o1.owner);
|
| | | return own2.compareTo(own1);
|
| | | }
|
| | | });
|
| | | } else if (prop.equals(SortBy.description.name())) {
|