Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java @ 8870:c26fb37899ca
Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
Also using now the localization info from the server instead of localizing the modules again on the client side.
author | gernotbelger |
---|---|
date | Wed, 07 Feb 2018 11:59:13 +0100 |
parents | 5e38e2924c07 |
children | ef5754ba5573 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Wed Feb 07 11:52:04 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Wed Feb 07 11:59:13 2018 +0100 @@ -617,30 +617,34 @@ NodeList modulenodes = (NodeList) XMLUtils.xpath( cfg, XPATH_MODULES, XPathConstants.NODESET); - int num = modulenodes != null ? modulenodes.getLength() : 0; - ArrayList<Module> modules = new ArrayList<Module>(num); + final int num = modulenodes != null ? modulenodes.getLength() : 0; + + final List<Module> modules = new ArrayList<>(num); for (int i = 0; i < num; i++) { - Element e = (Element) modulenodes.item(i); - String modulename = e.getAttribute("name"); - String attrselected = e.getAttribute("selected"); - boolean selected = attrselected == null ? false : - attrselected.equalsIgnoreCase("true"); + final Element e = (Element) modulenodes.item(i); + final String modulename = e.getAttribute("name"); + final String attrselected = e.getAttribute("selected"); + final boolean selected = Boolean.parseBoolean(attrselected); + final String group = e.getAttribute("group"); + log.debug("Loaded module " + modulename); - NodeList children = e.getChildNodes(); - List<String> rivers = new ArrayList<String>(children.getLength()); + + final NodeList children = e.getChildNodes(); + final List<String> rivers = new ArrayList<>(children.getLength()); for (int j = 0; j < children.getLength(); j++) { if (children.item(j).getNodeType() != Node.ELEMENT_NODE) { continue; } - Element ce = (Element)children.item(j); + + final Element ce = (Element)children.item(j); if (ce.hasAttribute("uuid")) { rivers.add(ce.getAttribute("uuid")); } else if (ce.hasAttribute("name")) { - List<River> allRivers = RiverFactory.getRivers(); - String name = ce.getAttribute("name"); - for (River r: allRivers) { + final List<River> allRivers = RiverFactory.getRivers(); + final String name = ce.getAttribute("name"); + for (final River r: allRivers) { if (name.equals(r.getName())) { rivers.add(r.getModelUuid()); break; @@ -648,7 +652,7 @@ } } } - modules.add(new Module(modulename, selected, rivers)); + modules.add(new Module(modulename, selected, group, rivers)); } context.put(RiverContext.MODULES, modules); }