|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
package org.gcube.portlets.user.workspace.client.view.windows;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
|
|
|
|
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 com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
@ -12,12 +15,14 @@ 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.LabelType;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
|
|
import com.google.gwt.event.dom.client.KeyPressEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
|
|
|
|
import com.google.gwt.i18n.client.NumberFormat;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
|
import com.google.gwt.user.client.Command;
|
|
|
|
@ -34,17 +39,24 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
|
|
|
|
|
interface DialogGetInfoBootstrapUiBinder extends UiBinder<Widget, DialogGetInfoBootstrap> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static final String EMPTY = "empty";
|
|
|
|
|
|
|
|
|
|
private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
|
|
|
|
|
|
|
|
|
|
public DialogGetInfoBootstrap() {
|
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static final String UNKNOWN = "unknown";
|
|
|
|
|
|
|
|
|
|
public static final String NOT_AVAILABLE = "n.a.";
|
|
|
|
|
|
|
|
|
|
private Map<String, String> gCubeProperties;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HorizontalPanel hpItemType;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HorizontalPanel hpHeaderDetails;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtName;
|
|
|
|
@ -61,6 +73,9 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtIsPublic;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtMimeType;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ControlGroup cgThreddsSynched;
|
|
|
|
|
|
|
|
|
@ -75,26 +90,31 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
TextArea txtAreaDescription;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtOwner;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtCreated;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtLastMofication;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtSize;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTML txtShared;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
Button buttonUpdateDescription;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
Button buttonUpdateGcubeProperties;
|
|
|
|
|
|
|
|
|
|
private FileModel fileModel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* TextField<String> txtType = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtCategory = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtOwner = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtLastMofication = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtCreated = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtSize = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtLocation = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtIsPublic = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtThreddsSynched = new TextField<String>(); private
|
|
|
|
|
* TextField<String> txtShared = new TextField<String>(); // private TextArea
|
|
|
|
|
* textAreaSharedWith = new TextArea(); private Html htmlUsersWidget = new
|
|
|
|
|
* Html(); private Html htmlPropertiesWidget = new Html(); private final
|
|
|
|
|
* NumberFormat number = ConstantsExplorer.numberFormatterKB; // private
|
|
|
|
@ -105,6 +125,8 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
public DialogGetInfoBootstrap(final FileModel fileModel) {
|
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
|
this.fileModel = fileModel;
|
|
|
|
|
|
|
|
|
|
hpHeaderDetails.add(new HTML("Details"));
|
|
|
|
|
|
|
|
|
|
hpItemType.add(fileModel.getIcon());
|
|
|
|
|
Label labelItemType = new Label();
|
|
|
|
@ -116,9 +138,9 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
if (typeEnum != null) {
|
|
|
|
|
label = typeEnum.getLabel();
|
|
|
|
|
label = label.replace("External ", "");
|
|
|
|
|
|
|
|
|
|
//loading gcube properties
|
|
|
|
|
if(typeEnum.equals(GXTFolderItemTypeEnum.GCUBE_ITEM))
|
|
|
|
|
|
|
|
|
|
// loading gcube properties
|
|
|
|
|
if (typeEnum.equals(GXTFolderItemTypeEnum.GCUBE_ITEM))
|
|
|
|
|
loadGcubeItemProperties();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
@ -146,46 +168,68 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
txtThreddsSynched.setVisible(true);
|
|
|
|
|
htmlSetValue(txtThreddsSynched, fileModel.getSynchedThreddsStatus() + "");
|
|
|
|
|
txtThreddsSynched.setHTML(fileModel.getSynchedThreddsStatus() + "");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//mimetype
|
|
|
|
|
htmlSetValue(txtMimeType, fileModel.getType());
|
|
|
|
|
|
|
|
|
|
txtAreaDescription.setResize(ResizeType.VERTICAL);
|
|
|
|
|
|
|
|
|
|
if (fileModel.isDirectory()) {
|
|
|
|
|
txtAreaDescription.setValue(fileModel.getDescription());
|
|
|
|
|
// add(txtAreaDescription);
|
|
|
|
|
} else
|
|
|
|
|
loadDescription(fileModel.getIdentifier());
|
|
|
|
|
|
|
|
|
|
//owner
|
|
|
|
|
htmlSetValue(txtOwner, fileModel.getOwnerFullName());
|
|
|
|
|
//creation date
|
|
|
|
|
loadCreationDate(fileModel.getIdentifier());
|
|
|
|
|
|
|
|
|
|
if(fileModel instanceof FileGridModel) {
|
|
|
|
|
FileGridModel fileGridModel = ((FileGridModel) fileModel);
|
|
|
|
|
//last update
|
|
|
|
|
htmlSetValue(txtLastMofication, fileGridModel.getLastModification().toString());
|
|
|
|
|
//size
|
|
|
|
|
htmlSetValue(txtSize, getFormattedSize(fileGridModel.getSize()));
|
|
|
|
|
}else {
|
|
|
|
|
loadLastModificationDate(fileModel.getIdentifier());
|
|
|
|
|
loadSize(fileModel.getIdentifier());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
htmlSetValue(txtShared, fileModel.isShared()+"");
|
|
|
|
|
|
|
|
|
|
addHandlers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addHandlers() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
txtAreaDescription.addKeyPressHandler(new KeyPressHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onKeyPress(KeyPressEvent event) {
|
|
|
|
|
|
|
|
|
|
GWT.log(event.getUnicodeCharCode()+"");
|
|
|
|
|
|
|
|
|
|
if(event.getUnicodeCharCode()==13) {
|
|
|
|
|
|
|
|
|
|
GWT.log(event.getUnicodeCharCode() + "");
|
|
|
|
|
|
|
|
|
|
if (event.getUnicodeCharCode() == 13) {
|
|
|
|
|
txtAreaDescription.setReadOnly(true);
|
|
|
|
|
Window.alert("Updating description");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttonUpdateDescription.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
txtAreaDescription.setReadOnly(false);
|
|
|
|
|
txtAreaDescription.setFocus(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Command cmdReloadProperties = new Command() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -193,17 +237,15 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
loadGcubeItemProperties();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttonUpdateGcubeProperties.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
|
|
|
|
|
DialogEditProperties editProperties = new DialogEditProperties(fileModel, cmdReloadProperties);
|
|
|
|
|
editProperties.setProperties(gCubeProperties);
|
|
|
|
|
editProperties.setZIndex(99999);
|
|
|
|
|
final DialogEditProperties editProperties = new DialogEditProperties(fileModel, cmdReloadProperties);
|
|
|
|
|
editProperties.show();
|
|
|
|
|
|
|
|
|
|
editProperties.setProperties(gCubeProperties);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -211,10 +253,23 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
private void htmlSetValue(HTML field, String value) {
|
|
|
|
|
|
|
|
|
|
if (value == null || value.isEmpty())
|
|
|
|
|
field.setHTML(UNKNOWN);
|
|
|
|
|
field.setHTML(NOT_AVAILABLE);
|
|
|
|
|
else
|
|
|
|
|
field.setHTML(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadLocation(String itemId) {
|
|
|
|
|
|
|
|
|
@ -226,7 +281,7 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
GWT.log("failure get list parents by item identifier " + caught);
|
|
|
|
|
removePlaceHolder(txtLocation);
|
|
|
|
|
txtLocation.setHTML(UNKNOWN);
|
|
|
|
|
txtLocation.setHTML(NOT_AVAILABLE);
|
|
|
|
|
// txtLocation.set(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -249,6 +304,77 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
public void onSuccess(Date result) {
|
|
|
|
|
removePlaceHolder(txtCreated);
|
|
|
|
|
if (result != null)
|
|
|
|
|
htmlSetValue(txtCreated, result.toString());
|
|
|
|
|
else
|
|
|
|
|
htmlSetValue(txtCreated, null);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
public void onSuccess(Date result) {
|
|
|
|
|
removePlaceHolder(txtLastMofication);
|
|
|
|
|
if (result != null)
|
|
|
|
|
htmlSetValue(txtLastMofication, result.toString());
|
|
|
|
|
else
|
|
|
|
|
htmlSetValue(txtLastMofication, null);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param identifier
|
|
|
|
@ -286,13 +412,13 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Map<String, String> result) {
|
|
|
|
|
txtAreaGcubeProperties.setText("");
|
|
|
|
|
GWT.log("Gcube Item Properties: "+result);
|
|
|
|
|
GWT.log("Gcube Item Properties: " + result);
|
|
|
|
|
gCubeProperties = result;
|
|
|
|
|
// unmask();
|
|
|
|
|
if(result!=null && result.size()>0) {
|
|
|
|
|
if (result != null && result.size() > 0) {
|
|
|
|
|
for (String key : result.keySet()) {
|
|
|
|
|
String text = txtAreaGcubeProperties.getText();
|
|
|
|
|
text+=key+"="+result.get(key)+";\n";
|
|
|
|
|
text += key + "=" + result.get(key) + ";\n";
|
|
|
|
|
txtAreaGcubeProperties.setText(text);
|
|
|
|
|
}
|
|
|
|
|
cgGcubeProperties.setVisible(true);
|
|
|
|
@ -303,11 +429,11 @@ public class DialogGetInfoBootstrap extends Composite {
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
// unmask();
|
|
|
|
|
cgGcubeProperties.setVisible(false);
|
|
|
|
|
GWT.log("an error occured in loadGcubeItemProperties " + fileModel.getIdentifier() + " " + caught.getMessage());
|
|
|
|
|
GWT.log("an error occured in loadGcubeItemProperties " + fileModel.getIdentifier() + " "
|
|
|
|
|
+ caught.getMessage());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setPlaceholder(HTML html, String placeholder) {
|
|
|
|
|
html.setHTML(placeholder);
|
|
|
|
|