diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1112:aeae4d20f32f

Fix translations of Main Values Facets. flys-artifacts/trunk@2619 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 31 Aug 2011 10:34:45 +0000
parents 82798c992975
children 5b38cdf65307
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Wed Aug 31 10:24:49 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Wed Aug 31 10:34:45 2011 +0000
@@ -29,6 +29,7 @@
 import de.intevation.flys.artifacts.model.WstValueTableFactory;
 
 import de.intevation.flys.artifacts.states.StaticState;
+import de.intevation.flys.artifacts.resources.Resources;
 
 import de.intevation.flys.utils.FLYSUtils;
 
@@ -71,9 +72,34 @@
         Document        data)
     {
         logger.debug("MainValuesArtifact.setup");
+        state = new StaticState("state.mainvalue.static", "state.mainvalue.static");
+        List<Facet> fs = new ArrayList<Facet>();
+        Facet qfacet = new MainValuesQFacet(Resources.getMsg(callMeta,
+                   "facet.discharge_curves.mainvalues.q",
+                   "facet.discharge_curves.mainvalues.q"));
+        Facet wfacet = new MainValuesWFacet(Resources.getMsg(callMeta,
+                   "facet.discharge_curves.mainvalues.w",
+                   "facet.discharge_curves.mainvalues.w"));
+        fs.add(qfacet);
+        fs.add(wfacet);
+        facets.put(state.getID(), fs);
+        spawnState();
         super.setup(identifier, factory, context, callMeta, data);
     }
 
+    protected State spawnState() {
+        state = new StaticState("state.mainvalue.static", "state.mainvalue.static");
+        List<Facet> fs = (List<Facet>) facets.get("state.mainvalue.static");
+        DefaultOutput mainValuesOutput2 = new DefaultOutput(
+                    "computed_discharge_curve",
+                    "output.computed_discharge_curve", "image/png",
+                    fs,
+                    "chart");
+
+        state.getOutputs().add(mainValuesOutput2);
+        return state;
+    }
+
 
     @Override
     protected void initialize(Artifact artifact, Object context, CallMeta meta) {
@@ -94,7 +120,7 @@
     @Override
     protected List<State> getStates(Object context) {
         ArrayList<State> states = new ArrayList<State>();
-        states.add(getState(null,null));
+        states.add(getState());
         return states;
     }
 
@@ -127,33 +153,10 @@
      */
     @Override
     protected State getState(Object context, String stateID) {
-        if (state != null) {
-            
-        }
-        else {
-            state = new StaticState();
-            List<Facet> fs = new ArrayList<Facet>();
-            Facet qfacet = new MainValuesQFacet();
-            Facet wfacet = new MainValuesWFacet();
-            fs.add(qfacet);
-            fs.add(wfacet);
-            // TODO check if facets and outputs already exist.
-            // TODO also check, this is usually done in initialize, too.
-            facets.put(state.getID(), fs);
-            DefaultOutput mainValuesOutput1 = new DefaultOutput(
-                        "discharge_curve", "output.discharge_curve", "image/png",
-                        fs,
-                        "chart");
-            DefaultOutput mainValuesOutput2 = new DefaultOutput(
-                        "computed_discharge_curve",
-                        "output.computed_discharge_curve", "image/png",
-                        fs,
-                        "chart");
-    
-            state.getOutputs().add(mainValuesOutput1);
-            state.getOutputs().add(mainValuesOutput2);
-        }
-        return state;
+        if (state != null)
+            return state;
+        else
+            return spawnState();
     }
 
 

http://dive4elements.wald.intevation.org