src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java

changeset 96
b7b685f31e39
parent 88
1438e5a22c55
child 97
602f75801644
--- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Sun Jun 21 12:38:15 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Sat Aug 22 16:25:03 2020 +0200
@@ -202,27 +202,27 @@
     }
 
 
-    private static final int BREADCRUMB_LEVEL_ROOT = 0;
-    private static final int BREADCRUMB_LEVEL_PROJECT = 1;
-    private static final int BREADCRUMB_LEVEL_VERSION = 2;
-    private static final int BREADCRUMB_LEVEL_ISSUE_LIST = 3;
-    private static final int BREADCRUMB_LEVEL_ISSUE = 4;
+    private static final int NAV_LEVEL_ROOT = 0;
+    private static final int NAV_LEVEL_PROJECT = 1;
+    private static final int NAV_LEVEL_VERSION = 2;
+    private static final int NAV_LEVEL_ISSUE_LIST = 3;
+    private static final int NAV_LEVEL_ISSUE = 4;
 
     /**
-     * Creates the breadcrumb menu.
+     * Creates the navigation menu.
      *
-     * @param level           the current active level (0: root, 1: project, 2: version, 3: issue list, 4: issue)
+     * @param level     the current active level (0: root, 1: project, 2: version, 3: issue list, 4: issue)
      * @param selection the currently selected objects
-     * @return a dynamic breadcrumb menu trying to display as many levels as possible
+     * @return a dynamic navigation menu trying to display as many levels as possible
      */
-    private List<MenuEntry> getBreadcrumbs(int level, SessionSelection selection) {
+    private List<MenuEntry> getNavMenu(int level, SessionSelection selection) {
         MenuEntry entry;
 
-        final var breadcrumbs = new ArrayList<MenuEntry>();
+        final var navigation = new ArrayList<MenuEntry>();
         entry = new MenuEntry(new ResourceKey("localization.lightpit", "menu.projects"),
                 "projects/");
-        breadcrumbs.add(entry);
-        if (level == BREADCRUMB_LEVEL_ROOT) entry.setActive(true);
+        navigation.add(entry);
+        if (level == NAV_LEVEL_ROOT) entry.setActive(true);
 
         if (selection.project != null) {
             if (selection.project.getId() < 0) {
@@ -232,8 +232,8 @@
                 entry = new MenuEntry(selection.project.getName(),
                         "projects/view?pid=" + selection.project.getId());
             }
-            if (level == BREADCRUMB_LEVEL_PROJECT) entry.setActive(true);
-            breadcrumbs.add(entry);
+            if (level == NAV_LEVEL_PROJECT) entry.setActive(true);
+            navigation.add(entry);
         }
 
         if (selection.version != null) {
@@ -244,19 +244,19 @@
                 entry = new MenuEntry(selection.version.getName(),
                         "projects/versions/view?vid=" + selection.version.getId());
             }
-            if (level == BREADCRUMB_LEVEL_VERSION) entry.setActive(true);
-            breadcrumbs.add(entry);
+            if (level == NAV_LEVEL_VERSION) entry.setActive(true);
+            navigation.add(entry);
         }
 
         if (selection.project != null) {
             String path = "projects/issues/?pid=" + selection.project.getId();
             if (selection.version != null) {
-                path += "&vid="+selection.version.getId();
+                path += "&vid=" + selection.version.getId();
             }
             entry = new MenuEntry(new ResourceKey("localization.projects", "menu.issues"),
                     path);
-            if (level == BREADCRUMB_LEVEL_ISSUE_LIST) entry.setActive(true);
-            breadcrumbs.add(entry);
+            if (level == NAV_LEVEL_ISSUE_LIST) entry.setActive(true);
+            navigation.add(entry);
         }
 
         if (selection.issue != null) {
@@ -268,11 +268,11 @@
                         // TODO: maybe change link to a view rather than directly opening the editor
                         "projects/issues/edit?issue=" + selection.issue.getId());
             }
-            if (level == BREADCRUMB_LEVEL_ISSUE) entry.setActive(true);
-            breadcrumbs.add(entry);
+            if (level == NAV_LEVEL_ISSUE) entry.setActive(true);
+            navigation.add(entry);
         }
 
-        return breadcrumbs;
+        return navigation;
     }
 
     @RequestMapping(method = HttpMethod.GET)
@@ -297,7 +297,7 @@
         setContentPage(req, "projects");
         setStylesheet(req, "projects");
 
-        setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ROOT, sessionSelection));
+        setNavItems(req, getNavMenu(NAV_LEVEL_ROOT, sessionSelection));
 
         return ResponseType.HTML;
     }
@@ -308,7 +308,7 @@
         viewModel.setUsers(dao.getUserDao().list());
         setViewModel(req, viewModel);
         setContentPage(req, "project-form");
-        setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_PROJECT, selection));
+        setNavItems(req, getNavMenu(NAV_LEVEL_PROJECT, selection));
         return viewModel;
     }
 
@@ -377,7 +377,7 @@
         viewModel.updateVersionInfo();
         setViewModel(req, viewModel);
 
-        setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_PROJECT, selection));
+        setNavItems(req, getNavMenu(NAV_LEVEL_PROJECT, selection));
         setContentPage(req, "project-details");
         setStylesheet(req, "projects");
 
@@ -400,7 +400,7 @@
         viewModel.setIssues(issues);
         setViewModel(req, viewModel);
 
-        setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_VERSION, selection));
+        setNavItems(req, getNavMenu(NAV_LEVEL_VERSION, selection));
         setContentPage(req, "version");
         setStylesheet(req, "projects");
 
@@ -414,7 +414,7 @@
         }
         setViewModel(req, viewModel);
         setContentPage(req, "version-form");
-        setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_VERSION, selection));
+        setNavItems(req, getNavMenu(NAV_LEVEL_VERSION, selection));
         return viewModel;
     }
 
@@ -445,7 +445,7 @@
             dao.getVersionDao().saveOrUpdate(version);
 
             // specifying the pid parameter will purposely reset the session selected version!
-            setRedirectLocation(req, "./projects/view?pid="+version.getProject().getId());
+            setRedirectLocation(req, "./projects/view?pid=" + version.getProject().getId());
             setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
         } catch (NoSuchElementException | IllegalArgumentException | SQLException ex) {
             LOG.warn("Form validation failure: {}", ex.getMessage());
@@ -471,7 +471,7 @@
         setViewModel(req, viewModel);
 
         setContentPage(req, "issue-form");
-        setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ISSUE, selection));
+        setNavItems(req, getNavMenu(NAV_LEVEL_ISSUE, selection));
         return viewModel;
     }
 
@@ -494,7 +494,7 @@
         }
         setViewModel(req, viewModel);
 
-        setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ISSUE_LIST, selection));
+        setNavItems(req, getNavMenu(NAV_LEVEL_ISSUE_LIST, selection));
         setContentPage(req, "issues");
         setStylesheet(req, "projects");
 
@@ -534,7 +534,7 @@
             getParameter(req, Integer[].class, "affected")
                     .map(Stream::of)
                     .map(stream ->
-                        stream.map(Version::new).collect(Collectors.toList())
+                            stream.map(Version::new).collect(Collectors.toList())
                     ).ifPresent(issue::setAffectedVersions);
             getParameter(req, Integer[].class, "resolved")
                     .map(Stream::of)
@@ -544,8 +544,8 @@
 
             dao.getIssueDao().saveOrUpdate(issue);
 
-            // specifying the issue parameter keeps the edited issue as breadcrumb
-            setRedirectLocation(req, "./projects/issues/?issue="+issue.getId());
+            // specifying the issue parameter keeps the edited issue as menu item
+            setRedirectLocation(req, "./projects/issues/?issue=" + issue.getId());
             setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
         } catch (NoSuchElementException | IllegalArgumentException | SQLException ex) {
             // TODO: set request attribute with error text

mercurial