annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/sq/SQCampaignChart.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 86e69788c946
children
rev   line source
3373
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui.sq;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import com.google.gwt.core.client.GWT;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import com.google.gwt.json.client.JSONNumber;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import com.google.gwt.json.client.JSONObject;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import com.google.gwt.json.client.JSONString;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import com.smartgwt.client.types.Alignment;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import com.smartgwt.client.widgets.Img;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import com.smartgwt.client.widgets.events.ResizedHandler;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import com.smartgwt.client.widgets.layout.VLayout;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.client.client.Config;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.client.shared.model.Artifact;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 public class SQCampaignChart extends VLayout {
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 private final Artifact artifact;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 protected Img chartImg;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 public SQCampaignChart(Artifact artifact, ResizedHandler resizeHandler) {
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 super();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 this.artifact = artifact;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 this.chartImg = new Img();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 addResizedHandler(resizeHandler);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 setAlign(Alignment.CENTER);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 }
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 public void update() {
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 Config config = Config.getInstance();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 String locale = config.getLocale();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 int hWidth = getWidth() - 12;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 int hHeight = getHeight() - 12;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 if ((int) (hHeight * 4f / 3) < hWidth) {
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 hWidth = (int) (hHeight * 4f / 3);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 }
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 else {
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 hHeight = (int) (hWidth * 3f / 4);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 }
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 String river = artifact.getArtifactDescription().getRiver();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 JSONObject jfix = new JSONObject();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 JSONObject jfilter = new JSONObject();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 JSONObject jrName = new JSONObject();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 JSONString jrValue = new JSONString(river);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 JSONObject jextent = new JSONObject();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 JSONNumber jwidth = new JSONNumber(hWidth);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 JSONNumber jheight = new JSONNumber(hHeight);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 jrName.put("name", jrValue);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 jfilter.put("river", jrName);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 jextent.put("width", jwidth);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 jextent.put("height", jheight);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 jfilter.put("extent", jextent);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 jfix.put("sq", jfilter);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 String filter = jfix.toString();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 String imgUrl = GWT.getModuleBaseURL();
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 imgUrl += "sq-km-chart";
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 imgUrl += "?locale=" + locale;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 imgUrl += "&filter=" + filter;
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 if (chartImg != null && hasMember(chartImg)) {
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 chartImg.setWidth(hWidth);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 chartImg.setHeight(hHeight);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 chartImg.setSrc(imgUrl);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 }
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 else {
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 chartImg = new Img(imgUrl, hWidth, hHeight);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 addMember(chartImg);
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
86e69788c946 Added a new UIProvider that allows the input of a time period; the helper panel displays the field campaigns of MINFO's SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 }

http://dive4elements.wald.intevation.org