From ad937c9f135af6d837135b5f2757332a52eb08b8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 14 Jul 2020 15:43:41 +0200 Subject: [PATCH] first release for testing of #19600 --- .../view/windows/DialogGetInfoBootstrap.java | 55 +++++++++++++------ .../windows/DialogGetInfoBootstrap.ui.xml | 20 ++++--- .../user/workspace/public/workspacetree.css | 27 +++++++-- .../user/workspace/server/ImageServlet.java | 23 +++++--- .../server/util/ThumbnailGenerator.java | 2 +- 5 files changed, 87 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java index 33f7e58..e2fcdb3 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java @@ -6,6 +6,7 @@ import java.util.Map; import org.gcube.portlets.user.workspace.client.AppControllerExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; +import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileModel; @@ -29,6 +30,7 @@ import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; +import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -37,6 +39,7 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; 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.Widget; @@ -83,7 +86,7 @@ public class DialogGetInfoBootstrap extends Composite { HorizontalPanel hpHeaderDetails; @UiField - HorizontalPanel hpImagePreview; + HTMLPanel htmlPanelImagePreview; @UiField HTML txtName; @@ -139,6 +142,9 @@ public class DialogGetInfoBootstrap extends Composite { @UiField Button buttonUpdateGcubeProperties; + @UiField + Button buttonUpdateShare; + @UiField ControlGroup cgSharedWith; @@ -146,6 +152,11 @@ public class DialogGetInfoBootstrap extends Composite { HTML txtSharedWith; private FileModel fileModel; + + private Command onCloseCommand; + + private DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd MMM yyyy, hh:mm aaa"); + /* * textAreaSharedWith = new TextArea(); private Html htmlUsersWidget = new @@ -164,6 +175,7 @@ public class DialogGetInfoBootstrap extends Composite { public DialogGetInfoBootstrap(final FileModel fileModel, final Command onCloseCommand) { initWidget(uiBinder.createAndBindUi(this)); this.fileModel = fileModel; + this.onCloseCommand = onCloseCommand; hpHeaderDetails.add(new HTML("Details")); @@ -243,7 +255,7 @@ public class DialogGetInfoBootstrap extends Composite { if(fileModel instanceof FileGridModel) { FileGridModel fileGridModel = ((FileGridModel) fileModel); //last update - htmlSetValue(txtLastMofication, fileGridModel.getLastModification().toString()); + htmlSetValue(txtLastMofication, dateFormatter.format(fileGridModel.getLastModification())); //size htmlSetValue(txtSize, getFormattedSize(fileGridModel.getSize())); }else { @@ -319,6 +331,15 @@ public class DialogGetInfoBootstrap extends Composite { editProperties.setProperties(gCubeProperties); } }); + + buttonUpdateShare.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + AppControllerExplorer.getEventBus().fireEvent(new CreateSharedFolderEvent(fileModel, fileModel.getParentFileModel(),false)); + onCloseCommand.execute(); + } + }); } /** @@ -439,11 +460,11 @@ public class DialogGetInfoBootstrap extends Composite { } @Override - public void onSuccess(Date result) { + public void onSuccess(Date dateResult) { removePlaceHolder(txtCreated); - if (result != null) - htmlSetValue(txtCreated, result.toString()); - else + if (dateResult != null) { + htmlSetValue(txtCreated, dateFormatter.format(dateResult)); + }else htmlSetValue(txtCreated, null); } @@ -467,11 +488,11 @@ public class DialogGetInfoBootstrap extends Composite { } @Override - public void onSuccess(Date result) { + public void onSuccess(Date dateResult) { removePlaceHolder(txtLastMofication); - if (result != null) - htmlSetValue(txtLastMofication, result.toString()); - else + if (dateResult != null) { + htmlSetValue(txtLastMofication, dateFormatter.format(dateResult)); + }else htmlSetValue(txtLastMofication, null); } @@ -580,9 +601,9 @@ public class DialogGetInfoBootstrap extends Composite { */ private void loadThumbnailsForImage() { - hpImagePreview.setVisible(true); + htmlPanelImagePreview.setVisible(true); final HTML txtLoadingPreview = new HTML(); - hpImagePreview.add(txtLoadingPreview); + htmlPanelImagePreview.add(txtLoadingPreview); setPlaceholder(txtLoadingPreview, "loading preview..."); AppControllerExplorer.rpcWorkspaceService.getImageById(fileModel.getIdentifier(), @@ -597,18 +618,18 @@ public class DialogGetInfoBootstrap extends Composite { @Override public void onSuccess(GWTWorkspaceItem item) { - removePlaceHolder(txtLoadingPreview); GWT.log("Image loaded: " + item.getName() + " label: " + item.getLabel() + " type: " + fileModel.getGXTFolderItemType()); if (fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT)) { GWTImageDocument theItemImage = (GWTImageDocument) item; - hpImagePreview.add(new Image(theItemImage.getThumbnailUrl())); - hpImagePreview.setVisible(true); + htmlPanelImagePreview.add(new Image(theItemImage.getThumbnailUrl())); + htmlPanelImagePreview.setVisible(true); }else { GWTExternalImage theExternalImage = (GWTExternalImage) item; - hpImagePreview.add(new Image(theExternalImage.getThumbnailUrl())); - hpImagePreview.setVisible(true); + htmlPanelImagePreview.add(new Image(theExternalImage.getThumbnailUrl())); + htmlPanelImagePreview.setVisible(true); } + removePlaceHolder(txtLoadingPreview); } }); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml index 602c4e4..6cb18b7 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml @@ -14,9 +14,9 @@ - - + + @@ -81,9 +81,9 @@ - + + ui:field="buttonUpdateDescription" type="LINK">Edit @@ -95,10 +95,9 @@ - + + ui:field="buttonUpdateGcubeProperties" type="LINK">Edit @@ -150,10 +149,13 @@ + + Share + - diff --git a/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css b/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css index 0708ca2..229f6b0 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css +++ b/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css @@ -303,7 +303,7 @@ table.userssuggest th { } .my-control-group-get-info { - margin-bottom: 10px !important; + margin-bottom: 5px !important; font-size: 14px !important; font-family: Arial, serif; color: #222; @@ -328,6 +328,7 @@ table.userssuggest th { .my-control-group-get-info .gwt-HTML { padding-top: 5px; font-family: Roboto, Arial, serif !important; + overflow-wrap: break-word; } .my-control-group-get-info .gwt-TextBox:hover { @@ -335,12 +336,17 @@ table.userssuggest th { } .my-control-group-get-info .gwt-TextArea { - width: 250px; + width: 260px; + min-height: 60px; height: 60px; } +.my-control-group-get-info .btn-link { + margin-left: 7px !important; +} + .item-type-style { - margin-top: 10px; + margin-top: 1px; margin-left: 10px; margin-bottom: 10px; padding-top: 5px; @@ -362,7 +368,9 @@ table.userssuggest th { } .item-details-header { - margin: 15px; + margin-top: 15px; + margin-left: 15px; + margin-right: 15px; } .item-details-header td { @@ -390,3 +398,14 @@ table.userssuggest th { display: inline-block !important; } +.preview-image-style { + width: 95%; + display: flex; + align-items: center; + justify-content: center; +} + +.preview-image-style img { + max-width: 400px; + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java index fe33f8a..57a4313 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java @@ -145,17 +145,21 @@ public class ImageServlet extends HttpServlet{ try{ streamDescr = wa.getThumbnailData(image.getId()); - - /*TODO - * UNCOMMENT THIS IF YOU WANT TO ADD MORE CONTROLS - ReusableInputStream ris = new ReusableInputStream(streamDescr.getStream()); + logger.debug("Thumbnail data has size: "+streamDescr.getSize()); + //CHECKING IF THE STREAM IS A VALID IMAGE + /* TODO + * ReusableInputStream ris = new ReusableInputStream(streamDescr.getStream()); boolean isAvalidImage = isAnImage(ris, image.getName()); - if(!isAvalidImage) + if(!isAvalidImage) { //CREATING THE THUMBNAIL + logger.debug("the stream seems not be a valid image, creating the thumbnail"); streamDescr = createThumbnailForImage(wa, image); - else { + }else { //ASSIGNING THE REUSABLE STREAM - streamDescr = new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(ris, image.getName(), null, image.getMimeType()); + logger.debug("using reusable stream"); + size = streamDescr.getSize()==null?0:streamDescr.getSize(); + logger.debug("ReusableInputStream has size: "+size); + streamDescr = new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(ris, image.getName(), size, streamDescr.getMimeType()); }*/ @@ -186,8 +190,9 @@ public class ImageServlet extends HttpServlet{ resp.setContentType(mimeType); //if image/thumbnail size is 0, skipping setContentLength - if(size!=0) - resp.setContentLength((int)size); + //AVOIDING TO SET IT, SOME CASES THE SIZE MISMATCH +// if(size!=0) +// resp.setContentLength((int)size); InputStream in = streamDescr.getStream(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/ThumbnailGenerator.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/ThumbnailGenerator.java index af11c18..b6e7932 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/ThumbnailGenerator.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/ThumbnailGenerator.java @@ -136,7 +136,7 @@ public class ThumbnailGenerator { extension = extension.startsWith(".") ? extension : "." + extension; final File tempFile = File.createTempFile(filename, extension); - //tempFile.deleteOnExit(); + tempFile.deleteOnExit(); try (FileOutputStream out = new FileOutputStream(tempFile)) { IOUtils.copy(in, out); }