|
|
|
@ -11,7 +11,10 @@ import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScav
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.MultipleDilaogUpload;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
|
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
|
|
|
@ -20,15 +23,18 @@ import com.github.gwtbootstrap.client.ui.Label;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.LabelType;
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
|
import com.google.gwt.user.client.Window;
|
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
|
|
|
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
@ -42,7 +48,7 @@ import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
*/
|
|
|
|
|
public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private static final String _700PX = "700px";
|
|
|
|
|
private static final String _FORM_FIELDS_SIZE = "740px";
|
|
|
|
|
|
|
|
|
|
private static final String UPLOAD_MISSING_FILE = "You must upload a file";
|
|
|
|
|
|
|
|
|
@ -75,7 +81,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private List<String> listFileSetPaths;
|
|
|
|
|
|
|
|
|
|
private boolean placeholderRemoved = false;
|
|
|
|
|
private boolean listBoxPathsPlaceholder = true;
|
|
|
|
|
|
|
|
|
|
private String recordId;
|
|
|
|
|
|
|
|
|
@ -85,9 +91,13 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private RECORD_TYPE recordType;
|
|
|
|
|
|
|
|
|
|
private MultipleDilaogUpload mDU;
|
|
|
|
|
// private MultipleDilaogUpload mDU;
|
|
|
|
|
|
|
|
|
|
private ChangeHandler listBoxIndexHandler;
|
|
|
|
|
private boolean listBoxIndexPlaceholder = true;
|
|
|
|
|
|
|
|
|
|
private HandlerManager uiBus = new HandlerManager(null);
|
|
|
|
|
|
|
|
|
|
private MetaDataField fieldUploadWidget;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new update fileset.
|
|
|
|
@ -103,7 +113,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
for (String path : listFileSetPaths) {
|
|
|
|
|
listBoxPaths.addItem(path);
|
|
|
|
|
}
|
|
|
|
|
listBoxPaths.setWidth(_700PX);
|
|
|
|
|
listBoxPaths.setWidth(_FORM_FIELDS_SIZE);
|
|
|
|
|
|
|
|
|
|
// add handler on select
|
|
|
|
|
listBoxPaths.addChangeHandler(new ChangeHandler() {
|
|
|
|
@ -113,9 +123,9 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
GWT.log("Profile type selection changed...");
|
|
|
|
|
cgSelectFile.setVisible(false);
|
|
|
|
|
|
|
|
|
|
if (!placeholderRemoved) {
|
|
|
|
|
listBoxPaths.removeItem(0); // this is the placeholder
|
|
|
|
|
placeholderRemoved = true;
|
|
|
|
|
if (listBoxPathsPlaceholder) {
|
|
|
|
|
listBoxPaths.removeItem(0); // this is the placeholder, removing it once
|
|
|
|
|
listBoxPathsPlaceholder = false;
|
|
|
|
|
}
|
|
|
|
|
showUploadFileGUI();
|
|
|
|
|
}
|
|
|
|
@ -141,12 +151,10 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
|
|
|
|
|
if (mDU != null) {
|
|
|
|
|
if (checkValidUpload()) {
|
|
|
|
|
Window.alert("I can save...");
|
|
|
|
|
} else {
|
|
|
|
|
Window.alert("New file not found. " + UPLOAD_MISSING_FILE);
|
|
|
|
|
}
|
|
|
|
|
if (checkValidUpload() == null) {
|
|
|
|
|
Window.alert("I can save...");
|
|
|
|
|
} else {
|
|
|
|
|
Window.alert("New file not found. " + UPLOAD_MISSING_FILE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -162,12 +170,14 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
buttonUpdate.setVisible(false);
|
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
|
controlsContent.clear();
|
|
|
|
|
listBoxIndexPlaceholder = true;
|
|
|
|
|
fieldUploadWidget = null;
|
|
|
|
|
|
|
|
|
|
// listBoxIndex.clear();
|
|
|
|
|
cgSelectFile.setVisible(true);
|
|
|
|
|
|
|
|
|
|
ListBox listBoxIndex = new ListBox();
|
|
|
|
|
listBoxIndex.setWidth(_700PX);
|
|
|
|
|
listBoxIndex.setWidth(_FORM_FIELDS_SIZE);
|
|
|
|
|
listBoxIndex.addItem("Select a content...");
|
|
|
|
|
|
|
|
|
|
if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) {
|
|
|
|
@ -230,24 +240,11 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
controlsContent.add(listBoxIndex);
|
|
|
|
|
|
|
|
|
|
// if (listBoxIndex.getItemCount() > 1) {
|
|
|
|
|
// listBoxIndex.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onChange(ChangeEvent event) {
|
|
|
|
|
// showFileBrowseInteraction();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title,
|
|
|
|
|
List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
|
|
|
|
|
// ListBox listBoxIndex = new ListBox();
|
|
|
|
|
// listBoxIndex.addItem("Select a content...");
|
|
|
|
|
|
|
|
|
|
if (listWSC == null || listWSC.isEmpty()) {
|
|
|
|
|
showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING);
|
|
|
|
|
return;
|
|
|
|
@ -257,42 +254,92 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
// adding handler once
|
|
|
|
|
if (posizIndex == 0) {
|
|
|
|
|
|
|
|
|
|
listBoxIndex.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
showFileBrowseInteraction();
|
|
|
|
|
|
|
|
|
|
if (listBoxIndexPlaceholder) {
|
|
|
|
|
listBoxIndex.removeItem(0); // this is the placeholder, removing it once
|
|
|
|
|
listBoxIndexPlaceholder = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showFileBrowseInteraction(listWSC);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// controlsContent.add(listBoxIndex);
|
|
|
|
|
|
|
|
|
|
for (WorkspaceContentDV wsContent : listWSC) {
|
|
|
|
|
String name = wsContent.getName() == null || wsContent.getName().isEmpty() ? wsContent.getLink()
|
|
|
|
|
: wsContent.getName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showFileBrowseInteraction() {
|
|
|
|
|
private void showFileBrowseInteraction(List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
|
HTML label = new HTML();
|
|
|
|
|
label.setHTML("With new one:");
|
|
|
|
|
|
|
|
|
|
if (listWSC.size() > 0) {
|
|
|
|
|
FlexTable table = new FlexTable();
|
|
|
|
|
table.addStyleName("table-current-content");
|
|
|
|
|
table.setHTML(0, 0, "<span style='color:rgb(155, 80, 78); font-weight:bold;'>Current content:</span>");
|
|
|
|
|
table.setHTML(1, 0, "<span style='color:rgb(155, 80, 78);'>Filename</span>");
|
|
|
|
|
table.setHTML(1, 1, "<span style='color:rgb(155, 80, 78);'>MimeType<span>");
|
|
|
|
|
table.setHTML(1, 2, "<span style='color:rgb(155, 80, 78);'>Link</span>");
|
|
|
|
|
int i = 2;
|
|
|
|
|
for (WorkspaceContentDV wsContent : listWSC) {
|
|
|
|
|
table.setHTML(i, 0, wsContent.getName());
|
|
|
|
|
table.setHTML(i, 1, wsContent.getMimetype());
|
|
|
|
|
String link = "<a href=" + wsContent.getLink() + ">Download</a>";
|
|
|
|
|
table.setHTML(i, 2, link);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uploadFileContainer.add(table);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTML label = new HTML();
|
|
|
|
|
label.getElement().getStyle().setMarginTop(10, Unit.PX);
|
|
|
|
|
label.setHTML("<b>With new content:</b>");
|
|
|
|
|
uploadFileContainer.add(label);
|
|
|
|
|
mDU = new MultipleDilaogUpload();
|
|
|
|
|
uploadFileContainer.add(mDU);
|
|
|
|
|
buttonUpdate.setVisible(true);
|
|
|
|
|
// mDU = new MultipleDilaogUpload();
|
|
|
|
|
|
|
|
|
|
MetadataFieldWrapper uploadField = new MetadataFieldWrapper();
|
|
|
|
|
uploadField.setFieldName("File");
|
|
|
|
|
uploadField.setMandatory(true);
|
|
|
|
|
uploadField.setType(DataTypeWrapper.File);
|
|
|
|
|
uploadField.setMaxOccurs(1000);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
fieldUploadWidget = new MetaDataField(uploadField, uiBus);
|
|
|
|
|
//BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget);
|
|
|
|
|
uploadFileContainer.add(fieldUploadWidget);
|
|
|
|
|
|
|
|
|
|
buttonUpdate.setVisible(true);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean checkValidUpload() {
|
|
|
|
|
GWT.log("Checking is valid File");
|
|
|
|
|
/**
|
|
|
|
|
* Test if profile data are valid.
|
|
|
|
|
*
|
|
|
|
|
* @return the string
|
|
|
|
|
*/
|
|
|
|
|
private String checkValidUpload() {
|
|
|
|
|
|
|
|
|
|
if (mDU.getFileUploadingState() != null && mDU.getFileUploadingState().getFile() != null) {
|
|
|
|
|
return mDU.getFileUploadingState().getFile().getTempSystemPath() != null;
|
|
|
|
|
for (MetaDataFieldSkeleton field : fieldUploadWidget.getListOfMetadataFields()) {
|
|
|
|
|
|
|
|
|
|
field.removeError();
|
|
|
|
|
|
|
|
|
|
String error = field.isFieldValueValid();
|
|
|
|
|
if (error != null) {
|
|
|
|
|
field.showError();
|
|
|
|
|
String errorMsg = field.getFieldNameOriginal() + " is not valid. Suggestion: " + error;
|
|
|
|
|
return errorMsg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showMessage(String txt, LabelType type) {
|
|
|
|
|