Mercurial > dive4elements > river
changeset 1438:432180235caf
Minor refactoring and fix initial settings when creating ui.
flys-client/trunk@3403 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 13 Dec 2011 13:24:43 +0000 |
parents | 1d82a2c695a6 |
children | 4df2d9a4b9b4 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java |
diffstat | 2 files changed, 59 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Dec 13 13:23:18 2011 +0000 +++ b/flys-client/ChangeLog Tue Dec 13 13:24:43 2011 +0000 @@ -1,3 +1,9 @@ +2011-12-13 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java: + Minor refactoring. Correct intial settings for master-cs-artifact + and chosen km. + 2011-12-13 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/client/shared/model/ThemeList.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Tue Dec 13 13:23:18 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Tue Dec 13 13:24:43 2011 +0000 @@ -22,7 +22,6 @@ import com.smartgwt.client.widgets.form.fields.SpinnerItem; import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; @@ -105,12 +104,30 @@ /** + * sets currentMasterUUID. + */ + public String findCurrentMaster() { + ThemeList themeList = getThemeList(); + int count = getThemeList().getThemeCount(); + for (int i = 1; i <= count; i++) { + Theme theme = themeList.getThemeAt(i); + String value = theme.getCollectionItem().getData().get("cross_section.master?"); + + if (value != null && !value.equals("0")) { + setCurrentMaster(theme.getArtifact()); + GWT.log("found a master! " + currentMasterUUID + "/" + theme.getDescription()); + return theme.getDescription(); + } + } + return null; + } + + /** * Create Layout, add a master selection box beneath. */ @Override protected VLayout createLayout() { - - layout = super.createLayout(); + layout = super.createLayout(); // Create "set master" combobox. SelectItem cbItem = new SelectItem(); @@ -126,8 +143,10 @@ form.setFields(cbItem); layout.addMember(form); - Config config = Config.getInstance(); - final String locale = config.getLocale(); + Config config = Config.getInstance(); + final String locale = config.getLocale(); + findCurrentMaster(); + cbItem.setValue(getCurrentMaster()); // Add Change Handler to first unset the old master and then set the // new master. @@ -148,7 +167,7 @@ feedData, new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { - GWT.log("Could not un-master artifact: " + + GWT.log("Could not un-master artifact ("+getCurrentMaster()+"): " + caught.getMessage()); SC.warn(MSG.getString(caught.getMessage())); enable(); @@ -239,6 +258,7 @@ public void onSuccess(Artifact artifact) { GWT.log("Successfully fed"); requestRedraw(); + // TODO also feed the winfo/masterartifact? (for plot subtitle) enable(); } }); @@ -341,7 +361,32 @@ /** + * Create a "kilometer spinner" for CrossSection Facets. + * @param facetRecord The respective Facet/Theme. + * @return label, intialized SpinnerItem. + */ + public SpinnerItem createSpinnerItem(FacetRecord facetRecord) { + SpinnerItem spinnerItem = new SpinnerItem(); + spinnerItem.setShowTitle(false); + spinnerItem.setTitle("Waterlevel-Spinner"); + spinnerItem.setWidth(45); + spinnerItem.setDefaultValue(facetRecord.getTheme() + .getCollectionItem() + .getData().get("cross_section.km")); + + // TODO actually use crosssectionkmservice with + // min/max-extension + spinnerItem.setMin(0); + spinnerItem.setMax(1000); + spinnerItem.setStep(5f); + spinnerItem.setChangeOnKeypress(true); + return spinnerItem; + } + + + /** * Create and configure the Grid to display. + * @return ListGrid with Themes and related controls inside. */ @Override protected ListGrid createGrid() { @@ -366,24 +411,9 @@ 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 - spinnerItem.setDefaultValue( - getKmForCrossSectionIdx(facetRecord.getTheme().getIndex())); - - // TODO actually use crosssectionkmservive - spinnerItem.setMin(0); - spinnerItem.setMax(1000); - spinnerItem.setStep(5f); - spinnerItem.setChangeOnKeypress(true); - + SpinnerItem spinnerItem = createSpinnerItem(facetRecord); spinnerItem.addChangedHandler( - createSpinnerHandler( - feedService, - facetRecord)); + createSpinnerHandler(feedService, facetRecord)); DynamicForm formWrap = new DynamicForm(); formWrap.setFields(spinnerItem);