counter = 0;
}
@Override
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 = groupRow.name;
if (name.startsWith(ModelUtils.getUserRepoPrefix())) {
// user page
String username = ModelUtils.getUserNameFromRepoPath(name);
UserModel user = app().users().getUserModel(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, groupRow.toString(), ProjectPage.class, WicketUtils.newProjectParameter(entry.name)));
row.add(new Label("groupDescription", entry.description == null ? "":entry.description));
}
WicketUtils.setCssClass(item, "group");
// reset counter so that first row is light background
counter = 0;
return;
}
Fragment row = new Fragment("rowContent", "repositoryRow", this);
item.add(row);
// try to strip group name for less cluttered list
String repoName = entry.toString();
if (!StringUtils.isEmpty(currGroupName) && (repoName.indexOf('/') > -1)) {
repoName = repoName.substring(currGroupName.length() + 1);
}
// repository swatch
Component swatch;
if (entry.isBare){
swatch = new Label("repositorySwatch", " ").setEscapeModelStrings(false);
} else {
swatch = new Label("repositorySwatch", "!");
WicketUtils.setHtmlTooltip(swatch, getString("gb.workingCopyWarning"));
}
WicketUtils.setCssBackground(swatch, entry.toString());
row.add(swatch);
swatch.setVisible(showSwatch);
if (linksActive) {
Class<? extends BasePage> linkPage = SummaryPage.class;
PageParameters pp = WicketUtils.newRepositoryParameter(entry.name);
row.add(new LinkPanel("repositoryName", "list", repoName, linkPage, pp));
row.add(new LinkPanel("repositoryDescription", "list", entry.description,
linkPage, pp));
} else {
// no links like on a federation page
row.add(new Label("repositoryName", repoName));
row.add(new Label("repositoryDescription", entry.description));
}
if (entry.hasCommits) {
// Existing repository
row.add(new Label("repositorySize", entry.size).setVisible(showSize));
} else {
// New repository
row.add(new Label("repositorySize", "<span class='empty'>(" + getString("gb.empty") + ")</span>")
.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.isMirror) {
row.add(WicketUtils.newImage("mirrorIcon", "mirror_16x16.png",
getString("gb.isMirror")));
} else {
row.add(WicketUtils.newClearPixel("mirrorIcon").setVisible(false));
}
if (entry.isFork()) {
row.add(WicketUtils.newImage("forkIcon", "commit_divide_16x16.png",
getString("gb.isFork")));
} else {
row.add(WicketUtils.newClearPixel("forkIcon").setVisible(false));
}