Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 4254:33b15ac17fd1
Only create and add GaugePanel when necessary
The GaugePanel isn't created always and only show if WINFO and a river is
selected now. It is only created on demand. Therefore all access to the
GaugePanel is abstraced via methods that check if the GaugePanel is null before
accessing it's methods.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Thu, 25 Oct 2012 13:58:53 +0200 |
parents | 207de712d79d |
children | cde9a6fe1844 |
comparison
equal
deleted
inserted
replaced
4253:a1bc5b8cff0f | 4254:33b15ac17fd1 |
---|---|
113 protected VLayout helperPanel; | 113 protected VLayout helperPanel; |
114 protected VLayout tablePanel; | 114 protected VLayout tablePanel; |
115 protected GaugePanel gaugePanel; | 115 protected GaugePanel gaugePanel; |
116 protected Canvas reportPanel; | 116 protected Canvas reportPanel; |
117 | 117 |
118 private SectionStack stack; | |
119 | |
118 public ParameterList(FLYS flys, CollectionView cView, String title) { | 120 public ParameterList(FLYS flys, CollectionView cView, String title) { |
119 super(title); | 121 super(title); |
120 | 122 |
121 this.cView = cView; | 123 this.cView = cView; |
122 this.flys = flys; | 124 this.flys = flys; |
204 setPane(topLayout); | 206 setPane(topLayout); |
205 } | 207 } |
206 | 208 |
207 | 209 |
208 protected SectionStack createSectionStack() { | 210 protected SectionStack createSectionStack() { |
209 final SectionStack stack = new SectionStack(); | 211 stack = new SectionStack(); |
210 stack.setHeight100(); | 212 stack.setHeight100(); |
211 stack.setCanResizeSections(true); | 213 stack.setCanResizeSections(true); |
212 stack.setVisibilityMode(VisibilityMode.MULTIPLE); | 214 stack.setVisibilityMode(VisibilityMode.MULTIPLE); |
213 | |
214 final SectionStackSection gaugeSection = new SectionStackSection(); | |
215 gaugeSection.setExpanded(false); | |
216 gaugeSection.setTitle(MSG.gaugePanelTitle()); | |
217 gaugePanel = new GaugePanel(flys, gaugeSection); | |
218 gaugePanel.setWidth100(); | |
219 gaugePanel.setHeight100(); | |
220 | 215 |
221 // This canvas is used to render helper widgets. | 216 // This canvas is used to render helper widgets. |
222 final SectionStackSection helperSection = new SectionStackSection(); | 217 final SectionStackSection helperSection = new SectionStackSection(); |
223 helperSection.setExpanded(false); | 218 helperSection.setExpanded(false); |
224 helperSection.setTitle(MSG.helperPanelTitle()); | 219 helperSection.setTitle(MSG.helperPanelTitle()); |
258 }; | 253 }; |
259 tablePanel.setHeight100(); | 254 tablePanel.setHeight100(); |
260 tablePanel.setWidth100(); | 255 tablePanel.setWidth100(); |
261 tableSection.setItems(tablePanel); | 256 tableSection.setItems(tablePanel); |
262 | 257 |
263 stack.setSections(gaugeSection, helperSection, tableSection); | 258 stack.setSections(helperSection, tableSection); |
264 | 259 |
265 return stack; | 260 return stack; |
266 } | 261 } |
267 | 262 |
268 | 263 |
756 setCurrentData(null, null); | 751 setCurrentData(null, null); |
757 } | 752 } |
758 } | 753 } |
759 if (art instanceof WINFOArtifact) { | 754 if (art instanceof WINFOArtifact) { |
760 String river = desc.getRiver(); | 755 String river = desc.getRiver(); |
756 | |
761 if (river != null) { | 757 if (river != null) { |
762 renderGaugeInfo(desc.getRiver(), desc.getOldData()); | 758 renderGaugeInfo(desc.getRiver(), desc.getOldData()); |
763 } | 759 } |
764 else { | 760 else { |
765 gaugePanel.hide(); | 761 hideGaugePanel(); |
766 } | 762 } |
763 } | |
764 else { | |
765 removeGaugePanel(); | |
767 } | 766 } |
768 | 767 |
769 addOldDatas( | 768 addOldDatas( |
770 desc.getOldData(), | 769 desc.getOldData(), |
771 event.getType() == ParameterChangeEvent.Type.BACK); | 770 event.getType() == ParameterChangeEvent.Type.BACK); |
941 protected void unlockUI() { | 940 protected void unlockUI() { |
942 cView.unlockUI(); | 941 cView.unlockUI(); |
943 } | 942 } |
944 | 943 |
945 | 944 |
945 private void createGaugePanel() { | |
946 GWT.log("ParameterList - createGaugePanel"); | |
947 if (gaugePanel == null) { | |
948 gaugePanel = new GaugePanel(flys); | |
949 gaugePanel.setWidth100(); | |
950 gaugePanel.setHeight100(); | |
951 } | |
952 } | |
953 | |
954 private void addGaugePanel() { | |
955 GWT.log("ParameterList - addGaugePanel"); | |
956 createGaugePanel(); | |
957 stack.addSection(gaugePanel.getSection(), 0); | |
958 } | |
959 | |
960 private void showGaugePanel() { | |
961 GWT.log("ParameterList - showGaugePanel"); | |
962 | |
963 /* Don't add GaugePanel twice */ | |
964 SectionStackSection exists = stack.getSection(GaugePanel.SECTION_ID); | |
965 if (exists == null) { | |
966 addGaugePanel(); | |
967 } | |
968 | |
969 gaugePanel.show(); | |
970 } | |
971 | |
972 private void hideGaugePanel() { | |
973 GWT.log("ParameterList - hideGaugePanel"); | |
974 | |
975 if (gaugePanel != null) { | |
976 gaugePanel.hide(); | |
977 } | |
978 } | |
979 | |
980 private void removeGaugePanel() { | |
981 GWT.log("ParameterList - removeGaugePanel"); | |
982 stack.removeSection(GaugePanel.SECTION_ID); | |
983 } | |
984 | |
985 | |
946 private void renderGaugeInfo(String river, DataList[] data) { | 986 private void renderGaugeInfo(String river, DataList[] data) { |
987 showGaugePanel(); | |
947 gaugePanel.setRiver(river); | 988 gaugePanel.setRiver(river); |
948 gaugePanel.setData(data); | 989 gaugePanel.setData(data); |
949 gaugePanel.show(); | |
950 } | 990 } |
951 | 991 |
952 } | 992 } |
953 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 993 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |