1.1 --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sun Jun 21 12:38:15 2020 +0200 1.2 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat Aug 22 16:25:03 2020 +0200 1.3 @@ -202,27 +202,27 @@ 1.4 } 1.5 1.6 1.7 - private static final int BREADCRUMB_LEVEL_ROOT = 0; 1.8 - private static final int BREADCRUMB_LEVEL_PROJECT = 1; 1.9 - private static final int BREADCRUMB_LEVEL_VERSION = 2; 1.10 - private static final int BREADCRUMB_LEVEL_ISSUE_LIST = 3; 1.11 - private static final int BREADCRUMB_LEVEL_ISSUE = 4; 1.12 + private static final int NAV_LEVEL_ROOT = 0; 1.13 + private static final int NAV_LEVEL_PROJECT = 1; 1.14 + private static final int NAV_LEVEL_VERSION = 2; 1.15 + private static final int NAV_LEVEL_ISSUE_LIST = 3; 1.16 + private static final int NAV_LEVEL_ISSUE = 4; 1.17 1.18 /** 1.19 - * Creates the breadcrumb menu. 1.20 + * Creates the navigation menu. 1.21 * 1.22 - * @param level the current active level (0: root, 1: project, 2: version, 3: issue list, 4: issue) 1.23 + * @param level the current active level (0: root, 1: project, 2: version, 3: issue list, 4: issue) 1.24 * @param selection the currently selected objects 1.25 - * @return a dynamic breadcrumb menu trying to display as many levels as possible 1.26 + * @return a dynamic navigation menu trying to display as many levels as possible 1.27 */ 1.28 - private List<MenuEntry> getBreadcrumbs(int level, SessionSelection selection) { 1.29 + private List<MenuEntry> getNavMenu(int level, SessionSelection selection) { 1.30 MenuEntry entry; 1.31 1.32 - final var breadcrumbs = new ArrayList<MenuEntry>(); 1.33 + final var navigation = new ArrayList<MenuEntry>(); 1.34 entry = new MenuEntry(new ResourceKey("localization.lightpit", "menu.projects"), 1.35 "projects/"); 1.36 - breadcrumbs.add(entry); 1.37 - if (level == BREADCRUMB_LEVEL_ROOT) entry.setActive(true); 1.38 + navigation.add(entry); 1.39 + if (level == NAV_LEVEL_ROOT) entry.setActive(true); 1.40 1.41 if (selection.project != null) { 1.42 if (selection.project.getId() < 0) { 1.43 @@ -232,8 +232,8 @@ 1.44 entry = new MenuEntry(selection.project.getName(), 1.45 "projects/view?pid=" + selection.project.getId()); 1.46 } 1.47 - if (level == BREADCRUMB_LEVEL_PROJECT) entry.setActive(true); 1.48 - breadcrumbs.add(entry); 1.49 + if (level == NAV_LEVEL_PROJECT) entry.setActive(true); 1.50 + navigation.add(entry); 1.51 } 1.52 1.53 if (selection.version != null) { 1.54 @@ -244,19 +244,19 @@ 1.55 entry = new MenuEntry(selection.version.getName(), 1.56 "projects/versions/view?vid=" + selection.version.getId()); 1.57 } 1.58 - if (level == BREADCRUMB_LEVEL_VERSION) entry.setActive(true); 1.59 - breadcrumbs.add(entry); 1.60 + if (level == NAV_LEVEL_VERSION) entry.setActive(true); 1.61 + navigation.add(entry); 1.62 } 1.63 1.64 if (selection.project != null) { 1.65 String path = "projects/issues/?pid=" + selection.project.getId(); 1.66 if (selection.version != null) { 1.67 - path += "&vid="+selection.version.getId(); 1.68 + path += "&vid=" + selection.version.getId(); 1.69 } 1.70 entry = new MenuEntry(new ResourceKey("localization.projects", "menu.issues"), 1.71 path); 1.72 - if (level == BREADCRUMB_LEVEL_ISSUE_LIST) entry.setActive(true); 1.73 - breadcrumbs.add(entry); 1.74 + if (level == NAV_LEVEL_ISSUE_LIST) entry.setActive(true); 1.75 + navigation.add(entry); 1.76 } 1.77 1.78 if (selection.issue != null) { 1.79 @@ -268,11 +268,11 @@ 1.80 // TODO: maybe change link to a view rather than directly opening the editor 1.81 "projects/issues/edit?issue=" + selection.issue.getId()); 1.82 } 1.83 - if (level == BREADCRUMB_LEVEL_ISSUE) entry.setActive(true); 1.84 - breadcrumbs.add(entry); 1.85 + if (level == NAV_LEVEL_ISSUE) entry.setActive(true); 1.86 + navigation.add(entry); 1.87 } 1.88 1.89 - return breadcrumbs; 1.90 + return navigation; 1.91 } 1.92 1.93 @RequestMapping(method = HttpMethod.GET) 1.94 @@ -297,7 +297,7 @@ 1.95 setContentPage(req, "projects"); 1.96 setStylesheet(req, "projects"); 1.97 1.98 - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ROOT, sessionSelection)); 1.99 + setNavItems(req, getNavMenu(NAV_LEVEL_ROOT, sessionSelection)); 1.100 1.101 return ResponseType.HTML; 1.102 } 1.103 @@ -308,7 +308,7 @@ 1.104 viewModel.setUsers(dao.getUserDao().list()); 1.105 setViewModel(req, viewModel); 1.106 setContentPage(req, "project-form"); 1.107 - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_PROJECT, selection)); 1.108 + setNavItems(req, getNavMenu(NAV_LEVEL_PROJECT, selection)); 1.109 return viewModel; 1.110 } 1.111 1.112 @@ -377,7 +377,7 @@ 1.113 viewModel.updateVersionInfo(); 1.114 setViewModel(req, viewModel); 1.115 1.116 - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_PROJECT, selection)); 1.117 + setNavItems(req, getNavMenu(NAV_LEVEL_PROJECT, selection)); 1.118 setContentPage(req, "project-details"); 1.119 setStylesheet(req, "projects"); 1.120 1.121 @@ -400,7 +400,7 @@ 1.122 viewModel.setIssues(issues); 1.123 setViewModel(req, viewModel); 1.124 1.125 - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_VERSION, selection)); 1.126 + setNavItems(req, getNavMenu(NAV_LEVEL_VERSION, selection)); 1.127 setContentPage(req, "version"); 1.128 setStylesheet(req, "projects"); 1.129 1.130 @@ -414,7 +414,7 @@ 1.131 } 1.132 setViewModel(req, viewModel); 1.133 setContentPage(req, "version-form"); 1.134 - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_VERSION, selection)); 1.135 + setNavItems(req, getNavMenu(NAV_LEVEL_VERSION, selection)); 1.136 return viewModel; 1.137 } 1.138 1.139 @@ -445,7 +445,7 @@ 1.140 dao.getVersionDao().saveOrUpdate(version); 1.141 1.142 // specifying the pid parameter will purposely reset the session selected version! 1.143 - setRedirectLocation(req, "./projects/view?pid="+version.getProject().getId()); 1.144 + setRedirectLocation(req, "./projects/view?pid=" + version.getProject().getId()); 1.145 setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL); 1.146 } catch (NoSuchElementException | IllegalArgumentException | SQLException ex) { 1.147 LOG.warn("Form validation failure: {}", ex.getMessage()); 1.148 @@ -471,7 +471,7 @@ 1.149 setViewModel(req, viewModel); 1.150 1.151 setContentPage(req, "issue-form"); 1.152 - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ISSUE, selection)); 1.153 + setNavItems(req, getNavMenu(NAV_LEVEL_ISSUE, selection)); 1.154 return viewModel; 1.155 } 1.156 1.157 @@ -494,7 +494,7 @@ 1.158 } 1.159 setViewModel(req, viewModel); 1.160 1.161 - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ISSUE_LIST, selection)); 1.162 + setNavItems(req, getNavMenu(NAV_LEVEL_ISSUE_LIST, selection)); 1.163 setContentPage(req, "issues"); 1.164 setStylesheet(req, "projects"); 1.165 1.166 @@ -534,7 +534,7 @@ 1.167 getParameter(req, Integer[].class, "affected") 1.168 .map(Stream::of) 1.169 .map(stream -> 1.170 - stream.map(Version::new).collect(Collectors.toList()) 1.171 + stream.map(Version::new).collect(Collectors.toList()) 1.172 ).ifPresent(issue::setAffectedVersions); 1.173 getParameter(req, Integer[].class, "resolved") 1.174 .map(Stream::of) 1.175 @@ -544,8 +544,8 @@ 1.176 1.177 dao.getIssueDao().saveOrUpdate(issue); 1.178 1.179 - // specifying the issue parameter keeps the edited issue as breadcrumb 1.180 - setRedirectLocation(req, "./projects/issues/?issue="+issue.getId()); 1.181 + // specifying the issue parameter keeps the edited issue as menu item 1.182 + setRedirectLocation(req, "./projects/issues/?issue=" + issue.getId()); 1.183 setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL); 1.184 } catch (NoSuchElementException | IllegalArgumentException | SQLException ex) { 1.185 // TODO: set request attribute with error text