From b86510ee926ced69cedda00ae59e8468d7c21719 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 15 Jul 2020 15:01:18 +0200 Subject: [PATCH] added download facility --- .../view/windows/DialogGetInfoBootstrap.java | 118 ++++++++++++------ .../windows/DialogGetInfoBootstrap.ui.xml | 14 ++- .../user/workspace/public/workspacetree.css | 8 +- 3 files changed, 94 insertions(+), 46 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 e2fcdb3..0a9c321 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 @@ -7,6 +7,8 @@ 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.event.FileDownloadEvent; +import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType; 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; @@ -19,10 +21,13 @@ import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.TextArea; +import com.github.gwtbootstrap.client.ui.Tooltip; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.IconSize; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.github.gwtbootstrap.client.ui.constants.ResizeType; +import com.github.gwtbootstrap.client.ui.resources.ButtonSize; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.Unit; @@ -85,9 +90,12 @@ public class DialogGetInfoBootstrap extends Composite { @UiField HorizontalPanel hpHeaderDetails; + @UiField + Button buttonClose; + @UiField HTMLPanel htmlPanelImagePreview; - + @UiField HTML txtName; @@ -138,6 +146,9 @@ public class DialogGetInfoBootstrap extends Composite { @UiField Button buttonUpdateDescription; + + @UiField + Button buttonSaveDescription; @UiField Button buttonUpdateGcubeProperties; @@ -155,16 +166,14 @@ public class DialogGetInfoBootstrap extends Composite { private Command onCloseCommand; + private Tooltip tooltipDownload = new Tooltip("Download"); + + private Button buttonDownload = new Button("Download"); + +// private Tooltip tooltipSharebleLink = new Tooltip("Get Shareable Link"); +// private Button buttonShareableLink = new Button(); + private DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd MMM yyyy, hh:mm aaa"); - - - /* - * textAreaSharedWith = new TextArea(); private Html htmlUsersWidget = new - * Html(); private Html htmlPropertiesWidget = new Html(); private final - * NumberFormat number = ConstantsExplorer.numberFormatterKB; // private - * TextField txtGcubeItemProperties; private HorizontalPanel - * hpGcubeProperties; private DialogEditProperties editProperties = null; - */ /** * Instantiates a new dialog get info bootstrap. @@ -177,29 +186,17 @@ public class DialogGetInfoBootstrap extends Composite { this.fileModel = fileModel; this.onCloseCommand = onCloseCommand; - hpHeaderDetails.add(new HTML("Details")); - - Button buttonClose = new Button(); - buttonClose.setType(ButtonType.LINK); - buttonClose.setIcon(IconType.REMOVE); - buttonClose.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - onCloseCommand.execute(); - } - }); - buttonClose.getElement().getStyle().setFloat(Float.RIGHT); - hpHeaderDetails.add(buttonClose); hpItemType.add(fileModel.getIcon()); Label labelItemType = new Label(); - labelItemType.setType(LabelType.INFO); - labelItemType.getElement().getStyle().setMarginLeft(10, Unit.PX); + labelItemType.setType(LabelType.DEFAULT); + //labelItemType.getElement().getStyle().setMarginLeft(10, Unit.PX); String label = null; GXTFolderItemTypeEnum typeEnum = fileModel.getGXTFolderItemType(); + + //if the item is categorized if (typeEnum != null) { label = typeEnum.getLabel(); label = label.replace("External ", ""); @@ -209,12 +206,24 @@ public class DialogGetInfoBootstrap extends Composite { loadGcubeItemProperties(); } else { + //using the type (i.e. mimetype) label = fileModel.getType(); } labelItemType.setText(label); - hpItemType.add(labelItemType); + + buttonDownload.setType(ButtonType.LINK); + buttonDownload.setIcon(IconType.CLOUD_DOWNLOAD); + tooltipDownload.add(buttonDownload); + hpItemType.add(tooltipDownload); + +// buttonShareableLink.setType(ButtonType.LINK); +// buttonShareableLink.setIcon(IconType.LINK); +// buttonShareableLink.set +// tooltipSharebleLink.add(buttonShareableLink); +// hpItemType.add(tooltipSharebleLink); + // Setting name htmlSetValue(txtName, fileModel.getName()); @@ -273,14 +282,12 @@ public class DialogGetInfoBootstrap extends Composite { loadACLsDescriptionForSharedFolder(fileModel.getIdentifier()); } - // is it an image? if (typeEnum!=null && (typeEnum.equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT) || typeEnum.equals(GXTFolderItemTypeEnum.EXTERNAL_IMAGE))) { loadThumbnailsForImage(); } - addHandlers(); } @@ -288,28 +295,47 @@ public class DialogGetInfoBootstrap extends Composite { * Adds the handlers. */ private void addHandlers() { - - txtAreaDescription.addKeyPressHandler(new KeyPressHandler() { - + + buttonClose.addClickHandler(new ClickHandler() { + @Override - public void onKeyPress(KeyPressEvent event) { - - GWT.log(event.getUnicodeCharCode() + ""); - - if (event.getUnicodeCharCode() == 13) { - txtAreaDescription.setReadOnly(true); - Window.alert("Updating description"); - } - + public void onClick(ClickEvent event) { + onCloseCommand.execute(); } }); +// txtAreaDescription.addKeyPressHandler(new KeyPressHandler() { +// +// @Override +// public void onKeyPress(KeyPressEvent event) { +// +// GWT.log(event.getUnicodeCharCode() + ""); +// +// if (event.getUnicodeCharCode() == 13) { +// txtAreaDescription.setReadOnly(true); +// Window.alert("Updating description"); +// } +// +// } +// }); + buttonUpdateDescription.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { txtAreaDescription.setReadOnly(false); txtAreaDescription.setFocus(true); + buttonSaveDescription.setVisible(true); + } + }); + + buttonSaveDescription.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + buttonSaveDescription.setVisible(false); + txtAreaDescription.setReadOnly(true); + Window.alert("To be implemented"); } }); @@ -340,6 +366,16 @@ public class DialogGetInfoBootstrap extends Composite { onCloseCommand.execute(); } }); + + buttonDownload.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + AppControllerExplorer.getEventBus() + .fireEvent(new FileDownloadEvent(fileModel.getIdentifier(), fileModel.getName(), + DownloadType.SHOW, fileModel.isDirectory() || fileModel.isVreFolder(), null)); + } + }); } /** 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 6cb18b7..ec05019 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 @@ -10,6 +10,8 @@ + Details + @@ -81,10 +83,14 @@ - - + Edit + + Save + - Share + 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 229f6b0..5f22e29 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 @@ -357,7 +357,6 @@ table.userssuggest th { height: 30px; } - .item-type-style td:first-child { width: 30px; padding-left: 5px; @@ -367,6 +366,13 @@ table.userssuggest th { vertical-align: middle !important; } +/*THIS IS THE SIZE OF DOWNLOAD ICON +IN THE 'DETAILS' PANEL*/ +.item-type-style td a i{ + font-size: 22px; +} + + .item-details-header { margin-top: 15px; margin-left: 15px;