Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/UserRGDState.java @ 5712:84e02b3f7a4f
Avoid NPE in sediment density factory and return a valid density if no exists.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 17:04:38 +0200 |
parents | 11c853b0854a |
children |
rev | line source |
---|---|
5310
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Element; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.artifacts.CallContext; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.flys.artifacts.FLYSArtifact; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 public class UserRGDState |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 extends DefaultState |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 @Override |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 protected String getUIProvider() { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 return "user_rgd_panel"; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 @Override |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 protected Element createStaticData( |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 FLYSArtifact flys, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 ElementCreator creator, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 CallContext cc, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 String name, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 String value, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 String type |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 ) { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 Element dataElement = creator.create("data"); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 creator.addAttr(dataElement, "name", name, true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 creator.addAttr(dataElement, "type", type, true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 Element itemElement = creator.create("item"); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 creator.addAttr(itemElement, "value", value, true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 creator.addAttr(itemElement, "label", getLabel(cc, value), true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 dataElement.appendChild(itemElement); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 return dataElement; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 public static String getLabel(CallContext cc, String value) { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 return value; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 } |