Mercurial > dive4elements > river
changeset 4211:47b7325eafeb
merged
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 22 Oct 2012 17:07:02 +0200 |
parents | e47559908acc (current diff) 0dd8963cec9c (diff) |
children | fbaba8e1a3a2 |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java |
diffstat | 61 files changed, 1440 insertions(+), 288 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/artifacts/gaugedischargecurve.xml Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/doc/conf/artifacts/gaugedischargecurve.xml Mon Oct 22 17:07:02 2012 +0200 @@ -3,7 +3,7 @@ <states> <state id="state.gaugedischargecurve.static" description="state.gaugedischargecurve.static" state="de.intevation.flys.artifacts.states.StaticState"> <data name="river" type="String" /> - <data name="reference_gauge" type="Double" /> + <data name="reference_gauge" type="Long" /> <data name="gauge_name" type="String" /> <outputmodes> <outputmode name="discharge_curve" description="output.discharge_curve" type="chart"> @@ -11,6 +11,11 @@ <facet name="gauge_discharge_curve"/> </facets> </outputmode> + <outputmode name="computed_dischargecurve_at_export" description="output.computed_dischargecurve_at_export" mime-type="text/plain" type="export"> + <facets> + <facet name="gauge_discharge_curve_at_export" description="facet.gauge_discharge_curve_export.at"/> + </facets> + </outputmode> </outputmodes> </state> </states>
--- a/flys-artifacts/doc/conf/conf.xml Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/doc/conf/conf.xml Mon Oct 22 17:07:02 2012 +0200 @@ -336,6 +336,7 @@ <output-generator name="fix_report">de.intevation.flys.exports.ReportGenerator</output-generator> <!-- AT exporter. --> <output-generator name="computed_dischargecurve_at_export">de.intevation.flys.exports.ATExporter</output-generator> + <output-generator name="gauge_discharge_curve_at_export">de.intevation.flys.exports.ATExporter</output-generator> <output-generator name="fix_wq_curve_at_export">de.intevation.flys.exports.fixings.FixATExport</output-generator> </output-generators>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeCurveArtifact.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeCurveArtifact.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -42,6 +43,17 @@ public static final String NAME = "gaugedischargecurve"; public static final String STATIC_STATE_NAME = "state.gaugedischargecurve.static"; public static final String UIPROVIDER = "gauge_discharge_curve"; + public static final String GAUGE_DISCHARGE_CURVE_FACET = + "gauge_discharge_curve"; + public static final String GAUGE_DISCHARGE_CURVE_AT_EXPORT_FACET = + "gauge_discharge_curve_at_export"; + public static final String GAUGE_DISCHARGE_CURVE_OUT = + "discharge_curve"; + public static final String GAUGE_DISCHARGE_CURVE_AT_EXPORT_OUT = + "computed_dischargecurve_at_export"; + + private Facet atexportfacet; + private Facet curvefacet; /** * Setup initializes the data by extracting the river and gauge from @@ -74,12 +86,17 @@ Resources.getMsg(callmeta, "facet.gauge_discharge_curve.reference_gauge", "Gauge official number"), - "Double", gaugeref)); + "Long", gaugeref)); Gauge gauge = FLYSUtils.getReferenceGauge(this); String gaugename = ""; + Double gaugelocation = null; if (gauge != null) { gaugename = gauge.getName(); + BigDecimal station = gauge.getStation(); + if (station != null) { + gaugelocation = station.doubleValue(); + } } addData("gauge_name", new DefaultStateData("gauge_name", @@ -88,16 +105,33 @@ "Name of the gauge"), "String", gaugename)); + if (gaugelocation != null) { + addData("ld_locations", new DefaultStateData("ld_locations", + Resources.getMsg(callmeta, + "facet.gauge_discharge_curve.gauge_location", + "Location of the gauge"), + "Double", gaugelocation.toString())); + } + String description = Resources.format(callmeta, "facet.gauge_discharge_curve.description", "Discharge curve on gauge", rivername, gaugename); - Facet gfacet = new GaugeDischargeCurveFacet(description); + List<Facet> fs = new ArrayList<Facet>(2); + curvefacet = new GaugeDischargeCurveFacet( + GAUGE_DISCHARGE_CURVE_FACET, description); + fs.add(curvefacet); - List<Facet> fs = new ArrayList<Facet>(1); - fs.add(gfacet); + description = Resources.format(callmeta, + "facet.gauge_discharge_curve_at_export.description", + "Discharge curve AT export on gauge", + rivername, + gaugename); + atexportfacet = new GaugeDischargeCurveFacet( + GAUGE_DISCHARGE_CURVE_AT_EXPORT_FACET, description); + fs.add(atexportfacet); addFacets(STATIC_STATE_NAME, fs); @@ -112,14 +146,28 @@ @Override protected void initStaticState() { StaticState state = new StaticState(STATIC_STATE_NAME); - List<Facet> fs = facets.get(STATIC_STATE_NAME); + + List<Facet> fs = new ArrayList<Facet>(1); + fs.add(curvefacet); + DefaultOutput output = new DefaultOutput( - "discharge_curve", - "output.discharge_curve", "image/png", + GAUGE_DISCHARGE_CURVE_OUT, + "output.discharge_curve", + "image/png", fs, "chart"); + state.addOutput(output); + fs = new ArrayList<Facet>(1); + fs.add(atexportfacet); + output = new DefaultOutput( + GAUGE_DISCHARGE_CURVE_AT_EXPORT_OUT, + "output.computed_dischargecurve_at_export", + "text/plain", + fs, + "export"); state.addOutput(output); + state.setUIProvider(UIPROVIDER); setStaticState(state); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Mon Oct 22 17:07:02 2012 +0200 @@ -185,6 +185,7 @@ String DISCHARGE_CURVE = "discharge_curve.curve"; String GAUGE_DISCHARGE_CURVE = "gauge_discharge_curve"; + String GAUGE_DISCHARGE_CURVE_AT_EXPORT = "gauge_discharge_curve_at_export"; String DURATION_W = "duration_curve.w"; String DURATION_Q = "duration_curve.q";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeCurveFacet.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeCurveFacet.java Mon Oct 22 17:07:02 2012 +0200 @@ -29,8 +29,8 @@ private static final Logger log = Logger.getLogger(GaugeDischargeCurveFacet.class); - public GaugeDischargeCurveFacet(String description) { - super(0, GAUGE_DISCHARGE_CURVE, description); + public GaugeDischargeCurveFacet(String name, String description) { + super(0, name, description); } @Override @@ -70,6 +70,7 @@ @Override public Facet deepCopy() { GaugeDischargeCurveFacet copy = new GaugeDischargeCurveFacet( + this.name, this.description); copy.set(this); return copy;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeInfoService.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeInfoService.java Mon Oct 22 17:07:02 2012 +0200 @@ -3,8 +3,6 @@ import java.util.Collections; import java.util.List; import java.util.Date; -import java.util.Calendar; -import java.util.GregorianCalendar; import org.apache.log4j.Logger;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeQInput.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeQInput.java Mon Oct 22 17:07:02 2012 +0200 @@ -2,8 +2,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Comparator; -import java.util.Collections; import org.apache.log4j.Logger; @@ -21,17 +19,19 @@ import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.artifacts.model.WstValueTable; +/* import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.Wst; +import de.intevation.flys.utils.FLYSUtils; +*/ import de.intevation.flys.artifacts.model.Range; import de.intevation.flys.model.River; -import de.intevation.flys.model.Wst; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.RangeWithValues; import de.intevation.flys.artifacts.states.DefaultState; import de.intevation.flys.artifacts.model.WstValueTableFactory; -import de.intevation.flys.utils.FLYSUtils; /** TODO Subclass WQAdapted. */
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveExporter.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveExporter.java Mon Oct 22 17:07:02 2012 +0200 @@ -9,7 +9,6 @@ import java.util.Map; import java.util.HashMap; import java.util.Locale; -import java.util.TreeMap; import org.w3c.dom.Document;
--- a/flys-artifacts/src/main/resources/messages.properties Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages.properties Mon Oct 22 17:07:02 2012 +0200 @@ -235,6 +235,7 @@ facet.gauge_discharge_curve.river = Name of the river facet.gauge_discharge_curve.reference_gauge = Gauge official number facet.gauge_discharge_curve.gauge_name = Name of the gauge +facet.gauge_discharge_curve.gauge_location = Location of the gauge chart.beddifference.height.title = Bedheight Difference chart.beddifference.height.xaxis.label = River-Km [km]
--- a/flys-artifacts/src/main/resources/messages_de.properties Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_de.properties Mon Oct 22 17:07:02 2012 +0200 @@ -235,6 +235,7 @@ facet.gauge_discharge_curve.river = Gew\u00e4sser facet.gauge_discharge_curve.reference_gauge = Pegelnummer facet.gauge_discharge_curve.gauge_name = Pegelname +facet.gauge_discharge_curve.gauge_location = Pegelort chart.beddifference.height.title = Sohlh\u00f6hendifferenz chart.beddifference.height.xaxis.label = Fluss-Km [km]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Mon Oct 22 17:07:02 2012 +0200 @@ -233,6 +233,7 @@ facet.gauge_discharge_curve.river = Gew\u00e4sser facet.gauge_discharge_curve.reference_gauge = Pegelnummer facet.gauge_discharge_curve.gauge_name = Pegelname +facet.gauge_discharge_curve.gauge_location = Pegelort chart.beddifference.height.title = Sohlh\u00f6hendifferenz chart.beddifference.height.xaxis.label = Fluss-Km [km]
--- a/flys-artifacts/src/main/resources/messages_en.properties Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_en.properties Mon Oct 22 17:07:02 2012 +0200 @@ -237,6 +237,7 @@ facet.gauge_discharge_curve.river = Name of the river facet.gauge_discharge_curve.reference_gauge = Gauge official number facet.gauge_discharge_curve.gauge_name = Name of the gauge +facet.gauge_discharge_curve.gauge_location = Location of the gauge chart.beddifference.height.title = Bedheight Difference chart.beddifference.height.xaxis.label = River-Km [km]
--- a/flys-backend/doc/schema/postgresql-minfo.sql Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/doc/schema/postgresql-minfo.sql Mon Oct 22 17:07:02 2012 +0200 @@ -352,6 +352,28 @@ ); +CREATE SEQUENCE MEASUREMENT_STATION_ID_SEQ; +CREATE TABLE measurement_station ( + id int NOT NULL, + name VARCHAR(256) NOT NULL, + river_id int NOT NULL, + station NUMERIC NOT NULL, + range_id int NOT NULL, + measurement_type VARCHAR(64) NOT NULL, + riverside VARCHAR(16), + reference_gauge_id int, + observation_timerange_id int, + operator VARCHAR(64), + comment VARCHAR(512), + PRIMARY KEY (id), + CONSTRAINT fk_ms_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) REFERENCES ranges(id), + CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) REFERENCES gauges(id), + CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id), + UNIQUE (river_id, station) +); + + CREATE SEQUENCE SQ_RELATION_ID_SEQ; CREATE TABLE sq_relation (
--- a/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java Mon Oct 22 17:07:02 2012 +0200 @@ -45,6 +45,7 @@ import de.intevation.flys.model.LocationSystem; import de.intevation.flys.model.MainValue; import de.intevation.flys.model.MainValueType; +import de.intevation.flys.model.MeasurementStation; import de.intevation.flys.model.MorphologicalWidth; import de.intevation.flys.model.MorphologicalWidthValue; import de.intevation.flys.model.NamedMainValue; @@ -155,6 +156,7 @@ Line.class, LocationSystem.class, MainValueType.class, + MeasurementStation.class, MorphologicalWidth.class, MorphologicalWidthValue.class, NamedMainValue.class,
--- a/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Mon Oct 22 17:07:02 2012 +0200 @@ -71,6 +71,9 @@ public static final String SKIP_WATERLEVEL_DIFFERENCES = "flys.backend.importer.skip.waterlevel.differences"; + public static final String SKIP_MEASUREMENT_STATIONS = + "flys.backend.importer.skip.measurement.stations"; + public static final String SKIP_SQ_RELATION = "flys.backend.importer.skip.sq.relation"; @@ -175,6 +178,10 @@ return getFlag(SKIP_WATERLEVEL_DIFFERENCES); } + public boolean skipMeasurementStations() { + return getFlag(SKIP_MEASUREMENT_STATIONS); + } + public boolean skipSQRelation() { return getFlag(SKIP_SQ_RELATION); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java Mon Oct 22 17:07:02 2012 +0200 @@ -0,0 +1,112 @@ +package de.intevation.flys.importer; + +import java.sql.SQLException; +import java.util.List; + +import org.apache.log4j.Logger; +import org.hibernate.Session; +import org.hibernate.exception.ConstraintViolationException; + +import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.MeasurementStation; +import de.intevation.flys.model.Range; +import de.intevation.flys.model.River; +import de.intevation.flys.model.TimeInterval; + + +public class ImportMeasurementStation { + + private static final Logger log = Logger + .getLogger(ImportMeasurementStation.class); + + private MeasurementStation peer; + + public String name; + public Double station; + public ImportRange range; + public String measurementType; + public String riverside; + public String gauge; + public ImportTimeInterval observationTimerange; + public String operator; + public String comment; + + public ImportMeasurementStation() { + } + + private Gauge getGaugeFromDB() { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + org.hibernate.Query query = session + .createQuery("FROM Gauge WHERE name=:name"); + + query.setParameter("name", gauge); + List<Gauge> gauges = query.list(); + + return gauges.isEmpty() ? null : gauges.get(0); + } + + public boolean storeDependencies(River river) throws SQLException, + ConstraintViolationException { + getPeer(river); + + return peer != null; + } + + public Object getPeer(River river) { + if (peer == null) { + Gauge gauge = null; + try { + gauge = getGaugeFromDB(); + if (gauge == null) { + log.warn("Skip measurement station '" + name + + "': unable to find gauge with name '" + this.gauge + + "'"); + return null; + } + } + catch (Exception e) { + log.error("Exception: " + e.getMessage()); + } + + Range range = this.range.getPeer(river); + if (range == null) { + log.warn("Skip measurement station '" + name + + "': unable to get range"); + return null; + } + + TimeInterval observationTimerange = this.observationTimerange + .getPeer(); + if (observationTimerange == null) { + log.warn("Skip measurement station '" + name + + "': unable to get time interval for observation time"); + return null; + } + + Session session = ImporterSession.getInstance() + .getDatabaseSession(); + + org.hibernate.Query query = session + .createQuery("FROM MeasurementStation " + + " WHERE river=:river AND station=:station"); + + query.setParameter("river", river); + query.setParameter("station", station); + + List<MeasurementStation> stations = query.list(); + + if (stations.isEmpty()) { + log.info("create new measurement station '" + name + "'"); + + peer = new MeasurementStation(river, name, measurementType, + riverside, station, range, gauge, observationTimerange, + operator, comment); + + session.save(peer); + } + } + + return peer; + } +}
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,34 +1,8 @@ package de.intevation.flys.importer; -import de.intevation.artifacts.common.utils.FileTools.HashedFile; - -import de.intevation.artifacts.common.utils.FileTools; - -import de.intevation.flys.importer.parsers.AnnotationClassifier; -import de.intevation.flys.importer.parsers.AnnotationsParser; -import de.intevation.flys.importer.parsers.BedHeightEpochParser; -import de.intevation.flys.importer.parsers.BedHeightSingleParser; -import de.intevation.flys.importer.parsers.FlowVelocityMeasurementParser; -import de.intevation.flys.importer.parsers.FlowVelocityModelParser; -import de.intevation.flys.importer.parsers.HYKParser; -import de.intevation.flys.importer.parsers.MorphologicalWidthParser; -import de.intevation.flys.importer.parsers.PRFParser; -import de.intevation.flys.importer.parsers.PegelGltParser; -import de.intevation.flys.importer.parsers.SedimentDensityParser; -import de.intevation.flys.importer.parsers.SedimentYieldParser; -import de.intevation.flys.importer.parsers.SQRelationParser; -import de.intevation.flys.importer.parsers.WaterlevelDifferencesParser; -import de.intevation.flys.importer.parsers.WaterlevelParser; -import de.intevation.flys.importer.parsers.WstParser; - -import de.intevation.flys.model.River; -import de.intevation.flys.model.Unit; - import java.io.File; import java.io.IOException; - import java.sql.SQLException; - import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -38,11 +12,31 @@ import java.util.Set; import org.apache.log4j.Logger; - import org.hibernate.Query; import org.hibernate.Session; +import org.hibernate.exception.ConstraintViolationException; -import org.hibernate.exception.ConstraintViolationException; +import de.intevation.artifacts.common.utils.FileTools; +import de.intevation.artifacts.common.utils.FileTools.HashedFile; +import de.intevation.flys.importer.parsers.AnnotationClassifier; +import de.intevation.flys.importer.parsers.AnnotationsParser; +import de.intevation.flys.importer.parsers.BedHeightEpochParser; +import de.intevation.flys.importer.parsers.BedHeightSingleParser; +import de.intevation.flys.importer.parsers.FlowVelocityMeasurementParser; +import de.intevation.flys.importer.parsers.FlowVelocityModelParser; +import de.intevation.flys.importer.parsers.HYKParser; +import de.intevation.flys.importer.parsers.MeasurementStationsParser; +import de.intevation.flys.importer.parsers.MorphologicalWidthParser; +import de.intevation.flys.importer.parsers.PRFParser; +import de.intevation.flys.importer.parsers.PegelGltParser; +import de.intevation.flys.importer.parsers.SQRelationParser; +import de.intevation.flys.importer.parsers.SedimentDensityParser; +import de.intevation.flys.importer.parsers.SedimentYieldParser; +import de.intevation.flys.importer.parsers.WaterlevelDifferencesParser; +import de.intevation.flys.importer.parsers.WaterlevelParser; +import de.intevation.flys.importer.parsers.WstParser; +import de.intevation.flys.model.River; +import de.intevation.flys.model.Unit; public class ImportRiver { @@ -97,6 +91,10 @@ public static final String MINFO_WATERLEVEL_DIFF_DIR = "Wasserspiegeldifferenzen"; + public static final String MINFO_BASE_DIR = "Basisdaten"; + + public static final String MINFO_CORE_DATA_FILE = "Stammdaten_Messstellen.csv"; + public static final String MINFO_SQ_DIR = "Feststofftransport-Abfluss-Beziehung"; @@ -142,6 +140,8 @@ protected List<ImportWaterlevelDifference> waterlevelDiffs; + protected List<ImportMeasurementStation> measurementStations; + protected List<ImportSQRelation> sqRelations; protected ImportWst wst; @@ -167,6 +167,7 @@ sedimentYields = new ArrayList<ImportSedimentYield>(); waterlevels = new ArrayList<ImportWaterlevel>(); waterlevelDiffs = new ArrayList<ImportWaterlevelDifference>(); + measurementStations = new ArrayList<ImportMeasurementStation>(); sqRelations = new ArrayList<ImportSQRelation>(); } @@ -238,6 +239,7 @@ parseSedimentYield(); parseWaterlevels(); parseWaterlevelDifferences(); + parseMeasurementStations(); parseSQRelation(); } @@ -498,6 +500,36 @@ waterlevels = parser.getWaterlevels(); } + protected void parseMeasurementStations() throws IOException { + if (Config.INSTANCE.skipMeasurementStations()) { + log.info("skip parsing measurement stations"); + return; + } + + log.info("Parse measurement stations"); + + File minfo = getMinfoDir(); + File minfoBaseDir = new File(minfo, MINFO_BASE_DIR); + File coredataFile = new File(minfoBaseDir, MINFO_CORE_DATA_FILE); + + if (coredataFile == null || !coredataFile.exists()) { + log.warn("No core data file '" + MINFO_CORE_DATA_FILE + "' found"); + return; + } + + MeasurementStationsParser parser = new MeasurementStationsParser(); + try { + parser.parse(coredataFile); + measurementStations = parser.getMeasurementStations(); + + log.info("Successfully parsed " + measurementStations.size() + " measurement stations."); + } + catch (IOException ioe) { + log.error("unable to parse file '" + coredataFile.getName() + + ": " + ioe.getMessage()); + } + } + protected void parseWaterlevelDifferences() throws IOException { if (Config.INSTANCE.skipWaterlevelDifferences()) { @@ -929,6 +961,7 @@ storeSedimentYield(); storeWaterlevels(); storeWaterlevelDifferences(); + storeMeasurementStations(); storeSQRelations(); } @@ -1224,6 +1257,34 @@ } + public void storeMeasurementStations() { + if (!Config.INSTANCE.skipMeasurementStations()) { + log.info("store measurement stations"); + + River river = getPeer(); + + int count = 0; + + for (ImportMeasurementStation station: measurementStations) { + try { + boolean success = station.storeDependencies(river); + if (success) { + count++; + } + } + catch (SQLException sqle) { + log.error("Error while storing measurement station.", sqle); + } + catch (ConstraintViolationException cve) { + log.error("Error while storing measurement station.", cve); + } + } + + log.info("stored " + count + " measurement stations."); + } + } + + public void storeSQRelations() { if (!Config.INSTANCE.skipSQRelation()) { log.info("store sq relations");
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityMeasurementParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityMeasurementParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -53,7 +53,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -72,7 +72,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/LineParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/LineParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -2,6 +2,10 @@ import java.io.File; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; @@ -26,7 +30,7 @@ public static final String SEPERATOR_CHAR = ";"; - protected abstract void handleLine(String line); + protected abstract void handleLine(int lineNum, String line); protected abstract void reset(); @@ -52,13 +56,15 @@ new InputStreamReader( new FileInputStream(file), ENCODING)); - String line = null; + String line = null; + int lineNum = 1; while ((line = in.readLine()) != null) { if ((line = line.trim()).length() == 0) { + lineNum++; continue; } - handleLine(line); + handleLine(lineNum++, line); } } finally { @@ -82,6 +88,20 @@ } } + public static double getDouble(String doubleString) throws ParseException { + NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); + Number value = nf.parse(doubleString); + + return value.doubleValue(); + } + + public static Date getDate(String dateString) throws ParseException { + DateFormat df = SimpleDateFormat.getDateInstance( + SimpleDateFormat.MEDIUM, DEFAULT_LOCALE); + + return df.parse(dateString); + } + public static Date getDateFromYear(int year) { Calendar cal = Calendar.getInstance();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -0,0 +1,192 @@ +package de.intevation.flys.importer.parsers; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.flys.importer.ImportMeasurementStation; +import de.intevation.flys.importer.ImportRange; +import de.intevation.flys.importer.ImportTimeInterval; + + +public class MeasurementStationsParser extends LineParser { + + public static class MeasurementStationParserException extends Exception { + + private static final long serialVersionUID = 1L; + + public MeasurementStationParserException(String msg) { + super(msg); + } + } + + public static final int MIN_COLUMNS = 10; + + private static final Logger log = Logger + .getLogger(MeasurementStationsParser.class); + + private List<ImportMeasurementStation> measurementStations; + private ImportMeasurementStation current; + + @Override + protected void reset() { + this.measurementStations = new ArrayList<ImportMeasurementStation>(); + } + + @Override + protected void finish() { + } + + @Override + protected void handleLine(int lineNum, String line) { + if (line == null || line.startsWith(START_META_CHAR)) { + log.info("skip meta information at line " + lineNum); + return; + } + + try { + current = new ImportMeasurementStation(); + handleDataLine(line); + measurementStations.add(current); + } + catch (MeasurementStationParserException e) { + log.warn("Problem in line " + lineNum + ": " + e.getMessage()); + } + } + + public List<ImportMeasurementStation> getMeasurementStations() { + return measurementStations; + } + + protected void handleDataLine(String line) + throws MeasurementStationParserException { + String[] cols = line.split(SEPERATOR_CHAR); + + if (cols == null || cols.length < MIN_COLUMNS) { + int num = cols != null ? cols.length : 0; + throw new MeasurementStationParserException("Not enough columns: " + + num); + } + + current.name = getName(cols); + current.station = getStation(cols); + current.range = getRange(cols); + current.measurementType = getMeasurementType(cols); + current.riverside = getRiverside(cols); + current.gauge = getGauge(cols); + current.observationTimerange = getObservationTimerange(cols); + current.operator = getOperator(cols); + current.comment = getComment(cols); + + log.debug("Found new measurement station '" + current.name + "' at km " + + current.station); + } + + protected String getName(String[] cols) + throws MeasurementStationParserException { + if (cols[0] == null || cols[0].length() == 0) { + throw new MeasurementStationParserException("invalid name '" + + cols[0] + "'"); + } + + return cols[0]; + } + + protected double getStation(String[] cols) + throws MeasurementStationParserException { + if (cols[1] == null || cols[1].length() == 0) { + throw new MeasurementStationParserException("invalid station '" + + cols[1] + "'"); + } + + try { + return getDouble(cols[1]); + } + catch (ParseException e) { + throw new MeasurementStationParserException( + "unable to parse station: " + e.getMessage()); + } + } + + protected ImportRange getRange(String[] cols) + throws MeasurementStationParserException { + if (cols[4] == null || cols[4].length() == 0) { + throw new MeasurementStationParserException("invalid lower range '" + + cols[4] + "'"); + } + + if (cols[5] == null || cols[5].length() == 0) { + throw new MeasurementStationParserException("invalid lower range '" + + cols[5] + "'"); + } + + try { + double lower = getDouble(cols[4]); + double upper = getDouble(cols[5]); + + return new ImportRange(new BigDecimal(lower), new BigDecimal(upper)); + } + catch (ParseException e) { + throw new MeasurementStationParserException( + "unable to parse range: " + e.getMessage()); + } + } + + protected String getMeasurementType(String[] cols) + throws MeasurementStationParserException { + if (cols[2] == null || cols[2].length() == 0) { + throw new MeasurementStationParserException( + "invalid measurement type '" + cols[2] + "'"); + } + + return cols[2]; + } + + protected String getRiverside(String[] cols) { + return cols[3]; + } + + protected String getGauge(String[] cols) + throws MeasurementStationParserException { + if (cols[6] == null || cols[6].length() == 0) { + throw new MeasurementStationParserException("invalid gauge '" + + cols[6] + "'"); + } + + return cols[6]; + } + + protected ImportTimeInterval getObservationTimerange(String[] cols) + throws MeasurementStationParserException { + if (cols[8] == null || cols[8].length() == 0) { + throw new MeasurementStationParserException( + "invalid observation time '" + cols[8] + "'"); + } + + try { + Date date = getDate(cols[8]); + + if (date != null) { + return new ImportTimeInterval(date); + } + + throw new MeasurementStationParserException( + "invalid observation time '" + cols[8] + "'"); + } + catch (ParseException pe) { + throw new MeasurementStationParserException(pe.getMessage()); + } + } + + protected String getOperator(String[] cols) { + return cols[9]; + } + + protected String getComment(String[] cols) { + return cols.length > 10 ? cols[10] : null; + } +}
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -55,7 +55,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SQRelationParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SQRelationParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -67,7 +67,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -72,7 +72,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -126,7 +126,7 @@ @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -74,7 +74,7 @@ } @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java Mon Oct 22 17:07:02 2012 +0200 @@ -77,7 +77,7 @@ } @Override - protected void handleLine(String line) { + protected void handleLine(int lineNum, String line) { if (line.startsWith(START_META_CHAR)) { handleMetaLine(stripMetaLine(line)); return;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/MeasurementStation.java Mon Oct 22 17:07:02 2012 +0200 @@ -0,0 +1,156 @@ +package de.intevation.flys.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; + + +@Entity +@Table(name = "measurement_station") +public class MeasurementStation { + + private Integer id; + + private String name; + private String measurementType; + private String riverside; + private String operator; + private String comment; + + private Double station; + private Range range; + + private River river; + + private Gauge gauge; + + private TimeInterval observationTimerange; + + public MeasurementStation(River river, String name, String measurementType, + String riverside, Double station, Range range, Gauge gauge, + TimeInterval observationTimerange, String operator, String comment) { + this.river = river; + this.name = name; + this.measurementType = measurementType; + this.riverside = riverside; + this.station = station; + this.range = range; + this.gauge = gauge; + this.observationTimerange = observationTimerange; + this.operator = operator; + this.comment = comment; + } + + @Id + @SequenceGenerator(name = "SEQ_MEASUREMENT_STATION_ID_SEQ", sequenceName = "MEASUREMENT_STATION_ID_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_MEASUREMENT_STATION_ID_SEQ") + @Column(name = "id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "measurement_type") + public String getMeasurementType() { + return measurementType; + } + + public void setMeasurementType(String measurementType) { + this.measurementType = measurementType; + } + + @Column(name = "riverside") + public String getRiverside() { + return riverside; + } + + public void setRiverside(String riverside) { + this.riverside = riverside; + } + + @OneToOne + @JoinColumn(name = "river_id") + public River getRiver() { + return river; + } + + public void setRiver(River river) { + this.river = river; + } + + @OneToOne + @JoinColumn(name = "reference_gauge_id") + public Gauge getGauge() { + return gauge; + } + + public void setGauge(Gauge gauge) { + this.gauge = gauge; + } + + @Column(name = "station") + public Double getStation() { + return station; + } + + public void setStation(Double station) { + this.station = station; + } + + @OneToOne + @JoinColumn(name = "range_id") + public Range getRange() { + return range; + } + + public void setRange(Range range) { + this.range = range; + } + + @OneToOne + @JoinColumn(name = "observation_timerange_id") + public TimeInterval getObservationTimerange() { + return observationTimerange; + } + + public void setObservationTimerange(TimeInterval observationTimerange) { + this.observationTimerange = observationTimerange; + } + + @Column(name = "operator") + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + @Column(name = "comment") + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Mon Oct 22 17:07:02 2012 +0200 @@ -477,7 +477,6 @@ public void onSuccess(Collection collection) { GWT.log("Successfully created a new collection."); final Collection col = collection; - final ProjectList plist = projectList; artifactService.createGaugeDischargeCurveArtifact( col, locale, riv, ref, new AsyncCallback<Artifact>() {
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Oct 22 17:07:02 2012 +0200 @@ -1057,5 +1057,8 @@ String gauge_url(); String gauge_curve_link(); + + String gauge_discharge_curve_at_export(); + } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Oct 22 17:07:02 2012 +0200 @@ -251,6 +251,7 @@ at = AT pdf = PDF computed_dischargecurve_at_export = AT Export +gauge_discharge_curve_at_export = Gauge Discharge Curve gauge_class = Gauge Class eventselect = Eventselection events = Events
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Oct 22 17:07:02 2012 +0200 @@ -248,6 +248,7 @@ at = AT pdf = PDF computed_dischargecurve_at_export = AT Export +gauge_discharge_curve_at_export = Abflusskurve am Pegel gauge_class = Abflussklasse eventselect = Ereignisauswahl events = Ereignisse
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Oct 22 17:07:02 2012 +0200 @@ -251,6 +251,7 @@ at = AT pdf = PDF computed_dischargecurve_at_export = AT Export +gauge_discharge_curve_at_export = Gauge Discharge Curve gauge_class = Gauge Class eventselect = Eventselection events = Events
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -8,6 +8,7 @@ import com.google.gwt.user.client.ui.Label; import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.events.ResizedEvent; import com.smartgwt.client.widgets.events.ResizedHandler; import com.smartgwt.client.widgets.layout.SectionStackSection; @@ -42,6 +43,7 @@ GWT.create(GaugeOverviewInfoService.class); protected GaugeTree gaugetree; + protected Canvas gaugetreecanvas; protected RiverInfoPanel riverinfopanel; @@ -54,6 +56,9 @@ */ public GaugePanel(FLYS flys, SectionStackSection sectionStack) { gaugetree = new GaugeTree(flys); + gaugetreecanvas = new Canvas(); + gaugetreecanvas.addChild(gaugetree); + setOverflow(Overflow.HIDDEN); sectionStack.setHidden(true); sectionStack.setItems(this); @@ -98,13 +103,20 @@ } public void renderGaugeOverviewInfo(RiverInfo riverinfo) { - removeMembers(getMembers()); + gaugetree.setGauges(riverinfo); - riverinfopanel = new RiverInfoPanel(riverinfo); - addMember(riverinfopanel); - addMember(gaugetree); + if (riverinfopanel == null) { + removeMembers(getMembers()); + riverinfopanel = new RiverInfoPanel(riverinfo); - gaugetree.setGauges(riverinfo); + gaugetreecanvas.setWidth("100%"); + + addMember(riverinfopanel); + addMember(gaugetreecanvas); + } + else { + riverinfopanel.setRiverInfo(riverinfo); + } } @Override @@ -112,16 +124,21 @@ /* this height calculation is only an approximation and doesn't reflect * the real height of the the gaugetree. */ int height = getInnerContentHeight() - - (RiverInfoPanel.HEIGHT + - (2 * RiverInfoPanel.BORDER_WIDTH) + - (2 * RiverInfoPanel.PADDING) + - (2 * RiverInfoPanel.MARGIN)); + RiverInfoPanel.getStaticHeight(); + int width = getInnerContentWidth(); if (height < 0) { height = 0; } + GWT.log("GaugePanel - onResize " + height); + gaugetree.setHeight("" + height + "px"); + gaugetree.setWidth("" + width + "px"); + + for (Canvas canvas : getMembers()) { + GWT.log("GaugePanel - member height " + canvas.getHeight()); + } } @@ -142,70 +159,4 @@ GWT.log("GaugePanel - show"); this.sectionStack.setHidden(false); } - - class RiverInfoPanel extends HorizontalPanel { - - public final static int HEIGHT = 30; - public final static int BORDER_WIDTH = 3; - public final static int PADDING = 8; - public final static int MARGIN = 10; - - public RiverInfoPanel(RiverInfo riverinfo) { - setStyleName("riverinfopanel"); - setHeight("" + HEIGHT + "px"); - setVerticalAlignment(ALIGN_MIDDLE); - - NumberFormat nf = NumberFormat.getDecimalFormat(); - - addLabel(riverinfo.getName(), false); - - String kmtext = ""; - Double start = riverinfo.getKmStart(); - Double end = riverinfo.getKmEnd(); - - if (!riverinfo.isKmUp()) { - Double tmp = end; - end = start; - start = tmp; - } - if (end != null) { - kmtext += nf.format(end); - kmtext += " - "; - } - if (start != null) { - kmtext += nf.format(start); - } - kmtext += " km"; - - addLabel(kmtext, false); - - String qtext = ""; - Double qmin = riverinfo.getMinQ(); - Double qmax = riverinfo.getMaxQ(); - if (qmin != null) { - qtext += nf.format(qmin); - qtext += " " + MSG.gauge_q_unit(); - qtext += " - "; - } - if (qmax != null) { - qtext += nf.format(qmax); - qtext += " " + MSG.gauge_q_unit(); - } - - addLabel(qtext, false); - - Long number = riverinfo.getOfficialNumber(); - String url = number != null ? - MSG.gauge_river_url() + number : - MSG.gauge_river_url(); - Anchor anchor = new Anchor(MSG.gauge_river_info_link(), url, "_blank"); - add(anchor); - } - - private void addLabel(String text, boolean wordwrap) { - Label label = new Label(text, wordwrap); - add(label); - setCellHeight(label, "" + HEIGHT + "px"); - } - } }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -76,6 +76,7 @@ this.maxLower = maxLower; } + @Override public Canvas create(DataList data) { setDataName(data); @@ -118,9 +119,7 @@ @Override public Canvas createOld(DataList dataList) { GWT.log("create old date."); - Data data = dataList.get(0); - DataItem[] items = data.getItems(); - + Data data = dataList.get(0); HLayout layout = new HLayout(); Label label = new Label(dataList.getLabel());
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java Mon Oct 22 17:07:02 2012 +0200 @@ -112,7 +112,7 @@ for (int i = 0; i < data.length; i++) { DataList dl = data[i]; String state = dl.getState(); - GWT.log("GaugeTree - setData " + state); + GWT.log("GaugeTree - open " + state); if (state.equals("state.winfo.location_distance")) { Double ldfrom = null; Double ldto = null;
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,37 +1,33 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.List; - import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; +import com.smartgwt.client.data.Record; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; -import com.smartgwt.client.widgets.form.fields.events.BlurEvent; - +import com.smartgwt.client.widgets.grid.events.RecordClickEvent; +import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; -import com.smartgwt.client.widgets.grid.events.RecordClickHandler; -import com.smartgwt.client.widgets.grid.events.RecordClickEvent; - -import com.smartgwt.client.data.Record; - +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.services.DistanceInfoService; +import de.intevation.flys.client.client.services.DistanceInfoServiceAsync; +import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource; +import de.intevation.flys.client.shared.DoubleUtils; import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.DistanceInfoObject; -import de.intevation.flys.client.shared.DoubleUtils; import de.intevation.flys.client.shared.model.RangeData; -import de.intevation.flys.client.client.services.DistanceInfoService; -import de.intevation.flys.client.client.services.DistanceInfoServiceAsync; -import de.intevation.flys.client.client.Config; -import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource; +import java.util.ArrayList; +import java.util.List; /** @@ -43,6 +39,8 @@ extends LocationPanel implements RecordClickHandler { + private static final long serialVersionUID = -3359966826794082718L; + /** The DistanceInfoService used to retrieve locations about rivers. */ protected DistanceInfoServiceAsync distanceInfoService = GWT.create(DistanceInfoService.class); @@ -113,6 +111,7 @@ * * @param list The DataList container that stores the Data objects. */ + @Override protected void initDefaults(DataList list) { Data data = list.get(0); @@ -163,6 +162,7 @@ } + @Override protected Canvas createWidget(DataList data) { VLayout layout = new VLayout(); inputLayout = new HLayout(); @@ -171,7 +171,8 @@ locationPanel = new DoubleArrayPanel( MSG.unitLocation(), getLocationValues(), - new BlurHandler(){public void onBlur(BlurEvent be) {validate();}}); + new BlurHandler(){@Override + public void onBlur(BlurEvent be) {validate();}}); picker.getLocationTable().setAutoFetchData(true); @@ -249,6 +250,7 @@ * * @return the selected/inserted data in feedable form. */ + @Override public Data[] getData() { saveLocationValues(locationPanel); double[] lValues = getLocationValues(); @@ -314,6 +316,7 @@ * Set the respective km-value in the location value field. * @param e event passed. */ + @Override public void onRecordClick (RecordClickEvent e) { Record record = e.getRecord(); double[] old = getLocationValues(); @@ -324,6 +327,7 @@ } catch(NumberFormatException nfe) { // Is there anything else to do here? + GWT.log(nfe.getMessage()); } // compare reference location and target location.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/NoInputPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/NoInputPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -9,6 +9,9 @@ public class NoInputPanel extends AbstractUIProvider { + private static final long serialVersionUID = -8789143404415288132L; + + @Override public Canvas create(DataList data) { return new Canvas();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Mon Oct 22 17:07:02 2012 +0200 @@ -66,6 +66,8 @@ HasParameterChangeHandler, CollectionChangeHandler, OutputModesChangeHandler, AdvanceHandler { + private static final long serialVersionUID = 5204784727239299980L; + public static final String STYLENAME_OLD_PARAMETERS = "oldParameters"; /** The message class that provides i18n strings.*/ @@ -355,6 +357,8 @@ widget.setContainer(helperPanel); handler.addStepForwardHandler(new StepForwardHandler() { + private static final long serialVersionUID = -6210719844707004860L; + @Override public void onStepForward(StepForwardEvent event) { lockUI(); @@ -366,8 +370,8 @@ String module = moduleItems[0].getStringValue(); String river = riversItems[0].getStringValue(); - if (module == null) { - // TODO throw / show error! + if (module == null || river == null) { + GWT.log("ParameterList.renderNew(): module == null || river == null"); unlockUI(); return; } @@ -387,7 +391,7 @@ public void onFailure(Throwable caught) { unlockUI(); GWT.log("Could not create the new artifact."); - SC.warn(MSG.getString(caught.getMessage())); + SC.warn(FLYS.getExceptionString(MSG, caught)); } @Override
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,19 +1,12 @@ package de.intevation.flys.client.client.ui; -import java.io.Serializable; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.user.client.ui.ClickListener; -import com.smartgwt.client.types.Autofit; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; @@ -26,6 +19,12 @@ import de.intevation.flys.client.shared.model.IntegerOptionsData; import de.intevation.flys.client.shared.model.StringOptionsData; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Some parameters take the form of on/off options that can also be seen @@ -40,6 +39,9 @@ protected ListGrid listGrid = null; public static class Column implements Serializable { + + private static final long serialVersionUID = -3493426383086860118L; + protected String name; protected Map<String, String> values; @@ -233,10 +235,10 @@ /** Create Checkbox for column/value. */ protected Canvas createCheckBox(final String colName, final String value) { CheckBox box = new CheckBox(); - box.addClickListener(new ClickListener() { + box.addClickHandler(new ClickHandler() { + @Override - public void onClick(Widget sender) { - CheckBox box = (CheckBox) sender; + public void onClick(ClickEvent event) { Map<String, List<String>> selection = getSelection(); List<String> values = selection.get(colName); @@ -259,12 +261,11 @@ if (listGrid == null) { return selected; } - + ListGridRecord[] records = listGrid.getRecords(); for (ListGridRecord record: records) { for (int i = 0, n = columnNames.size(); i < n; i++) { String columnName = columnNames.get(i); - Column col = columns.get(columnName); List<String> chosenItems = selected.get(columnName); if (Boolean.valueOf(record.getAttribute(columnName)) == true) { chosenItems.add(record.getAttribute(columnName + "-value"));
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,12 +1,6 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.google.gwt.core.client.GWT; - import com.google.gwt.user.client.ui.HTML; import com.smartgwt.client.widgets.Canvas; @@ -23,11 +17,18 @@ import de.intevation.flys.client.shared.model.IntegerOptionsData; import de.intevation.flys.client.shared.model.StringOptionsData; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ParameterMatrixPanel extends AbstractUIProvider { + private static final long serialVersionUID = -5827445025768340371L; + /** The message class that provides i18n strings. */ protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/PeriodPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/PeriodPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,25 +1,17 @@ package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; - -import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; - import com.google.gwt.i18n.client.DateTimeFormat; import com.smartgwt.client.util.SC; - import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; - import com.smartgwt.client.widgets.form.DynamicForm; - import com.smartgwt.client.widgets.form.fields.DateRangeItem; - import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.client.FLYSConstants; - import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; @@ -38,6 +30,8 @@ public class PeriodPanel extends AbstractUIProvider { + private static final long serialVersionUID = -5249560815807538821L; + /** The message class that provides i18n strings. */ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -59,6 +53,7 @@ } + @Override public Canvas create(DataList list) { VLayout layout = new VLayout(); @@ -152,6 +147,7 @@ * * @return the selected/inserted data. */ + @Override public Data[] getData() { List<Data> data = new ArrayList<Data>();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Mon Oct 22 17:07:02 2012 +0200 @@ -4,6 +4,7 @@ import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; + import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.Autofit; import com.smartgwt.client.types.ListGridEditEvent; @@ -657,8 +658,6 @@ * @param search String to search for in collection names. */ protected void filterCollections(String search) { - int j = 0; - // Clear the collection list. filteredCollections.clear(); @@ -680,7 +679,6 @@ // matches. if (name.contains(search.toLowerCase())) { filteredCollections.add(collections.get(i)); - j++; } } updateGrid();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/QSegmentedInputPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/QSegmentedInputPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,12 +1,5 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -16,17 +9,22 @@ import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.RadioGroupItem; +import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; -import com.smartgwt.client.widgets.form.fields.events.BlurEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; -import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet; -import com.smartgwt.client.widgets.tab.Tab; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.services.WQInfoService; +import de.intevation.flys.client.client.services.WQInfoServiceAsync; +import de.intevation.flys.client.client.ui.wq.QDTable; +import de.intevation.flys.client.client.ui.wq.WTable; +import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; @@ -35,15 +33,12 @@ import de.intevation.flys.client.shared.model.WQDataItem; import de.intevation.flys.client.shared.model.WQInfoObject; import de.intevation.flys.client.shared.model.WQInfoRecord; -import de.intevation.flys.client.shared.model.ArtifactDescription; - -import de.intevation.flys.client.client.FLYSConstants; -import de.intevation.flys.client.client.Config; -import de.intevation.flys.client.client.services.WQInfoService; -import de.intevation.flys.client.client.services.WQInfoServiceAsync; -import de.intevation.flys.client.client.ui.wq.WTable; -import de.intevation.flys.client.client.ui.wq.QDTable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; /** @@ -53,6 +48,9 @@ extends AbstractUIProvider implements ChangeHandler, BlurHandler { + + private static final long serialVersionUID = -8627825064071479905L; + public static final String FIELD_WQ_MODE = "wq_isq"; public static final String FIELD_WQ_Q = "Q"; @@ -98,6 +96,7 @@ /** Create main UI Canvas. */ + @Override public Canvas create(DataList data) { initHelperPanel(); @@ -140,6 +139,7 @@ /** Create display for passive mode. */ + @Override public Canvas createOld(DataList dataList) { List<Data> all = dataList.getAll(); Data wqData = getData(all, "ranges"); @@ -304,7 +304,6 @@ if (item instanceof WQDataItem) { WQDataItem wq = (WQDataItem) item; double[] mmQ = wq.getQRange(); - double[] mmW = wq.getWRange(); qranges.put(title, mmQ); } @@ -344,6 +343,7 @@ } + @Override public Data[] getData() { Data values = getWQValues(); @@ -397,11 +397,13 @@ } + @Override public void onChange(ChangeEvent event) { // TODO IMPLEMENT ME } + @Override public void onBlur(BlurEvent event) { DoubleArrayPanel dap = (DoubleArrayPanel) event.getForm(); dap.validateForm(event.getItem()); @@ -420,11 +422,13 @@ wqInfoService.getWQInfo(locale, river, mm[0], mm[0], new AsyncCallback<WQInfoObject[]>() { + @Override public void onFailure(Throwable caught) { GWT.log("Could not recieve wq informations."); SC.warn(caught.getMessage()); } + @Override public void onSuccess(WQInfoObject[] wqi) { int num = wqi != null ? wqi.length :0; GWT.log("Recieved " + num + " wq informations.");
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RadioPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RadioPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,8 +1,7 @@ package de.intevation.flys.client.client.ui; -import java.util.LinkedHashMap; +import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; @@ -16,14 +15,17 @@ import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; +import java.util.LinkedHashMap; + public class RadioPanel extends AbstractUIProvider { + private static final long serialVersionUID = 3357071563224461043L; + protected String dataName; protected DynamicForm form; @Override public Canvas createOld(DataList dataList) { - // TODO Auto-generated method stub Data data = dataList.get(0); DataItem[] items = data.getItems();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,8 +1,5 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.List; - import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.Alignment; @@ -16,11 +13,14 @@ import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.client.FLYSConstants; -import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.RangeData; +import java.util.ArrayList; +import java.util.List; + /** * An UIProvider for inserting ranges. @@ -29,6 +29,8 @@ */ public abstract class RangePanel extends AbstractUIProvider { + private static final long serialVersionUID = -9213089589150335651L; + public static final String FIELD_LOWER = "field_lower"; public static final String FIELD_UPPER = "field_upper"; @@ -126,8 +128,6 @@ protected RangeData findRangeData(DataList dataList) { - RangeData data = null; - for (int i = 0, n = dataList.size(); i < n; i++) { Data tmp = dataList.get(i); @@ -135,7 +135,6 @@ return (RangeData) tmp; } } - return null; }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangeTableFilter.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangeTableFilter.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,9 +1,5 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.form.DynamicForm; @@ -14,11 +10,15 @@ import com.smartgwt.client.widgets.form.fields.events.KeyUpHandler; import com.smartgwt.client.widgets.layout.HLayout; +import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.FilterHandler; import de.intevation.flys.client.client.event.RangeFilterEvent; -import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.utils.DoubleValidator; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + /** * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ @@ -60,15 +60,17 @@ } + @Override public void onChanged(ChangedEvent event) { // This event handler is to slow... // fireFilterCriteriaChanged(getSearchString()); } + @Override public void onKeyUp(KeyUpEvent event) { DoubleValidator validator = new DoubleValidator(); - Map errors = filterForm.getErrors(); + Map<?,?> errors = filterForm.getErrors(); if(event.getItem().getValue() != null && !validator.validate(event.getItem(), errors)) { filterForm.setErrors(errors, true); @@ -124,6 +126,7 @@ } + @Override public void clear() { fromField.clearValue(); toField.clearValue();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,6 +1,7 @@ package de.intevation.flys.client.client.ui; import com.smartgwt.client.widgets.grid.ListGridRecord; + import de.intevation.flys.client.shared.model.Recommendation; @@ -30,6 +31,7 @@ /** Trivial, blocked constructor. */ + @SuppressWarnings("unused") private RecommendationPairRecord() { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RiverInfoPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -0,0 +1,118 @@ +package de.intevation.flys.client.client.ui; + +import java.util.Iterator; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; +import com.google.gwt.user.client.ui.Anchor; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Widget; + +import de.intevation.flys.client.client.FLYSConstants; + +import de.intevation.flys.client.shared.model.RiverInfo; + +/** + * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> + */ +public class RiverInfoPanel extends HorizontalPanel { + + /** + * Panel to display information about a river + */ + + /** The message class that provides i18n strings.*/ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + public final static int HEIGHT = 30; + public final static int BORDER_WIDTH = 3; + public final static int PADDING = 8; + public final static int MARGIN = 10; + + public RiverInfoPanel(RiverInfo riverinfo) { + setStyleName("riverinfopanel"); + setHeight("" + HEIGHT + "px"); + setVerticalAlignment(ALIGN_MIDDLE); + + setRiverInfo(riverinfo); + } + + public void setRiverInfo(RiverInfo riverinfo) { + GWT.log("RiverInfoPanel - setRiverInfo"); + + NumberFormat nf = NumberFormat.getDecimalFormat(); + + removeAllLabels(); + + addLabel(riverinfo.getName(), false); + + String kmtext = ""; + Double start = riverinfo.getKmStart(); + Double end = riverinfo.getKmEnd(); + + if (!riverinfo.isKmUp()) { + Double tmp = end; + end = start; + start = tmp; + } + if (end != null) { + kmtext += nf.format(end); + kmtext += " - "; + } + if (start != null) { + kmtext += nf.format(start); + } + kmtext += " km"; + + addLabel(kmtext, false); + + String qtext = ""; + Double qmin = riverinfo.getMinQ(); + Double qmax = riverinfo.getMaxQ(); + if (qmin != null) { + qtext += nf.format(qmin); + qtext += " " + MSG.gauge_q_unit(); + qtext += " - "; + } + if (qmax != null) { + qtext += nf.format(qmax); + qtext += " " + MSG.gauge_q_unit(); + } + + addLabel(qtext, false); + + Long number = riverinfo.getOfficialNumber(); + String url = number != null ? + MSG.gauge_river_url() + number : + MSG.gauge_river_url(); + Anchor anchor = new Anchor(MSG.gauge_river_info_link(), url, "_blank"); + add(anchor); + } + + public static int getStaticHeight() { + return RiverInfoPanel.HEIGHT + + (2 * RiverInfoPanel.BORDER_WIDTH) + + (2 * RiverInfoPanel.PADDING) + + (2 * RiverInfoPanel.MARGIN); + } + + private void addLabel(String text, boolean wordwrap) { + Label label = new Label(text, wordwrap); + add(label); + setCellHeight(label, "" + HEIGHT + "px"); + } + + private void removeAllLabels() { + GWT.log("RiverInfoPanel - removeAllLabels"); + + Iterator<Widget> it = this.iterator(); + while(it.hasNext()) { + it.next(); + it.remove(); + } + /* for (Widget wid: this) { */ + /* this.remove(wid); */ + /* } */ + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,9 +1,5 @@ package de.intevation.flys.client.client.ui; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.VerticalAlignment; @@ -14,13 +10,16 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; -import de.intevation.flys.client.client.FLYSConstants; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; /** @@ -31,6 +30,8 @@ public class SelectProvider extends AbstractUIProvider { + private static final long serialVersionUID = 4696637534424070726L; + /** The message class that provides i18n strings.*/ protected FLYSConstants messages = GWT.create(FLYSConstants.class); @@ -47,6 +48,7 @@ * * @return a combobox. */ + @Override public Canvas create(DataList data) { VLayout v = new VLayout(); v.setMembersMargin(10); @@ -61,6 +63,7 @@ } + @Override public Canvas createOld(DataList dataList) { HLayout layout = new HLayout(); VLayout vLayout = new VLayout(); @@ -109,7 +112,7 @@ layout.setAlign(VerticalAlignment.TOP); layout.setHeight(25); - LinkedHashMap initial = new LinkedHashMap(); + LinkedHashMap<String, String> initial = new LinkedHashMap<String, String>(); form = new DynamicForm(); @@ -166,9 +169,10 @@ } + @Override protected Data[] getData() { - Map values = form.getValues(); - Iterator keys = values.keySet().iterator(); + Map<?,?> values = form.getValues(); + Iterator<?> keys = values.keySet().iterator(); Data[] list = new Data[values.size()]; int i = 0;
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -3,7 +3,6 @@ import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.data.Record; - import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import de.intevation.flys.client.shared.model.Data; @@ -17,6 +16,9 @@ public class SingleLocationPanel extends MultipleLocationPanel { + private static final long serialVersionUID = -300641333561787454L; + + /** * Creates a new SingleLocationPanel instance. */ @@ -78,6 +80,7 @@ * * @return the selected/inserted data. */ + @Override public Data[] getData() { saveLocationValues(locationPanel); double[] values = getLocationValues(); @@ -101,6 +104,7 @@ * Set the respective km-value in the location value field. * @param e event passed. */ + @Override public void onRecordClick (RecordClickEvent e) { Record record = e.getRecord(); double[] selected = new double[1]; @@ -115,6 +119,7 @@ } + @Override protected String getLabelString() { return MSG.single_location(); }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,26 +1,24 @@ package de.intevation.flys.client.client.ui; -import java.util.List; - import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.i18n.client.NumberFormat; +import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.widgets.layout.VLayout; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.services.CSVExportService; +import de.intevation.flys.client.client.services.CSVExportServiceAsync; import de.intevation.flys.client.shared.model.DataList; -import de.intevation.flys.client.client.FLYSConstants; -import de.intevation.flys.client.client.Config; - -import de.intevation.flys.client.client.services.CSVExportService; -import de.intevation.flys.client.client.services.CSVExportServiceAsync; +import java.util.List; /** * This UIProvider creates a widget that displays calculated data in a table. @@ -72,11 +70,13 @@ exportService.getCSV(locale, uuid, name, new AsyncCallback<List<String[]>>() { + @Override public void onFailure(Throwable caught) { GWT.log("Could not recieve csv."); SC.warn(caught.getMessage()); } + @Override public void onSuccess(List<String[]> l) { GWT.log("Recieved csv with " + l.size() + " lines."); setData(l); @@ -110,11 +110,11 @@ /** - * This method sets the data to a dynmic table. + * This method sets the data to a dynamic table. * * @param list List if String[] containing the data. */ - public void setData(List list) { + public void setData(List<String[]> list) { if (list == null || list.size() < 2) { dataTable.setEmptyMessage(MESSAGES.error_no_calc_result()); dataTable.redraw(); @@ -132,8 +132,8 @@ nf = NumberFormat.getFormat("#.##"); } - String[] header = (String[])list.get(0); - String[] firstValues = (String[])list.get(1); + String[] header = list.get(0); + String[] firstValues = list.get(1); ListGridField[] fields = new ListGridField[header.length]; @@ -154,7 +154,7 @@ dataTable.setFields(fields); for(int i = 1; i < list.size(); i++) { - String[] sItem = (String[])list.get(i); + String[] sItem = list.get(i); ListGridRecord r = new ListGridRecord(); for(int j = 0; j < sItem.length; j++) { r.setAttribute(String.valueOf(j), sItem[j]);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TextProvider.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TextProvider.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,8 +1,5 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.List; - import com.google.gwt.core.client.GWT; import com.smartgwt.client.data.DataSource; @@ -18,13 +15,15 @@ import com.smartgwt.client.widgets.form.validator.Validator; import com.smartgwt.client.widgets.layout.HLayout; +import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; -import de.intevation.flys.client.client.FLYSConstants; +import java.util.ArrayList; +import java.util.List; /** @@ -34,6 +33,7 @@ extends AbstractUIProvider implements ItemChangedHandler { + private static final long serialVersionUID = -6868303464989138497L; public static final String FIELD_NAME = "textprovider_inputfield"; public static final int FORM_WIDTH = 400;
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -1,13 +1,10 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.List; - import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.util.BooleanCallback; import com.smartgwt.client.util.SC; -import com.smartgwt.client.util.BooleanCallback; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -20,13 +17,6 @@ import com.smartgwt.client.widgets.menu.events.ClickHandler; import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; -import de.intevation.flys.client.shared.model.Collection; -import de.intevation.flys.client.shared.model.CollectionItemAttribute; -import de.intevation.flys.client.shared.model.FacetRecord; -import de.intevation.flys.client.shared.model.OutputMode; -import de.intevation.flys.client.shared.model.Theme; -import de.intevation.flys.client.shared.model.ThemeList; - import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.HasOutputParameterChangeHandlers; @@ -35,13 +25,22 @@ import de.intevation.flys.client.client.event.OnMoveHandler; import de.intevation.flys.client.client.event.OutputParameterChangeEvent; import de.intevation.flys.client.client.event.OutputParameterChangeHandler; -import de.intevation.flys.client.client.event.RedrawRequestHandler; import de.intevation.flys.client.client.event.RedrawRequestEvent; import de.intevation.flys.client.client.event.RedrawRequestEvent.Type; +import de.intevation.flys.client.client.event.RedrawRequestHandler; import de.intevation.flys.client.client.services.CollectionAttributeService; import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; import de.intevation.flys.client.client.services.CollectionItemAttributeService; import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync; +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.CollectionItemAttribute; +import de.intevation.flys.client.shared.model.FacetRecord; +import de.intevation.flys.client.shared.model.OutputMode; +import de.intevation.flys.client.shared.model.Theme; +import de.intevation.flys.client.shared.model.ThemeList; + +import java.util.ArrayList; +import java.util.List; /** * ThemePanel on the left in CollectionView. @@ -93,8 +92,9 @@ this.list = createGrid(); this.view = view; list.addRowContextClickHandler(new RowContextClickHandler() { + @Override public void onRowContextClick(RowContextClickEvent event) { - ListGridRecord[] records = list.getSelection(); + ListGridRecord[] records = list.getSelectedRecords(); Menu menu = null; @@ -164,6 +164,7 @@ * * @param h The new handler. */ + @Override public void addOutputParameterChangeHandler(OutputParameterChangeHandler h){ if (h != null) { outHandlers.add(h); @@ -176,6 +177,7 @@ * * @param h The new handler. */ + @Override public void addRedrawRequestHandler(RedrawRequestHandler h){ if (h != null) { redrawRequestHandlers.add(h); @@ -298,6 +300,7 @@ disable(); updater.update(getCollection(), loc, new AsyncCallback<Collection>() { + @Override public void onFailure(Throwable caught) { GWT.log("Could not update collection attributes."); SC.warn(MSG.getString(caught.getMessage())); @@ -306,6 +309,7 @@ } + @Override public void onSuccess(Collection collection) { setCollection(collection); @@ -386,6 +390,7 @@ MenuItem properties = new MenuItem(MSG.properties()); properties.addClickHandler(new ClickHandler() { + @Override public void onClick(MenuItemClickEvent evt) { GWT.log("clicked properties"); for (ListGridRecord record: records) { @@ -402,6 +407,7 @@ MenuItem activate = new MenuItem(MSG.activateTheme()); activate.addClickHandler(new ClickHandler() { + @Override public void onClick(MenuItemClickEvent evt) { for (ListGridRecord record: records) { FacetRecord facet = (FacetRecord) record; @@ -420,6 +426,7 @@ MenuItem deactivate = new MenuItem(MSG.deactivateTheme()); deactivate.addClickHandler(new ClickHandler() { + @Override public void onClick(MenuItemClickEvent evt) { for (ListGridRecord record: records) { FacetRecord facet = (FacetRecord) record; @@ -451,6 +458,7 @@ MenuItem remove = new MenuItem(MSG.removeTheme()); remove.addClickHandler(new ClickHandler() { + @Override public void onClick(MenuItemClickEvent evt) { SC.ask(MSG.askThemeRemove(), new BooleanCallback() { @Override @@ -497,7 +505,7 @@ * @param newIdx The index of the theme after it was moved. */ protected void fireThemeMoved(Theme theme, int oldIdx, int newIdx) { - // TODO Implement in subclasses + // Do nothing } @@ -507,7 +515,7 @@ GWT.log("ThemePanel.onMove: " + type); - ListGridRecord[] records = list.getSelection(); + ListGridRecord[] records = list.getSelectedRecords(); if (records == null || records.length == 0) { GWT.log("ThemePanel.onMove: No records selected."); @@ -626,9 +634,11 @@ artifact, locale, new AsyncCallback<CollectionItemAttribute>() { + @Override public void onFailure (Throwable caught) { SC.warn(MSG.getString(caught.getMessage())); } + @Override public void onSuccess(CollectionItemAttribute cia) { GWT.log("Successfully loaded collectionitem attributes."); showStyleEditor(cia, record);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQSimpleArrayPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQSimpleArrayPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -7,7 +7,6 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.user.client.rpc.AsyncCallback; - import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; @@ -18,9 +17,19 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet; -import com.smartgwt.client.widgets.tab.Tab; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.services.GaugeInfoService; +import de.intevation.flys.client.client.services.GaugeInfoServiceAsync; +import de.intevation.flys.client.client.services.WQInfoService; +import de.intevation.flys.client.client.services.WQInfoServiceAsync; +import de.intevation.flys.client.client.ui.wq.ClickableQDTable; +import de.intevation.flys.client.client.ui.wq.ClickableWTable; +import de.intevation.flys.client.client.ui.wq.ClickableWTable.ClickMode; +import de.intevation.flys.client.client.ui.wq.QDTable; import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; @@ -30,17 +39,8 @@ import de.intevation.flys.client.shared.model.DoubleArrayData; import de.intevation.flys.client.shared.model.Gauge; import de.intevation.flys.client.shared.model.IntegerOptionsData; -import de.intevation.flys.client.shared.model.WQInfoRecord; import de.intevation.flys.client.shared.model.WQInfoObject; - -import de.intevation.flys.client.client.Config; -import de.intevation.flys.client.client.FLYSConstants; -import de.intevation.flys.client.client.services.GaugeInfoService; -import de.intevation.flys.client.client.services.GaugeInfoServiceAsync; -import de.intevation.flys.client.client.services.WQInfoService; -import de.intevation.flys.client.client.services.WQInfoServiceAsync; -import de.intevation.flys.client.client.ui.wq.WTable; -import de.intevation.flys.client.client.ui.wq.QDTable; +import de.intevation.flys.client.shared.model.WQInfoRecord; /** @@ -71,12 +71,14 @@ protected Canvas valuesWrapper; + protected TabSet tabs; + protected DynamicForm modeForm; protected DoubleArrayPanel panelW; protected DoubleArrayPanel panelQ; - protected WTable wTable; - protected QDTable qTable; + protected ClickableWTable wTable; + protected ClickableQDTable qTable; @Override @@ -170,15 +172,37 @@ protected void initializeTables() { - wTable = new WTable(); - qTable = new QDTable(); + wTable = new ClickableWTable(new ClickableWTable.WClickedListener() { + @Override + public void clickedUpper(double value) { + // nothing to do here + } + + @Override + public void clickedLower(double value) { + panelW.addValue(value); + } + }, ClickMode.SINGLE); + + qTable = new ClickableQDTable(new ClickableQDTable.QClickedListener() { + + @Override + public void clickedUpper(double value) { + // nothing to do here + } + + @Override + public void clickedLower(double value) { + panelQ.addValue(value); + } + }, ClickableQDTable.ClickMode.SINGLE); fetchWQData(); } protected void initializeHelperPanel() { - TabSet tabs = new TabSet(); + tabs = new TabSet(); tabs.setWidth100(); tabs.setHeight100(); @@ -376,9 +400,23 @@ if (newMode.equals("0")) { valuesWrapper.addChild(panelW); + showWTable(); } else if (newMode.equals("1")) { valuesWrapper.addChild(panelQ); + showQDTable(); + } + } + + public void showWTable() { + if (tabs != null) { + tabs.selectTab(0); + } + } + + public void showQDTable() { + if (tabs != null) { + tabs.selectTab(1); } }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WaterlevelGroundPanel.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WaterlevelGroundPanel.java Mon Oct 22 17:07:02 2012 +0200 @@ -2,6 +2,8 @@ public class WaterlevelGroundPanel extends DistancePanel { + private static final long serialVersionUID = 6598703468619862469L; + public static final String FIELD_LOWER = "diff_from"; public static final String FIELD_UPPER = "diff_to"; public static final String FIELD_STEP = "diff_diff";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/ClickableQDTable.java Mon Oct 22 17:07:02 2012 +0200 @@ -0,0 +1,171 @@ +package de.intevation.flys.client.client.ui.wq; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; +import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.types.SelectionStyle; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.events.CellClickEvent; +import com.smartgwt.client.widgets.grid.events.CellClickHandler; + +import de.intevation.flys.client.client.FLYSConstants; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class ClickableQDTable extends ListGrid { + + public static enum ClickMode { + NONE, SINGLE, RANGE + } + + public static interface QClickedListener { + + void clickedLower(double value); + + void clickedUpper(double value); + } + + /** The message class that provides i18n strings. */ + protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class); + + private QClickedListener qClickedListener; + private ClickMode clickMode; + + protected boolean lockClick; + + public ClickableQDTable() { + this.clickMode = ClickMode.NONE; + init(); + } + + public ClickableQDTable(QClickedListener qClickedListener, + ClickMode clickMode) { + this.qClickedListener = qClickedListener; + this.clickMode = clickMode; + init(); + } + + private void init() { + setWidth100(); + setHeight100(); + setSelectionType(SelectionStyle.SINGLE); + setSelectionType(SelectionStyle.SINGLE); + setShowHeaderContextMenu(false); + setShowRecordComponents(true); + setShowRecordComponentsByCell(true); + setEmptyMessage(MESSAGE.empty_table()); + + ListGridField name = new ListGridField("name", MESSAGE.discharge()); + name.setType(ListGridFieldType.TEXT); + name.setWidth("*"); + + ListGridField type = new ListGridField("type", MESSAGE.type()); + type.setType(ListGridFieldType.TEXT); + type.setWidth("20%"); + + final NumberFormat nf = NumberFormat.getDecimalFormat(); + + ListGridField value = new ListGridField("value", MESSAGE.wq_value_q()); + value.setType(ListGridFieldType.FLOAT); + value.setCellFormatter(new CellFormatter() { + + @Override + public String format(Object v, ListGridRecord r, int row, int col) { + if (v == null) { + return null; + } + + try { + double value = Double.valueOf(v.toString()); + return nf.format(value); + } + catch (NumberFormatException nfe) { + return v.toString(); + } + } + }); + value.setWidth("20%"); + + switch (clickMode) { + case NONE: + setFields(name, type, value); + break; + case SINGLE: + initSingleClickMode(name, type, value); + break; + case RANGE: + initRangeClickMode(name, type, value); + break; + } + } + + private void initSingleClickMode(ListGridField name, ListGridField type, + ListGridField value) { + ListGridField select = new ListGridField("select", MESSAGE.selection()); + select.setType(ListGridFieldType.ICON); + select.setWidth(70); + select.setCellIcon(GWT.getHostPageBaseURL() + MESSAGE.markerGreen()); + + addCellClickHandler(new CellClickHandler() { + + @Override + public void onCellClick(CellClickEvent event) { + if (event.getColNum() == 0) { + ListGridRecord r = event.getRecord(); + fireLowerClickEvent(r.getAttributeAsDouble("value")); + } + } + }); + + setFields(select, name, type, value); + } + + private void initRangeClickMode(ListGridField name, ListGridField type, + ListGridField value) { + ListGridField addMin = new ListGridField("min", MESSAGE.to()); + addMin.setType(ListGridFieldType.ICON); + addMin.setWidth(30); + addMin.setCellIcon(GWT.getHostPageBaseURL() + MESSAGE.markerGreen()); + + ListGridField addMax = new ListGridField("max", MESSAGE.from()); + addMax.setType(ListGridFieldType.ICON); + addMax.setWidth(30); + addMax.setCellIcon(GWT.getHostPageBaseURL() + MESSAGE.markerRed()); + + addCellClickHandler(new CellClickHandler() { + + @Override + public void onCellClick(CellClickEvent event) { + if (event.getColNum() == 0) { + ListGridRecord r = event.getRecord(); + fireLowerClickEvent(r.getAttributeAsDouble("value")); + } + + if (event.getColNum() == 1) { + ListGridRecord r = event.getRecord(); + fireUpperClickEvent(r.getAttributeAsDouble("value")); + } + } + }); + + setFields(addMin, addMax, name, type, value); + } + + private void fireLowerClickEvent(double value) { + if (qClickedListener != null) { + qClickedListener.clickedLower(value); + } + } + + private void fireUpperClickEvent(double value) { + if (qClickedListener != null) { + qClickedListener.clickedUpper(value); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/ClickableWTable.java Mon Oct 22 17:07:02 2012 +0200 @@ -0,0 +1,172 @@ +package de.intevation.flys.client.client.ui.wq; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; +import com.smartgwt.client.data.Record; +import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.types.SelectionStyle; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.events.CellClickEvent; +import com.smartgwt.client.widgets.grid.events.CellClickHandler; + +import de.intevation.flys.client.client.FLYSConstants; + + +public class ClickableWTable extends ListGrid { + + public static enum ClickMode { + NONE, SINGLE, RANGE + } + + public static interface WClickedListener { + + void clickedLower(double value); + + void clickedUpper(double value); + } + + /** The message class that provides i18n strings. */ + protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class); + + private WClickedListener wClickedListener; + private ClickMode clickMode; + + public ClickableWTable() { + this.clickMode = ClickMode.NONE; + init(); + } + + public ClickableWTable(WClickedListener lowerListener, + ClickMode selectionMode) { + this.wClickedListener = lowerListener; + this.clickMode = selectionMode; + init(); + } + + private void init() { + setWidth100(); + setHeight100(); + setSelectionType(SelectionStyle.NONE); + setSelectionType(SelectionStyle.NONE); + setShowHeaderContextMenu(false); + setShowRecordComponents(true); + setShowRecordComponentsByCell(true); + setEmptyMessage(MESSAGE.empty_table()); + + ListGridField name = new ListGridField("name", MESSAGE.name()); + name.setType(ListGridFieldType.TEXT); + name.setWidth("*"); + + ListGridField type = new ListGridField("type", MESSAGE.type()); + type.setType(ListGridFieldType.TEXT); + type.setWidth("50"); + + final NumberFormat nf = NumberFormat.getDecimalFormat(); + + ListGridField value = new ListGridField("value", MESSAGE.wq_value_w()); + value.setType(ListGridFieldType.FLOAT); + value.setCellFormatter(new CellFormatter() { + + @Override + public String format(Object v, ListGridRecord r, int row, int col) { + if (v == null) { + return null; + } + + try { + double value = Double.valueOf(v.toString()); + return nf.format(value); + } + catch (NumberFormatException nfe) { + return v.toString(); + } + } + }); + + switch (clickMode) { + case NONE: + setFields(name, type, value); + break; + case SINGLE: + initSingleClickMode(name, type, value); + break; + case RANGE: + initRangeClickMode(name, type, value); + break; + } + } + + private void initSingleClickMode(ListGridField name, ListGridField type, + ListGridField value) { + ListGridField lower = new ListGridField("selection", + MESSAGE.selection()); + lower.setType(ListGridFieldType.ICON); + lower.setWidth("65"); + lower.setCellIcon(GWT.getHostPageBaseURL() + MESSAGE.markerGreen()); + addCellClickHandler(new CellClickHandler() { + + @Override + public void onCellClick(CellClickEvent event) { + if (event.getColNum() == 0) { + Record r = event.getRecord(); + double val = r.getAttributeAsDouble("value"); + fireLowerClickEvent(val); + } + } + }); + + setFields(lower, name, type, value); + } + + private void initRangeClickMode(ListGridField name, ListGridField type, + ListGridField value) { + ListGridField lower = new ListGridField("lower", MESSAGE.lower()); + lower.setType(ListGridFieldType.ICON); + lower.setWidth("50"); + lower.setCellIcon(GWT.getHostPageBaseURL() + MESSAGE.markerRed()); + addCellClickHandler(new CellClickHandler() { + + @Override + public void onCellClick(CellClickEvent event) { + if (event.getColNum() == 0) { + Record r = event.getRecord(); + double val = r.getAttributeAsDouble("value"); + fireLowerClickEvent(val); + } + } + }); + + ListGridField upper = new ListGridField("upper", MESSAGE.upper()); + upper.setType(ListGridFieldType.ICON); + upper.setWidth("50"); + upper.setCellIcon(GWT.getHostPageBaseURL() + MESSAGE.markerGreen()); + addCellClickHandler(new CellClickHandler() { + + @Override + public void onCellClick(CellClickEvent event) { + if (event.getColNum() == 1) { + Record r = event.getRecord(); + double val = r.getAttributeAsDouble("value"); + fireUpperClickEvent(val); + } + } + }); + + setFields(lower, upper, name, type, value); + } + + private void fireLowerClickEvent(double value) { + if (wClickedListener != null) { + wClickedListener.clickedLower(value); + } + } + + private void fireUpperClickEvent(double value) { + if (wClickedListener != null) { + wClickedListener.clickedUpper(value); + } + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java Mon Oct 22 17:07:02 2012 +0200 @@ -32,6 +32,7 @@ private boolean deactivate = false; private String authmethod; + private String redirecturl; private ServletContext sc; public static final String LOGIN_JSP = "/login.jsp"; @@ -52,6 +53,7 @@ this.sc = config.getServletContext(); logger.debug("GGInAFilter context " + this.sc.getContextPath()); this.authmethod = sc.getInitParameter("authentication"); + this.redirecturl = sc.getInitParameter("redirect-url"); if (deactivate != null && deactivate.equalsIgnoreCase("true")) { this.deactivate = true; } @@ -95,9 +97,16 @@ return; } + boolean redirect = false; + HttpSession session = sreq.getSession(); - String uri = requesturi; + String uri = path + "/" + this.redirecturl; + + if (requesturi.equals(uri)) { + redirect = true; + } + if (sreq.getQueryString() != null) { uri = uri + "?" + sreq.getQueryString(); } @@ -106,7 +115,7 @@ User user = (User)session.getAttribute("user"); if (user == null) { logger.debug("No user in session: " + requesturi); - this.redirect(resp); + this.handleResponse(resp, redirect); return; } if (user.hasExpired()) { @@ -117,12 +126,12 @@ Authentication auth = this.auth(user, encoding); if (auth == null || !auth.isSuccess()) { logger.debug("Re-athentication not successful"); - this.redirect(resp); + this.handleResponse(resp, redirect); } } catch(AuthenticationException e) { logger.error("Failure during re-authentication", e); - this.redirect(resp); + this.handleResponse(resp, redirect); return; } } @@ -138,6 +147,20 @@ "/login.jsp"); } + private void sendNotAuthenticated(ServletResponse resp) throws IOException { + logger.debug("Send not authenticated"); + ((HttpServletResponse)resp).sendError(HttpServletResponse.SC_FORBIDDEN, "User not authenticated"); + } + + private void handleResponse(ServletResponse resp, boolean redirect) throws IOException { + if (redirect) { + this.redirect(resp); + } + else { + this.sendNotAuthenticated(resp); + } + } + /** * Do nothing at destruction.
--- a/flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java Mon Oct 22 17:07:02 2012 +0200 @@ -40,7 +40,9 @@ private void redirectSuccess(HttpServletResponse resp, String path, String uri) throws IOException { if (uri == null) { - uri = path + "/FLYS.html"; + String redirecturl = getServletContext().getInitParameter("redirect-url"); + + uri = "/" + redirecturl; } resp.sendRedirect(uri); }
--- a/flys-client/src/main/webapp/WEB-INF/web.xml Mon Oct 22 09:10:40 2012 +0200 +++ b/flys-client/src/main/webapp/WEB-INF/web.xml Mon Oct 22 17:07:02 2012 +0200 @@ -11,6 +11,12 @@ </context-param> <context-param> + <!-- URL to be redirected after successfull authentication --> + <param-name>redirect-url</param-name> + <param-value>FLYS.html</param-value> + </context-param> + + <context-param> <param-name>authentication</param-name> <param-value>GGInA</param-value> </context-param>