Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java @ 5462:f2371f3aaf03
Show top level folder icons only if node has no factory
If you have an empty folder the folder icon is still shown.
This makes it possible to add functional "Top Level" entries
in the Datacage
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 26 Mar 2013 18:29:13 +0100 |
parents | 8af500d62098 |
children |
line wrap: on
line source
package de.intevation.flys.client.client.ui.map; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ButtonItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.services.CollectionAttributeService; import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.OutputSettings; import de.intevation.flys.client.shared.model.Property; import de.intevation.flys.client.shared.model.PropertySetting; import de.intevation.flys.client.shared.model.Settings; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; public class MapPrintSettingsPanel extends Canvas { public static final String MAPFISH_COMMENT = "mapfish-comment"; public static final String MAPFISH_LAYOUT = "mapfish-layout"; public static final String MAPFISH_MAPTITLE = "mapfish-mapTitle"; public static final String MAPFISH_PAGESIZE = "mapfish-pageSize"; /** The interface that provides i18n messages. */ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); /** CollectionAttribute Update Service. */ protected CollectionAttributeServiceAsync updater = GWT.create(CollectionAttributeService.class); protected Collection collection; protected Settings settings; protected TextItem pageTitle = new TextItem(); protected SelectItem pageFormat = createPageFormatSelectItem(); protected TextItem pageComment = new TextItem(); protected MapToolbar mapToolbar; protected MapPrintSettingsWindow parent; public MapPrintSettingsPanel(Collection collection, MapToolbar mapToolbar, MapPrintSettingsWindow parent) { this.collection = collection; this.mapToolbar = mapToolbar; this.parent = parent; initLayout(); this.settings = collection.getSettings("print-settings"); if (settings == null) { settings = new OutputSettings(); GWT.log("settings are empty"); } else { List<Property> properties = settings.getSettings("default"); for (Property prop : properties) { GWT.log("prop=" + prop.getName()); PropertySetting props = (PropertySetting)prop; if (props.getName().equals(MAPFISH_PAGESIZE)) { this.pageFormat.setValue(props.getValue()); } else if (props.getName().equals(MAPFISH_MAPTITLE)) { this.pageTitle.setValue(props.getValue()); GWT.log(props.getName() + "=" + props.getValue()); } else if (props.getName().equals(MAPFISH_COMMENT)) { this.pageComment.setValue(props.getValue()); } } } } protected void initLayout() { // TODO: i18n this.pageTitle.setTitle("Seitentitel:"); this.pageComment.setTitle("Kommentar:"); DynamicForm df = new DynamicForm(); df.setFields( this.pageFormat, this.pageTitle, this.pageComment, createSaveSettingsButtonItem() ); addChild(df); } protected SelectItem createPageFormatSelectItem() { LinkedHashMap values = new LinkedHashMap(); // TODO: i18n values.put("A4 landscape", "DIN A4 (Querformat)"); //values.put("A4 portrait", "DIN A4 (Hochformat)"); //values.put("A0 portrait", "DIN A0 (Hochformat)"); SelectItem selItem = new SelectItem(); selItem.setTitle("Seitengröße:"); // TODO: i18n selItem.setValueMap(values); selItem.setDefaultToFirstOption(true); return selItem; } protected ButtonItem createSaveSettingsButtonItem() { ButtonItem btn = new ButtonItem(); btn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { updateCollection(); mapToolbar.updatePrintUrl(); parent.destroy(); } }); btn.setTitle("Speichern"); return btn; } protected void updateCollection() { final Config config = Config.getInstance(); final String loc = config.getLocale(); GWT.log("MapPrintSettingsPanel.updateCollection via RPC now"); List<Property> properties = new ArrayList<Property>(); properties.add(new PropertySetting(MAPFISH_MAPTITLE, this.pageTitle.getValueAsString())); properties.add(new PropertySetting(MAPFISH_COMMENT, this.pageComment.getValueAsString())); properties.add(new PropertySetting(MAPFISH_LAYOUT, this.pageFormat.getValueAsString())); settings.setSettings("default", properties); collection.addSettings("print-settings", settings); updater.update(collection, loc, new AsyncCallback<Collection>() { @Override public void onFailure(Throwable caught) { GWT.log("Could not update collection attributes."); SC.warn(MSG.getString(caught.getMessage())); } @Override public void onSuccess(Collection collection) { GWT.log("MapPrintSettings: collection attributes updated"); } }); } }