# HG changeset patch # User Björn Ricks # Date 1351165978 -7200 # Node ID a1bc5b8cff0fbee4c264c4b1e4eaf5e1b239ef4b # Parent 5ebaa0a62d2c49dbe19e74df76d2a2bd067bfb9e Refactor GaugePanel to create it's own SectionStackSection The GaugePanel constructor now creates a SectionStackSection instead of using a provided one. Improve the rendering of the GaugePanel by having access to the SmartGWT wrapper (WidgetCanvas) object for the GWT Tree (GaugeTree) directly. Add methods to close and open the section. Also add a getter for the section. diff -r 5ebaa0a62d2c -r a1bc5b8cff0f flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Thu Oct 25 13:42:21 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Thu Oct 25 13:52:58 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() { @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); } }