ingo@30: package de.intevation.flys.client.client.ui; ingo@30: ingo@30: import com.google.gwt.core.client.GWT; ingo@30: ingo@30: import com.smartgwt.client.widgets.Canvas; ingo@30: import com.smartgwt.client.widgets.IButton; ingo@30: import com.smartgwt.client.widgets.Label; ingo@30: import com.smartgwt.client.widgets.form.DynamicForm; ingo@30: import com.smartgwt.client.widgets.form.fields.RadioGroupItem; ingo@30: import com.smartgwt.client.widgets.layout.HLayout; ingo@30: import com.smartgwt.client.widgets.layout.VLayout; ingo@30: ingo@30: import de.intevation.flys.client.shared.model.Data; ingo@30: import de.intevation.flys.client.shared.model.DataItem; ingo@30: import de.intevation.flys.client.shared.model.DefaultData; ingo@30: import de.intevation.flys.client.shared.model.DefaultDataItem; ingo@30: ingo@30: import de.intevation.flys.client.client.FLYSMessages; ingo@30: ingo@30: /** ingo@30: * The ModuleSelection combines the river selection and the module selection in ingo@30: * one widget. It will display a vertical splitted widget - the upper part will ingo@30: * render checkboxes for each module, the lower one will display a combobox at ingo@30: * the left and a map panel on the right to choose the river. ingo@30: * ingo@30: * @author Ingo Weinzierl ingo@30: */ ingo@30: public class ModuleSelection extends MapSelection { ingo@30: ingo@30: /** The message class that provides i18n strings.*/ ingo@30: protected FLYSMessages MESSAGES = GWT.create(FLYSMessages.class); ingo@30: ingo@30: /** The module checkboxes.*/ ingo@30: protected RadioGroupItem radio; ingo@30: ingo@30: ingo@30: /** ingo@30: * The default constructor. ingo@30: */ ingo@30: public ModuleSelection() { ingo@30: } ingo@30: ingo@30: ingo@30: /** ingo@30: * This method returns a widget that renders the checkboxes for each module ingo@30: * and the MapSelection that lets the user choose the river. ingo@30: * ingo@30: * @param data The provided rivers. ingo@30: * ingo@30: * @return the module selection combined with the river selection. ingo@30: */ ingo@30: public Canvas create(Data data) { ingo@38: dataName = data.getLabel(); ingo@38: ingo@30: VLayout newLayout = new VLayout(); ingo@30: newLayout.setMembersMargin(10); ingo@30: ingo@30: Canvas moduleSelection = createWidget(); ingo@30: Canvas riverSelection = super.createWidget(data); ingo@30: IButton go = new IButton(MESSAGES.next(), this); ingo@30: ingo@30: moduleSelection.setHeight(25); ingo@30: ingo@30: newLayout.addMember(moduleSelection); ingo@30: newLayout.addMember(riverSelection); ingo@30: newLayout.addMember(go); ingo@30: ingo@30: return newLayout; ingo@30: } ingo@30: ingo@30: ingo@30: /** ingo@30: * Creates a widget that displays a checkbox for each module. ingo@30: * ingo@30: * @return a widget with checkboxes. ingo@30: */ ingo@30: protected Canvas createWidget() { ingo@30: HLayout layout = new HLayout(); ingo@30: ingo@30: Label label = new Label(MESSAGES.module_selection()); ingo@30: DynamicForm form = new DynamicForm(); ingo@30: ingo@30: radio = new RadioGroupItem("plugin"); ingo@30: ingo@30: label.setWidth(50); ingo@30: ingo@30: radio.setShowTitle(false); ingo@30: radio.setVertical(false); ingo@30: radio.setValueMap( ingo@30: messages.winfo(), ingo@30: messages.minfo(), ingo@30: messages.map(), ingo@30: messages.fix()); ingo@30: ingo@30: form.setFields(radio); ingo@30: ingo@30: layout.addMember(label); ingo@30: layout.addMember(form); ingo@30: ingo@30: return layout; ingo@30: } ingo@30: ingo@30: ingo@30: /** ingo@30: * This method prepares the data of two widgets - the module selection and ingo@30: * the river selection. The returning field will contain the Data that ingo@30: * represents the module selection at first position, the second position ingo@30: * stores the Data object that represents the river selection. ingo@30: * ingo@30: * @return the Data that was chosen in this widget. ingo@30: */ ingo@30: protected Data[] getData() { ingo@30: Data[] river = super.getData(); ingo@30: ingo@30: String module = radio.getValueAsString(); ingo@30: ingo@30: DataItem[] items = new DefaultDataItem[1]; ingo@30: items[0] = new DefaultDataItem(module, module, module); ingo@30: ingo@30: Data data = new DefaultData("module", null, null, items, null); ingo@30: ingo@30: return new Data[] {data, river[0]}; ingo@30: } ingo@30: } ingo@30: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :