teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5861: * Software engineering by Intevation GmbH teichmann@5861: * teichmann@5861: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5861: * documentation coming with Dive4Elements River for details. teichmann@5861: */ teichmann@5861: teichmann@5835: package org.dive4elements.river.client.client.ui; ingo@1343: ingo@1343: import com.smartgwt.client.types.Overflow; ingo@1343: import com.smartgwt.client.widgets.HTMLPane; ingo@1343: ingo@1343: ingo@1343: public class ImgLink extends HTMLPane { ingo@1343: ingo@2391: private int width; ingo@2391: private int height; ingo@2391: ingo@2391: private String href; ingo@2391: private String imgUrl; ingo@2391: ingo@2500: private boolean newTab; ingo@2500: ingo@2391: ingo@1343: public ImgLink(String imgUrl, String href, int width, int height) { ingo@1343: super(); ingo@1343: ingo@2391: this.width = width; ingo@2391: this.height = height; ingo@2391: this.href = href; ingo@2391: this.imgUrl = imgUrl; ingo@2500: this.newTab = false; ingo@2500: ingo@2500: update(); ingo@2500: } ingo@2500: ingo@2500: ingo@2500: public ImgLink(String imgUrl, String href, int w, int h, boolean newTab) { ingo@2500: this(imgUrl, href, w, h); ingo@2500: this.newTab = newTab; ingo@2391: ingo@2391: update(); ingo@2391: } ingo@2391: ingo@2391: ingo@2391: protected void update() { ingo@2500: String target = newTab ? "_blank" : "_self"; ingo@2500: ingo@2500: setContents(""); ingo@1343: setWidth(width); ingo@1343: setHeight(height); ingo@1343: setOverflow(Overflow.VISIBLE); ingo@1343: } ingo@2391: ingo@2391: ingo@2391: public void setSource(String href) { ingo@2391: this.href = href; ingo@2391: update(); ingo@2391: } ingo@1343: }