|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
|
|
|
|
@ -13,8 +14,11 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataE
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
|
|
|
|
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.client.ui.upload.DialogUpload;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
|
|
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
|
|
|
@ -50,8 +54,6 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private static final String _FORM_FIELDS_SIZE = "740px";
|
|
|
|
|
|
|
|
|
|
private static final String UPLOAD_MISSING_FILE = "You must upload a file";
|
|
|
|
|
|
|
|
|
|
private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -81,9 +83,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private List<String> listFileSetPaths;
|
|
|
|
|
|
|
|
|
|
private boolean listBoxPathsPlaceholder = true;
|
|
|
|
|
|
|
|
|
|
private String recordId;
|
|
|
|
|
private boolean placeholderListBoxPaths = true;
|
|
|
|
|
|
|
|
|
|
private BaseConcessioneDV selectedConcessione;
|
|
|
|
|
|
|
|
|
@ -91,13 +91,13 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private RECORD_TYPE recordType;
|
|
|
|
|
|
|
|
|
|
// private MultipleDilaogUpload mDU;
|
|
|
|
|
|
|
|
|
|
private boolean listBoxIndexPlaceholder = true;
|
|
|
|
|
private boolean placeholderListBoxIndex = true;
|
|
|
|
|
|
|
|
|
|
private HandlerManager uiBus = new HandlerManager(null);
|
|
|
|
|
|
|
|
|
|
private MetaDataField fieldUploadWidget;
|
|
|
|
|
|
|
|
|
|
private Integer pathIndex = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new update fileset.
|
|
|
|
@ -123,9 +123,9 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
GWT.log("Profile type selection changed...");
|
|
|
|
|
cgSelectFile.setVisible(false);
|
|
|
|
|
|
|
|
|
|
if (listBoxPathsPlaceholder) {
|
|
|
|
|
if (placeholderListBoxPaths) {
|
|
|
|
|
listBoxPaths.removeItem(0); // this is the placeholder, removing it once
|
|
|
|
|
listBoxPathsPlaceholder = false;
|
|
|
|
|
placeholderListBoxPaths = false;
|
|
|
|
|
}
|
|
|
|
|
showUploadFileGUI();
|
|
|
|
|
}
|
|
|
|
@ -151,10 +151,27 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
|
|
|
|
|
if (checkValidUpload() == null) {
|
|
|
|
|
Window.alert("I can save...");
|
|
|
|
|
String errorMsg = checkValidUpload();
|
|
|
|
|
if (errorMsg == null) {
|
|
|
|
|
List<FileUploaded> listFilesUploaded = new ArrayList<FileUploaded>();
|
|
|
|
|
List<MetaDataFieldSkeleton> listMetaDataFieldSkeleton = fieldUploadWidget.getListOfMetadataFields();
|
|
|
|
|
for (MetaDataFieldSkeleton field : listMetaDataFieldSkeleton) {
|
|
|
|
|
DialogUpload dUpload = (DialogUpload) field.getHolder();
|
|
|
|
|
// adding it only if exists
|
|
|
|
|
if (dUpload.getFileUploadingState() != null)
|
|
|
|
|
listFilesUploaded.add(dUpload.getFileUploadingState().getFile());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GenericDatasetBean gdb = new GenericDatasetBean();
|
|
|
|
|
gdb.setFilesUploaded(listFilesUploaded);
|
|
|
|
|
// adding it only if exists
|
|
|
|
|
|
|
|
|
|
GWT.log("Section selected: " + listBoxPaths.getSelectedItemText());
|
|
|
|
|
GWT.log("Content index selected: " + pathIndex);
|
|
|
|
|
GWT.log("FileUploaded selected: " + gdb.getFilesUploaded());
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Window.alert("New file not found. " + UPLOAD_MISSING_FILE);
|
|
|
|
|
Window.alert(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -170,15 +187,16 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
buttonUpdate.setVisible(false);
|
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
|
controlsContent.clear();
|
|
|
|
|
listBoxIndexPlaceholder = true;
|
|
|
|
|
placeholderListBoxIndex = true;
|
|
|
|
|
fieldUploadWidget = null;
|
|
|
|
|
pathIndex = null;
|
|
|
|
|
|
|
|
|
|
// listBoxIndex.clear();
|
|
|
|
|
cgSelectFile.setVisible(true);
|
|
|
|
|
|
|
|
|
|
ListBox listBoxIndex = new ListBox();
|
|
|
|
|
listBoxIndex.setWidth(_FORM_FIELDS_SIZE);
|
|
|
|
|
listBoxIndex.addItem("Select a content...");
|
|
|
|
|
ListBox listBoxContentIndex = new ListBox();
|
|
|
|
|
listBoxContentIndex.setWidth(_FORM_FIELDS_SIZE);
|
|
|
|
|
listBoxContentIndex.addItem("Select a content...");
|
|
|
|
|
|
|
|
|
|
if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) {
|
|
|
|
|
AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo();
|
|
|
|
@ -188,7 +206,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "abstract_relazione", posizIndex, ar.getTitolo(),
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "abstract_relazione", posizIndex, ar.getTitolo(),
|
|
|
|
|
ar.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("immagini")) {
|
|
|
|
@ -199,7 +217,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
for (UploadedImageDV uploadedImageDV : listImmagini) {
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "immagini", posizIndex, uploadedImageDV.getTitolo(),
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "immagini", posizIndex, uploadedImageDV.getTitolo(),
|
|
|
|
|
uploadedImageDV.getListWsContent());
|
|
|
|
|
posizIndex++;
|
|
|
|
|
}
|
|
|
|
@ -211,7 +229,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "relazione", posizIndex, realzione.getTitolo(),
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "relazione", posizIndex, realzione.getTitolo(),
|
|
|
|
|
realzione.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("posizionamentoScavo")) {
|
|
|
|
@ -221,7 +239,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(),
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(),
|
|
|
|
|
posiz.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("piante")) {
|
|
|
|
@ -232,17 +250,17 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
for (LayerConcessioneDV lcDV : piante) {
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "piante", posizIndex, lcDV.getTitolo(), lcDV.getListWsContent());
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "piante", posizIndex, lcDV.getTitolo(), lcDV.getListWsContent());
|
|
|
|
|
posizIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
controlsContent.add(listBoxIndex);
|
|
|
|
|
controlsContent.add(listBoxContentIndex);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title,
|
|
|
|
|
private void fillListBoxToBeReplaced(ListBox listBoxContentIndex, String section, int posizIndex, String title,
|
|
|
|
|
List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
|
|
|
|
|
if (listWSC == null || listWSC.isEmpty()) {
|
|
|
|
@ -250,22 +268,22 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listBoxIndex.addItem(title, posizIndex + "");
|
|
|
|
|
listBoxContentIndex.addItem(title, posizIndex + "");
|
|
|
|
|
|
|
|
|
|
// adding handler once
|
|
|
|
|
if (posizIndex == 0) {
|
|
|
|
|
|
|
|
|
|
listBoxIndex.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
listBoxContentIndex.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
|
|
|
|
|
if (listBoxIndexPlaceholder) {
|
|
|
|
|
listBoxIndex.removeItem(0); // this is the placeholder, removing it once
|
|
|
|
|
listBoxIndexPlaceholder = false;
|
|
|
|
|
if (placeholderListBoxIndex) {
|
|
|
|
|
listBoxContentIndex.removeItem(0); // this is the placeholder, removing it once
|
|
|
|
|
placeholderListBoxIndex = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showFileBrowseInteraction(listWSC);
|
|
|
|
|
showFileBrowseInteraction(listBoxContentIndex.getSelectedIndex(), listWSC);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -273,9 +291,10 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showFileBrowseInteraction(List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
private void showFileBrowseInteraction(int pathContentIndex, List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
|
|
|
|
|
|
pathIndex = pathContentIndex;
|
|
|
|
|
|
|
|
|
|
if (listWSC.size() > 0) {
|
|
|
|
|
FlexTable table = new FlexTable();
|
|
|
|
|
table.addStyleName("table-current-content");
|
|
|
|
@ -309,9 +328,9 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
fieldUploadWidget = new MetaDataField(uploadField, uiBus);
|
|
|
|
|
//BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget);
|
|
|
|
|
// BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget);
|
|
|
|
|
uploadFileContainer.add(fieldUploadWidget);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttonUpdate.setVisible(true);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
@ -327,6 +346,9 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
*/
|
|
|
|
|
private String checkValidUpload() {
|
|
|
|
|
|
|
|
|
|
if (fieldUploadWidget == null)
|
|
|
|
|
return "No file uploaded";
|
|
|
|
|
|
|
|
|
|
for (MetaDataFieldSkeleton field : fieldUploadWidget.getListOfMetadataFields()) {
|
|
|
|
|
|
|
|
|
|
field.removeError();
|
|
|
|
|