diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/LinkPreviewer.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/LinkPreviewer.java index 12ae332..39fd172 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/LinkPreviewer.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/LinkPreviewer.java @@ -13,7 +13,9 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; public class LinkPreviewer extends Composite { - + + private static final String HTTP_ERROR_301 = "Moved Permanently"; + private static LinkPreviewUiBinder uiBinder = GWT .create(LinkPreviewUiBinder.class); @@ -26,6 +28,8 @@ public class LinkPreviewer extends Composite { private SaveInWorkspaceBox saveCopy; + private boolean showImage = true; + @UiField HTML closeImage; @UiField @@ -50,11 +54,18 @@ public class LinkPreviewer extends Composite { this.parent = parent; this.toShow = toShow; - titleArea.setHTML(""+toShow.getTitle()+" - " + toShow.getHost() + ""); + String title = toShow.getTitle(); + String desc = toShow.getDescription(); + if (title.compareTo(HTTP_ERROR_301) == 0) { + this.toShow.setTitle(title = "HTTP Link"); + this.toShow.setDescription(desc = ""); + this.showImage = false; + } + titleArea.setHTML("" + title + " - " + toShow.getHost() + ""); + descText.setHTML((desc.length() > 256) ? desc.substring(0, 256)+"..." : desc); String url = toShow.getUrl(); urlText.setHTML((url.length() > 80) ? url.substring(0, 80)+"..." : url); - String desc = toShow.getDescription(); - descText.setHTML((desc.length() > 256) ? desc.substring(0, 256)+"..." : desc); + switcher.setImages(toShow.getImageUrls()); if (isFilePreview) { saveCopy = new SaveInWorkspaceBox(); @@ -62,9 +73,6 @@ public class LinkPreviewer extends Composite { } } - - - public ImageSwitcher getSwitcher() { return switcher; } @@ -97,6 +105,8 @@ public class LinkPreviewer extends Composite { return toShow.getHost(); } public String getUrlThumbnail() { + if (!showImage) + return null; return switcher.getSelectedImageURL(); } protected boolean isSharingFile() {