[Dive4elements-commits] [PATCH 1 of 2] Commit performance improvement written by Sascha Teichmann
Wald Commits
scm-commit at wald.intevation.org
Tue May 14 18:43:14 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1368549703 -7200
# Node ID 078677c684af8b921c13a8504e730a233d694eec
# Parent ff70221c078bbe0ed0913218259e03a79734a96f
Commit performance improvement written by Sascha Teichmann
diff -r ff70221c078b -r 078677c684af gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LinkSelection.java
--- 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);
}
}
More information about the Dive4elements-commits
mailing list