Mercurial > dive4elements > river
changeset 575:5277f46a63c2
The description of a facet is now displayed in the ChartThemePanel.
flys-client/trunk@2141 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 17 Jun 2011 09:57:23 +0000 |
parents | 3629d36f0e5d |
children | a0884f486711 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultTheme.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Facet.java flys-client/src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Theme.java |
diffstat | 7 files changed, 119 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu Jun 16 15:57:20 2011 +0000 +++ b/flys-client/ChangeLog Fri Jun 17 09:57:23 2011 +0000 @@ -1,3 +1,19 @@ +2011-06-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java: + Read "index" and "description" of facets from collection's describe + document. In addition, I replaced the expensive XPath search for + attributes with DOM methods. + + * src/main/java/de/intevation/flys/client/shared/model/Theme.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultTheme.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java: + Themes and facets have now indices and descriptions. + + * src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java: + Display the description of a theme in the theme panel instead of the + name (which represents the facet type). + 2011-06-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Thu Jun 16 15:57:20 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Fri Jun 17 09:57:23 2011 +0000 @@ -8,6 +8,7 @@ import javax.xml.xpath.XPathConstants; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -203,7 +204,7 @@ List<Theme> themeList = new ArrayList<Theme>(num); for (int i = 0; i < num; i++) { - Theme theme = parseTheme(themes.item(i)); + Theme theme = parseTheme((Element) themes.item(i)); if (theme != null) { themeList.add(theme); @@ -214,27 +215,27 @@ } - protected Theme parseTheme(Node node) { + protected Theme parseTheme(Element ele) { System.out.println("DescribeCollectionServiceImpl.parseTheme"); - String strAct = XMLUtils.xpathString( - node, "@art:active", ArtifactNamespaceContext.INSTANCE); - - String art = XMLUtils.xpathString( - node, "@art:artifact", ArtifactNamespaceContext.INSTANCE); + String uri = ArtifactNamespaceContext.NAMESPACE_URI; - String fac = XMLUtils.xpathString( - node, "@art:facet", ArtifactNamespaceContext.INSTANCE); + String strAct = ele.getAttributeNS(uri, "active"); + String art = ele.getAttributeNS(uri, "artifact"); + String fac = ele.getAttributeNS(uri, "facet"); + String strPos = ele.getAttributeNS(uri, "pos"); + String desc = ele.getAttributeNS(uri, "description"); + String strIdx = ele.getAttributeNS(uri, "index"); - String strPos = XMLUtils.xpathString( - node, "@art:pos", ArtifactNamespaceContext.INSTANCE); - - if (strAct != null && art != null && fac != null && strPos != null) { + if (strAct != null && art != null && fac != null + && strPos != null && strIdx != null) + { try { int pos = Integer.valueOf(strPos); int active = Integer.valueOf(strAct); + int idx = Integer.valueOf(strIdx); - return new DefaultTheme(pos, active > 0, art, fac); + return new DefaultTheme(pos, idx, active > 0, art, fac, desc); } catch (NumberFormatException nfe) { nfe.printStackTrace(); @@ -359,14 +360,17 @@ List<Facet> facets = new ArrayList<Facet>(num); - for (int i = 0; i < num; i++) { - Node facetNode = facetList.item(i); + String uri = ArtifactNamespaceContext.NAMESPACE_URI; - String name = XMLUtils.xpathString( - facetNode, "@art:name", ArtifactNamespaceContext.INSTANCE); + for (int i = 0; i < num; i++) { + Element facetEl = (Element) facetList.item(i); - if (name != null && name.length() > 0) { - facets.add(new DefaultFacet(name)); + String name = facetEl.getAttributeNS(uri, "name"); + String desc = facetEl.getAttributeNS(uri, "description"); + String index = facetEl.getAttributeNS(uri, "index"); + + if (name != null && name.length() > 0 && index != null) { + facets.add(new DefaultFacet(name, Integer.valueOf(index),desc)); } }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java Thu Jun 16 15:57:20 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java Fri Jun 17 09:57:23 2011 +0000 @@ -11,6 +11,12 @@ /** The name of the facet.*/ protected String name; + /** The description of the facet.*/ + protected String description; + + /** The index of the facet.*/ + protected int index; + /** * An empty constructor. @@ -29,8 +35,26 @@ } + public DefaultFacet(String name, int index, String description) { + this(name); + + this.index = index; + this.description = description; + } + + public String getName() { return name; } + + + public String getDescription() { + return description; + } + + + public int getIndex() { + return index; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultTheme.java Thu Jun 16 15:57:20 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultTheme.java Fri Jun 17 09:57:23 2011 +0000 @@ -8,22 +8,35 @@ protected int position; + protected int index; + protected boolean active; protected String artifact; protected String facet; + protected String description; + public DefaultTheme() { } - public DefaultTheme(int pos, boolean active, String art, String facet) { - this.position = pos; - this.active = active; - this.artifact = art; - this.facet = facet; + public DefaultTheme( + int pos, + int index, + boolean active, + String art, + String facet, + String description) + { + this.position = pos; + this.index = index; + this.active = active; + this.artifact = art; + this.facet = facet; + this.description = description; } @@ -37,6 +50,11 @@ } + public int getIndex() { + return index; + } + + public boolean isActive() { return active; } @@ -57,6 +75,11 @@ } + public String getDescription() { + return description; + } + + public boolean equals(Object o) { if (!(o instanceof DefaultTheme)) { return false; @@ -80,6 +103,14 @@ return false; } + if (!other.description.equals(description)) { + return false; + } + + if (other.index != index) { + return false; + } + return true; } }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Facet.java Thu Jun 16 15:57:20 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Facet.java Fri Jun 17 09:57:23 2011 +0000 @@ -16,5 +16,19 @@ * @return the name of a facet. */ String getName(); + + /** + * Returns the index of this facet. + * + * @return the index. + */ + int getIndex(); + + /** + * Returns the description of this facet. + * + * @return the description. + */ + String getDescription(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java Thu Jun 16 15:57:20 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java Fri Jun 17 09:57:23 2011 +0000 @@ -19,7 +19,7 @@ this.theme = theme; setActive(theme.isActive()); - setName(theme.getFacet()); + setName(theme.getDescription()); } @@ -28,10 +28,10 @@ } - public void setName(String name) { + public void setName(String description) { // TODO Add a setter method setName() to Facet // facet.setName(name); - setAttribute("name", name); + setAttribute("name", description); }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Theme.java Thu Jun 16 15:57:20 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Theme.java Fri Jun 17 09:57:23 2011 +0000 @@ -20,6 +20,8 @@ String getFacet(); + String getDescription(); + boolean equals(Object o); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :