Bug fix for multi-attachment
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@122415 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c8019b8100
commit
81a42d8866
|
@ -54,6 +54,7 @@ public class AttachmentPreviewer extends Composite {
|
|||
|
||||
public AttachmentPreviewer(Attachment a) {
|
||||
|
||||
// init
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
||||
// save the attachment
|
||||
|
@ -62,8 +63,8 @@ public class AttachmentPreviewer extends Composite {
|
|||
// set image preview
|
||||
imagePreview.setUrl(a.getThumbnailURL());
|
||||
|
||||
// set file name
|
||||
String shownName = a.getName().length() > 21 ? a.getName().substring(0, 15) + "..." : a.getName();
|
||||
// set file name (be careful on file name length)
|
||||
String shownName = a.getName().length() > 21 ? a.getName().substring(0, 18) + "..." : a.getName();
|
||||
fileNameLabel.setText(shownName);
|
||||
fileNameLabel.setTitle(a.getName());
|
||||
|
||||
|
@ -72,7 +73,7 @@ public class AttachmentPreviewer extends Composite {
|
|||
downloadLabel.setHref(attachment.getUri());
|
||||
downloadLabel.setTarget("_blank");
|
||||
|
||||
// preview
|
||||
// preview TODO
|
||||
showPreviewLabel.setText("Show");
|
||||
showPreviewLabel.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
border-radius: 4px;
|
||||
margin: 5px;
|
||||
display: inline-block;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.label-filename-style {
|
||||
overflow-x: hidden;
|
||||
width: 100%;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
|||
|
||||
.display-inline-style {
|
||||
display: inline-block;
|
||||
margin-right:5px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel styleName="{style.container-style}" ui:field="attachmentContainer">
|
||||
|
|
|
@ -16,8 +16,10 @@ import com.google.gwt.user.client.ui.WidgetCollection;
|
|||
*/
|
||||
public class Placeholder extends FlowPanel {
|
||||
|
||||
private static final String SHOW_OTHER_ATTACHMENTS_LABEL = "Show all";
|
||||
|
||||
// check if we need to show more attachments
|
||||
private boolean appendShowMoreLabel = false;
|
||||
private boolean appendShowMoreLabel;
|
||||
|
||||
/**
|
||||
* Modified version of the add method.
|
||||
|
@ -29,7 +31,6 @@ public class Placeholder extends FlowPanel {
|
|||
// check the size
|
||||
int size = listOfChildren.size();
|
||||
|
||||
|
||||
if(size % 2 == 0){
|
||||
// in this case the next attachment we are going to add remains with the same width
|
||||
add((Widget)atPrev);
|
||||
|
@ -48,6 +49,7 @@ 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
|
||||
appendShowMoreLabel = true;
|
||||
}
|
||||
}
|
||||
|
@ -57,14 +59,14 @@ public class Placeholder extends FlowPanel {
|
|||
*/
|
||||
public void appendShowMoreLabel(){
|
||||
|
||||
final WidgetCollection listOfChildren = this.getChildren();
|
||||
|
||||
if(appendShowMoreLabel){
|
||||
|
||||
final WidgetCollection listOfChildren = this.getChildren();
|
||||
|
||||
final SimplePanel sp = new SimplePanel();
|
||||
sp.setStyleName("centered");
|
||||
|
||||
final Anchor showMoreAttachments = new Anchor("Show other attachments");
|
||||
final Anchor showMoreAttachments = new Anchor(SHOW_OTHER_ATTACHMENTS_LABEL);
|
||||
showMoreAttachments.setStyleName("link");
|
||||
sp.add(showMoreAttachments);
|
||||
|
||||
|
@ -73,7 +75,7 @@ public class Placeholder extends FlowPanel {
|
|||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
// retrieve the list of attachmentPreviewers
|
||||
// retrieve the list of attachmentPreviewers and show them
|
||||
for(Widget w: listOfChildren){
|
||||
w.setVisible(true);
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ public class Placeholder extends FlowPanel {
|
|||
}
|
||||
});
|
||||
|
||||
// show it
|
||||
// show the panel
|
||||
this.add(sp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,13 +131,6 @@ public class TweetTemplate extends Composite {
|
|||
this.myFeed = myFeed;
|
||||
isAppFeed = myFeed.getFeed().isApplicationFeed();
|
||||
Feed feed = myFeed.getFeed();
|
||||
|
||||
GWT.log("Is feed multiupload? " + feed.isMultiFileUpload());
|
||||
// if there is one attachment, maintain backward compatibility
|
||||
if (feed.getUri() != null && feed.getUri().compareTo("") != 0 && feed.getLinkTitle() != null && feed.getLinkTitle().compareTo("") != 0 && !feed.isMultiFileUpload()) {
|
||||
previewPanel.add(new LinkPreviewer(feed.getLinkTitle(), feed.getLinkDescription(), feed.getLinkHost(), feed.getUriThumbnail(), feed.getUri()));
|
||||
}
|
||||
|
||||
this.eventBus = eventBus;
|
||||
this.isUsers = myFeed.isUsers();
|
||||
myComments = new ArrayList<SingleComment>();
|
||||
|
@ -149,9 +142,25 @@ public class TweetTemplate extends Composite {
|
|||
closeImage.removeFromParent();
|
||||
}
|
||||
|
||||
GWT.log("Is feed multiupload? " + feed.isMultiFileUpload());
|
||||
// if there is one attachment, maintain backward compatibility
|
||||
if (feed.getUri() != null && feed.getUri().compareTo("") != 0 && feed.getLinkTitle() != null && feed.getLinkTitle().compareTo("") != 0 && !feed.isMultiFileUpload()) {
|
||||
|
||||
// add link preview
|
||||
previewPanel.add(new LinkPreviewer(feed.getLinkTitle(), feed.getLinkDescription(), feed.getLinkHost(), feed.getUriThumbnail(), feed.getUri()));
|
||||
|
||||
// hide the attachments panel
|
||||
attachmentPreviewPanel.setVisible(false);
|
||||
}
|
||||
|
||||
// in case there are attachments, we have to fill attachmentPreviewPanel instead of the previewPanel
|
||||
if(feed.isMultiFileUpload()){
|
||||
|
||||
// set style to the attachment container
|
||||
attachmentPreviewPanel.setStyleName("attachment-preview-container");
|
||||
|
||||
// hide link preview panel
|
||||
previewPanel.setVisible(false);
|
||||
|
||||
// remember that one attachment is stored in the fields: uri, uriThumbnail, linkTitle, linkDescription, linkHost
|
||||
// build up an attachment
|
||||
|
@ -166,19 +175,15 @@ public class TweetTemplate extends Composite {
|
|||
// add it to the panel
|
||||
attachmentPreviewPanel.add(new AttachmentPreviewer(firstAttachment));
|
||||
|
||||
|
||||
for (Attachment otherAttachment : myFeed.getAttachments()) {
|
||||
|
||||
// try to build the attachment viewer
|
||||
attachmentPreviewPanel.add(new AttachmentPreviewer(otherAttachment));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// invoke append label
|
||||
attachmentPreviewPanel.appendShowMoreLabel();
|
||||
|
||||
// set style to the attachment container
|
||||
attachmentPreviewPanel.setStyleName("attachment-preview-container");
|
||||
}
|
||||
|
||||
openImage.setStyleName("openImage");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/**
|
||||
|
@ -1054,10 +1054,4 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
return toReturn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -600,4 +600,4 @@ a.link:hover {
|
|||
transition: background .25s ease-in-out;
|
||||
-moz-transition: background .25s ease-in-out;
|
||||
-webkit-transition: background .25s ease-in-out;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue