Image preview embedded
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@122492 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4a17191707
commit
4145a09afd
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.newsfeed.client.ui;
|
||||
|
||||
import org.gcube.portal.databook.shared.Attachment;
|
||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.EnhancedImage;
|
||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -49,16 +50,19 @@ public class AttachmentPreviewer extends Composite {
|
|||
|
||||
@UiField
|
||||
Anchor showPreviewLabel;
|
||||
|
||||
|
||||
@UiField
|
||||
Label labelSeparator;
|
||||
|
||||
// save attachment
|
||||
private Attachment attachment;
|
||||
|
||||
|
||||
// carousel reference
|
||||
private Carousel carousel;
|
||||
|
||||
// enhanced image associated with this carousel
|
||||
private EnhancedImage img;
|
||||
|
||||
public AttachmentPreviewer(Attachment a) {
|
||||
|
||||
// init
|
||||
|
@ -82,20 +86,21 @@ public class AttachmentPreviewer extends Composite {
|
|||
|
||||
// preview in case of an image
|
||||
if(a.getMimeType().contains("image/")){
|
||||
|
||||
|
||||
showPreviewLabel.setText("Show");
|
||||
showPreviewLabel.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
carousel.show();
|
||||
if(img != null)
|
||||
carousel.show(img);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
// hide the show button and the separator label
|
||||
showPreviewLabel.setVisible(false);
|
||||
labelSeparator.setVisible(false);
|
||||
|
@ -117,19 +122,19 @@ public class AttachmentPreviewer extends Composite {
|
|||
attachmentContainer.getElement().getStyle().setWidth(newWidth, unit);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set carousel to open when the user clicks on the image.
|
||||
* Open the carousel when the user clicks on the preview's image.
|
||||
* @param carousel
|
||||
*/
|
||||
public void onImageClickOpenCarousel(final Carousel carousel) {
|
||||
|
||||
|
||||
// save it
|
||||
this.carousel = carousel;
|
||||
|
||||
// change cursor type on hover
|
||||
imagePreview.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||
|
||||
|
||||
// change tooltipe
|
||||
imagePreview.setTitle("Click for a preview");
|
||||
|
||||
|
@ -145,4 +150,36 @@ public class AttachmentPreviewer extends Composite {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the carousel and show this enhancedImage when the user clicks on the preview's image.
|
||||
* @param carousel
|
||||
* @param enhancedImage the image to show
|
||||
*/
|
||||
public void onImageClickOpenCarousel(final Carousel carousel, final EnhancedImage enhancedImage) {
|
||||
|
||||
// save the carousel ref.
|
||||
this.carousel = carousel;
|
||||
|
||||
// save img ref
|
||||
this.img = enhancedImage;
|
||||
|
||||
// change cursor type on hover
|
||||
imagePreview.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||
|
||||
// change tooltipe
|
||||
imagePreview.setTitle("Click for a preview");
|
||||
|
||||
// add handler
|
||||
imagePreview.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
if(img != null)
|
||||
carousel.show(img);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package org.gcube.portlets.user.newsfeed.client.ui;
|
||||
|
||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -59,7 +60,7 @@ public class LinkPreviewer extends Composite {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set carousel to open when the user clicks on the image.
|
||||
* Open the carousel when the user clicks on the preview's image.
|
||||
* @param carousel
|
||||
*/
|
||||
public void onImageClickOpenCarousel(final Carousel carousel) {
|
||||
|
@ -69,9 +70,6 @@ public class LinkPreviewer extends Composite {
|
|||
|
||||
// change cursor type on hover
|
||||
image.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||
|
||||
// change tooltipe
|
||||
image.setTitle("Click for a preview");
|
||||
|
||||
// add handler
|
||||
image.addClickHandler(new ClickHandler() {
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.google.gwt.user.client.ui.WidgetCollection;
|
|||
*/
|
||||
public class Placeholder extends FlowPanel {
|
||||
|
||||
private static final String SHOW_OTHER_ATTACHMENTS_LABEL = "Show all";
|
||||
private static final String SHOW_OTHER_ATTACHMENTS_LABEL = "Show All";
|
||||
|
||||
// check if we need to show more attachments
|
||||
private boolean appendShowMoreLabel;
|
||||
|
@ -26,6 +26,7 @@ public class Placeholder extends FlowPanel {
|
|||
*/
|
||||
public void add(AttachmentPreviewer atPrev){
|
||||
|
||||
// retrieve the list of children
|
||||
WidgetCollection listOfChildren = this.getChildren();
|
||||
|
||||
// check the size
|
||||
|
@ -49,13 +50,13 @@ public class Placeholder extends FlowPanel {
|
|||
// ok, we are going to add the 5th attachment and so forth but we hide them..
|
||||
atPrev.setVisible(false);
|
||||
|
||||
// remember to add the button to show them later
|
||||
// remember to add the button to let the user show them later
|
||||
appendShowMoreLabel = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append show more label
|
||||
* Append "Show All" label to the post template.
|
||||
*/
|
||||
public void appendShowMoreLabel(){
|
||||
|
||||
|
@ -67,6 +68,7 @@ public class Placeholder extends FlowPanel {
|
|||
sp.setStyleName("centered");
|
||||
|
||||
final Anchor showMoreAttachments = new Anchor(SHOW_OTHER_ATTACHMENTS_LABEL);
|
||||
showMoreAttachments.setTitle("Show all the attached files");
|
||||
showMoreAttachments.setStyleName("link");
|
||||
sp.add(showMoreAttachments);
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public class TweetTemplate extends Composite {
|
|||
closeImage.removeFromParent();
|
||||
}
|
||||
|
||||
// if there is one attachment, maintain backward compatibility
|
||||
// if there is one attachment or a link preview, maintain backward compatibility
|
||||
if (feed.getUri() != null && feed.getUri().compareTo("") != 0 && feed.getLinkTitle() != null && feed.getLinkTitle().compareTo("") != 0 && !feed.isMultiFileUpload()) {
|
||||
|
||||
// hide the attachments panel
|
||||
|
@ -175,10 +175,13 @@ public class TweetTemplate extends Composite {
|
|||
|
||||
// set handler on the linkpreviewer image to show this carousel
|
||||
linkPreviewer.onImageClickOpenCarousel(carousel);
|
||||
|
||||
// remove next and prev buttons of the carousel since we have only an image
|
||||
carousel.hideArrows();
|
||||
|
||||
}
|
||||
|
||||
// add link preview
|
||||
// add link preview to the preview panel
|
||||
previewPanel.add(linkPreviewer);
|
||||
}
|
||||
|
||||
|
@ -218,7 +221,7 @@ public class TweetTemplate extends Composite {
|
|||
);
|
||||
|
||||
listOfEnhancedImages.add(enhancedImage);
|
||||
firstAttachmentPreviewer.onImageClickOpenCarousel(carousel);
|
||||
firstAttachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
|
||||
|
||||
}
|
||||
|
||||
|
@ -243,7 +246,7 @@ public class TweetTemplate extends Composite {
|
|||
listOfEnhancedImages.add(enhancedImage);
|
||||
|
||||
// pass the carousel
|
||||
attachmentPreviewer.onImageClickOpenCarousel(carousel);
|
||||
attachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
*/
|
||||
public String getDevelopmentUser() {
|
||||
String user = NewsConstants.TEST_USER;
|
||||
user = "costantino.perciante";
|
||||
// user = "costantino.perciante";
|
||||
return user;
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue