Added method to show a specific image in the carousel
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/image-previewer-widget@122482 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fdc03577dd
commit
3caf2336b0
|
@ -83,6 +83,7 @@ public class EnhancedImage {
|
||||||
* @param image
|
* @param image
|
||||||
* @param titleToShow
|
* @param titleToShow
|
||||||
* @param toolTipToShow
|
* @param toolTipToShow
|
||||||
|
* @param download url
|
||||||
*/
|
*/
|
||||||
public EnhancedImage(Image image, String titleToShow, String toolTipToShow, String downloadUrl) {
|
public EnhancedImage(Image image, String titleToShow, String toolTipToShow, String downloadUrl) {
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class Carousel extends Composite{
|
||||||
|
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
|
||||||
// hide show button (not needed when the widget is used)
|
// hide show button (not needed when the widget is used...it was used while creating the widget)
|
||||||
showButton.setVisible(false);
|
showButton.setVisible(false);
|
||||||
|
|
||||||
// set alignment of the horizontal panel's children
|
// set alignment of the horizontal panel's children
|
||||||
|
@ -108,6 +108,7 @@ public class Carousel extends Composite{
|
||||||
@UiHandler("downloadButton")
|
@UiHandler("downloadButton")
|
||||||
public void downloadOnClick(ClickEvent e){
|
public void downloadOnClick(ClickEvent e){
|
||||||
|
|
||||||
|
mainModalPanel.hide();
|
||||||
Window.open(listOfAttachmentsToShow.get(currentPreviewPosition).getDownloadUrl(), "_blank", "");
|
Window.open(listOfAttachmentsToShow.get(currentPreviewPosition).getDownloadUrl(), "_blank", "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -168,15 +169,18 @@ public class Carousel extends Composite{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the current image.
|
* Used to show a specific image of this carousel.
|
||||||
* @param newPosition index of the new image to show
|
|
||||||
*/
|
*/
|
||||||
public void changeIndexImageShown(int newPosition){
|
public void show(EnhancedImage image){
|
||||||
|
|
||||||
if(newPosition < 0 || newPosition >= listOfAttachmentsToShow.size())
|
// evaluate where this image is
|
||||||
|
int index = evaluateImagePosition(image);
|
||||||
|
|
||||||
|
if(index == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentPreviewPosition = newPosition;
|
// take the first object
|
||||||
|
currentPreviewPosition = index;
|
||||||
|
|
||||||
// show it
|
// show it
|
||||||
shownImage.setUrl(listOfAttachmentsToShow.get(currentPreviewPosition).getImageUrl());
|
shownImage.setUrl(listOfAttachmentsToShow.get(currentPreviewPosition).getImageUrl());
|
||||||
|
@ -187,6 +191,20 @@ public class Carousel extends Composite{
|
||||||
// change the title to the modal
|
// change the title to the modal
|
||||||
mainModalPanel.setTitle(listOfAttachmentsToShow.get(currentPreviewPosition).getTitleToShow());
|
mainModalPanel.setTitle(listOfAttachmentsToShow.get(currentPreviewPosition).getTitleToShow());
|
||||||
|
|
||||||
|
mainModalPanel.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int evaluateImagePosition(EnhancedImage image) {
|
||||||
|
|
||||||
|
for(int index = 0; index < listOfAttachmentsToShow.size(); index++){
|
||||||
|
|
||||||
|
if(listOfAttachmentsToShow.get(index).equals(image))
|
||||||
|
return index;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue