[PATCH] refactoring

Wald Commits scm-commit at wald.intevation.org
Wed Jan 20 18:30:40 CET 2021


# HG changeset patch
# User dnt_bjoernsen <d.tironi at bjoernsen.de>
# Date 1611163826 -3600
#      Wed Jan 20 18:30:26 2021 +0100
# Node ID 94362af5928e72164dfdb0ae46593252728b8140
# Parent  812a6a3eaaf5beabd65974bcfdcb737aaf0ae8dd
refactoring

diff -r 812a6a3eaaf5 -r 94362af5928e 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 17:19:59 2021 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Wed Jan 20 18:30:26 2021 +0100
@@ -17,11 +17,7 @@
 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;
@@ -60,7 +56,6 @@
 
 	private void addLegends() {
 		final List<Theme> themes = this.themeList.getActiveThemes();
-		com.smartgwt.client.util.SC.say("themescount " + themes.size());
 
 		for (int i = 0; i < themes.size(); i++) {
 			final Theme theme = themes.get(i);
@@ -69,15 +64,10 @@
 			}
 			try {
 				if (theme instanceof AttributedTheme) {
-					theme.setActive(0);
 					Canvas createLegendGraphicsRow = createLegendGraphicsRow((AttributedTheme) theme);
-//					this.legendContainer.addMember(createLegendGraphicsRow);
-					theme.setActive(1);
-					Canvas createLegendGraphicsRow2 = createLegendGraphicsRow((AttributedTheme) theme);
-					this.legendContainer.addMember(createLegendGraphicsRow2);
+					 this.legendContainer.addMember(createLegendGraphicsRow);
 				}
 			} catch (Exception e) {
-				com.smartgwt.client.util.SC.say("exception at index " + themes.size());
 				continue;
 			}
 		}
@@ -91,32 +81,21 @@
 		row.addMember(label);
 		row.addMember(img);
 
-		String url = "url";
-
+//		String url = "url";
 		if (img instanceof Image) {
-			Image.prefetch(((Image) img).getUrl());
-			
-			url = " url " + ((Image) img).getUrl();
-			
-			
-			MyLoadHandler handler = new MyLoadHandler(row, ((Image) img));
-			
-		 final HandlerRegistration handelReg = ((Image) img).addLoadHandler( handler);
-		 handler.setHandelReg(handelReg);
-		 
+//			url = " url " + ((Image) img).getUrl();
+			new MyLoadHandler(row, ((Image) img));
+
 		} else if (img instanceof Img) {
 			setDimensions(row, ((Img) img).getHeight(), ((Img) img).getWidth());
-			url = " dataPath " + ((Img) img).getDataPath();
+//			url = " dataPath " + ((Img) img).getDataPath();
 		} else {
 			setDimensions(row, 150, 400); // not sure when this is executed
 		}
-		String labelText = at.getDescription() + ", height: " + row.getHeight() + "width: " + row.getWidth() + " "
-				+ url;
-		//
-		// final HLayout row2= new HLayout();
-		// row.addMember(new Label(labelText));
+//		String labelText = at.getDescription() + ", height: " + row.getHeight() + "width: " + row.getWidth() + " "
+//				+ url;
 
-		com.smartgwt.client.util.SC.say(labelText);
+//		com.smartgwt.client.util.SC.say(labelText);
 		return row;
 	}
 
diff -r 812a6a3eaaf5 -r 94362af5928e gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java	Wed Jan 20 17:19:59 2021 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java	Wed Jan 20 18:30:26 2021 +0100
@@ -6,33 +6,26 @@
 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 HLayout m_row;
 	private HandlerRegistration m_handelReg;
 
 	public MyLoadHandler(HLayout row, Image image) {
 		m_image = image;
 		m_row = row;
+		m_handelReg = image.addLoadHandler(this);
 	}
 
 	@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);
 	}
-
-}
+}
\ No newline at end of file


More information about the Dive4Elements-commits mailing list