annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ExportPanel.java @ 9190:0633f963c5be

uinfo.inundationduration workflow
author gernotbelger
date Thu, 28 Jun 2018 15:10:04 +0200
parents fc42d82aa71c
children a4121ec450d6
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client.ui;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
11 import java.util.ArrayList;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import java.util.List;
2931
d6983b78de45 Export panel: Make code more robust when trying to resolve missing i18n strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1356
diff changeset
13 import java.util.MissingResourceException;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
15 import org.dive4elements.river.client.client.Config;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
16 import org.dive4elements.river.client.client.FLYSConstants;
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
17 import org.dive4elements.river.client.shared.model.Collection;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
18 import org.dive4elements.river.client.shared.model.ExportMode;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
19 import org.dive4elements.river.client.shared.model.Facet;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
21 import com.google.gwt.core.client.GWT;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
22 import com.smartgwt.client.types.Alignment;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
23 import com.smartgwt.client.widgets.Canvas;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
24 import com.smartgwt.client.widgets.Label;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
25 import com.smartgwt.client.widgets.form.DynamicForm;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
26 import com.smartgwt.client.widgets.form.fields.FormItem;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
27 import com.smartgwt.client.widgets.form.fields.TextAreaItem;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
28 import com.smartgwt.client.widgets.layout.HLayout;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
29 import com.smartgwt.client.widgets.layout.VLayout;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 /**
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 * A panel that displays an download icon for all available export modes of a
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 * Collection.
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 *
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 */
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public class ExportPanel extends VLayout {
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
39 private static final String LABEL_URL_SEPARATOR = ";";// always sync with server (InundationDurationState)
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
40 /** The message class that provides i18n strings. */
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
43 protected Collection c;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 protected List<ExportMode> exports;
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
46 /** This layout will store a list of available export types. */
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 protected HLayout container;
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
49 public ExportPanel(final Collection c, final List<ExportMode> exports) {
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 super();
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
52 this.c = c;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
53 this.exports = exports;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 this.container = new HLayout();
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
56 final Label title = new Label(this.MSG.dataexport());
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 title.setHeight(15);
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 title.setStyleName("fontNormalSmallUnderlined");
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 addMember(title);
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 addMember(createExportItems());
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
62 addMember(createVlayoutExportItems());
277
50b88b641be6 Changed the height of the export panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 275
diff changeset
63 setHeight(45);
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 setMembersMargin(5);
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 }
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
67 private VLayout createVlayoutExportItems() {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
68 final VLayout layout = new VLayout();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
69 final DynamicForm form1 = new DynamicForm();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
70 form1.setColWidths("10%");
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
71 form1.setWidth(400);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
72 form1.setAlign(Alignment.LEFT);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
73 final List<FormItem> items = new ArrayList<FormItem>();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
74 for (final ExportMode mode : this.exports) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
75 final String name = mode.getName();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
76 final List<Facet> facets = mode.getFacets();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
77
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
78 for (int i = 0; i < facets.size(); i++) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
79 final Facet facet = facets.get(i);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
80 final String facetName = facet.getName();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
81
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
82 if (!facetName.equals("wms_url"))
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
83 continue;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
84 if ("wms_url".equals(facetName))
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
85 items.add(createUrlLine(facet.getDescription(), i));
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
86 }
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
87 }
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
88 form1.setFields(items.toArray(new FormItem[items.size()]));
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
89 layout.addMember(form1);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
90 return layout;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
91 }
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
92
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
93 private FormItem createUrlLine(final String labelAndUrl, final int count) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
94
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
95 final String[] labelAndurlSplit = labelAndUrl.split(LABEL_URL_SEPARATOR);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
96 if (labelAndurlSplit.length == 2) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
97
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
98 final TextAreaItem label = new TextAreaItem();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
99 label.setTitle(labelAndurlSplit[0]);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
100
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
101 label.setWrapTitle(true);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
102 label.setTitleColSpan(3);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
103 label.setColSpan(7);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
104 label.setWidth(250);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
105
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
106 label.setTitleAlign(Alignment.LEFT);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
107
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
108 label.setValue(labelAndurlSplit[1]);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
109 label.setCanEdit(false);
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
110
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
111 return label;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
112 }
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
113 return null;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
114 }
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 /**
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 * This method is used to create an item (created by createExportButton) for
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 * each facet for each export mode.
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 *
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 * @return a horizontal list of buttons.
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 */
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 protected HLayout createExportItems() {
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
123 final HLayout layout = new HLayout();
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
125 for (final ExportMode mode : this.exports) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
126 final String name = mode.getName();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
127 final List<Facet> facets = mode.getFacets();
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
129 for (final Facet facet : facets) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
130 final String facetName = facet.getName();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
131
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
132 if (name.equals("fix_wq_curve_at_export"))
3525
b67af5b44d68 Hide the W/Q AT export button in fix analysis parameter tab.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2931
diff changeset
133 continue;
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
134
4912
94b95e002fb9 Added filename to export url.
Raimund Renkert <rrenkert@intevation.de>
parents: 3525
diff changeset
135 String filename = name;
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
136 if (name.equals("computed_dischargecurve_at_export"))
4912
94b95e002fb9 Added filename to export url.
Raimund Renkert <rrenkert@intevation.de>
parents: 3525
diff changeset
137 filename = "dischargecurve";
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
138
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
139 if ("wms_url".equals(facetName))
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
140 continue;
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
141
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
142 layout.addMember(createExportButton(name, facetName, filename));
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 }
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 }
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 return layout;
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 }
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 /**
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 * This method is used to create a button (with click handler) for a
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 * concrete export mode / type.
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 *
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
153 * @param name
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
154 * The name of the export.
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
155 * @param facet
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
156 * The name of the export type (e.g. CSV, WST).
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 *
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 * @return an image with click handler.
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 */
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
160 protected Canvas createExportButton(final String name, final String facet, final String filename) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
161 String url = getExportUrl(name, facet, filename);
5144
2c31625d4e6a New icons! Use the new icons in project list and for export buttons.
Raimund Renkert <rrenkert@intevation.de>
parents: 4912
diff changeset
162 String imgUrl = GWT.getHostPageBaseURL();
2c31625d4e6a New icons! Use the new icons in project list and for export buttons.
Raimund Renkert <rrenkert@intevation.de>
parents: 4912
diff changeset
163 if (facet.equals("pdf")) {
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
164 imgUrl += this.MSG.downloadPDF();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
165 } else if (facet.equals("at")) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
166 imgUrl += this.MSG.downloadAT();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
167 } else if (facet.equals("wst")) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
168 imgUrl += this.MSG.downloadWST();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
169 } else if (facet.equals("csv")) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
170 url += "&encoding=UTF-8";
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
171 imgUrl += this.MSG.downloadCSV();
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
172 } else {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
173 imgUrl += this.MSG.imageSave();
5144
2c31625d4e6a New icons! Use the new icons in project list and for export buttons.
Raimund Renkert <rrenkert@intevation.de>
parents: 4912
diff changeset
174 }
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
175 final ImgLink link = new ImgLink(imgUrl, url, 30, 30);
1343
0d3d3860beb5 Added a ImgLink class which creates an html link with an image.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 433
diff changeset
176 link.setTooltip(getTooltipText(name, facet));
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177
1343
0d3d3860beb5 Added a ImgLink class which creates an html link with an image.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 433
diff changeset
178 return link;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 }
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 /**
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 * Creates the URL used to trigger an export.
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 *
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
184 * @param name
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
185 * The name of the export.
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
186 * @param facet
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
187 * The name of the export type (e.g. CSV, WST).
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 *
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 * @return the export URL.
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 */
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
191 protected String getExportUrl(final String name, final String facet, final String filename) {
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
192 final Config config = Config.getInstance();
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 String url = GWT.getModuleBaseURL();
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 url += "export";
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
196 url += "?uuid=" + this.c.identifier();
4912
94b95e002fb9 Added filename to export url.
Raimund Renkert <rrenkert@intevation.de>
parents: 3525
diff changeset
197 url += "&name=" + filename;
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 url += "&mode=" + name;
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 url += "&type=" + facet;
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 url += "&server=" + config.getServerUrl();
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 url += "&locale=" + config.getLocale();
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 return url;
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 }
433
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
205
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
206 /**
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
207 * Creates a text used as tooltip for a specific export and type.
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
208 *
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
209 * @param name
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
210 * The name of the export.
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
211 * @param facet
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
212 * The name of the export type (e.g. CSV, WST).
433
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
213 *
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
214 * @return a tooltip text.
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
215 */
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
216 protected String getTooltipText(final String name, final String facet) {
2931
d6983b78de45 Export panel: Make code more robust when trying to resolve missing i18n strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1356
diff changeset
217 try {
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
218 return this.MSG.getString(name) + " | " + this.MSG.getString(facet);
2931
d6983b78de45 Export panel: Make code more robust when trying to resolve missing i18n strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1356
diff changeset
219 }
9190
0633f963c5be uinfo.inundationduration workflow
gernotbelger
parents: 7140
diff changeset
220 catch (final MissingResourceException mre) {
2931
d6983b78de45 Export panel: Make code more robust when trying to resolve missing i18n strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1356
diff changeset
221 return name + " | " + facet;
d6983b78de45 Export panel: Make code more robust when trying to resolve missing i18n strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1356
diff changeset
222 }
433
ad2c4fb17318 Adjusted the width of an export button and added a tooltip to distinguish different exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
223 }
275
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 }
8264b02091ef ISSUE-56 Display download buttons to export the computed data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org