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;
|
package org.gcube.portlets.user.newsfeed.client.ui;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.Attachment;
|
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 org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -59,6 +60,9 @@ public class AttachmentPreviewer extends Composite {
|
||||||
// carousel reference
|
// carousel reference
|
||||||
private Carousel carousel;
|
private Carousel carousel;
|
||||||
|
|
||||||
|
// enhanced image associated with this carousel
|
||||||
|
private EnhancedImage img;
|
||||||
|
|
||||||
public AttachmentPreviewer(Attachment a) {
|
public AttachmentPreviewer(Attachment a) {
|
||||||
|
|
||||||
// init
|
// init
|
||||||
|
@ -89,7 +93,8 @@ public class AttachmentPreviewer extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
carousel.show();
|
if(img != null)
|
||||||
|
carousel.show(img);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -119,7 +124,7 @@ public class AttachmentPreviewer 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
|
* @param carousel
|
||||||
*/
|
*/
|
||||||
public void onImageClickOpenCarousel(final Carousel carousel) {
|
public void onImageClickOpenCarousel(final Carousel carousel) {
|
||||||
|
@ -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;
|
package org.gcube.portlets.user.newsfeed.client.ui;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
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
|
* @param carousel
|
||||||
*/
|
*/
|
||||||
public void onImageClickOpenCarousel(final Carousel carousel) {
|
public void onImageClickOpenCarousel(final Carousel carousel) {
|
||||||
|
@ -70,9 +71,6 @@ public class LinkPreviewer extends Composite {
|
||||||
// change cursor type on hover
|
// change cursor type on hover
|
||||||
image.getElement().getStyle().setCursor(Cursor.POINTER);
|
image.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||||
|
|
||||||
// change tooltipe
|
|
||||||
image.setTitle("Click for a preview");
|
|
||||||
|
|
||||||
// add handler
|
// add handler
|
||||||
image.addClickHandler(new ClickHandler() {
|
image.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import com.google.gwt.user.client.ui.WidgetCollection;
|
||||||
*/
|
*/
|
||||||
public class Placeholder extends FlowPanel {
|
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
|
// check if we need to show more attachments
|
||||||
private boolean appendShowMoreLabel;
|
private boolean appendShowMoreLabel;
|
||||||
|
@ -26,6 +26,7 @@ public class Placeholder extends FlowPanel {
|
||||||
*/
|
*/
|
||||||
public void add(AttachmentPreviewer atPrev){
|
public void add(AttachmentPreviewer atPrev){
|
||||||
|
|
||||||
|
// retrieve the list of children
|
||||||
WidgetCollection listOfChildren = this.getChildren();
|
WidgetCollection listOfChildren = this.getChildren();
|
||||||
|
|
||||||
// check the size
|
// 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..
|
// ok, we are going to add the 5th attachment and so forth but we hide them..
|
||||||
atPrev.setVisible(false);
|
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;
|
appendShowMoreLabel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append show more label
|
* Append "Show All" label to the post template.
|
||||||
*/
|
*/
|
||||||
public void appendShowMoreLabel(){
|
public void appendShowMoreLabel(){
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ public class Placeholder extends FlowPanel {
|
||||||
sp.setStyleName("centered");
|
sp.setStyleName("centered");
|
||||||
|
|
||||||
final Anchor showMoreAttachments = new Anchor(SHOW_OTHER_ATTACHMENTS_LABEL);
|
final Anchor showMoreAttachments = new Anchor(SHOW_OTHER_ATTACHMENTS_LABEL);
|
||||||
|
showMoreAttachments.setTitle("Show all the attached files");
|
||||||
showMoreAttachments.setStyleName("link");
|
showMoreAttachments.setStyleName("link");
|
||||||
sp.add(showMoreAttachments);
|
sp.add(showMoreAttachments);
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class TweetTemplate extends Composite {
|
||||||
closeImage.removeFromParent();
|
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()) {
|
if (feed.getUri() != null && feed.getUri().compareTo("") != 0 && feed.getLinkTitle() != null && feed.getLinkTitle().compareTo("") != 0 && !feed.isMultiFileUpload()) {
|
||||||
|
|
||||||
// hide the attachments panel
|
// hide the attachments panel
|
||||||
|
@ -176,9 +176,12 @@ public class TweetTemplate extends Composite {
|
||||||
// set handler on the linkpreviewer image to show this carousel
|
// set handler on the linkpreviewer image to show this carousel
|
||||||
linkPreviewer.onImageClickOpenCarousel(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);
|
previewPanel.add(linkPreviewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +221,7 @@ public class TweetTemplate extends Composite {
|
||||||
);
|
);
|
||||||
|
|
||||||
listOfEnhancedImages.add(enhancedImage);
|
listOfEnhancedImages.add(enhancedImage);
|
||||||
firstAttachmentPreviewer.onImageClickOpenCarousel(carousel);
|
firstAttachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +246,7 @@ public class TweetTemplate extends Composite {
|
||||||
listOfEnhancedImages.add(enhancedImage);
|
listOfEnhancedImages.add(enhancedImage);
|
||||||
|
|
||||||
// pass the carousel
|
// pass the carousel
|
||||||
attachmentPreviewer.onImageClickOpenCarousel(carousel);
|
attachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
*/
|
*/
|
||||||
public String getDevelopmentUser() {
|
public String getDevelopmentUser() {
|
||||||
String user = NewsConstants.TEST_USER;
|
String user = NewsConstants.TEST_USER;
|
||||||
user = "costantino.perciante";
|
// user = "costantino.perciante";
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue