Search in sources :

Example 1 with ParameterMenuItem

use of com.gitblit.models.Menu.ParameterMenuItem in project gitblit by gitblit.

the class DashboardPage method addDropDownMenus.

@Override
protected void addDropDownMenus(List<NavLink> navLinks) {
    PageParameters params = getPageParameters();
    DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", GitBlitWebApp.get().getHomePage());
    // preserve repository filter option on time choices
    menu.menuItems.addAll(getTimeFilterItems(params));
    if (menu.menuItems.size() > 0) {
        // Reset Filter
        menu.menuItems.add(new ParameterMenuItem(getString("gb.reset")));
    }
    navLinks.add(menu);
}
Also used : DropDownPageMenuNavLink(com.gitblit.models.NavLink.DropDownPageMenuNavLink) PageParameters(org.apache.wicket.PageParameters) ParameterMenuItem(com.gitblit.models.Menu.ParameterMenuItem)

Example 2 with ParameterMenuItem

use of com.gitblit.models.Menu.ParameterMenuItem 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;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MenuDivider(com.gitblit.models.Menu.MenuDivider) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) PageLinkMenuItem(com.gitblit.models.Menu.PageLinkMenuItem) ParameterMenuItem(com.gitblit.models.Menu.ParameterMenuItem) ExternalLinkMenuItem(com.gitblit.models.Menu.ExternalLinkMenuItem) MenuItem(com.gitblit.models.Menu.MenuItem) ToggleMenuItem(com.gitblit.models.Menu.ToggleMenuItem) PageParameters(org.apache.wicket.PageParameters) ParameterMenuItem(com.gitblit.models.Menu.ParameterMenuItem)

Example 3 with ParameterMenuItem

use of com.gitblit.models.Menu.ParameterMenuItem 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;
}
Also used : MenuDivider(com.gitblit.models.Menu.MenuDivider) ArrayList(java.util.ArrayList) MenuItem(com.gitblit.models.Menu.MenuItem) ParameterMenuItem(com.gitblit.models.Menu.ParameterMenuItem) ProjectModel(com.gitblit.models.ProjectModel) ParameterMenuItem(com.gitblit.models.Menu.ParameterMenuItem)

Example 4 with ParameterMenuItem

use of com.gitblit.models.Menu.ParameterMenuItem in project gitblit by gitblit.

the class ProjectsPage method addDropDownMenus.

@Override
protected void addDropDownMenus(List<NavLink> navLinks) {
    PageParameters params = getPageParameters();
    DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", ProjectsPage.class);
    // preserve time filter option on repository choices
    menu.menuItems.addAll(getRepositoryFilterItems(params));
    // preserve repository filter option on time choices
    menu.menuItems.addAll(getTimeFilterItems(params));
    if (menu.menuItems.size() > 0) {
        // Reset Filter
        menu.menuItems.add(new ParameterMenuItem(getString("gb.reset")));
    }
    navLinks.add(menu);
}
Also used : DropDownPageMenuNavLink(com.gitblit.models.NavLink.DropDownPageMenuNavLink) PageParameters(org.apache.wicket.PageParameters) ParameterMenuItem(com.gitblit.models.Menu.ParameterMenuItem)

Example 5 with ParameterMenuItem

use of com.gitblit.models.Menu.ParameterMenuItem in project gitblit by gitblit.

the class RepositoriesPage method addDropDownMenus.

@Override
protected void addDropDownMenus(List<NavLink> navLinks) {
    PageParameters params = getPageParameters();
    DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", RepositoriesPage.class);
    // preserve time filter option on repository choices
    menu.menuItems.addAll(getRepositoryFilterItems(params));
    // preserve repository filter option on time choices
    menu.menuItems.addAll(getTimeFilterItems(params));
    if (menu.menuItems.size() > 0) {
        // Reset Filter
        menu.menuItems.add(new ParameterMenuItem(getString("gb.reset")));
    }
    navLinks.add(menu);
}
Also used : DropDownPageMenuNavLink(com.gitblit.models.NavLink.DropDownPageMenuNavLink) PageParameters(org.apache.wicket.PageParameters) ParameterMenuItem(com.gitblit.models.Menu.ParameterMenuItem)

Aggregations

ParameterMenuItem (com.gitblit.models.Menu.ParameterMenuItem)8 PageParameters (org.apache.wicket.PageParameters)7 DropDownPageMenuNavLink (com.gitblit.models.NavLink.DropDownPageMenuNavLink)6 MenuDivider (com.gitblit.models.Menu.MenuDivider)2 MenuItem (com.gitblit.models.Menu.MenuItem)2 ArrayList (java.util.ArrayList)2 ExternalLinkMenuItem (com.gitblit.models.Menu.ExternalLinkMenuItem)1 PageLinkMenuItem (com.gitblit.models.Menu.PageLinkMenuItem)1 ToggleMenuItem (com.gitblit.models.Menu.ToggleMenuItem)1 ProjectModel (com.gitblit.models.ProjectModel)1 TreeSet (java.util.TreeSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1