Mercurial > dive4elements > river
changeset 4256:9a1a3406deb5
Merged.
author | Ingo Weinzierl <weinzierl.ingo@googlemail.com> |
---|---|
date | Thu, 25 Oct 2012 14:02:39 +0200 |
parents | 33b15ac17fd1 (diff) 670e98f5a441 (current diff) |
children | 1dfe3e1d304e |
files | |
diffstat | 2 files changed, 96 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Thu Oct 25 14:01:46 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Thu Oct 25 14:02:39 2012 +0200 @@ -9,6 +9,7 @@ import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.WidgetCanvas; import com.smartgwt.client.widgets.events.ResizedEvent; import com.smartgwt.client.widgets.events.ResizedHandler; import com.smartgwt.client.widgets.layout.SectionStackSection; @@ -47,6 +48,10 @@ protected RiverInfoPanel riverinfopanel; + public final static String SECTION_ID = "GaugePanelSection"; + private final static String GAUGE_TREE_CANVAS_ID = + "GaugeTreeCanvas"; + /** * Creates a new VLayout with a SectionStackSection * The GaugePanel's SectionStackSection is hidden by default. @@ -54,16 +59,24 @@ * @param flys The FLYS object * @param section The section stack section to place the VLayout in. */ - public GaugePanel(FLYS flys, SectionStackSection section) { + public GaugePanel(FLYS flys) { + SectionStackSection section = new SectionStackSection(); + section.setExpanded(false); + section.setTitle(MSG.gaugePanelTitle()); + section.setName(SECTION_ID); + section.setID(SECTION_ID); + gaugetree = new GaugeTree(flys); - gaugetreecanvas = new Canvas(); - gaugetreecanvas.addChild(gaugetree); + gaugetreecanvas = new WidgetCanvas(gaugetree); + gaugetreecanvas.setID(GAUGE_TREE_CANVAS_ID); setOverflow(Overflow.HIDDEN); + setStyleName("gaugepanel"); + section.setHidden(true); section.setItems(this); this.section = section; - setStyleName("gaugepanel"); + addResizedHandler(this); } @@ -88,6 +101,8 @@ * Loads the river info and renders it afterwards */ public void refresh() { + contract(); + riverInfoService.getGauges(this.river, new AsyncCallback<RiverInfo>() { @Override public void onFailure(Throwable e) { @@ -98,6 +113,7 @@ public void onSuccess(RiverInfo riverinfo) { GWT.log("Loaded river info"); renderGaugeOverviewInfo(riverinfo); + expand(); } }); } @@ -106,11 +122,10 @@ gaugetree.setGauges(riverinfo); if (riverinfopanel == null) { - removeMembers(getMembers()); + removeAllMembers(); + riverinfopanel = new RiverInfoPanel(riverinfo); - gaugetreecanvas.setWidth("100%"); - addMember(riverinfopanel); addMember(gaugetreecanvas); } @@ -135,10 +150,6 @@ gaugetree.setHeight("" + height + "px"); gaugetree.setWidth("" + width + "px"); - - for (Canvas canvas : getMembers()) { - GWT.log("GaugePanel - member height " + canvas.getHeight()); - } } @@ -163,12 +174,34 @@ @Override public void addMember(Canvas component) { super.addMember(component); - section.setExpanded(true); + expand(); } @Override public void removeMembers(Canvas[] components) { super.removeMembers(components); + contract(); + } + + public SectionStackSection getSection() { + return this.section; + } + + private void removeAllMembers() { + removeMembers(getMembers()); + } + + /** + * Expands the gauge section + */ + public void expand() { + section.setExpanded(true); + } + + /** + * Contracts/shrinks the expanded gauge section + */ + public void contract() { section.setExpanded(false); } }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Thu Oct 25 14:01:46 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Thu Oct 25 14:02:39 2012 +0200 @@ -115,6 +115,8 @@ protected GaugePanel gaugePanel; protected Canvas reportPanel; + private SectionStack stack; + public ParameterList(FLYS flys, CollectionView cView, String title) { super(title); @@ -206,18 +208,11 @@ protected SectionStack createSectionStack() { - final SectionStack stack = new SectionStack(); + stack = new SectionStack(); stack.setHeight100(); stack.setCanResizeSections(true); stack.setVisibilityMode(VisibilityMode.MULTIPLE); - final SectionStackSection gaugeSection = new SectionStackSection(); - gaugeSection.setExpanded(false); - gaugeSection.setTitle(MSG.gaugePanelTitle()); - gaugePanel = new GaugePanel(flys, gaugeSection); - gaugePanel.setWidth100(); - gaugePanel.setHeight100(); - // This canvas is used to render helper widgets. final SectionStackSection helperSection = new SectionStackSection(); helperSection.setExpanded(false); @@ -260,7 +255,7 @@ tablePanel.setWidth100(); tableSection.setItems(tablePanel); - stack.setSections(gaugeSection, helperSection, tableSection); + stack.setSections(helperSection, tableSection); return stack; } @@ -758,13 +753,17 @@ } if (art instanceof WINFOArtifact) { String river = desc.getRiver(); + if (river != null) { renderGaugeInfo(desc.getRiver(), desc.getOldData()); } else { - gaugePanel.hide(); + hideGaugePanel(); } } + else { + removeGaugePanel(); + } addOldDatas( desc.getOldData(), @@ -943,10 +942,51 @@ } + private void createGaugePanel() { + GWT.log("ParameterList - createGaugePanel"); + if (gaugePanel == null) { + gaugePanel = new GaugePanel(flys); + gaugePanel.setWidth100(); + gaugePanel.setHeight100(); + } + } + + private void addGaugePanel() { + GWT.log("ParameterList - addGaugePanel"); + createGaugePanel(); + stack.addSection(gaugePanel.getSection(), 0); + } + + private void showGaugePanel() { + GWT.log("ParameterList - showGaugePanel"); + + /* Don't add GaugePanel twice */ + SectionStackSection exists = stack.getSection(GaugePanel.SECTION_ID); + if (exists == null) { + addGaugePanel(); + } + + gaugePanel.show(); + } + + private void hideGaugePanel() { + GWT.log("ParameterList - hideGaugePanel"); + + if (gaugePanel != null) { + gaugePanel.hide(); + } + } + + private void removeGaugePanel() { + GWT.log("ParameterList - removeGaugePanel"); + stack.removeSection(GaugePanel.SECTION_ID); + } + + private void renderGaugeInfo(String river, DataList[] data) { + showGaugePanel(); gaugePanel.setRiver(river); gaugePanel.setData(data); - gaugePanel.show(); } }