# HG changeset patch # User Felix Wolfsteller # Date 1324042583 0 # Node ID bdac8a72f7e632d34e29aed0a8850a5db0dd111d # Parent ec0460dbbae25e58b339e149aaf0096aee4f2246 Area creation UI update. flys-client/trunk@3440 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r ec0460dbbae2 -r bdac8a72f7e6 flys-client/ChangeLog --- a/flys-client/ChangeLog Fri Dec 16 13:28:47 2011 +0000 +++ b/flys-client/ChangeLog Fri Dec 16 13:36:23 2011 +0000 @@ -1,3 +1,13 @@ +2011-12-16 Felix Wolfsteller + + Bring further UI regarding area creation (in cross-sections). + + * src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java + (createAreaArtifact): New, create an areaartifact. + (feedTellArea): New, feed an areaartifact with relevant information. + (getSingleContextMenu): New, add further (sub)menuitems to trigger + area creation. + 2011-12-16 Felix Wolfsteller * src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java: diff -r ec0460dbbae2 -r bdac8a72f7e6 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Fri Dec 16 13:28:47 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Fri Dec 16 13:36:23 2011 +0000 @@ -19,6 +19,10 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.menu.events.ClickHandler; +import com.smartgwt.client.widgets.menu.Menu; +import com.smartgwt.client.widgets.menu.MenuItem; +import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; import com.smartgwt.client.widgets.form.fields.SpinnerItem; import com.smartgwt.client.widgets.form.DynamicForm; @@ -39,11 +43,16 @@ import de.intevation.flys.client.shared.model.DefaultDataItem; import de.intevation.flys.client.shared.model.FacetRecord; import de.intevation.flys.client.shared.model.OutputMode; +import de.intevation.flys.client.shared.model.Recommendation; import de.intevation.flys.client.shared.model.Theme; import de.intevation.flys.client.shared.model.ThemeList; +import de.intevation.flys.client.client.services.CrossSectionKMServiceAsync; import de.intevation.flys.client.client.services.FeedServiceAsync; -import de.intevation.flys.client.client.services.CrossSectionKMServiceAsync; +import de.intevation.flys.client.client.services.LoadArtifactService; +import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; + + /** * ThemePanel much like ChartThemePanel, but shows an "Actions" column, @@ -52,6 +61,9 @@ */ public class CrossSectionChartThemePanel extends ChartThemePanel { + /** Artifact Clone/Creation service. */ + protected LoadArtifactServiceAsync loadService = + GWT.create(LoadArtifactService.class); /** Service to query measurement points of cross sections. */ CrossSectionKMServiceAsync kmService = GWT.create( @@ -104,6 +116,39 @@ /** + * Tell an area artifact where to get the upper and lower curve from. + */ + public void feedTellArea(final String artifact, Theme under, Theme over) { + Data[] feedData = new Data[] { + DefaultData.createSimpleStringData("area.curve_under", + under.getArtifact() + under.getIndex()), + DefaultData.createSimpleStringData("area.curve_over", + over.getArtifact() + over.getIndex()), + }; + + feedService.feed( + Config.getInstance().getLocale(), + new DefaultArtifact(artifact, "TODO:hash"), + feedData, + new AsyncCallback() { + public void onFailure(Throwable caught) { + GWT.log("Could not feed artifact (" + artifact + + ") with area info: " + caught.getMessage()); + SC.warn(MSG.getString(caught.getMessage())); + enable(); + } + public void onSuccess(Artifact artifact) { + GWT.log("Successfully set area params to " + artifact); + requestRedraw(); + enable(); + // TODO: Update the grid/collection, to include this new + // facet. + //updateCollection? + } + }); + } + + /** * sets currentMasterUUID. */ public String findCurrentMaster() { @@ -122,6 +167,7 @@ return null; } + /** * Create Layout, add a master selection box beneath. */ @@ -475,5 +521,91 @@ public void setCurrentMaster(String currentMasterUuid) { this.currentMasterUUID = currentMasterUuid; } + + + /** + * Create and parameterize a new area artifact. + */ + public void createAreaArtifact(final Theme under, final Theme over) { + Config config = Config.getInstance(); + String locale = config.getLocale(); + + Recommendation area = new Recommendation( + "area", + "", + "", + null); + Recommendation[] recommendations = new Recommendation[] {area}; + + loadService.loadMany( + this.collection, + recommendations, + null, //use individual factories. + locale, + new AsyncCallback() { + public void onFailure(Throwable caught) { + GWT.log("Failed, no area artifact: " + caught.getMessage()); + enable(); + // TODO SC.warn + } + public void onSuccess(Artifact[] artifacts) { + GWT.log("Success, created area artifact: " + + artifacts[0].getUuid()); + // Now, feed the artifact with the relevant data. + feedTellArea(artifacts[0].getUuid(), under, over); + } + } + ); + } + + /** + * Include area specific menu items. + */ + protected Menu getSingleContextMenu(final ListGridRecord[] records) { + Menu menu = super.getSingleContextMenu(records); + + final Theme facetTheme = ((FacetRecord)records[0]).getTheme(); + String thisItem = facetTheme.getDescription(); + if (facetTheme.getFacet().equals("area")) { + return menu; + } + + menu.addItem(createSeparator()); + + // TODO i18n + //MenuItem properties = new MenuItem(MSG.properties()); + MenuItem areaMenuItem = new MenuItem("New Area..."); + Menu areaMenu = new Menu(); + + ThemeList themes = getThemeList(); + int nThemes = themes.getThemeCount(); + for (int i = 0; i < nThemes; i++) { + final Theme theme = themes.getThemeAt(i+1); + if (theme.getDescription().equals(thisItem) + || theme.getFacet().equals("area")) { + continue; + } + MenuItem againster = new MenuItem(theme.getDescription()); + areaMenu.addItem(againster); + + againster.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent evt) { + disable(); + createAreaArtifact(facetTheme, theme); + } + }); + } + + MenuItem underMenuItem = new MenuItem("Under ..."); + MenuItem overMenuItem = new MenuItem("Over ..."); + areaMenu.addItem(createSeparator()); + areaMenu.addItem(underMenuItem); + areaMenu.addItem(overMenuItem); + + areaMenuItem.setSubmenu(areaMenu); + menu.addItem(areaMenuItem); + + return menu; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :