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 c00e127..33f7e58 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 @@ -9,14 +9,21 @@ import org.gcube.portlets.user.workspace.client.ConstantsExplorer; 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; +import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem; +import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage; +import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument; +import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync; 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.constants.ButtonType; +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.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -31,12 +38,26 @@ 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.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Widget; +// TODO: Auto-generated Javadoc +/** + * The Class DialogGetInfoBootstrap. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Jul 13, 2020 + */ public class DialogGetInfoBootstrap extends Composite { private static DialogGetInfoBootstrapUiBinder uiBinder = GWT.create(DialogGetInfoBootstrapUiBinder.class); + /** + * The Interface DialogGetInfoBootstrapUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Jul 13, 2020 + */ interface DialogGetInfoBootstrapUiBinder extends UiBinder { } @@ -44,6 +65,9 @@ public class DialogGetInfoBootstrap extends Composite { private final NumberFormat number = ConstantsExplorer.numberFormatterKB; + /** + * Instantiates a new dialog get info bootstrap. + */ public DialogGetInfoBootstrap() { initWidget(uiBinder.createAndBindUi(this)); } @@ -57,6 +81,9 @@ public class DialogGetInfoBootstrap extends Composite { @UiField HorizontalPanel hpHeaderDetails; + + @UiField + HorizontalPanel hpImagePreview; @UiField HTML txtName; @@ -84,7 +111,7 @@ public class DialogGetInfoBootstrap extends Composite { @UiField ControlGroup cgGcubeProperties; - + @UiField TextArea txtAreaGcubeProperties; @@ -111,6 +138,12 @@ public class DialogGetInfoBootstrap extends Composite { @UiField Button buttonUpdateGcubeProperties; + + @UiField + ControlGroup cgSharedWith; + + @UiField + HTML txtSharedWith; private FileModel fileModel; @@ -122,11 +155,31 @@ public class DialogGetInfoBootstrap extends Composite { * hpGcubeProperties; private DialogEditProperties editProperties = null; */ - public DialogGetInfoBootstrap(final FileModel fileModel) { + /** + * Instantiates a new dialog get info bootstrap. + * + * @param fileModel the file model + * @param onCloseCommand the on close command + */ + public DialogGetInfoBootstrap(final FileModel fileModel, final Command onCloseCommand) { initWidget(uiBinder.createAndBindUi(this)); this.fileModel = fileModel; 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(); @@ -158,7 +211,7 @@ public class DialogGetInfoBootstrap extends Composite { if (fileModel.isRoot()) txtLocation.setHTML("/"); else - loadLocation(fileModel.getIdentifier()); + loadLocation(fileModel); if (fileModel.isDirectory()) { cgTxtIsPublic.setVisible(true); @@ -201,9 +254,27 @@ public class DialogGetInfoBootstrap extends Composite { htmlSetValue(txtShared, fileModel.isShared()+""); + // USERS SHARED + if (fileModel.isShared()) { + + cgSharedWith.setVisible(true); + loadACLsDescriptionForSharedFolder(fileModel.getIdentifier()); + } + + + // is it an image? + if (typeEnum!=null && (typeEnum.equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT) + || typeEnum.equals(GXTFolderItemTypeEnum.EXTERNAL_IMAGE))) { + loadThumbnailsForImage(); + } + + addHandlers(); } + /** + * Adds the handlers. + */ private void addHandlers() { txtAreaDescription.addKeyPressHandler(new KeyPressHandler() { @@ -250,6 +321,12 @@ public class DialogGetInfoBootstrap extends Composite { }); } + /** + * Html set value. + * + * @param field the field + * @param value the value + */ private void htmlSetValue(HTML field, String value) { if (value == null || value.isEmpty()) @@ -258,6 +335,12 @@ public class DialogGetInfoBootstrap extends Composite { field.setHTML(value); } + /** + * Gets the formatted size. + * + * @param value the value + * @return the formatted size + */ private String getFormattedSize(long value) { if (value > 0) { @@ -271,10 +354,15 @@ public class DialogGetInfoBootstrap extends Composite { return ""; } - private void loadLocation(String itemId) { - + /** + * Load location. + * + * @param fileModel the file model + */ + private void loadLocation(FileModel fileModel) { + setPlaceholder(txtLocation, "loading..."); - AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(itemId, false, + AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(fileModel.getIdentifier(), false, new AsyncCallback>() { @Override @@ -305,6 +393,11 @@ public class DialogGetInfoBootstrap extends Composite { } + /** + * Load size. + * + * @param itemId the item id + */ private void loadSize(final String itemId) { GWT.log("Load size"); setPlaceholder(txtSize, "loading..."); @@ -329,6 +422,11 @@ public class DialogGetInfoBootstrap extends Composite { }); } + /** + * Load creation date. + * + * @param itemId the item id + */ private void loadCreationDate(final String itemId) { setPlaceholder(txtCreated, "loading..."); @@ -352,6 +450,11 @@ public class DialogGetInfoBootstrap extends Composite { }); } + /** + * Load last modification date. + * + * @param itemId the item id + */ private void loadLastModificationDate(final String itemId) { setPlaceholder(txtLastMofication, "loading..."); @@ -377,7 +480,9 @@ public class DialogGetInfoBootstrap extends Composite { } /** - * @param identifier + * Load description. + * + * @param identifier the identifier */ private void loadDescription(String identifier) { txtAreaDescription.setEnabled(false); @@ -404,6 +509,9 @@ public class DialogGetInfoBootstrap extends Composite { } + /** + * Load gcube item properties. + */ private void loadGcubeItemProperties() { // mask("Loading properties..."); AppControllerExplorer.rpcWorkspaceService.loadGcubeItemProperties(fileModel.getIdentifier(), @@ -434,15 +542,96 @@ public class DialogGetInfoBootstrap extends Composite { } }); } + + /** + * Load AC ls description for shared folder. + * + * @param sharedId the shared id + */ + private void loadACLsDescriptionForSharedFolder(String sharedId) { - private void setPlaceholder(HTML html, String placeholder) { - html.setHTML(placeholder); - html.getElement().getStyle().setColor("#E8E8E8"); + setPlaceholder(txtSharedWith, "loading..."); + + WorkspaceSharingServiceAsync.INSTANCE.getACLsDescriptionForSharedFolderId(sharedId, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + removePlaceHolder(txtSharedWith); + txtSharedWith.setHTML("Error on recovering users"); + + } + + @Override + public void onSuccess(String result) { + removePlaceHolder(txtSharedWith); + txtSharedWith.getElement().addClassName("shared-with-style"); + GWT.log("Loaded ACLs: " + result); + txtSharedWith.setHTML(result); + + } + }); + + } + + + /** + * Load thumbnails for image. + */ + private void loadThumbnailsForImage() { + + hpImagePreview.setVisible(true); + final HTML txtLoadingPreview = new HTML(); + hpImagePreview.add(txtLoadingPreview); + setPlaceholder(txtLoadingPreview, "loading preview..."); + + AppControllerExplorer.rpcWorkspaceService.getImageById(fileModel.getIdentifier(), + fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT), false, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + removePlaceHolder(txtLoadingPreview); + + } + + @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); + }else { + GWTExternalImage theExternalImage = (GWTExternalImage) item; + hpImagePreview.add(new Image(theExternalImage.getThumbnailUrl())); + hpImagePreview.setVisible(true); + } + } + }); } + /** + * Sets the placeholder. + * + * @param html the html + * @param placeholder the placeholder + */ + private void setPlaceholder(HTML html, String placeholder) { + html.setHTML(placeholder); + html.getElement().addClassName("placeholder-loading"); + } + + /** + * Removes the place holder. + * + * @param html the html + */ private void removePlaceHolder(HTML html) { html.setHTML(""); - html.getElement().getStyle().setColor("#000"); + html.getElement().removeClassName("placeholder-loading"); } } 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 2df0b1a..602c4e4 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 @@ -6,11 +6,6 @@ .no-border { border: 0px; } - - .html-value-style { - padding-top: 5px; - font-family: Arial, Helvetica, sans-serif; - } + + @@ -145,6 +143,17 @@ + + Shared with + + + + + + + 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 a68a1e9..0708ca2 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 @@ -306,6 +306,7 @@ table.userssuggest th { margin-bottom: 10px !important; font-size: 14px !important; font-family: Arial, serif; + color: #222; } .my-control-group-get-info .controls { @@ -316,6 +317,7 @@ table.userssuggest th { width: 80px !important; text-align: center !important; padding-right: 10px !important; + font-family: Roboto, Arial, serif !important; color: #959595; } @@ -359,9 +361,32 @@ table.userssuggest th { vertical-align: middle !important; } +.item-details-header { + margin: 15px; +} + +.item-details-header td { + vertical-align: middle !important; +} + +.item-details-header td:last-child { + width: 85%; + color: #555; +} + .item-details-header .gwt-HTML { font-size: 20px; font-family: Roboto, Arial, serif !important; - color: #777; - margin: 15px; -} \ No newline at end of file + color: #555; +} + +.placeholder-loading { + color: #E8E8E8; +} + +.shared-with-style{ + width: 90% !important; + font-size: 12px !important; + display: inline-block !important; +} +