comparison flys-client/src/main/java/de/intevation/flys/client/shared/model/ThemeList.java @ 528:39d9291513cc

Connected the actions in the navigation panel with the theme list in the ChartThemePanel - themes can be moved now. flys-client/trunk@2009 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 26 May 2011 13:53:36 +0000
parents 96e60e0a4345
children f6fbfdc813f0
comparison
equal deleted inserted replaced
527:902609b5cc79 528:39d9291513cc
61 public void addTheme(Theme theme) { 61 public void addTheme(Theme theme) {
62 if (theme != null) { 62 if (theme != null) {
63 themes.add(theme); 63 themes.add(theme);
64 } 64 }
65 } 65 }
66
67
68 /**
69 * Modifies the order of themes in this list and the position of the
70 * <i>theme</i> itself.
71 *
72 * @param theme The theme which position has to be modified.
73 * @param newPos The new position.
74 */
75 public void setThemePosition(Theme theme, int newPos) {
76 int count = getThemeCount();
77 int oldPos = theme.getPosition();
78
79 if (newPos == oldPos || newPos > count || newPos < 1) {
80 return;
81 }
82
83 boolean moveUp = newPos < oldPos;
84
85 for (Theme aTheme: themes) {
86 int tmpPos = aTheme.getPosition();
87
88 if (theme.equals(aTheme)) {
89 theme.setPosition(newPos);
90 }
91 else if (tmpPos >= newPos && tmpPos < oldPos && moveUp) {
92 aTheme.setPosition(tmpPos+1);
93 }
94 else if (tmpPos <= newPos && tmpPos > oldPos && !moveUp) {
95 aTheme.setPosition(tmpPos-1);
96 }
97 }
98 }
66 } 99 }
67 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org