diff --git a/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ImagePreviewer.java b/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ImagePreviewer.java index d98009d..3345193 100644 --- a/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ImagePreviewer.java +++ b/src/main/java/org/gcube/portlets/widgets/imagepreviewerwidget/client/ImagePreviewer.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel; + import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; @@ -20,6 +21,7 @@ public class ImagePreviewer implements EntryPoint { } + @SuppressWarnings("unused") private void test(){ // random images for test @@ -29,6 +31,8 @@ public class ImagePreviewer implements EntryPoint { images.add(new EnhancedImage("http://nerdist.com/wp-content/uploads/2014/07/ned-stark-970x545.jpg")); images.add(new EnhancedImage("http://vignette2.wikia.nocookie.net/gameofthrones/images/2/25/Eddard's_Head.png/revision/latest?cb=20121205211321")); images.add(new EnhancedImage("https://upload.wikimedia.org/wikipedia/it/1/17/Il_grande_Lebowski.jpg")); - RootPanel.get("image-previewer-div").add(new Carousel(images)); + Carousel c = new Carousel(); + c.updateImages(images); + RootPanel.get("image-previewer-div").add(c); } } 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 037f363..3b4fb09 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 @@ -62,7 +62,7 @@ public class Carousel extends Composite{ * Build a carousel that shows imagesToShow images. * @param imagesToShow */ - public Carousel(List imagesToShow) { + public Carousel() { initWidget(uiBinder.createAndBindUi(this)); @@ -89,21 +89,6 @@ public class Carousel extends Composite{ // next button nextButton.setText(">>"); - // save the attachments list - listOfAttachmentsToShow = imagesToShow; - - // take the first object - currentPreviewPosition = 0; - - // show it - shownImage.setUrl(listOfAttachmentsToShow.get(currentPreviewPosition).getImageUrl()); - - // change image tooltip - shownImage.setTitle(listOfAttachmentsToShow.get(currentPreviewPosition).getToolTipToShow()); - - // change the title to the modal - mainModalPanel.setTitle(listOfAttachmentsToShow.get(currentPreviewPosition).getTitleToShow()); - } @UiHandler("showButton") @@ -167,6 +152,18 @@ public class Carousel extends Composite{ */ public void show(){ + // take the first object + currentPreviewPosition = 0; + + // show it + shownImage.setUrl(listOfAttachmentsToShow.get(currentPreviewPosition).getImageUrl()); + + // change image tooltip + shownImage.setTitle(listOfAttachmentsToShow.get(currentPreviewPosition).getToolTipToShow()); + + // change the title to the modal + mainModalPanel.setTitle(listOfAttachmentsToShow.get(currentPreviewPosition).getTitleToShow()); + mainModalPanel.show(); }