use of com.gitblit.wicket.panels.ProjectRepositoryPanel in project gitblit by gitblit.
the class UserPage method setup.
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
authenticationError("Please login");
return;
}
String userName = WicketUtils.getUsername(params);
if (StringUtils.isEmpty(userName)) {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
UserModel user = app().users().getUserModel(userName);
if (user == null) {
// construct a temporary user model
user = new UserModel(userName);
}
add(new UserTitlePanel("userTitlePanel", user, user.username));
UserModel sessionUser = GitBlitWebSession.get().getUser();
boolean isMyProfile = sessionUser != null && sessionUser.equals(user);
if (isMyProfile) {
addPreferences(user);
if (app().services().isServingSSH()) {
// show the SSH key management tab
addSshKeys(user);
} else {
// SSH daemon is disabled, hide keys tab
add(new Label("sshKeysLink").setVisible(false));
add(new Label("sshKeysTab").setVisible(false));
}
} else {
// visiting user
add(new Label("preferencesLink").setVisible(false));
add(new Label("preferencesTab").setVisible(false));
add(new Label("sshKeysLink").setVisible(false));
add(new Label("sshKeysTab").setVisible(false));
}
List<RepositoryModel> repositories = getRepositories(params);
Collections.sort(repositories, new Comparator<RepositoryModel>() {
@Override
public int compare(RepositoryModel o1, RepositoryModel o2) {
// reverse-chronological sort
return o2.lastChange.compareTo(o1.lastChange);
}
});
final ListDataProvider<RepositoryModel> dp = new ListDataProvider<RepositoryModel>(repositories);
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("repositoryList", dp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<RepositoryModel> item) {
final RepositoryModel entry = item.getModelObject();
ProjectRepositoryPanel row = new ProjectRepositoryPanel("repository", getLocalizer(), this, showAdmin, entry, getAccessRestrictions());
item.add(row);
}
};
add(dataView);
}
Aggregations