src/main/java/de/uapcore/lightpit/ModuleManager.java

Sat, 16 May 2020 13:29:44 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 16 May 2020 13:29:44 +0200
changeset 51
dd0a45ae25d7
parent 45
cc7f082c5ef3
child 57
1262b5433644
permissions
-rw-r--r--

adds the possibility to add users / developers

6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
3 *
24
8137ec335416 updates copyright header
Mike Becker <universe@uap-core.de>
parents: 22
diff changeset
4 * Copyright 2018 Mike Becker. All rights reserved.
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
5 *
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
27 *
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 */
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 package de.uapcore.lightpit;
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30
30
fb30f7b78f9b moves DAO classes to different package
Mike Becker <universe@uap-core.de>
parents: 29
diff changeset
31 import org.slf4j.Logger;
fb30f7b78f9b moves DAO classes to different package
Mike Becker <universe@uap-core.de>
parents: 29
diff changeset
32 import org.slf4j.LoggerFactory;
fb30f7b78f9b moves DAO classes to different package
Mike Becker <universe@uap-core.de>
parents: 29
diff changeset
33
7
598670d5b0b8 core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
34 import javax.servlet.Registration;
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 import javax.servlet.ServletContext;
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 import javax.servlet.ServletContextEvent;
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 import javax.servlet.ServletContextListener;
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 import javax.servlet.annotation.WebListener;
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
39 import java.util.ArrayList;
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
40 import java.util.Collections;
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
41 import java.util.List;
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
42 import java.util.Optional;
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 /**
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 * Scans registered servlets for LightPIT modules.
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 */
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 @WebListener
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
48 public final class ModuleManager implements ServletContextListener {
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
49
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
50 private static final Logger LOG = LoggerFactory.getLogger(ModuleManager.class);
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
51
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 /**
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 * The attribute name in the servlet context under which an instance of this class can be found.
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 */
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 public static final String SC_ATTR_NAME = ModuleManager.class.getName();
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
56 private ServletContext sc;
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
57
20
bd1a76c91d5b module synchronization with database
Mike Becker <universe@uap-core.de>
parents: 18
diff changeset
58 /**
27
1f2a96efa69f removes caching of main menu
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
59 * Maps class names to module information.
1f2a96efa69f removes caching of main menu
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
60 */
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
61 private final List<LightPITModule> registeredModules = new ArrayList<>();
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
62
27
1f2a96efa69f removes caching of main menu
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
63 /**
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
64 * Contains the menu entries for the loaded modules.
20
bd1a76c91d5b module synchronization with database
Mike Becker <universe@uap-core.de>
parents: 18
diff changeset
65 */
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
66 private final List<MenuEntry> mainMenu = new ArrayList<>();
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
67
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 @Override
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 public void contextInitialized(ServletContextEvent sce) {
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 sc = sce.getServletContext();
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 reloadAll();
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 sc.setAttribute(SC_ATTR_NAME, this);
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 LOG.info("Module manager injected into ServletContext.");
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 }
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 @Override
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 public void contextDestroyed(ServletContextEvent sce) {
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 unloadAll();
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 }
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
80
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
81 private Optional<LightPITModule> getModuleInfo(Registration reg) {
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 try {
33
fd8c40ff78c3 fixes several warnings
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
83 final Class<?> scclass = Class.forName(reg.getClassName());
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
84
9
20a9b2bc9063 makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents: 8
diff changeset
85 final boolean lpservlet = AbstractLightPITServlet.class.isAssignableFrom(scclass);
7
598670d5b0b8 core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
86 final boolean lpmodule = scclass.isAnnotationPresent(LightPITModule.class);
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
87
7
598670d5b0b8 core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
88 if (lpservlet && !lpmodule) {
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
89 LOG.warn(
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
90 "{} is a LightPIT Servlet but is missing the module annotation.",
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
91 reg.getClassName()
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
92 );
7
598670d5b0b8 core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
93 } else if (!lpservlet && lpmodule) {
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
94 LOG.warn(
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
95 "{} is annotated as a LightPIT Module but does not extend {}.",
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
96 reg.getClassName(),
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
97 AbstractLightPITServlet.class.getSimpleName()
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
98 );
7
598670d5b0b8 core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
99 }
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
100
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
101 if (lpservlet && lpmodule) {
33
fd8c40ff78c3 fixes several warnings
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
102 final LightPITModule moduleInfo = scclass.getAnnotation(LightPITModule.class);
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
103 return Optional.of(moduleInfo);
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
104 } else {
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
105 return Optional.empty();
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
106 }
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 } catch (ClassNotFoundException ex) {
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
108 LOG.error(
9
20a9b2bc9063 makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents: 8
diff changeset
109 "Servlet registration refers to class {} which cannot be found by the class loader (Reason: {})",
20a9b2bc9063 makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents: 8
diff changeset
110 reg.getClassName(),
20a9b2bc9063 makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents: 8
diff changeset
111 ex.getMessage()
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
112 );
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
113 return Optional.empty();
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
114 }
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 }
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
116
7
598670d5b0b8 core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
117 private void handleServletRegistration(String name, Registration reg) {
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
118 final Optional<LightPITModule> moduleInfo = getModuleInfo(reg);
20
bd1a76c91d5b module synchronization with database
Mike Becker <universe@uap-core.de>
parents: 18
diff changeset
119 if (moduleInfo.isPresent()) {
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
120 registeredModules.add(moduleInfo.get());
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
121 LOG.info("Module detected: {}", name);
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 } else {
8
2dfdb79b5344 adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
123 LOG.debug("Servlet {} is no module, skipping.", name);
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124 }
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 }
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
126
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 /**
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 * Scans for modules and reloads them all.
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 */
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 public void reloadAll() {
21
b213fef2539e adds first part of a module manager UI
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
131 registeredModules.clear();
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132 sc.getServletRegistrations().forEach(this::handleServletRegistration);
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
133 createMainMenu();
30
fb30f7b78f9b moves DAO classes to different package
Mike Becker <universe@uap-core.de>
parents: 29
diff changeset
134
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
135 LOG.info("Modules loaded.");
20
bd1a76c91d5b module synchronization with database
Mike Becker <universe@uap-core.de>
parents: 18
diff changeset
136 }
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
137
20
bd1a76c91d5b module synchronization with database
Mike Becker <universe@uap-core.de>
parents: 18
diff changeset
138 /**
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 * Unloads all found modules.
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140 */
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141 public void unloadAll() {
21
b213fef2539e adds first part of a module manager UI
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
142 registeredModules.clear();
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 LOG.info("All modules unloaded.");
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144 }
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
145
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
146 /**
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
147 * Populates the main menu based on the registered modules.
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
148 */
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
149 private void createMainMenu() {
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
150 mainMenu.clear();
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
151 registeredModules
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
152 .stream()
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
153 .filter(mod -> !mod.systemModule())
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
154 .map(mod -> new MenuEntry(
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
155 new ResourceKey(
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
156 mod.bundleBaseName(),
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
157 mod.menuKey()),
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
158 mod.modulePath(),
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
159 mod.defaultPriority()))
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
160 .sorted()
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
161 .forEachOrdered(mainMenu::add);
10
89e3e6e28b69 implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
162 }
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
163
21
b213fef2539e adds first part of a module manager UI
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
164 /**
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
165 * Returns the main menu.
34
824d4042c857 cleanup and simplification of database access layer
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
166 *
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
167 * @return a list of menu items
21
b213fef2539e adds first part of a module manager UI
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
168 */
36
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
169 public List<MenuEntry> getMainMenu() {
0f4f8f255c32 removes features that are not (and probably will not) used anyway
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
170 return Collections.unmodifiableList(mainMenu);
21
b213fef2539e adds first part of a module manager UI
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
171 }
6
da61a1646eba adds module manager
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 }

mercurial