use of com.gitblit.models.Menu.MenuDivider in project gitblit by gitblit.
the class RootPage method getTimeFilterItems.
protected List<MenuItem> getTimeFilterItems(PageParameters params) {
// days back choices - additive parameters
int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
if (daysBack < 1) {
daysBack = 7;
}
if (daysBack > maxDaysBack) {
daysBack = maxDaysBack;
}
PageParameters clonedParams;
if (params == null) {
clonedParams = new PageParameters();
} else {
clonedParams = new PageParameters(params);
}
if (!clonedParams.containsKey("db")) {
clonedParams.put("db", daysBack);
}
List<MenuItem> items = new ArrayList<MenuItem>();
Set<Integer> choicesSet = new TreeSet<Integer>(app().settings().getIntegers(Keys.web.activityDurationChoices));
if (choicesSet.isEmpty()) {
choicesSet.addAll(Arrays.asList(1, 3, 7, 14, 21, 28));
}
List<Integer> choices = new ArrayList<Integer>(choicesSet);
Collections.sort(choices);
String lastDaysPattern = getString("gb.lastNDays");
for (Integer db : choices) {
if (db == 1) {
items.add(new ParameterMenuItem(getString("gb.time.today"), "db", db.toString(), clonedParams));
} else {
String txt = MessageFormat.format(lastDaysPattern, db);
items.add(new ParameterMenuItem(txt, "db", db.toString(), clonedParams));
}
}
items.add(new MenuDivider());
return items;
}
use of com.gitblit.models.Menu.MenuDivider in project gitblit by gitblit.
the class ProjectPage method getProjectsMenu.
protected List<MenuItem> getProjectsMenu() {
List<MenuItem> menu = new ArrayList<MenuItem>();
List<ProjectModel> projects = new ArrayList<ProjectModel>();
for (ProjectModel model : getProjectModels()) {
if (!model.isUserProject()) {
projects.add(model);
}
}
int maxProjects = 15;
boolean showAllProjects = projects.size() > maxProjects;
if (showAllProjects) {
// sort by last changed
Collections.sort(projects, new Comparator<ProjectModel>() {
@Override
public int compare(ProjectModel o1, ProjectModel o2) {
return o2.lastChange.compareTo(o1.lastChange);
}
});
// take most recent subset
projects = projects.subList(0, maxProjects);
// sort those by name
Collections.sort(projects);
}
for (ProjectModel project : projects) {
menu.add(new ParameterMenuItem(project.getDisplayName(), "p", project.name));
}
if (showAllProjects) {
menu.add(new MenuDivider());
menu.add(new ParameterMenuItem("all projects"));
}
return menu;
}
use of com.gitblit.models.Menu.MenuDivider in project gitblit by gitblit.
the class RootPage method getRepositoryFilterItems.
protected List<com.gitblit.models.Menu.MenuItem> getRepositoryFilterItems(PageParameters params) {
final UserModel user = GitBlitWebSession.get().getUser();
Set<MenuItem> filters = new LinkedHashSet<MenuItem>();
List<RepositoryModel> repositories = getRepositoryModels();
// accessible repositories by federation set
Map<String, AtomicInteger> setMap = new HashMap<String, AtomicInteger>();
for (RepositoryModel repository : repositories) {
for (String set : repository.federationSets) {
String key = set.toLowerCase();
if (setMap.containsKey(key)) {
setMap.get(key).incrementAndGet();
} else {
setMap.put(key, new AtomicInteger(1));
}
}
}
if (setMap.size() > 0) {
List<String> sets = new ArrayList<String>(setMap.keySet());
Collections.sort(sets);
for (String set : sets) {
filters.add(new ToggleMenuItem(MessageFormat.format("{0} ({1})", set, setMap.get(set).get()), "set", set, params));
}
// divider
filters.add(new MenuDivider());
}
// user's team memberships
if (user != null && user.teams.size() > 0) {
List<TeamModel> teams = new ArrayList<TeamModel>(user.teams);
Collections.sort(teams);
for (TeamModel team : teams) {
filters.add(new ToggleMenuItem(MessageFormat.format("{0} ({1})", team.name, team.repositories.size()), "team", team.name, params));
}
// divider
filters.add(new MenuDivider());
}
// custom filters
String customFilters = app().settings().getString(Keys.web.customFilters, null);
if (!StringUtils.isEmpty(customFilters)) {
boolean addedExpression = false;
List<String> expressions = StringUtils.getStringsFromValue(customFilters, "!!!");
for (String expression : expressions) {
if (!StringUtils.isEmpty(expression)) {
addedExpression = true;
filters.add(new ToggleMenuItem(null, "x", expression, params));
}
}
// if we added any custom expressions, add a divider
if (addedExpression) {
filters.add(new MenuDivider());
}
}
return new ArrayList<MenuItem>(filters);
}
Aggregations