Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/shared/model/ThemeList.java @ 3719:e82acd5c86f7
Merged revisions 5495-5496,5509,5514-5515,5521-5526 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-client/trunk
........
r5495 | ingo | 2012-09-17 14:55:09 +0200 (Mo, 17 Sep 2012) | 1 line
Added missing i18n strings for minfo state description.
........
r5496 | ingo | 2012-09-17 15:47:43 +0200 (Mo, 17 Sep 2012) | 1 line
Tagged 'flys-client' as 2.9.1
........
r5509 | teichmann | 2012-09-18 17:54:37 +0200 (Di, 18 Sep 2012) | 1 line
Removed trailing whitespace.
........
r5514 | bricks | 2012-09-19 09:56:42 +0200 (Mi, 19 Sep 2012) | 2 lines
Add missing Changelog entry for r5472
........
r5515 | bricks | 2012-09-19 09:59:35 +0200 (Mi, 19 Sep 2012) | 2 lines
Implement a scrolling gauge info tree
........
r5521 | bricks | 2012-09-19 14:41:48 +0200 (Mi, 19 Sep 2012) | 2 lines
Add station info to the gauges
........
r5522 | bricks | 2012-09-19 14:43:43 +0200 (Mi, 19 Sep 2012) | 2 lines
Improve the handling of the GaugePanel in the ParameterList
........
r5523 | bricks | 2012-09-19 14:51:02 +0200 (Mi, 19 Sep 2012) | 4 lines
Improve the GaugePanel
Be locale aware and only load the gauge info if the river name changes.
........
r5524 | bricks | 2012-09-19 15:14:46 +0200 (Mi, 19 Sep 2012) | 5 lines
Fix a NullPointerException
When iterating over a list it must be checked if the reference to the list is
valid.
........
r5525 | bricks | 2012-09-19 15:16:24 +0200 (Mi, 19 Sep 2012) | 2 lines
Don't display the GaugePanel if no river is selected
........
r5526 | bricks | 2012-09-19 15:18:36 +0200 (Mi, 19 Sep 2012) | 2 lines
Use the wstunit from the river as unit for the Pegelnullpunkt
........
flys-client/tags/2.9.1@5528 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 19 Sep 2012 14:42:48 +0000 |
parents | e0f4ea518d59 |
children |
line wrap: on
line source
package de.intevation.flys.client.shared.model; import java.io.Serializable; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; /** * Data Model for list of themes (shown facets). * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ThemeList implements Serializable { public List<Theme> themes; public ThemeList() { } public ThemeList(List<Theme> themes) { this.themes = themes; } public List<Theme> getThemes() { return themes; } public List<Theme> getActiveThemes() { List<Theme> active = new ArrayList<Theme>(); List<Theme> all = getThemes(); if (all == null || all.isEmpty()) { return active; } for (Theme theme: all) { if (theme.getActive() == 1) { active.add(theme); } } return active; } public int getThemeCount() { return themes.size(); } /** * Returns (first) theme of which the artifact has given uuid, null if none * found. * @param uuid Artifacts identifier for which to search theme. * @return theme of which getArtifact() equals given uuid. */ public Theme getTheme(String uuid) { for (Theme theme: themes) { if (theme.getArtifact().equals(uuid)) { return theme; } } return null; } /** * Returns a theme at a specific position. <b>NOTE: Themes start at position * 1. So, take care in loops, that might start at index 0!</b> * * @param pos The position of the desired theme. * * @return a theme. */ public Theme getThemeAt(int pos) { for (Theme theme: themes) { if (theme.getPosition() == pos) { return theme; } } return null; } public void removeTheme(Theme theme) { if (theme != null) { themes.remove(theme); } } public void addTheme(Theme theme) { if (theme != null) { themes.add(theme); } } /** * Modifies the order of themes in this list and the position of the * <i>theme</i> itself. * * @param theme The theme which position has to be modified. * @param newPos The new position. */ public void setThemePosition(Theme theme, int newPos) { int count = getThemeCount(); int oldPos = theme.getPosition(); if (newPos == oldPos || newPos > count || newPos < 1) { return; } boolean moveUp = newPos < oldPos; for (Theme aTheme: themes) { int tmpPos = aTheme.getPosition(); if (theme.equals(aTheme)) { theme.setPosition(newPos); } else if (tmpPos >= newPos && tmpPos < oldPos && moveUp) { aTheme.setPosition(tmpPos+1); } else if (tmpPos <= newPos && tmpPos > oldPos && !moveUp) { aTheme.setPosition(tmpPos-1); } } } /** * Create a map from index to description of facets that have a given name. * Only visible facets are taken into account. * @param facetName name to match against facets whose info to put in map. * @return mapping of index to description */ public LinkedHashMap<String, String> toMapIndexDescription(String facetName) { int count = getThemeCount(); LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(); for (int i = 0; i <= count; i++) { Theme theme = getThemeAt(i + 1); if (theme == null || theme.getVisible() == 0) { continue; } if (theme.getFacet().equals(facetName)) { valueMap.put(String.valueOf(theme.getIndex()), theme.getDescription()); } } return valueMap; } public LinkedHashMap<String, String> toMapArtifactUUIDDescription(String facetName ) { int count = getThemeCount(); LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(); for (int i = 0; i <= count; i++) { Theme theme = getThemeAt(i + 1); if (theme == null || theme.getVisible() == 0) { continue; } if (theme.getFacet().equals(facetName)) { valueMap.put(theme.getArtifact(), theme.getDescription()); } } return valueMap; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :