Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java @ 1408:5b5a20e4c4e5
Added a service that loads the Capabilities of a specified WMS - display those information in the ExternalWMSWindow.
flys-client/trunk@3295 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 21 Nov 2011 12:00:48 +0000 |
parents | 546f7f890ffa |
children | bc06a671ef60 |
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.Alignment; import com.smartgwt.client.widgets.Canvas; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.form.fields.SpinnerItem; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DefaultArtifact; import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; import de.intevation.flys.client.shared.model.FacetRecord; import de.intevation.flys.client.client.services.FeedServiceAsync; /** * ThemePanel much like ChartThemePanel, but shows an "Actions" column, * needed for interaction in the CrossSection Charts. */ public class CrossSectionChartThemePanel extends ChartThemePanel { /** * Trivial constructor. */ public CrossSectionChartThemePanel( Collection collection, OutputMode mode) { super(collection, mode); } /** * Create the handler for ChangeEvents on the Spinner in the * facets that control km of cross section. * * @param feedService The FeedService to send (changed) data to. * @param facetRecord The FacetRecord (~row in table) where this * handler is added to (to a child, to be exact). */ public final ChangedHandler createSpinnerHandler( final FeedServiceAsync feedService, final FacetRecord facetRecord) { Config config = Config.getInstance(); final String serverUrl = config.getServerUrl(); final String locale = config.getLocale(); ChangedHandler handler = new ChangedHandler() { @Override public void onChanged(ChangedEvent ce) { if (ce.getValue() == null) { return; } DefaultDataItem kmItem = new DefaultDataItem( "cross_section.km", "cross_section.km", ce.getValue().toString()); DefaultData km = new DefaultData( "cross_section.km", null, null, new DataItem[] {kmItem}); Data[] feedData = new Data[] {km}; feedService.feed(serverUrl, locale, new DefaultArtifact( facetRecord.getTheme().getArtifact(), "TODO:hash"), feedData, new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { GWT.log("Could not feed artifact " + caught.getMessage()); // TODO SC.warn } public void onSuccess(Artifact artifact) { GWT.log("Successfully fed"); // TODO: Also update content of spinnerbox requestRedraw(); } }); } }; return handler; } /** * Create and configure the Grid to display. */ @Override protected ListGrid createGrid() { ListGrid list = new ListGrid() { @Override protected Canvas createRecordComponent( final ListGridRecord record, Integer colNum) { // Only cross_section Facets display an action widget. final FacetRecord facetRecord = (FacetRecord) record; if (!facetRecord.getTheme().getFacet().equals( "cross_section")) { return null; } String fieldName = this.getFieldName(colNum); if (fieldName.equals(GRID_FIELD_ACTIONS)) { HLayout recordCanvas = new HLayout(3); recordCanvas.setHeight(22); recordCanvas.setAlign(Alignment.CENTER); // TODO Refactor in createSpinner(data, artifact) SpinnerItem spinnerItem = new SpinnerItem(); spinnerItem.setShowTitle(false); spinnerItem.setTitle("Waterlevel-Spinner"); spinnerItem.setWidth(45); // TODO actually get the value from artifact // TODO actually get the range from artifact (or river?) spinnerItem.setDefaultValue(0); spinnerItem.setMin(0); spinnerItem.setMax(1000); spinnerItem.setStep(5f); spinnerItem.setChangeOnKeypress(true); spinnerItem.addChangedHandler( createSpinnerHandler( feedService, facetRecord)); DynamicForm formWrap = new DynamicForm(); formWrap.setFields(spinnerItem); formWrap.setTitlePrefix(""); formWrap.setTitleSuffix(""); recordCanvas.addMember(formWrap); return recordCanvas; } else { return null; } } }; list.setCanResizeFields(true); list.setShowRecordComponents(true); list.setShowRecordComponentsByCell(true); list.setShowAllRecords(true); list.setShowHeaderContextMenu(false); return list; } /** * Initializes the components (columns) of the theme grid. */ @Override protected void initGrid() { list.setCanEdit(true); list.setCanSort(false); list.setShowRecordComponents(true); 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); ListGridField actions = new ListGridField(GRID_FIELD_ACTIONS, MSG.chart_themepanel_header_actions(), 50); list.setFields(active, name, actions); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :