From 52ccc192ec5e85a537ed89b483b570206cf93abb Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Tue, 6 Jun 2017 16:17:28 +0000 Subject: [PATCH] added thumbnailUrl parameter and fixed showMethod git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/image-previewer-widget@149321 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 4 +- .../client/EnhancedImage.java | 54 +++++++++++-------- .../client/ui/Carousel.java | 3 +- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.classpath b/.classpath index 052d3e8..a78b0f8 100644 --- a/.classpath +++ b/.classpath @@ -28,9 +28,9 @@ - + - + diff --git a/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/EnhancedImage.java b/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/EnhancedImage.java index df8d650..4ba9895 100644 --- a/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/EnhancedImage.java +++ b/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/EnhancedImage.java @@ -5,9 +5,10 @@ import org.gcube.portlets.widgets.imagepreviewerwidget.shared.Orientation; /** * This class allows to build the image to show within the carousel. It contains: *
    - *
  • title to show: a title to show in the header of the carousel;
  • - *
  • tooltip : a tooltip shown on image hover event;
  • - *
  • download url: in case of a file, this field can be used to download it.
  • + *
  • title to show: a title to show in the header of the carousel; + *
  • tooltip : a tooltip shown on image hover event; + *
  • download url: in case of a file, this field can be used to download it. + *
  • thumbnailUrl for the thumbnail *
* If tooltip/download url/title to show is not specified, its value will be equal to the image url. * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) @@ -29,6 +30,11 @@ public class EnhancedImage { */ private String downloadUrl; + /** + * The url of the image to show + */ + private String thumbnailUrl; + /** * The orientation */ @@ -44,6 +50,7 @@ public class EnhancedImage { this.titleToShow = imageUrl; this.toolTipToShow = imageUrl; this.downloadUrl = imageUrl; + this.thumbnailUrl = downloadUrl; } @@ -53,12 +60,13 @@ public class EnhancedImage { * @param titleToShow * @param toolTipToShow */ - public EnhancedImage(String url, String titleToShow, String toolTipToShow) { + public EnhancedImage(String downloadUrl, String titleToShow, String toolTipToShow) { super(); this.titleToShow = titleToShow; this.toolTipToShow = toolTipToShow; - this.downloadUrl = url; + this.downloadUrl = downloadUrl; + this.thumbnailUrl = downloadUrl; } @@ -69,42 +77,37 @@ public class EnhancedImage { * @param toolTipToShow * @param download url */ - public EnhancedImage(String url, String titleToShow, String toolTipToShow, String downloadUrl) { + public EnhancedImage(String thumbnailUrl, String titleToShow, String toolTipToShow, String downloadUrl) { super(); this.titleToShow = titleToShow; this.toolTipToShow = toolTipToShow; - this.downloadUrl = url; + this.thumbnailUrl = thumbnailUrl; + this.downloadUrl = downloadUrl; + } + + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; } public String getTitleToShow() { - return titleToShow; - } public void setTitleToShow(String titleToShow) { - this.titleToShow = titleToShow; - } public String getToolTipToShow() { - return toolTipToShow; - } public void setToolTipToShow(String toolTipToShow) { - this.toolTipToShow = toolTipToShow; - - } - - public String getImageUrl(){ - - return this.downloadUrl; - } public String getDownloadUrl() { @@ -114,6 +117,10 @@ public class EnhancedImage { public void setDownloadUrl(String downloadUrl) { this.downloadUrl = downloadUrl; } + + public String getImageUrl(){ + return this.thumbnailUrl != null? this.thumbnailUrl: this.downloadUrl; + } /** * @return the orientation @@ -128,12 +135,13 @@ public class EnhancedImage { public void setOrientation(Orientation orientation) { this.orientation = orientation; } - + @Override public String toString() { return "EnhancedImage [titleToShow=" + titleToShow + ", toolTipToShow=" + toolTipToShow + ", downloadUrl=" + downloadUrl - + ", orientation=" + orientation + "]"; + + ", thumbnailUrl=" + thumbnailUrl + ", orientation=" + + orientation + "]"; } } diff --git a/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ui/Carousel.java b/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ui/Carousel.java index e59641e..5d30dbb 100644 --- a/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ui/Carousel.java +++ b/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ui/Carousel.java @@ -278,6 +278,7 @@ public class Carousel extends Composite implements CarouselInterface { */ public void show(EnhancedImage image){ GWT.log("image=" + image.getDownloadUrl()); + GWT.log("image=" + image.getThumbnailUrl()); // evaluate where this image is int index = evaluateImagePosition(image); GWT.log("index=" + index); @@ -388,8 +389,6 @@ public class Carousel extends Composite implements CarouselInterface { // fetch the image from the url shownImage.setUrl(url); - - // change image tooltip shownImage.setTitle(imageToShow.getToolTipToShow());