view gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelRecommendationInfo.java @ 9416:05405292a7ca

Navigationtheme panel now shows themes of dWt and WQ charts grayed out, if the current station is outside the valid range of the theme.
author gernotbelger
date Thu, 16 Aug 2018 16:28:03 +0200
parents e3c2ae1887e8
children
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
 * Software engineering by
 *  Björnsen Beratende Ingenieure GmbH
 *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */
package org.dive4elements.river.client.client.ui;

import org.dive4elements.river.client.client.ui.DatacageTwinPanel.IDatacageTwinPanelInfo;
import org.dive4elements.river.client.shared.model.Recommendation;

import com.google.gwt.core.client.GWT;

/**
 * Factored out code from the old WaterlevelTwinPanel; contains some evil hacks about the involved artifact factories. See original comments below...
 *
 * @author Gernot Belger
 */
public final class WaterlevelRecommendationInfo implements IDatacageTwinPanelInfo {

    private final String outs;

    /**
     * @param tweakFactory See evil hack below
     */
    public WaterlevelRecommendationInfo(final String outs) {
        this.outs = outs;
    }

    @Override
    public String getFactory(final String originalFactory) {
        // FIXME: why are the factory here and the one used in createDataString different?
        // Probably also because of the 'throw all this code away comment'
        return "waterlevel";
    }

    @Override
    public String getDataStringFactory(final Recommendation recommendation) {
        return "staticwkms";
    }

    @Override
    public void adjustRecommendation(final Recommendation recommendation) {

        // XXX: THIS IS AN EVIL HACK TO MAKE W-DIFFERENCES WORK AGAIN!
        // TODO: Throw all this code away and do it with server side recommendations!
        recommendation.setTargetOut("w_differences");

        if (recommendation.getIDs() != null) {
            GWT.log("Setting staticwkms factory for rec with ID "
                    + recommendation.getIDs());
            recommendation.setFactory("staticwkms");
        }
        /*
        // So far, we do not need to rewrite the factory anymore,
        // except for staticwkms; probably other cases will pop up later.
        else if (recommendation.getFactory().equals("winfo")) {
            GWT.log("Setting waterlevel factory for a winfo rec.");
            recommendation.setFactory("waterlevel");
        }
         */
        else {
            GWT.log("Leave rec. id " + recommendation.getIDs() + ", factory "
                    + recommendation.getFactory() + " untouched.");
        }
    }

    @Override
    public String getOuts() {
        return this.outs;
    }

    @Override
    public String getColumnLabel() {
        return null;
    }
}

http://dive4elements.wald.intevation.org