view flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java @ 1431:987f95ceb623

Added property fields to the chart properties editor dialog. flys-client/trunk@3385 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 12 Dec 2011 09:02:13 +0000
parents 16b7adc66330
children 8da36efc839a
line wrap: on
line source
package de.intevation.flys.client.client.ui.chart;

import java.util.LinkedHashMap;

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

import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.tab.TabSet;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;

import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
import com.smartgwt.client.types.Alignment;

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

/**
 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
 */
public class ChartPropertiesEditor
extends Window
implements ClickHandler
{
    /** The interface that provides i18n messages. */
    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);

    /** The tab called the editor window. */
    protected OutputTab tab;

    /** The tabset for chart properties */
    protected TabSet tabs;

    /**
     * Setup editor dialog.
     * @param callerTab      The tab called the editor window.
     */
    public ChartPropertiesEditor(OutputTab callerTab) {
        this.tab = callerTab;
        this.tabs = new TabSet();

        init();
    }

    /**
     * Initialize the editor window and its components.
     */
    protected void init() {
        setTitle(MSG.properties());
        setCanDragReposition(true);
        setCanDragResize(true);

        Tab diagram = new Tab(MSG.diagram());
        Tab axes = new Tab(MSG.axes());
        Tab legend = new Tab(MSG.legend());
        tabs.addTab(diagram);
        tabs.addTab(axes);
        tabs.addTab(legend);

        Button accept = new Button(MSG.label_ok());
        Button cancel = new Button(MSG.label_cancel());
        cancel.addClickHandler(this);
        accept.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent e) {

            }
        });

        HLayout buttons = new HLayout();
        buttons.addMember(accept);
        buttons.addMember(cancel);
        buttons.setAlign(Alignment.CENTER);
        buttons.setHeight(30);

        initChartPropertiesTab(diagram);
        initAxesPropertiesTab(axes);
        initLegendPropertiesTab(legend);

        addItem(tabs);
        addItem(buttons);
        setWidth(340);
        setHeight(470);
        centerInPage();
    }

    /**
     * This method is called when the user aborts theming.
     * @param event The event.
     */
    public void onClick(ClickEvent event) {
        this.hide();
    }

    /**
     * Initializes the tab for general chart properties.
     */
    protected void initChartPropertiesTab(Tab t) {
        VLayout properties = new VLayout();
        DynamicForm form = new DynamicForm();

        TextItem title = new TextItem ();
        title.setTitle(MSG.chart_title());
        title.setTitleAlign(Alignment.LEFT);

        TextItem subTitle = new TextItem();
        subTitle.setTitle(MSG.chart_subtitle());
        subTitle.setTitleAlign(Alignment.LEFT);

        CheckboxItem grid = new CheckboxItem("grid", MSG.grid());
        grid.setLabelAsTitle(true);
        grid.setTitleStyle("color:#000;");
        grid.setTitleAlign(Alignment.LEFT);

        CheckboxItem antialiasing = new CheckboxItem("antialiasing",
                                                     MSG.antialiasing());
        antialiasing.setLabelAsTitle(true);
        antialiasing.setTitleStyle("color:#000;");
        antialiasing.setTitleAlign(Alignment.LEFT);

        form.setFields(new FormItem[] {title, subTitle, grid, antialiasing});
        properties.addMember(form);
        t.setPane(properties);
    }

    /**
     * Initializes the tab for axes properties.
     */
    protected void initAxesPropertiesTab(Tab t) {
        VLayout properties = new VLayout();
        Label scale = new Label(MSG.scale() + " :");
        Label scale1 = new Label(MSG.scale() + " :");
        Label scale2 = new Label(MSG.scale() + " :");
        Label scale3 = new Label(MSG.scale() + " :");
        scale.setHeight(25);
        scale1.setHeight(25);
        scale2.setHeight(25);
        scale3.setHeight(25);

        DynamicForm xform1 = new DynamicForm();
        DynamicForm xform2 = new DynamicForm();
        xform2.setNumCols(6);

        Label x_axis = new Label (MSG.x_axis());
        x_axis.setHeight(30);
        HLayout x_scale = new HLayout();
        TextItem xname = new TextItem ();
        xname.setTitle(MSG.axis_name());
        xname.setTitleAlign(Alignment.LEFT);

        TextItem xrange1 = new TextItem();
        xrange1.setTitle(MSG.chart_start());
        xrange1.setTitleAlign(Alignment.LEFT);
        xrange1.setWidth(50);

        TextItem xrange2 = new TextItem();
        xrange2.setTitle(MSG.chart_end());
        xrange2.setTitleAlign(Alignment.LEFT);
        xrange2.setWidth(50);

        CheckboxItem xfix = new CheckboxItem("xfix", "Fix");
        xfix.setLabelAsTitle(true);
        xfix.setTitleStyle("color:#000;");
        xfix.setTitleAlign(Alignment.LEFT);

        xform1.setFields(xname);
        xform2.setFields(xrange1, xrange2, xfix);
        x_scale.addMember(scale);
        x_scale.addMember(xform2);


        DynamicForm y1form1 = new DynamicForm();
        DynamicForm y1form2 = new DynamicForm();
        y1form2.setNumCols(6);

        Label y1_axis = new Label (MSG.y1_axis());
        y1_axis.setHeight(30);
        HLayout y1_scale = new HLayout();
        TextItem y1name = new TextItem ();
        y1name.setTitle(MSG.axis_name());
        y1name.setTitleAlign(Alignment.LEFT);

        TextItem y1range1 = new TextItem();
        y1range1.setTitle(MSG.chart_start());
        y1range1.setTitleAlign(Alignment.LEFT);
        y1range1.setWidth(50);

        TextItem y1range2 = new TextItem();
        y1range2.setTitle(MSG.chart_end());
        y1range2.setTitleAlign(Alignment.LEFT);
        y1range2.setWidth(50);

        CheckboxItem y1fix = new CheckboxItem("y1fix", "Fix");
        y1fix.setLabelAsTitle(true);
        y1fix.setTitleStyle("color:#000;");
        y1fix.setTitleAlign(Alignment.LEFT);

        y1form1.setFields(y1name);
        y1form2.setFields(y1range1, y1range2, y1fix);
        y1_scale.addMember(scale1);
        y1_scale.addMember(y1form2);


        DynamicForm y2form1 = new DynamicForm();
        DynamicForm y2form2 = new DynamicForm();
        y2form2.setNumCols(6);

        Label y2_axis = new Label (MSG.y2_axis());
        y2_axis.setHeight(30);
        HLayout y2_scale = new HLayout();
        TextItem y2name = new TextItem ();
        y2name.setTitle(MSG.axis_name());
        y2name.setTitleAlign(Alignment.LEFT);

        TextItem y2range1 = new TextItem();
        y2range1.setTitle(MSG.chart_start());
        y2range1.setTitleAlign(Alignment.LEFT);
        y2range1.setWidth(50);

        TextItem y2range2 = new TextItem();
        y2range2.setTitle(MSG.chart_end());
        y2range2.setTitleAlign(Alignment.LEFT);
        y2range2.setWidth(50);

        CheckboxItem y2fix = new CheckboxItem("y2fix", "Fix");
        y2fix.setLabelAsTitle(true);
        y2fix.setTitleStyle("color:#000;");
        y2fix.setTitleAlign(Alignment.LEFT);

        y2form1.setFields(y2name);
        y2form2.setFields(y2range1, y2range2, y2fix);
        y2_scale.addMember(scale2);
        y2_scale.addMember(y2form2);


        DynamicForm y3form1 = new DynamicForm();
        DynamicForm y3form2 = new DynamicForm();
        y3form2.setNumCols(6);

        Label y3_axis = new Label (MSG.y3_axis());
        y3_axis.setHeight(30);
        HLayout y3_scale = new HLayout();
        TextItem y3name = new TextItem ();
        y3name.setTitle(MSG.axis_name());
        y3name.setTitleAlign(Alignment.LEFT);

        TextItem y3range1 = new TextItem();
        y3range1.setTitle(MSG.chart_start());
        y3range1.setTitleAlign(Alignment.LEFT);
        y3range1.setWidth(50);

        TextItem y3range2 = new TextItem();
        y3range2.setTitle(MSG.chart_end());
        y3range2.setTitleAlign(Alignment.LEFT);
        y3range2.setWidth(50);

        CheckboxItem y3fix = new CheckboxItem("y3fix", "Fix");
        y3fix.setLabelAsTitle(true);
        y3fix.setTitleStyle("color:#000;");
        y3fix.setTitleAlign(Alignment.LEFT);

        y3form1.setFields(y3name);
        y3form2.setFields(y3range1, y3range2, y3fix);
        y3_scale.addMember(scale3);
        y3_scale.addMember(y3form2);


        properties.addMember(x_axis);
        properties.addMember(xform1);
        properties.addMember(x_scale);
        properties.addMember(y1_axis);
        properties.addMember(y1form1);
        properties.addMember(y1_scale);
        properties.addMember(y2_axis);
        properties.addMember(y2form1);
        properties.addMember(y2_scale);
        properties.addMember(y3_axis);
        properties.addMember(y3form1);
        properties.addMember(y3_scale);

        t.setPane(properties);
    }

    /**
     * Initializes the tab for legend properties.
     */
    protected void initLegendPropertiesTab(Tab t) {
        VLayout properties = new VLayout();
        DynamicForm form = new DynamicForm();

        TextItem name = new TextItem ();
        name.setTitle(MSG.legend_name());
        name.setTitleAlign(Alignment.LEFT);

        CheckboxItem show = new CheckboxItem("show", MSG.show_legend());
        show.setLabelAsTitle(true);
        show.setTitleStyle("color:#000;");
        show.setTitleAlign(Alignment.LEFT);

        form.setFields(name, show);
        properties.addMember(form);
        t.setPane(properties);
    }

}

http://dive4elements.wald.intevation.org