view flys-client/src/main/java/de/intevation/flys/client/client/ui/ContinuePanel.java @ 4253:a1bc5b8cff0f

Refactor GaugePanel to create it's own SectionStackSection The GaugePanel constructor now creates a SectionStackSection instead of using a provided one. Improve the rendering of the GaugePanel by having access to the SmartGWT wrapper (WidgetCanvas) object for the GWT Tree (GaugeTree) directly. Add methods to close and open the section. Also add a getter for the section.
author Björn Ricks <bjoern.ricks@intevation.de>
date Thu, 25 Oct 2012 13:52:58 +0200
parents 360e22afb98b
children
line wrap: on
line source
package de.intevation.flys.client.client.ui;

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

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;

import de.intevation.flys.client.client.FLYSConstants;
import de.intevation.flys.client.client.event.AdvanceHandler;
import de.intevation.flys.client.shared.model.ArtifactDescription;
import de.intevation.flys.client.shared.model.Data;
import de.intevation.flys.client.shared.model.DataList;

import java.util.ArrayList;
import java.util.List;


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class ContinuePanel extends AbstractUIProvider {

    private static final long serialVersionUID = -5882814816875137397L;

    protected static FLYSConstants MSG = GWT.create(FLYSConstants.class);

    protected List<AdvanceHandler> advHandlers;


    @Override
    public Canvas create(DataList dataList) {
        DynamicForm form = new DynamicForm();
        form.setWidth(200);
        form.setHeight(35);

        LinkItem next = new LinkItem();
        next.setShowTitle(false);
        next.setLinkTitle(MSG.next());

        final ArtifactDescription desc = artifact.getArtifactDescription();
        final String[] reachable       = desc.getReachableStates();

        next.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent e) {
                fireOnAdvance(reachable[0]);
            }
        });

        form.setFields(next);

        return form;
    }


    @Override
    public Canvas createOld(DataList dataList) {
        return null;
    }


    @Override
    protected Data[] getData() {
        return new Data[0];
    }


    public void addAdvanceHandler(AdvanceHandler handler) {
        if (advHandlers == null) {
            advHandlers = new ArrayList<AdvanceHandler>();
        }

        if (handler != null) {
            advHandlers.add(handler);
        }
    }


    public void fireOnAdvance(String target) {
        if (advHandlers == null || advHandlers.isEmpty()) {
            return;
        }

        for (AdvanceHandler handler: advHandlers) {
            handler.onAdvance(target);
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org