workspace-tree-widget/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java

695 lines
18 KiB
Java
Raw Normal View History

2020-07-08 18:14:06 +02:00
package org.gcube.portlets.user.workspace.client.view.windows;
2020-07-13 15:35:02 +02:00
import java.util.Date;
2020-07-08 18:14:06 +02:00
import java.util.List;
2020-07-10 18:14:15 +02:00
import java.util.Map;
2020-07-08 18:14:06 +02:00
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
2020-07-13 15:35:02 +02:00
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
2020-07-14 15:43:41 +02:00
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent;
2020-07-15 15:01:18 +02:00
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
2020-07-10 15:07:03 +02:00
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
2020-07-13 15:35:02 +02:00
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
2020-07-08 18:14:06 +02:00
import org.gcube.portlets.user.workspace.client.model.FileModel;
2020-07-13 18:04:53 +02:00
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;
2020-07-08 18:14:06 +02:00
2020-07-10 18:14:15 +02:00
import com.github.gwtbootstrap.client.ui.Button;
2020-07-08 18:14:06 +02:00
import com.github.gwtbootstrap.client.ui.ControlGroup;
2020-07-10 15:07:03 +02:00
import com.github.gwtbootstrap.client.ui.Label;
2020-07-08 18:14:06 +02:00
import com.github.gwtbootstrap.client.ui.TextArea;
2020-07-15 15:01:18 +02:00
import com.github.gwtbootstrap.client.ui.Tooltip;
2020-07-13 18:04:53 +02:00
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
2020-07-15 15:01:18 +02:00
import com.github.gwtbootstrap.client.ui.constants.IconSize;
2020-07-13 18:04:53 +02:00
import com.github.gwtbootstrap.client.ui.constants.IconType;
2020-07-10 15:07:03 +02:00
import com.github.gwtbootstrap.client.ui.constants.LabelType;
2020-07-13 15:35:02 +02:00
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
2020-07-15 15:01:18 +02:00
import com.github.gwtbootstrap.client.ui.resources.ButtonSize;
2020-07-08 18:14:06 +02:00
import com.google.gwt.core.client.GWT;
2020-07-13 18:04:53 +02:00
import com.google.gwt.dom.client.Style.Float;
2020-07-10 15:07:03 +02:00
import com.google.gwt.dom.client.Style.Unit;
2020-07-10 12:55:36 +02:00
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
2020-07-10 18:14:15 +02:00
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
2020-07-14 15:43:41 +02:00
import com.google.gwt.i18n.client.DateTimeFormat;
2020-07-13 15:35:02 +02:00
import com.google.gwt.i18n.client.NumberFormat;
2020-07-08 18:14:06 +02:00
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
2020-07-10 18:14:15 +02:00
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
2020-07-08 18:14:06 +02:00
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
2020-07-10 12:55:36 +02:00
import com.google.gwt.user.client.ui.HTML;
2020-07-14 15:43:41 +02:00
import com.google.gwt.user.client.ui.HTMLPanel;
2020-07-10 15:07:03 +02:00
import com.google.gwt.user.client.ui.HorizontalPanel;
2020-07-13 18:04:53 +02:00
import com.google.gwt.user.client.ui.Image;
2020-07-08 18:14:06 +02:00
import com.google.gwt.user.client.ui.Widget;
2020-07-13 18:04:53 +02:00
// TODO: Auto-generated Javadoc
/**
* The Class DialogGetInfoBootstrap.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* Jul 13, 2020
*/
2020-07-08 18:14:06 +02:00
public class DialogGetInfoBootstrap extends Composite {
private static DialogGetInfoBootstrapUiBinder uiBinder = GWT.create(DialogGetInfoBootstrapUiBinder.class);
2020-07-13 18:04:53 +02:00
/**
* The Interface DialogGetInfoBootstrapUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* Jul 13, 2020
*/
2020-07-08 18:14:06 +02:00
interface DialogGetInfoBootstrapUiBinder extends UiBinder<Widget, DialogGetInfoBootstrap> {
}
2020-07-13 15:35:02 +02:00
public static final String EMPTY = "empty";
private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
2020-07-08 18:14:06 +02:00
2020-07-13 18:04:53 +02:00
/**
* Instantiates a new dialog get info bootstrap.
*/
2020-07-08 18:14:06 +02:00
public DialogGetInfoBootstrap() {
initWidget(uiBinder.createAndBindUi(this));
}
2020-07-13 15:35:02 +02:00
public static final String NOT_AVAILABLE = "n.a.";
2020-07-10 18:14:15 +02:00
private Map<String, String> gCubeProperties;
2020-07-08 18:14:06 +02:00
2020-07-10 15:07:03 +02:00
@UiField
HorizontalPanel hpItemType;
2020-07-13 15:35:02 +02:00
@UiField
HorizontalPanel hpHeaderDetails;
2020-07-13 18:04:53 +02:00
2020-07-15 15:01:18 +02:00
@UiField
Button buttonClose;
2020-07-13 18:04:53 +02:00
@UiField
2020-07-14 15:43:41 +02:00
HTMLPanel htmlPanelImagePreview;
2020-07-15 15:01:18 +02:00
2020-07-08 18:14:06 +02:00
@UiField
2020-07-10 12:55:36 +02:00
HTML txtName;
2020-07-08 18:14:06 +02:00
@UiField
2020-07-10 12:55:36 +02:00
HTML txtId;
2020-07-08 18:14:06 +02:00
@UiField
2020-07-10 12:55:36 +02:00
HTML txtLocation;
2020-07-08 18:14:06 +02:00
@UiField
ControlGroup cgTxtIsPublic;
@UiField
2020-07-10 12:55:36 +02:00
HTML txtIsPublic;
2020-07-08 18:14:06 +02:00
2020-07-13 15:35:02 +02:00
@UiField
HTML txtMimeType;
2020-07-10 18:14:15 +02:00
@UiField
ControlGroup cgThreddsSynched;
@UiField
HTML txtThreddsSynched;
@UiField
ControlGroup cgGcubeProperties;
2020-07-13 18:04:53 +02:00
2020-07-10 18:14:15 +02:00
@UiField
TextArea txtAreaGcubeProperties;
2020-07-08 18:14:06 +02:00
@UiField
TextArea txtAreaDescription;
2020-07-13 15:35:02 +02:00
@UiField
HTML txtOwner;
@UiField
HTML txtCreated;
@UiField
HTML txtLastMofication;
@UiField
HTML txtSize;
@UiField
HTML txtShared;
2020-07-10 18:14:15 +02:00
@UiField
Button buttonUpdateDescription;
2020-07-15 15:01:18 +02:00
@UiField
Button buttonSaveDescription;
2020-07-13 15:35:02 +02:00
2020-07-10 18:14:15 +02:00
@UiField
Button buttonUpdateGcubeProperties;
2020-07-13 18:04:53 +02:00
2020-07-14 15:43:41 +02:00
@UiField
Button buttonUpdateShare;
2020-07-13 18:04:53 +02:00
@UiField
ControlGroup cgSharedWith;
@UiField
HTML txtSharedWith;
2020-07-10 18:14:15 +02:00
private FileModel fileModel;
2020-07-14 15:43:41 +02:00
private Command onCloseCommand;
2020-07-15 15:01:18 +02:00
private Tooltip tooltipDownload = new Tooltip("Download");
2020-07-14 15:43:41 +02:00
2020-07-15 15:01:18 +02:00
private Button buttonDownload = new Button("Download");
2020-07-13 15:35:02 +02:00
2020-07-15 15:01:18 +02:00
// private Tooltip tooltipSharebleLink = new Tooltip("Get Shareable Link");
// private Button buttonShareableLink = new Button();
private DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd MMM yyyy, hh:mm aaa");
2020-07-08 18:14:06 +02:00
2020-07-13 18:04:53 +02:00
/**
* 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) {
2020-07-08 18:14:06 +02:00
initWidget(uiBinder.createAndBindUi(this));
2020-07-10 18:14:15 +02:00
this.fileModel = fileModel;
2020-07-14 15:43:41 +02:00
this.onCloseCommand = onCloseCommand;
2020-07-13 15:35:02 +02:00
2020-07-13 18:04:53 +02:00
buttonClose.getElement().getStyle().setFloat(Float.RIGHT);
2020-07-10 18:14:15 +02:00
2020-07-10 15:07:03 +02:00
hpItemType.add(fileModel.getIcon());
Label labelItemType = new Label();
2020-07-15 15:01:18 +02:00
labelItemType.setType(LabelType.DEFAULT);
//labelItemType.getElement().getStyle().setMarginLeft(10, Unit.PX);
2020-07-10 15:07:03 +02:00
String label = null;
2020-07-10 18:14:15 +02:00
2020-07-10 15:07:03 +02:00
GXTFolderItemTypeEnum typeEnum = fileModel.getGXTFolderItemType();
2020-07-15 15:01:18 +02:00
//if the item is categorized
2020-07-10 18:14:15 +02:00
if (typeEnum != null) {
2020-07-10 15:07:03 +02:00
label = typeEnum.getLabel();
label = label.replace("External ", "");
2020-07-13 15:35:02 +02:00
// loading gcube properties
if (typeEnum.equals(GXTFolderItemTypeEnum.GCUBE_ITEM))
2020-07-10 18:14:15 +02:00
loadGcubeItemProperties();
} else {
2020-07-15 15:01:18 +02:00
//using the type (i.e. mimetype)
2020-07-10 15:07:03 +02:00
label = fileModel.getType();
}
2020-07-10 18:14:15 +02:00
2020-07-10 15:07:03 +02:00
labelItemType.setText(label);
hpItemType.add(labelItemType);
2020-07-15 15:01:18 +02:00
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);
2020-07-08 18:14:06 +02:00
// Setting name
2020-07-10 12:55:36 +02:00
htmlSetValue(txtName, fileModel.getName());
htmlSetValue(txtId, fileModel.getIdentifier());
2020-07-08 18:14:06 +02:00
if (fileModel.isRoot())
2020-07-10 12:55:36 +02:00
txtLocation.setHTML("/");
2020-07-08 18:14:06 +02:00
else
2020-07-13 18:04:53 +02:00
loadLocation(fileModel);
2020-07-08 18:14:06 +02:00
if (fileModel.isDirectory()) {
cgTxtIsPublic.setVisible(true);
2020-07-10 18:14:15 +02:00
htmlSetValue(txtIsPublic, fileModel.isPublic() + "");
if (fileModel.getSynchedThreddsStatus() != null) {
txtThreddsSynched.setVisible(true);
htmlSetValue(txtThreddsSynched, fileModel.getSynchedThreddsStatus() + "");
txtThreddsSynched.setHTML(fileModel.getSynchedThreddsStatus() + "");
}
2020-07-08 18:14:06 +02:00
}
2020-07-13 15:35:02 +02:00
//mimetype
htmlSetValue(txtMimeType, fileModel.getType());
2020-07-08 18:14:06 +02:00
2020-07-13 15:35:02 +02:00
txtAreaDescription.setResize(ResizeType.VERTICAL);
2020-07-08 18:14:06 +02:00
if (fileModel.isDirectory()) {
txtAreaDescription.setValue(fileModel.getDescription());
// add(txtAreaDescription);
} else
loadDescription(fileModel.getIdentifier());
2020-07-10 18:14:15 +02:00
2020-07-13 15:35:02 +02:00
//owner
htmlSetValue(txtOwner, fileModel.getOwnerFullName());
//creation date
loadCreationDate(fileModel.getIdentifier());
if(fileModel instanceof FileGridModel) {
FileGridModel fileGridModel = ((FileGridModel) fileModel);
//last update
2020-07-14 15:43:41 +02:00
htmlSetValue(txtLastMofication, dateFormatter.format(fileGridModel.getLastModification()));
2020-07-13 15:35:02 +02:00
//size
htmlSetValue(txtSize, getFormattedSize(fileGridModel.getSize()));
}else {
loadLastModificationDate(fileModel.getIdentifier());
loadSize(fileModel.getIdentifier());
}
htmlSetValue(txtShared, fileModel.isShared()+"");
2020-07-13 18:04:53 +02:00
// 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();
}
2020-07-10 12:55:36 +02:00
addHandlers();
}
2020-07-10 18:14:15 +02:00
2020-07-13 18:04:53 +02:00
/**
* Adds the handlers.
*/
2020-07-10 12:55:36 +02:00
private void addHandlers() {
2020-07-15 15:01:18 +02:00
buttonClose.addClickHandler(new ClickHandler() {
2020-07-10 18:14:15 +02:00
@Override
2020-07-15 15:01:18 +02:00
public void onClick(ClickEvent event) {
onCloseCommand.execute();
2020-07-10 18:14:15 +02:00
}
});
2020-07-13 15:35:02 +02:00
2020-07-15 15:01:18 +02:00
// 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");
// }
//
// }
// });
2020-07-10 18:14:15 +02:00
buttonUpdateDescription.addClickHandler(new ClickHandler() {
2020-07-13 15:35:02 +02:00
2020-07-10 12:55:36 +02:00
@Override
public void onClick(ClickEvent event) {
2020-07-10 18:14:15 +02:00
txtAreaDescription.setReadOnly(false);
txtAreaDescription.setFocus(true);
2020-07-15 15:01:18 +02:00
buttonSaveDescription.setVisible(true);
}
});
buttonSaveDescription.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
buttonSaveDescription.setVisible(false);
txtAreaDescription.setReadOnly(true);
Window.alert("To be implemented");
2020-07-10 18:14:15 +02:00
}
});
2020-07-13 15:35:02 +02:00
2020-07-10 18:14:15 +02:00
final Command cmdReloadProperties = new Command() {
@Override
public void execute() {
loadGcubeItemProperties();
}
};
2020-07-13 15:35:02 +02:00
2020-07-10 18:14:15 +02:00
buttonUpdateGcubeProperties.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
2020-07-13 15:35:02 +02:00
final DialogEditProperties editProperties = new DialogEditProperties(fileModel, cmdReloadProperties);
2020-07-10 18:14:15 +02:00
editProperties.show();
2020-07-13 15:35:02 +02:00
editProperties.setProperties(gCubeProperties);
2020-07-10 12:55:36 +02:00
}
});
2020-07-14 15:43:41 +02:00
buttonUpdateShare.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
AppControllerExplorer.getEventBus().fireEvent(new CreateSharedFolderEvent(fileModel, fileModel.getParentFileModel(),false));
onCloseCommand.execute();
}
});
2020-07-15 15:01:18 +02:00
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));
}
});
2020-07-08 18:14:06 +02:00
}
2020-07-13 18:04:53 +02:00
/**
* Html set value.
*
* @param field the field
* @param value the value
*/
2020-07-10 12:55:36 +02:00
private void htmlSetValue(HTML field, String value) {
2020-07-08 18:14:06 +02:00
if (value == null || value.isEmpty())
2020-07-13 15:35:02 +02:00
field.setHTML(NOT_AVAILABLE);
2020-07-08 18:14:06 +02:00
else
2020-07-10 12:55:36 +02:00
field.setHTML(value);
2020-07-08 18:14:06 +02:00
}
2020-07-13 15:35:02 +02:00
2020-07-13 18:04:53 +02:00
/**
* Gets the formatted size.
*
* @param value the value
* @return the formatted size
*/
2020-07-13 15:35:02 +02:00
private String getFormattedSize(long value) {
if (value > 0) {
double kb = value / 1024;
if (kb < 1)
kb = 1;
return number.format(kb);
} else if (value == 0) {
return EMPTY;
} else
return "";
}
2020-07-08 18:14:06 +02:00
2020-07-13 18:04:53 +02:00
/**
* Load location.
*
* @param fileModel the file model
*/
private void loadLocation(FileModel fileModel) {
2020-07-10 12:55:36 +02:00
setPlaceholder(txtLocation, "loading...");
2020-07-13 18:04:53 +02:00
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(fileModel.getIdentifier(), false,
2020-07-08 18:14:06 +02:00
new AsyncCallback<List<FileModel>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("failure get list parents by item identifier " + caught);
2020-07-10 12:55:36 +02:00
removePlaceHolder(txtLocation);
2020-07-13 15:35:02 +02:00
txtLocation.setHTML(NOT_AVAILABLE);
2020-07-10 18:14:15 +02:00
// txtLocation.set(false);
2020-07-08 18:14:06 +02:00
}
@Override
public void onSuccess(List<FileModel> result) {
2020-07-10 12:55:36 +02:00
removePlaceHolder(txtLocation);
2020-07-10 18:14:15 +02:00
2020-07-08 18:14:06 +02:00
String location = "";
if (result != null) {
for (FileModel fileModel : result) {
if (fileModel != null)
location += "/" + fileModel.getName();
}
}
if (location.isEmpty())
location = "/";
2020-07-10 12:55:36 +02:00
txtLocation.setHTML(location);
2020-07-08 18:14:06 +02:00
}
});
}
2020-07-13 15:35:02 +02:00
2020-07-13 18:04:53 +02:00
/**
* Load size.
*
* @param itemId the item id
*/
2020-07-13 15:35:02 +02:00
private void loadSize(final String itemId) {
GWT.log("Load size");
setPlaceholder(txtSize, "loading...");
AppControllerExplorer.rpcWorkspaceService.loadSizeByItemId(itemId, new AsyncCallback<Long>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("an error occured in load creation date by Id " + itemId + " " + caught.getMessage());
removePlaceHolder(txtSize);
}
@Override
public void onSuccess(Long result) {
GWT.log("Loaded size=" + result);
removePlaceHolder(txtSize);
if(result!=null)
htmlSetValue(txtSize, getFormattedSize(result));
else
htmlSetValue(txtSize, null);
}
});
}
2020-07-13 18:04:53 +02:00
/**
* Load creation date.
*
* @param itemId the item id
*/
2020-07-13 15:35:02 +02:00
private void loadCreationDate(final String itemId) {
setPlaceholder(txtCreated, "loading...");
AppControllerExplorer.rpcWorkspaceService.getItemCreationDateById(itemId, new AsyncCallback<Date>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("an error occured in load creation date by Id " + itemId + " " + caught.getMessage());
removePlaceHolder(txtCreated);
}
@Override
2020-07-14 15:43:41 +02:00
public void onSuccess(Date dateResult) {
2020-07-13 15:35:02 +02:00
removePlaceHolder(txtCreated);
2020-07-14 15:43:41 +02:00
if (dateResult != null) {
htmlSetValue(txtCreated, dateFormatter.format(dateResult));
}else
2020-07-13 15:35:02 +02:00
htmlSetValue(txtCreated, null);
}
});
}
2020-07-13 18:04:53 +02:00
/**
* Load last modification date.
*
* @param itemId the item id
*/
2020-07-13 15:35:02 +02:00
private void loadLastModificationDate(final String itemId) {
setPlaceholder(txtLastMofication, "loading...");
AppControllerExplorer.rpcWorkspaceService.loadLastModificationDateById(itemId, new AsyncCallback<Date>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("an error occured in loadLastModificationDateById " + itemId + " " + caught.getMessage());
removePlaceHolder(txtLastMofication);
}
@Override
2020-07-14 15:43:41 +02:00
public void onSuccess(Date dateResult) {
2020-07-13 15:35:02 +02:00
removePlaceHolder(txtLastMofication);
2020-07-14 15:43:41 +02:00
if (dateResult != null) {
htmlSetValue(txtLastMofication, dateFormatter.format(dateResult));
}else
2020-07-13 15:35:02 +02:00
htmlSetValue(txtLastMofication, null);
}
});
}
2020-07-10 18:14:15 +02:00
2020-07-08 18:14:06 +02:00
/**
2020-07-13 18:04:53 +02:00
* Load description.
*
* @param identifier the identifier
2020-07-08 18:14:06 +02:00
*/
private void loadDescription(String identifier) {
txtAreaDescription.setEnabled(false);
AppControllerExplorer.rpcWorkspaceService.getItemDescriptionById(identifier, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable arg0) {
txtAreaDescription.setEnabled(false);
}
@Override
public void onSuccess(String result) {
if (result != null)
txtAreaDescription.setValue(result);
else
txtAreaDescription.setValue("");
txtAreaDescription.setEnabled(true);
}
});
}
2020-07-10 18:14:15 +02:00
2020-07-13 18:04:53 +02:00
/**
* Load gcube item properties.
*/
2020-07-10 18:14:15 +02:00
private void loadGcubeItemProperties() {
// mask("Loading properties...");
AppControllerExplorer.rpcWorkspaceService.loadGcubeItemProperties(fileModel.getIdentifier(),
new AsyncCallback<Map<String, String>>() {
@Override
public void onSuccess(Map<String, String> result) {
txtAreaGcubeProperties.setText("");
2020-07-13 15:35:02 +02:00
GWT.log("Gcube Item Properties: " + result);
2020-07-10 18:14:15 +02:00
gCubeProperties = result;
// unmask();
2020-07-13 15:35:02 +02:00
if (result != null && result.size() > 0) {
2020-07-10 18:14:15 +02:00
for (String key : result.keySet()) {
String text = txtAreaGcubeProperties.getText();
2020-07-13 15:35:02 +02:00
text += key + "=" + result.get(key) + ";\n";
2020-07-10 18:14:15 +02:00
txtAreaGcubeProperties.setText(text);
}
cgGcubeProperties.setVisible(true);
}
}
@Override
public void onFailure(Throwable caught) {
// unmask();
cgGcubeProperties.setVisible(false);
2020-07-13 15:35:02 +02:00
GWT.log("an error occured in loadGcubeItemProperties " + fileModel.getIdentifier() + " "
+ caught.getMessage());
2020-07-10 18:14:15 +02:00
}
});
}
2020-07-13 18:04:53 +02:00
/**
* 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() {
2020-07-14 15:43:41 +02:00
htmlPanelImagePreview.setVisible(true);
2020-07-13 18:04:53 +02:00
final HTML txtLoadingPreview = new HTML();
2020-07-14 15:43:41 +02:00
htmlPanelImagePreview.add(txtLoadingPreview);
2020-07-13 18:04:53 +02:00
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) {
GWT.log("Image loaded: " + item.getName() + " label: " + item.getLabel() + " type: "
+ fileModel.getGXTFolderItemType());
if (fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT)) {
GWTImageDocument theItemImage = (GWTImageDocument) item;
2020-07-14 15:43:41 +02:00
htmlPanelImagePreview.add(new Image(theItemImage.getThumbnailUrl()));
htmlPanelImagePreview.setVisible(true);
2020-07-13 18:04:53 +02:00
}else {
GWTExternalImage theExternalImage = (GWTExternalImage) item;
2020-07-14 15:43:41 +02:00
htmlPanelImagePreview.add(new Image(theExternalImage.getThumbnailUrl()));
htmlPanelImagePreview.setVisible(true);
2020-07-13 18:04:53 +02:00
}
2020-07-14 15:43:41 +02:00
removePlaceHolder(txtLoadingPreview);
2020-07-13 18:04:53 +02:00
}
});
}
2020-07-10 18:14:15 +02:00
2020-07-13 18:04:53 +02:00
/**
* Sets the placeholder.
*
* @param html the html
* @param placeholder the placeholder
*/
2020-07-10 12:55:36 +02:00
private void setPlaceholder(HTML html, String placeholder) {
html.setHTML(placeholder);
2020-07-13 18:04:53 +02:00
html.getElement().addClassName("placeholder-loading");
2020-07-10 12:55:36 +02:00
}
2020-07-10 18:14:15 +02:00
2020-07-13 18:04:53 +02:00
/**
* Removes the place holder.
*
* @param html the html
*/
2020-07-10 12:55:36 +02:00
private void removePlaceHolder(HTML html) {
html.setHTML("");
2020-07-13 18:04:53 +02:00
html.getElement().removeClassName("placeholder-loading");
2020-07-10 12:55:36 +02:00
}
2020-07-08 18:14:06 +02:00
}