comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java @ 4204:9f9843491ac4

Only create the GaugeTree and RiverInfoPanel once This fixes resizing issues when changing the river. SmartGWT is not able to recalculate the height and width if a GWT widget is inserted later. Every attempt to call a recalculation manually did fail. Fix for flys/issue925 (W-INFO / Pegel-Info-Modul / Zeile Gewässer-INFOS)
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 22 Oct 2012 15:29:56 +0200
parents de795c13dcfb
children 0dd8963cec9c
comparison
equal deleted inserted replaced
4203:de795c13dcfb 4204:9f9843491ac4
6 import com.google.gwt.user.client.ui.Anchor; 6 import com.google.gwt.user.client.ui.Anchor;
7 import com.google.gwt.user.client.ui.HorizontalPanel; 7 import com.google.gwt.user.client.ui.HorizontalPanel;
8 import com.google.gwt.user.client.ui.Label; 8 import com.google.gwt.user.client.ui.Label;
9 9
10 import com.smartgwt.client.types.Overflow; 10 import com.smartgwt.client.types.Overflow;
11 import com.smartgwt.client.widgets.Canvas;
11 import com.smartgwt.client.widgets.events.ResizedEvent; 12 import com.smartgwt.client.widgets.events.ResizedEvent;
12 import com.smartgwt.client.widgets.events.ResizedHandler; 13 import com.smartgwt.client.widgets.events.ResizedHandler;
13 import com.smartgwt.client.widgets.layout.SectionStackSection; 14 import com.smartgwt.client.widgets.layout.SectionStackSection;
14 import com.smartgwt.client.widgets.layout.VLayout; 15 import com.smartgwt.client.widgets.layout.VLayout;
15 16
40 41
41 protected GaugeOverviewInfoServiceAsync gaugeOverviewInfoService = 42 protected GaugeOverviewInfoServiceAsync gaugeOverviewInfoService =
42 GWT.create(GaugeOverviewInfoService.class); 43 GWT.create(GaugeOverviewInfoService.class);
43 44
44 protected GaugeTree gaugetree; 45 protected GaugeTree gaugetree;
46 protected Canvas gaugetreecanvas;
45 47
46 protected RiverInfoPanel riverinfopanel; 48 protected RiverInfoPanel riverinfopanel;
47 49
48 /** 50 /**
49 * Creates a new VLayout with a SectionStackSection 51 * Creates a new VLayout with a SectionStackSection
52 * @param flys The FLYS object 54 * @param flys The FLYS object
53 * @param sectionStack The section stack section to place the VLayout in. 55 * @param sectionStack The section stack section to place the VLayout in.
54 */ 56 */
55 public GaugePanel(FLYS flys, SectionStackSection sectionStack) { 57 public GaugePanel(FLYS flys, SectionStackSection sectionStack) {
56 gaugetree = new GaugeTree(flys); 58 gaugetree = new GaugeTree(flys);
59 gaugetreecanvas = new Canvas();
60 gaugetreecanvas.addChild(gaugetree);
61
57 setOverflow(Overflow.HIDDEN); 62 setOverflow(Overflow.HIDDEN);
58 sectionStack.setHidden(true); 63 sectionStack.setHidden(true);
59 sectionStack.setItems(this); 64 sectionStack.setItems(this);
60 this.sectionStack = sectionStack; 65 this.sectionStack = sectionStack;
61 setStyleName("gaugepanel"); 66 setStyleName("gaugepanel");
96 } 101 }
97 }); 102 });
98 } 103 }
99 104
100 public void renderGaugeOverviewInfo(RiverInfo riverinfo) { 105 public void renderGaugeOverviewInfo(RiverInfo riverinfo) {
101 removeMembers(getMembers()); 106 gaugetree.setGauges(riverinfo);
102 107
103 riverinfopanel = new RiverInfoPanel(riverinfo); 108 if (riverinfopanel == null) {
104 addMember(riverinfopanel); 109 removeMembers(getMembers());
105 addMember(gaugetree); 110 riverinfopanel = new RiverInfoPanel(riverinfo);
106 111
107 gaugetree.setGauges(riverinfo); 112 gaugetreecanvas.setWidth("100%");
113
114 addMember(riverinfopanel);
115 addMember(gaugetreecanvas);
116 }
117 else {
118 riverinfopanel.setRiverInfo(riverinfo);
119 }
108 } 120 }
109 121
110 @Override 122 @Override
111 public void onResized(ResizedEvent event) { 123 public void onResized(ResizedEvent event) {
112 /* this height calculation is only an approximation and doesn't reflect 124 /* this height calculation is only an approximation and doesn't reflect

http://dive4elements.wald.intevation.org