view flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java @ 1309:a95e82d6bcc1

Refactored the code to create a context menu and a style editor so that it is also available for maps. flys-client/trunk@2943 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 12 Oct 2011 08:53:17 +0000
parents d9cb362b8b34
children 6bb6d43eeb2d
line wrap: on
line source
package de.intevation.flys.client.client.ui.chart;

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

import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.VLayout;

import de.intevation.flys.client.shared.model.Collection;
import de.intevation.flys.client.shared.model.Theme;
import de.intevation.flys.client.shared.model.OutputMode;

import de.intevation.flys.client.client.FLYSConstants;
import de.intevation.flys.client.client.ui.ThemePanel;

import de.intevation.flys.client.client.services.FeedService;
import de.intevation.flys.client.client.services.FeedServiceAsync;

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

    /** The interface that provides i18n messages. */
    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);

    /** The collection */
    protected Collection collection;

    public static final String GRID_FIELD_ACTIVE  = "active";
    public static final String GRID_FIELD_NAME    = "name";
    public static final String GRID_FIELD_ACTIONS = "actions";

    FeedServiceAsync feedService = GWT.create(
        de.intevation.flys.client.client.services.FeedService.class);

    public ChartThemePanel(Collection collection, OutputMode mode) {
        super(collection, mode);
        this.collection = collection;

        initGrid();
        initLayout();

        updateGrid();
    }


    /**
     * Initializes the layout of this panel.
     */
    protected void initLayout() {
        setWidth100();
        setHeight100();

        VLayout layout = new VLayout();
        layout.setWidth100();
        layout.setHeight100();

        layout.addMember(list);
        layout.addMember(navigation);

        addChild(layout);
    }


    /**
     * Initializes the components (columns) of the theme grid.
     */
    protected void initGrid() {
        list.setCanEdit(true);
        list.setCanSort(false);
        list.setShowRecordComponents(false);
        list.setShowRecordComponentsByCell(true);
        list.setShowHeader(true);
        list.setShowHeaderContextMenu(false);
        list.setWidth100();
        list.setHeight100();

        list.addEditCompleteHandler(this);

        ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20);
        active.setType(ListGridFieldType.BOOLEAN);

        ListGridField name = new ListGridField(
            GRID_FIELD_NAME, MSG.chart_themepanel_header_themes());
        name.setType(ListGridFieldType.TEXT);

        list.setFields(active, name);
    }


    @Override
    public void activateTheme(Theme theme, boolean active) {
        theme.setActive(active ? 1 : 0);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org