working on show preview for image

This commit is contained in:
Francesco Mangiacrapa 2020-07-13 18:04:53 +02:00
parent b9370463b0
commit 239810f194
3 changed files with 242 additions and 19 deletions

View File

@ -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.interfaces.GXTFolderItemTypeEnum;
import org.gcube.portlets.user.workspace.client.model.FileGridModel; 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.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.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.TextArea; 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.LabelType;
import com.github.gwtbootstrap.client.ui.constants.ResizeType; import com.github.gwtbootstrap.client.ui.constants.ResizeType;
import com.google.gwt.core.client.GWT; 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.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; 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.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget; 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 { public class DialogGetInfoBootstrap extends Composite {
private static DialogGetInfoBootstrapUiBinder uiBinder = GWT.create(DialogGetInfoBootstrapUiBinder.class); 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<Widget, DialogGetInfoBootstrap> { interface DialogGetInfoBootstrapUiBinder extends UiBinder<Widget, DialogGetInfoBootstrap> {
} }
@ -44,6 +65,9 @@ public class DialogGetInfoBootstrap extends Composite {
private final NumberFormat number = ConstantsExplorer.numberFormatterKB; private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
/**
* Instantiates a new dialog get info bootstrap.
*/
public DialogGetInfoBootstrap() { public DialogGetInfoBootstrap() {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
} }
@ -57,6 +81,9 @@ public class DialogGetInfoBootstrap extends Composite {
@UiField @UiField
HorizontalPanel hpHeaderDetails; HorizontalPanel hpHeaderDetails;
@UiField
HorizontalPanel hpImagePreview;
@UiField @UiField
HTML txtName; HTML txtName;
@ -84,7 +111,7 @@ public class DialogGetInfoBootstrap extends Composite {
@UiField @UiField
ControlGroup cgGcubeProperties; ControlGroup cgGcubeProperties;
@UiField @UiField
TextArea txtAreaGcubeProperties; TextArea txtAreaGcubeProperties;
@ -111,6 +138,12 @@ public class DialogGetInfoBootstrap extends Composite {
@UiField @UiField
Button buttonUpdateGcubeProperties; Button buttonUpdateGcubeProperties;
@UiField
ControlGroup cgSharedWith;
@UiField
HTML txtSharedWith;
private FileModel fileModel; private FileModel fileModel;
@ -122,11 +155,31 @@ public class DialogGetInfoBootstrap extends Composite {
* hpGcubeProperties; private DialogEditProperties editProperties = null; * 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)); initWidget(uiBinder.createAndBindUi(this));
this.fileModel = fileModel; this.fileModel = fileModel;
hpHeaderDetails.add(new HTML("Details")); 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()); hpItemType.add(fileModel.getIcon());
Label labelItemType = new Label(); Label labelItemType = new Label();
@ -158,7 +211,7 @@ public class DialogGetInfoBootstrap extends Composite {
if (fileModel.isRoot()) if (fileModel.isRoot())
txtLocation.setHTML("/"); txtLocation.setHTML("/");
else else
loadLocation(fileModel.getIdentifier()); loadLocation(fileModel);
if (fileModel.isDirectory()) { if (fileModel.isDirectory()) {
cgTxtIsPublic.setVisible(true); cgTxtIsPublic.setVisible(true);
@ -201,9 +254,27 @@ public class DialogGetInfoBootstrap extends Composite {
htmlSetValue(txtShared, fileModel.isShared()+""); 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(); addHandlers();
} }
/**
* Adds the handlers.
*/
private void addHandlers() { private void addHandlers() {
txtAreaDescription.addKeyPressHandler(new KeyPressHandler() { 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) { private void htmlSetValue(HTML field, String value) {
if (value == null || value.isEmpty()) if (value == null || value.isEmpty())
@ -258,6 +335,12 @@ public class DialogGetInfoBootstrap extends Composite {
field.setHTML(value); field.setHTML(value);
} }
/**
* Gets the formatted size.
*
* @param value the value
* @return the formatted size
*/
private String getFormattedSize(long value) { private String getFormattedSize(long value) {
if (value > 0) { if (value > 0) {
@ -271,10 +354,15 @@ public class DialogGetInfoBootstrap extends Composite {
return ""; return "";
} }
private void loadLocation(String itemId) { /**
* Load location.
*
* @param fileModel the file model
*/
private void loadLocation(FileModel fileModel) {
setPlaceholder(txtLocation, "loading..."); setPlaceholder(txtLocation, "loading...");
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(itemId, false, AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(fileModel.getIdentifier(), false,
new AsyncCallback<List<FileModel>>() { new AsyncCallback<List<FileModel>>() {
@Override @Override
@ -305,6 +393,11 @@ public class DialogGetInfoBootstrap extends Composite {
} }
/**
* Load size.
*
* @param itemId the item id
*/
private void loadSize(final String itemId) { private void loadSize(final String itemId) {
GWT.log("Load size"); GWT.log("Load size");
setPlaceholder(txtSize, "loading..."); 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) { private void loadCreationDate(final String itemId) {
setPlaceholder(txtCreated, "loading..."); 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) { private void loadLastModificationDate(final String itemId) {
setPlaceholder(txtLastMofication, "loading..."); 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) { private void loadDescription(String identifier) {
txtAreaDescription.setEnabled(false); txtAreaDescription.setEnabled(false);
@ -404,6 +509,9 @@ public class DialogGetInfoBootstrap extends Composite {
} }
/**
* Load gcube item properties.
*/
private void loadGcubeItemProperties() { private void loadGcubeItemProperties() {
// mask("Loading properties..."); // mask("Loading properties...");
AppControllerExplorer.rpcWorkspaceService.loadGcubeItemProperties(fileModel.getIdentifier(), 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) { setPlaceholder(txtSharedWith, "loading...");
html.setHTML(placeholder);
html.getElement().getStyle().setColor("#E8E8E8"); WorkspaceSharingServiceAsync.INSTANCE.getACLsDescriptionForSharedFolderId(sharedId,
new AsyncCallback<String>() {
@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<GWTWorkspaceItem>() {
@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) { private void removePlaceHolder(HTML html) {
html.setHTML(""); html.setHTML("");
html.getElement().getStyle().setColor("#000"); html.getElement().removeClassName("placeholder-loading");
} }
} }

View File

@ -6,11 +6,6 @@
.no-border { .no-border {
border: 0px; border: 0px;
} }
.html-value-style {
padding-top: 5px;
font-family: Arial, Helvetica, sans-serif;
}
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<g:HorizontalPanel ui:field="hpHeaderDetails" <g:HorizontalPanel ui:field="hpHeaderDetails"
@ -19,6 +14,9 @@
<g:HorizontalPanel ui:field="hpItemType" <g:HorizontalPanel ui:field="hpItemType"
addStyleNames="item-type-style"> addStyleNames="item-type-style">
</g:HorizontalPanel> </g:HorizontalPanel>
<g:HorizontalPanel ui:field="hpImagePreview"
visible="false">
</g:HorizontalPanel>
<b:Form type="HORIZONTAL"> <b:Form type="HORIZONTAL">
<b:Alert ui:field="actionAlert" close="false" type="INFO" <b:Alert ui:field="actionAlert" close="false" type="INFO"
visible="false"> visible="false">
@ -145,6 +143,17 @@
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup
addStyleNames="my-control-group-get-info" ui:field="cgSharedWith"
visible="false">
<b:ControlLabel>Shared with</b:ControlLabel>
<b:Controls>
<g:HTML ui:field="txtSharedWith">
</g:HTML>
</b:Controls>
</b:ControlGroup>
<b:Alert close="false" ui:field="errorAlert" type="ERROR" <b:Alert close="false" ui:field="errorAlert" type="ERROR"
visible="false"></b:Alert> visible="false"></b:Alert>
</b:Fieldset> </b:Fieldset>

View File

@ -306,6 +306,7 @@ table.userssuggest th {
margin-bottom: 10px !important; margin-bottom: 10px !important;
font-size: 14px !important; font-size: 14px !important;
font-family: Arial, serif; font-family: Arial, serif;
color: #222;
} }
.my-control-group-get-info .controls { .my-control-group-get-info .controls {
@ -316,6 +317,7 @@ table.userssuggest th {
width: 80px !important; width: 80px !important;
text-align: center !important; text-align: center !important;
padding-right: 10px !important; padding-right: 10px !important;
font-family: Roboto, Arial, serif !important;
color: #959595; color: #959595;
} }
@ -359,9 +361,32 @@ table.userssuggest th {
vertical-align: middle !important; 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 { .item-details-header .gwt-HTML {
font-size: 20px; font-size: 20px;
font-family: Roboto, Arial, serif !important; font-family: Roboto, Arial, serif !important;
color: #777; color: #555;
margin: 15px; }
}
.placeholder-loading {
color: #E8E8E8;
}
.shared-with-style{
width: 90% !important;
font-size: 12px !important;
display: inline-block !important;
}