diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.java index 3054bd4..138cf75 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.java @@ -10,6 +10,7 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Label; @@ -35,6 +36,9 @@ public class AttachmentPreviewer extends Composite { //private static final String DELETE_ATTACHMENT = "Delete this attachment?"; private static final String RETRY_TO_UPLOAD = "Retry to upload this attachment on the server."; + + @UiField + HTMLPanel attachmentContainer; @UiField HTML deleteAttachment; @@ -150,5 +154,11 @@ public class AttachmentPreviewer extends Composite { attachmentResult.add(retryButton); } + + public void changeAttachmentWidth(int newWidth, Unit unit){ + + attachmentContainer.getElement().getStyle().setWidth(newWidth, unit); + + } } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.ui.xml b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.ui.xml index 435474e..46fd3d6 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.ui.xml +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/AttachmentPreviewer.ui.xml @@ -33,7 +33,7 @@ background-image: none; border: 1px solid #DDD; border-radius: 4px; - width: 278px; + width: 579px; margin: 5px; display: inline-block; } @@ -43,7 +43,7 @@ width: 200px } - + diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/Placeholder.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/Placeholder.java index 7d7381c..c07f980 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/Placeholder.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/Placeholder.java @@ -1,8 +1,11 @@ package org.gcube.portlets.user.shareupdates.client.view; +import com.google.gwt.core.shared.GWT; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; +import com.google.gwt.user.client.ui.WidgetCollection; /** * This panel will contain the attachments/previews * @author Massimiliano Assante at ISTI CNR @@ -11,4 +14,31 @@ import com.google.gwt.user.client.ui.VerticalPanel; */ public class Placeholder extends FlowPanel { + /** + * Modified version of the add method. + */ + public void add(AttachmentPreviewer atPrev){ + + WidgetCollection listOfChildren = this.getChildren(); + + // check the size + int size = listOfChildren.size(); + + GWT.log("Size is " + size); + + if(size % 2 == 0){ + // in this case the next attachment we are going to add remains with the same width + add((Widget)atPrev); + GWT.log("added without changing size"); + } + else{ + // we need to change the length of the last element added and of this new one + ((AttachmentPreviewer) listOfChildren.get(size -1)).changeAttachmentWidth(278, Unit.PX); + atPrev.changeAttachmentWidth(278, Unit.PX); + + // add it finally + add((Widget)atPrev); + } + } + } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java index f55062d..cd742e9 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java @@ -247,33 +247,6 @@ public class ShareUpdateForm extends Composite { GWT.log("Drag and drop not supported."); } - -// ClientFeed notification = new ClientFeed(); -// //Subscribe to message and associate subsequent receptions with custom subscriber data -// try { -// pageBusAdapter.PageBusSubscribe("org.gcube.portal.databook.shared", null, null, notification, (Jsonizer)GWT.create(ClientFeedJsonizer.class)); -// } -// catch (PageBusAdapterException e1) { -// GWT.log(e1.toString()); -// } -// -// pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener() { -// public void onPageBusSubscriptionCallback(PageBusEvent event) { -// // translate JavaScript message contents and subscriber data to their Java equivalents -// try { -// -// GWT.log("Receiving..."); -// ClientFeed feed = (ClientFeed)event.getMessage((Jsonizer)GWT.create(ClientFeedJsonizer.class)); -// GWT.log("Received client feed " + feed); -// -// } catch (PageBusAdapterException e) { -// e.printStackTrace(); -// } -// } -// public String getName() { -// return null; -// } -// }); } }); } @@ -668,7 +641,7 @@ public class ShareUpdateForm extends Composite { // create temp view of the attached file and add to the previewer final AttachmentPreviewer atPrev = new AttachmentPreviewer(fileName, attachedDefaultImageUrl, preview, this); - preview.add(atPrev); + //preview.add(atPrev); // disable the submit button till we know the result of the upload process submitButton.setEnabled(false); @@ -777,7 +750,7 @@ public class ShareUpdateForm extends Composite { atPrev.setImagePreview(result.getImageUrls().get(0)); } - + preview.add(atPrev); // enable checkbox to save in workspace if it's the case diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml index 533bac9..317a929 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml @@ -2,12 +2,17 @@ + + .attachment-container { + width: 600px; + } + - + @@ -39,9 +44,10 @@ - + + text="Share" visible="false" />