[PATCH] another try

Wald Commits scm-commit at wald.intevation.org
Wed Jan 20 17:20:11 CET 2021


# HG changeset patch
# User dnt_bjoernsen <d.tironi at bjoernsen.de>
# Date 1611159599 -3600
#      Wed Jan 20 17:19:59 2021 +0100
# Node ID 812a6a3eaaf5beabd65974bcfdcb737aaf0ae8dd
# Parent  15404504ea9edaa4f8f8b1c2a480304c079d7750
another try

diff -r 15404504ea9e -r 812a6a3eaaf5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Wed Jan 20 16:17:32 2021 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Wed Jan 20 17:19:59 2021 +0100
@@ -17,7 +17,11 @@
 import org.dive4elements.river.client.shared.model.ThemeList;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.LoadEvent;
 import com.google.gwt.event.dom.client.LoadHandler;
+import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.SimpleEventBus;
 import com.google.gwt.http.client.URL;
 import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.Widget;
@@ -80,7 +84,6 @@
 	}
 
 	private Canvas createLegendGraphicsRow(final AttributedTheme at) {
-		com.smartgwt.client.util.SC.say("init");
 		final Label label = new Label(at.getDescription());
 		final Widget img = createLegendGraphics(at);
 
@@ -92,8 +95,15 @@
 
 		if (img instanceof Image) {
 			Image.prefetch(((Image) img).getUrl());
-			setDimensions(row, ((Image) img).getHeight(), ((Image) img).getWidth());
+			
 			url = " url " + ((Image) img).getUrl();
+			
+			
+			MyLoadHandler handler = new MyLoadHandler(row, ((Image) img));
+			
+		 final HandlerRegistration handelReg = ((Image) img).addLoadHandler( handler);
+		 handler.setHandelReg(handelReg);
+		 
 		} else if (img instanceof Img) {
 			setDimensions(row, ((Img) img).getHeight(), ((Img) img).getWidth());
 			url = " dataPath " + ((Img) img).getDataPath();
diff -r 15404504ea9e -r 812a6a3eaaf5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java	Wed Jan 20 17:19:59 2021 +0100
@@ -0,0 +1,38 @@
+package org.dive4elements.river.client.client.ui.map;
+
+import com.google.gwt.event.dom.client.LoadEvent;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.Image;
+import com.smartgwt.client.widgets.layout.HLayout;
+
+public class MyLoadHandler implements com.google.gwt.event.dom.client.LoadHandler {
+
+	private Image m_image;
+	HLayout m_row;
+
+	public void setHandelReg(HandlerRegistration m_handelReg) {
+		this.m_handelReg = m_handelReg;
+	}
+
+	private HandlerRegistration m_handelReg;
+
+	public MyLoadHandler(HLayout row, Image image) {
+		m_image = image;
+		m_row = row;
+	}
+
+	@Override
+	public void onLoad(LoadEvent event) {
+	
+		setDimensions(m_row, m_image.getHeight(), m_image.getWidth());
+		if (m_handelReg != null)
+			m_handelReg.removeHandler();
+	}
+	
+	private void setDimensions(HLayout row, int height, int width) {
+		final int minHeight = 30;
+		row.setHeight(height < minHeight ? minHeight : height);
+		row.setWidth(width);
+	}
+
+}


More information about the Dive4Elements-commits mailing list