Carousel's constructor changed

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/image-previewer-widget@122477 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-22 17:14:48 +00:00
parent c412bfabf2
commit fdc03577dd
2 changed files with 18 additions and 17 deletions

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel; import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
@ -20,6 +21,7 @@ public class ImagePreviewer implements EntryPoint {
} }
@SuppressWarnings("unused")
private void test(){ private void test(){
// random images for 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://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("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")); 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);
} }
} }

View File

@ -62,7 +62,7 @@ public class Carousel extends Composite{
* Build a carousel that shows imagesToShow images. * Build a carousel that shows imagesToShow images.
* @param imagesToShow * @param imagesToShow
*/ */
public Carousel(List<EnhancedImage> imagesToShow) { public Carousel() {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
@ -89,21 +89,6 @@ public class Carousel extends Composite{
// next button // next button
nextButton.setText(">>"); 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") @UiHandler("showButton")
@ -167,6 +152,18 @@ public class Carousel extends Composite{
*/ */
public void show(){ 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(); mainModalPanel.show();
} }