Mercurial > dive4elements > river
changeset 3475:9b29facddbd1
Show tooltips for datacage rows.
flys-client/trunk@5169 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 08 Aug 2012 08:11:43 +0000 (2012-08-08) |
parents | 4b8b9b2ac873 |
children | 4a6321dd5186 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java |
diffstat | 3 files changed, 62 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Aug 08 07:00:52 2012 +0000 +++ b/flys-client/ChangeLog Wed Aug 08 08:11:43 2012 +0000 @@ -1,3 +1,11 @@ +2012-08-08 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/client/server/meta/Converter.java: + Cosmetics, reordered code. + + * src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java: + Show tooltip for rows in datacage widget. + 2012-08-08 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/client/server/meta/Converter.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java Wed Aug 08 07:00:52 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java Wed Aug 08 08:11:43 2012 +0000 @@ -28,6 +28,8 @@ import com.smartgwt.client.widgets.grid.events.RecordDoubleClickEvent; import com.smartgwt.client.widgets.grid.events.RecordDoubleClickHandler; +import com.smartgwt.client.widgets.grid.HoverCustomizer; + import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.shared.model.ToLoad; @@ -137,6 +139,32 @@ treeGrid.setEmptyMessage(messages.databasket_loading()); treeGrid.setLoadingDataMessage(messages.databasket_loading()); + treeGrid.setHoverMoveWithMouse(true); + treeGrid.setCanHover(true); + treeGrid.setShowHover(true); + treeGrid.setHoverOpacity(75); + + treeGrid.setHoverCustomizer(new HoverCustomizer() { + @Override + public String hoverHTML(Object value, + ListGridRecord record, + int rowNum, + int colNum + ) { + if(record instanceof TreeNode) { + TreeNode hoveredTreeNode = (TreeNode)record; + String info = hoveredTreeNode.getAttribute("info"); + if (info == null) { + info = hoveredTreeNode.getName(); + } + return info; + } + else { + return "";// should not happen + } + } + }); + treeGrid.addRecordDoubleClickHandler(new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { @@ -358,6 +386,7 @@ } + /** Get meta-data and populate tree with it. */ protected void triggerTreeBuilding() { Config config = Config.getInstance(); String locale = config.getLocale();
--- a/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java Wed Aug 08 07:00:52 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java Wed Aug 08 08:11:43 2012 +0000 @@ -62,25 +62,7 @@ } } // I18NConverter - private static Map<String, NodeConverter> converters; - - protected void convertChildren(DataCageNode parent, Element sub) { - //System.err.println("convertChildren called"); - NodeList children = sub.getChildNodes(); - for (int i = 0, N = children.getLength(); i < N; ++i) { - Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) { - String name = child.getLocalName(); - NodeConverter converter = converters.get(name); - if (converter == null) { - converter = I18N_CONVERTER; - } - DataCageNode son = converter.convert( - (Element)child, this); - parent.addChild(son); - } - } // for all children - } + private static Map<String, NodeConverter> converters = new HashMap<String, NodeConverter>(); public static final NodeConverter NAME_CONVERTER = new NameConverter(); public static final NodeConverter I18N_CONVERTER = new I18NConverter(); @@ -92,15 +74,16 @@ converters.put("column", NAME_CONVERTER); } + + /** Trivial constructor. */ public Converter() { - converters = new HashMap<String, NodeConverter>(); } + public DataCageTree convert(Document document) { logger.debug("convert called"); //System.err.println(XMLUtils.toString(document)); - // TODO Fetch descriptions/tooltips if any... ArrayList<DataCageNode> roots = new ArrayList<DataCageNode>(); NodeList nodes = document.getChildNodes(); for (int i = 0, N = nodes.getLength(); i < N; ++i) { @@ -119,6 +102,27 @@ : new DataCageTree(roots.get(0)); } + protected void convertChildren(DataCageNode parent, Element sub) { + //System.err.println("convertChildren called"); + NodeList children = sub.getChildNodes(); + for (int i = 0, N = children.getLength(); i < N; ++i) { + Node child = children.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + String name = child.getLocalName(); + NodeConverter converter = converters.get(name); + if (converter == null) { + converter = I18N_CONVERTER; + } + DataCageNode son = converter.convert( + (Element)child, this); + parent.addChild(son); + + if (((Element)child).hasAttribute("description")) + logger.debug("nwd: " + ((Element)child).getAttribute("description")); + } + } // for all children + } + /** * Creates key/value pairs from Nodes Attributes.