working on show preview for image
This commit is contained in:
parent
b9370463b0
commit
239810f194
|
@ -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<Widget, DialogGetInfoBootstrap> {
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -58,6 +82,9 @@ public class DialogGetInfoBootstrap extends Composite {
|
|||
@UiField
|
||||
HorizontalPanel hpHeaderDetails;
|
||||
|
||||
@UiField
|
||||
HorizontalPanel hpImagePreview;
|
||||
|
||||
@UiField
|
||||
HTML txtName;
|
||||
|
||||
|
@ -112,6 +139,12 @@ public class DialogGetInfoBootstrap extends Composite {
|
|||
@UiField
|
||||
Button buttonUpdateGcubeProperties;
|
||||
|
||||
@UiField
|
||||
ControlGroup cgSharedWith;
|
||||
|
||||
@UiField
|
||||
HTML txtSharedWith;
|
||||
|
||||
private FileModel fileModel;
|
||||
|
||||
/*
|
||||
|
@ -122,12 +155,32 @@ 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();
|
||||
labelItemType.setType(LabelType.INFO);
|
||||
|
@ -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<List<FileModel>>() {
|
||||
|
||||
@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(),
|
||||
|
@ -435,14 +543,95 @@ public class DialogGetInfoBootstrap extends Composite {
|
|||
});
|
||||
}
|
||||
|
||||
private void setPlaceholder(HTML html, String placeholder) {
|
||||
html.setHTML(placeholder);
|
||||
html.getElement().getStyle().setColor("#E8E8E8");
|
||||
/**
|
||||
* Load AC ls description for shared folder.
|
||||
*
|
||||
* @param sharedId the shared id
|
||||
*/
|
||||
private void loadACLsDescriptionForSharedFolder(String sharedId) {
|
||||
|
||||
setPlaceholder(txtSharedWith, "loading...");
|
||||
|
||||
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) {
|
||||
html.setHTML("");
|
||||
html.getElement().getStyle().setColor("#000");
|
||||
html.getElement().removeClassName("placeholder-loading");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,6 @@
|
|||
.no-border {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
.html-value-style {
|
||||
padding-top: 5px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<g:HorizontalPanel ui:field="hpHeaderDetails"
|
||||
|
@ -19,6 +14,9 @@
|
|||
<g:HorizontalPanel ui:field="hpItemType"
|
||||
addStyleNames="item-type-style">
|
||||
</g:HorizontalPanel>
|
||||
<g:HorizontalPanel ui:field="hpImagePreview"
|
||||
visible="false">
|
||||
</g:HorizontalPanel>
|
||||
<b:Form type="HORIZONTAL">
|
||||
<b:Alert ui:field="actionAlert" close="false" type="INFO"
|
||||
visible="false">
|
||||
|
@ -145,6 +143,17 @@
|
|||
</b:Controls>
|
||||
</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"
|
||||
visible="false"></b:Alert>
|
||||
</b:Fieldset>
|
||||
|
|
|
@ -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;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.placeholder-loading {
|
||||
color: #E8E8E8;
|
||||
}
|
||||
|
||||
.shared-with-style{
|
||||
width: 90% !important;
|
||||
font-size: 12px !important;
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue