|
|
|
@ -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));
|
|
|
|
|
}
|
|
|
|
@ -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<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(),
|
|
|
|
@ -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) {
|
|
|
|
|
|
|
|
|
|
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().getStyle().setColor("#E8E8E8");
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|