Mercurial > dive4elements > river
changeset 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 | b96ce07ba56c |
children | 5b38cdf65307 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java |
diffstat | 5 files changed, 60 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed Aug 31 10:24:49 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Aug 31 10:34:45 2011 +0000 @@ -1,3 +1,18 @@ +2011-08-31 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Fix translations of Main Values Facets. + + * src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java: + Do acrobatics to keep state transient but get translated title. + + * src/main/java/de/intevation/flys/artifacts/MainValuesQFacet.java, + src/main/java/de/intevation/flys/artifacts/MainValuesWFacet.java: + Changed constructor to get description (which is then already be translated) + dynamically, adjust deepCopy. + + * src/main/java/de/intevation/flys/states/StaticState.java: + Adjust constructor accordingly. + 2011-08-31 Felix Wolfsteller <felix.wolfsteller@intevation.de> Add sceleton for CrossSection outs. @@ -5,7 +20,7 @@ * doc/conf/artifacts/winfo.xml: Added new output mode to respective state of winfo artifact configuration. - * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java + * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java: Add new Dummy-Facet in state. * doc/conf/conf.xml:
--- 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(); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java Wed Aug 31 10:24:49 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java Wed Aug 31 10:34:45 2011 +0000 @@ -5,6 +5,7 @@ import de.intevation.artifactdatabase.state.DefaultFacet; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.MainValuesArtifact; +import de.intevation.flys.artifacts.resources.Resources; /** * Facet to show Main Q Values. @@ -14,9 +15,8 @@ implements FacetTypes { /** Trivial Constructor. */ - public MainValuesQFacet() { - //Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION)); - description = "facet.discharge_curves.mainvalues.description"; + public MainValuesQFacet(String description) { + this.description = description; name = COMPUTED_DISCHARGE_MAINVALUES_Q; index = 0; } @@ -43,7 +43,7 @@ */ @Override public MainValuesQFacet deepCopy() { - MainValuesQFacet copy = new MainValuesQFacet(); + MainValuesQFacet copy = new MainValuesQFacet(description); copy.set(this); return copy; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java Wed Aug 31 10:24:49 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MainValuesWFacet.java Wed Aug 31 10:34:45 2011 +0000 @@ -14,9 +14,8 @@ implements FacetTypes { /** Trivial Constructor. */ - public MainValuesWFacet() { - //Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION)); - description = "facet.discharge_curves.mainvalues.description"; + public MainValuesWFacet(String description) { + this.description = description; name = COMPUTED_DISCHARGE_MAINVALUES_W; index = 0; } @@ -43,7 +42,7 @@ */ @Override public MainValuesWFacet deepCopy() { - MainValuesWFacet copy = new MainValuesWFacet(); + MainValuesWFacet copy = new MainValuesWFacet(description); copy.set(this); return copy; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java Wed Aug 31 10:24:49 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java Wed Aug 31 10:34:45 2011 +0000 @@ -13,4 +13,10 @@ { /** The logger that is used in this state. */ private static final Logger logger = Logger.getLogger(StaticState.class); + + public StaticState(String id, String description) { + super(); + setID(id); + setDescription(description); + } }