Mercurial > dive4elements > river
changeset 6019:078677c684af
Commit performance improvement written by Sascha Teichmann
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 14 May 2013 18:41:43 +0200 |
parents | ff70221c078b |
children | bf5dba3f66ac |
files | gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LinkSelection.java |
diffstat | 1 files changed, 25 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LinkSelection.java Tue May 14 18:36:04 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LinkSelection.java Tue May 14 18:41:43 2013 +0200 @@ -53,18 +53,19 @@ /** The selected river*/ protected Data river; private static Map<String, LinkItem> rivers; + private static HLayout columns; private static Trigger trigger; private Canvas module; + private class Trigger { private LinkSelection ls; public Trigger(LinkSelection ls) { this.ls = ls; - // TODO Auto-generated constructor stub } public void trigger(String name) { @@ -162,8 +163,9 @@ VLayout layout = new VLayout(); layout.setAlign(VerticalAlignment.TOP); + // XXX: This an evil hack because of misuse of static vars! layout.setHeight(25); - HLayout colums = new HLayout(); + columns = new HLayout(); VLayout formLayout1 = new VLayout(); VLayout formLayout2 = new VLayout(); @@ -178,15 +180,6 @@ label.setValign(VerticalAlignment.TOP); label.setHeight(20); label.setWidth(400); - LinkedHashMap<String, String> it = new LinkedHashMap<String, String>(); - boolean defaultSet = false; - boolean first = true; - DataItem def = d.getDefault(); - String defValue = def != null ? def.getStringValue() : null; - - if (defValue != null && defValue.length() > 0) { - defaultSet = true; - } int counter = 0; for (DataItem item: d.getItems()) { @@ -226,17 +219,21 @@ @Override public void onItemHover(ItemHoverEvent event) { String river = ((LinkItem)event.getItem()).getLinkTitle(); - for (String s : rivers.keySet()) { - LinkItem item = rivers.get(s); + for (Map.Entry<String, LinkItem> entry: rivers.entrySet()) { + String s = entry.getKey(); + LinkItem item = entry.getValue(); if (item.getLinkTitle().equals(river)) { item.setCellStyle("riverLinkHighlight"); + callHighlightRiver(river); } else { item.setCellStyle("formCell"); callUnHighlightRiver(s); } } - callHighlightRiver(river); + if (columns != null) { + columns.redraw(); + } } }); } @@ -247,9 +244,9 @@ label.setWidth(50); layout.addMember(label); - colums.addMember(formLayout1); - colums.addMember(formLayout2); - layout.addMember(colums); + columns.addMember(formLayout1); + columns.addMember(formLayout2); + layout.addMember(columns); } layout.addMember(getNextButton()); @@ -279,34 +276,24 @@ }-*/; private static void highlightCallback(String name) { - for (String s : rivers.keySet()) { - if (s.equals(name)) { - LinkItem item = rivers.get(name); - item.setCellStyle("riverLinkHighlight"); - item.redraw(); - } - else { - LinkItem item = rivers.get(s); - item.setCellStyle("formCell"); - item.redraw(); - } + for (Map.Entry<String, LinkItem> entry: rivers.entrySet()) { + String s = entry.getKey(); + LinkItem item = entry.getValue(); + item.setCellStyle(s.equals(name) ? "riverLinkHighlight" : "formCell"); + } + if (columns != null) { + columns.redraw(); } } private static boolean availableRiver(String river) { - if (rivers.containsKey(river)) { - if(rivers.get(river).isVisible()) { - return true; - } - } - return false; + LinkItem ri = rivers.get(river); + return ri != null && ri.isVisible(); } private static void selectCallback(String name) { - if (rivers.containsKey(name)) { - if (rivers.get(name).isVisible()) { - trigger.trigger(name); - } + if (availableRiver(name)) { + trigger.trigger(name); } }