2021-09-27 18:32:19 +02:00
|
|
|
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
import java.util.ArrayList;
|
2021-10-05 19:17:05 +02:00
|
|
|
import java.util.Collection;
|
2021-09-30 13:06:14 +02:00
|
|
|
import java.util.HashMap;
|
2021-09-27 18:32:19 +02:00
|
|
|
import java.util.List;
|
2021-09-30 13:06:14 +02:00
|
|
|
import java.util.Map;
|
2021-09-27 18:32:19 +02:00
|
|
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV;
|
2021-09-28 17:31:16 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
|
2021-09-27 18:32:19 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
2021-10-05 19:17:05 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
2022-09-01 17:11:04 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ModalConfirm;
|
2021-10-12 17:18:54 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.StringUtil;
|
2021-09-29 16:13:39 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
|
2022-03-03 18:44:21 +01:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
2021-09-29 16:13:39 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
2021-09-29 18:27:22 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload;
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
2021-09-29 16:13:39 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
2021-09-29 18:27:22 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
|
2021-09-27 18:32:19 +02:00
|
|
|
|
2021-09-28 17:31:16 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
2021-09-27 18:32:19 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
2021-09-28 17:31:16 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Controls;
|
2021-09-27 18:32:19 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Label;
|
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
2021-09-30 13:06:14 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
2021-09-27 18:32:19 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.constants.LabelType;
|
|
|
|
import com.google.gwt.core.client.GWT;
|
2021-10-05 19:17:05 +02:00
|
|
|
import com.google.gwt.dom.client.Document;
|
2021-09-29 16:13:39 +02:00
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
2021-09-27 18:32:19 +02:00
|
|
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
2021-09-28 17:31:16 +02:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
2021-10-05 19:17:05 +02:00
|
|
|
import com.google.gwt.event.dom.client.DomEvent;
|
2021-09-29 16:13:39 +02:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2021-09-27 18:32:19 +02:00
|
|
|
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;
|
2021-09-29 16:13:39 +02:00
|
|
|
import com.google.gwt.user.client.ui.FlexTable;
|
2021-09-27 18:32:19 +02:00
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class UpdateFileset.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
* Sep 27, 2021
|
|
|
|
*/
|
|
|
|
public class UpdateFileset extends Composite {
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
private static final String SECTION_PIANTE = "piante";
|
|
|
|
|
|
|
|
private static final String SECTION_POSIZIONAMENTO_SCAVO = "posizionamentoScavo";
|
|
|
|
|
|
|
|
private static final String SECTION_RELAZIONE = "relazione";
|
|
|
|
|
|
|
|
private static final String SECTION_IMMAGINI = "immagini";
|
|
|
|
|
|
|
|
private static final String SECTION_ABSTRACT_RELAZIONE = "abstract_relazione";
|
|
|
|
|
2021-09-30 13:06:14 +02:00
|
|
|
private static final String _FORM_WIDTH_FIELDS_SIZE = "730px";
|
2021-09-29 11:08:15 +02:00
|
|
|
|
2021-09-27 18:32:19 +02:00
|
|
|
private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Interface UpdateFilesetUiBinder.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
* Sep 27, 2021
|
|
|
|
*/
|
|
|
|
interface UpdateFilesetUiBinder extends UiBinder<Widget, UpdateFileset> {
|
|
|
|
}
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
ListBox listBoxPaths;
|
|
|
|
|
|
|
|
@UiField
|
2021-09-28 17:31:16 +02:00
|
|
|
ControlGroup cgSelectFile;
|
2021-09-27 18:32:19 +02:00
|
|
|
|
|
|
|
@UiField
|
2021-09-28 17:31:16 +02:00
|
|
|
Controls controlsContent;
|
2021-09-27 18:32:19 +02:00
|
|
|
|
|
|
|
@UiField
|
|
|
|
HTMLPanel uploadFileContainer;
|
|
|
|
|
2021-09-28 17:31:16 +02:00
|
|
|
@UiField
|
|
|
|
Button buttonUpdate;
|
|
|
|
|
2021-09-27 18:32:19 +02:00
|
|
|
private List<String> listFileSetPaths;
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
private boolean placeholderListBoxPaths = true;
|
2021-09-27 18:32:19 +02:00
|
|
|
|
|
|
|
private BaseConcessioneDV selectedConcessione;
|
|
|
|
|
|
|
|
private ConcessioneDV fullConcessione;
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
private boolean placeholderListBoxIndex = true;
|
2021-09-29 16:13:39 +02:00
|
|
|
|
|
|
|
private HandlerManager uiBus = new HandlerManager(null);
|
|
|
|
|
|
|
|
private MetaDataField fieldUploadWidget;
|
2021-09-30 13:06:14 +02:00
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
private Integer pathIndex = null;
|
2021-09-28 17:31:16 +02:00
|
|
|
|
2021-09-30 13:06:14 +02:00
|
|
|
private Map<Integer, WorkspaceContentDV> mapForCCUploading = null;
|
2021-10-05 19:17:05 +02:00
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
private Map<Integer, List<WorkspaceContentDV>> mapWSContentListBox = null;
|
|
|
|
|
|
|
|
private HandlerManager editorManagerBus;
|
2022-09-23 16:37:37 +02:00
|
|
|
|
|
|
|
private String profileID;
|
2021-10-06 16:01:39 +02:00
|
|
|
|
2021-09-30 13:06:14 +02:00
|
|
|
|
2021-09-27 18:32:19 +02:00
|
|
|
/**
|
|
|
|
* Instantiates a new update fileset.
|
|
|
|
*
|
2021-10-06 16:01:39 +02:00
|
|
|
* @param editorManagerBus the editor manager bus
|
|
|
|
* @param selectedConcessione the selected concessione
|
|
|
|
* @param recordType the record type
|
2021-09-27 18:32:19 +02:00
|
|
|
* @param listFileSetPaths the list file set paths
|
|
|
|
*/
|
2022-09-23 16:37:37 +02:00
|
|
|
public UpdateFileset(HandlerManager editorManagerBus, BaseConcessioneDV selectedConcessione, String profileID, List<String> listFileSetPaths) {
|
2021-09-27 18:32:19 +02:00
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
2021-10-06 16:01:39 +02:00
|
|
|
this.editorManagerBus = editorManagerBus;
|
2021-09-27 18:32:19 +02:00
|
|
|
this.selectedConcessione = selectedConcessione;
|
2022-09-23 16:37:37 +02:00
|
|
|
this.profileID = profileID;
|
2021-09-27 18:32:19 +02:00
|
|
|
this.listFileSetPaths = listFileSetPaths;
|
|
|
|
listBoxPaths.addItem("Select a section...");
|
|
|
|
for (String path : listFileSetPaths) {
|
|
|
|
listBoxPaths.addItem(path);
|
|
|
|
}
|
2021-09-30 13:06:14 +02:00
|
|
|
listBoxPaths.setWidth(_FORM_WIDTH_FIELDS_SIZE);
|
2021-09-27 18:32:19 +02:00
|
|
|
|
|
|
|
// add handler on select
|
|
|
|
listBoxPaths.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
GWT.log("Profile type selection changed...");
|
|
|
|
cgSelectFile.setVisible(false);
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
if (placeholderListBoxPaths) {
|
2021-09-29 16:13:39 +02:00
|
|
|
listBoxPaths.removeItem(0); // this is the placeholder, removing it once
|
2021-09-29 18:27:22 +02:00
|
|
|
placeholderListBoxPaths = false;
|
2021-09-27 18:32:19 +02:00
|
|
|
}
|
|
|
|
showUploadFileGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2022-09-23 16:37:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
Window.alert("This part must be revisited");
|
|
|
|
|
|
|
|
// GeoPortalDataEntryApp.geoportalDataEntryService.getRecord(selectedConcessione.getItemId(), recordType,
|
|
|
|
// new AsyncCallback<ConcessioneDV>() {
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void onSuccess(ConcessioneDV theRecord) {
|
|
|
|
// fullConcessione = theRecord;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void onFailure(Throwable caught) {
|
|
|
|
// Window.alert(caught.getMessage());
|
|
|
|
// }
|
|
|
|
// });
|
2021-09-27 18:32:19 +02:00
|
|
|
|
2021-09-28 17:31:16 +02:00
|
|
|
buttonUpdate.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
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());
|
|
|
|
|
2021-10-05 19:17:05 +02:00
|
|
|
List<WorkspaceContentDV> listCurrentContent = new ArrayList<WorkspaceContentDV>();
|
|
|
|
if (mapForCCUploading != null) {
|
|
|
|
Collection<WorkspaceContentDV> currentContent = mapForCCUploading.values();
|
|
|
|
if (currentContent != null)
|
|
|
|
listCurrentContent.addAll(currentContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
String htmlMsg = "Going to update the section " + listBoxPaths.getSelectedItemText() + ":";
|
|
|
|
htmlMsg += "<ul>";
|
|
|
|
htmlMsg += "<li>keeping " + listCurrentContent.size() + " current file/s </li>";
|
|
|
|
htmlMsg += "<li>uploading " + listFilesUploaded.size() + " new file/s </li>";
|
|
|
|
htmlMsg += "</ul>";
|
|
|
|
htmlMsg += "<br>";
|
|
|
|
htmlMsg += "This operation cannot be undone. Would you like to proceed?";
|
|
|
|
|
|
|
|
GWT.log(htmlMsg);
|
|
|
|
|
2022-09-01 16:51:12 +02:00
|
|
|
final ModalConfirm dialogConfirm = new ModalConfirm(null, "Update Confirm?", htmlMsg);
|
2021-10-05 19:17:05 +02:00
|
|
|
dialogConfirm.getElement().getStyle().setZIndex(100000);
|
|
|
|
dialogConfirm.getYesButton().addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
dialogConfirm.hide();
|
|
|
|
buttonUpdate.setEnabled(false);
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
final DialogInform dialogInf = new DialogInform(null, "Updating Project...", "");
|
2021-10-05 19:17:05 +02:00
|
|
|
dialogInf.setZIndex(100000);
|
2021-10-06 16:01:39 +02:00
|
|
|
dialogInf.showLoader("Updating file/s for project: "+fullConcessione.getNome());
|
2021-10-05 19:17:05 +02:00
|
|
|
//dialogInf.setWidth("400px");
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().updateSectionForRecord(
|
|
|
|
fullConcessione.getItemId(), fullConcessione.getRecordType(),
|
|
|
|
listBoxPaths.getSelectedItemText(), pathIndex, listCurrentContent, gdb,
|
|
|
|
new AsyncCallback<ConcessioneDV>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
dialogInf.hideLoader();
|
|
|
|
dialogInf.setMsg(
|
|
|
|
"Sorry error occurred during project update. Error reported: "
|
|
|
|
+ caught.getMessage());
|
|
|
|
buttonUpdate.setEnabled(true);
|
|
|
|
showUploadFileGUI();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(ConcessioneDV result) {
|
|
|
|
dialogInf.hideLoader();
|
|
|
|
dialogInf.setText("Project updated!");
|
|
|
|
dialogInf.setMsg(result.getNome() + " updated correclty");
|
|
|
|
dialogInf.center();
|
|
|
|
fullConcessione = result;
|
2021-10-06 16:01:39 +02:00
|
|
|
GWT.log("new concessione: "+fullConcessione);
|
2021-10-05 19:17:05 +02:00
|
|
|
buttonUpdate.setEnabled(true);
|
|
|
|
showUploadFileGUI();
|
2022-03-17 18:08:58 +01:00
|
|
|
|
|
|
|
Window.alert("updateSectionForRecord must be revisited");
|
|
|
|
|
|
|
|
/*
|
2021-10-06 16:01:39 +02:00
|
|
|
editorManagerBus.fireEvent(
|
2022-09-13 13:52:44 +02:00
|
|
|
new OperationPerformedOnItemEvent<ConcessioneDV>(Arrays.asList(fullConcessione), ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
2022-03-17 18:08:58 +01:00
|
|
|
|
|
|
|
*/
|
2021-10-05 19:17:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogInf.center();
|
|
|
|
}
|
|
|
|
});
|
2022-09-01 16:51:12 +02:00
|
|
|
dialogConfirm.show();
|
2021-10-05 19:17:05 +02:00
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
} else {
|
2021-09-29 18:27:22 +02:00
|
|
|
Window.alert(errorMsg);
|
2021-09-28 17:31:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-09-27 18:32:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show upload file GUI.
|
|
|
|
*/
|
|
|
|
private void showUploadFileGUI() {
|
|
|
|
uploadFileContainer.setVisible(true);
|
2021-09-28 17:31:16 +02:00
|
|
|
buttonUpdate.setVisible(false);
|
2021-09-27 18:32:19 +02:00
|
|
|
uploadFileContainer.clear();
|
2021-09-28 17:31:16 +02:00
|
|
|
controlsContent.clear();
|
2021-09-29 18:27:22 +02:00
|
|
|
placeholderListBoxIndex = true;
|
2021-09-29 16:13:39 +02:00
|
|
|
fieldUploadWidget = null;
|
2021-09-29 18:27:22 +02:00
|
|
|
pathIndex = null;
|
2021-09-30 13:06:14 +02:00
|
|
|
mapForCCUploading = null;
|
2021-10-06 16:01:39 +02:00
|
|
|
mapWSContentListBox = null;
|
2021-09-27 18:32:19 +02:00
|
|
|
|
2021-09-28 17:31:16 +02:00
|
|
|
// listBoxIndex.clear();
|
2021-09-27 18:32:19 +02:00
|
|
|
cgSelectFile.setVisible(true);
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
ListBox listBoxContentIndex = new ListBox();
|
2021-09-30 13:06:14 +02:00
|
|
|
listBoxContentIndex.setWidth(_FORM_WIDTH_FIELDS_SIZE);
|
2021-09-29 18:27:22 +02:00
|
|
|
listBoxContentIndex.addItem("Select a content...");
|
2021-10-06 16:01:39 +02:00
|
|
|
String section = null;
|
|
|
|
Integer posizIndex = 0;
|
|
|
|
if (listBoxPaths.getSelectedItemText().contains(SECTION_ABSTRACT_RELAZIONE)) {
|
|
|
|
section = SECTION_ABSTRACT_RELAZIONE;
|
2021-09-27 18:32:19 +02:00
|
|
|
AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo();
|
2021-10-06 16:01:39 +02:00
|
|
|
|
2021-09-27 18:32:19 +02:00
|
|
|
if (ar == null) {
|
2021-10-06 16:01:39 +02:00
|
|
|
showMessage(SECTION_ABSTRACT_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
// pathIndex = 0;
|
|
|
|
// showNewFileUpload();
|
2021-09-27 18:32:19 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-09-28 17:31:16 +02:00
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, ar.getTitolo(),
|
2021-09-28 17:31:16 +02:00
|
|
|
ar.getListWsContent());
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains(SECTION_IMMAGINI)) {
|
|
|
|
section = SECTION_IMMAGINI;
|
2021-09-27 18:32:19 +02:00
|
|
|
List<UploadedImageDV> listImmagini = fullConcessione.getImmaginiRappresentative();
|
|
|
|
if (listImmagini == null || listImmagini.isEmpty()) {
|
2021-10-06 16:01:39 +02:00
|
|
|
showMessage(SECTION_IMMAGINI + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
// pathIndex = 0;
|
|
|
|
// showNewFileUpload();
|
2021-09-27 18:32:19 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-10-06 16:01:39 +02:00
|
|
|
|
2021-09-27 18:32:19 +02:00
|
|
|
for (UploadedImageDV uploadedImageDV : listImmagini) {
|
2021-10-12 17:18:54 +02:00
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, StringUtil.ellipsize(uploadedImageDV.getDidascalia(),30),
|
2021-09-28 17:31:16 +02:00
|
|
|
uploadedImageDV.getListWsContent());
|
|
|
|
posizIndex++;
|
|
|
|
}
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains(SECTION_RELAZIONE)) {
|
|
|
|
section = SECTION_RELAZIONE;
|
|
|
|
RelazioneScavoDV relazioneScavo = fullConcessione.getRelazioneScavo();
|
|
|
|
if (relazioneScavo == null) {
|
|
|
|
showMessage(SECTION_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
// pathIndex = 0;
|
|
|
|
// showNewFileUpload();
|
2021-09-28 17:31:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, relazioneScavo.getTitolo(),
|
|
|
|
relazioneScavo.getListWsContent());
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains(SECTION_POSIZIONAMENTO_SCAVO)) {
|
|
|
|
section = SECTION_POSIZIONAMENTO_SCAVO;
|
2021-09-28 17:31:16 +02:00
|
|
|
LayerConcessioneDV posiz = fullConcessione.getPosizionamentoScavo();
|
2021-10-06 16:01:39 +02:00
|
|
|
if (posiz == null) {
|
|
|
|
showMessage(SECTION_POSIZIONAMENTO_SCAVO + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
// pathIndex = 0;
|
|
|
|
// showNewFileUpload();
|
2021-09-28 17:31:16 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-10-06 16:01:39 +02:00
|
|
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, posiz.getTitolo(),
|
2021-09-28 17:31:16 +02:00
|
|
|
posiz.getListWsContent());
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains(SECTION_PIANTE)) {
|
|
|
|
section = SECTION_PIANTE;
|
2021-09-28 17:31:16 +02:00
|
|
|
List<LayerConcessioneDV> piante = fullConcessione.getPianteFineScavo();
|
|
|
|
if (piante == null || piante.isEmpty()) {
|
2021-10-06 16:01:39 +02:00
|
|
|
showMessage(SECTION_PIANTE + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
// pathIndex = 0;
|
|
|
|
// showNewFileUpload();
|
2021-09-28 17:31:16 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-10-06 16:01:39 +02:00
|
|
|
|
2021-09-28 17:31:16 +02:00
|
|
|
for (LayerConcessioneDV lcDV : piante) {
|
2021-10-06 16:01:39 +02:00
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, SECTION_PIANTE, posizIndex, lcDV.getTitolo(),
|
2021-09-30 13:06:14 +02:00
|
|
|
lcDV.getListWsContent());
|
2021-09-28 17:31:16 +02:00
|
|
|
posizIndex++;
|
2021-09-27 18:32:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
controlsContent.add(listBoxContentIndex);
|
2021-10-05 19:17:05 +02:00
|
|
|
|
|
|
|
if (listBoxContentIndex.getItemCount() == 2) {
|
|
|
|
// listBoxContentIndex.setSelectedIndex(1);
|
|
|
|
listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(1));
|
|
|
|
|
|
|
|
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBoxContentIndex);
|
2021-09-30 13:06:14 +02:00
|
|
|
}
|
2021-09-27 18:32:19 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
private void fillListBoxToBeReplaced(ListBox listBoxContentIndex, String section, int posizIndex, String title,
|
2021-09-28 17:31:16 +02:00
|
|
|
List<WorkspaceContentDV> listWSC) {
|
2021-10-06 16:01:39 +02:00
|
|
|
GWT.log("fillListBoxToBeReplaced called, posizIndex: "+posizIndex+", listWSC: "+listWSC);
|
2021-09-27 18:32:19 +02:00
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
if(mapWSContentListBox==null) {
|
|
|
|
mapWSContentListBox = new HashMap<Integer, List<WorkspaceContentDV>>();
|
|
|
|
}
|
2021-09-27 18:32:19 +02:00
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
listBoxContentIndex.addItem(title, posizIndex + "");
|
2021-10-06 16:01:39 +02:00
|
|
|
mapWSContentListBox.put(posizIndex, listWSC);
|
2021-09-28 17:31:16 +02:00
|
|
|
|
|
|
|
// adding handler once
|
|
|
|
if (posizIndex == 0) {
|
2021-09-29 16:13:39 +02:00
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
listBoxContentIndex.addChangeHandler(new ChangeHandler() {
|
2021-09-28 17:31:16 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChange(ChangeEvent event) {
|
2021-10-11 14:30:41 +02:00
|
|
|
GWT.log("listBoxContentIndex changed, value: "+listBoxContentIndex.getSelectedValue());
|
2021-10-06 16:01:39 +02:00
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
if (placeholderListBoxIndex) {
|
|
|
|
listBoxContentIndex.removeItem(0); // this is the placeholder, removing it once
|
|
|
|
placeholderListBoxIndex = false;
|
2021-09-29 16:13:39 +02:00
|
|
|
}
|
2021-10-06 16:01:39 +02:00
|
|
|
int selectedIndex = listBoxContentIndex.getSelectedIndex();
|
|
|
|
GWT.log("selected index: "+selectedIndex);
|
2021-10-11 14:30:41 +02:00
|
|
|
List<WorkspaceContentDV> theListWC = mapWSContentListBox.get(selectedIndex);
|
|
|
|
|
|
|
|
if (theListWC == null || theListWC.isEmpty()) {
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
showMessage(section + " does not contain file!", LabelType.WARNING);
|
|
|
|
pathIndex = posizIndex;
|
|
|
|
showNewFileUpload();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
showFileBrowseInteraction(selectedIndex, mapWSContentListBox.get(selectedIndex));
|
2021-09-28 17:31:16 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//
|
|
|
|
|
2021-09-27 18:32:19 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
private void showFileBrowseInteraction(int pathContentIndex, List<WorkspaceContentDV> listWSC) {
|
2021-09-27 18:32:19 +02:00
|
|
|
uploadFileContainer.clear();
|
2021-09-29 18:27:22 +02:00
|
|
|
pathIndex = pathContentIndex;
|
2021-10-06 16:01:39 +02:00
|
|
|
GWT.log("showing pathContentIndex: "+pathContentIndex);
|
|
|
|
GWT.log("showing ws content: "+listWSC);
|
2021-09-30 13:06:14 +02:00
|
|
|
|
|
|
|
// map for current content uploading
|
|
|
|
mapForCCUploading = new HashMap<Integer, WorkspaceContentDV>(listWSC.size());
|
|
|
|
int index = 0;
|
|
|
|
for (WorkspaceContentDV workspaceContentDV : listWSC) {
|
|
|
|
workspaceContentDV.setCliendId(index);
|
|
|
|
mapForCCUploading.put(index, workspaceContentDV);
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
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>");
|
2021-09-30 13:06:14 +02:00
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
int i = 2;
|
2021-09-30 13:06:14 +02:00
|
|
|
for (final WorkspaceContentDV wsContent : listWSC) {
|
2021-09-29 16:13:39 +02:00
|
|
|
table.setHTML(i, 0, wsContent.getName());
|
|
|
|
table.setHTML(i, 1, wsContent.getMimetype());
|
2021-09-30 13:06:14 +02:00
|
|
|
String link = "<a target=\"_blank\" href=" + wsContent.getLink() + ">View</a>";
|
2021-09-29 16:13:39 +02:00
|
|
|
table.setHTML(i, 2, link);
|
2021-09-30 13:06:14 +02:00
|
|
|
|
|
|
|
final int rowIndexToRem = i;
|
|
|
|
Button buttonRemoveFile = new Button();
|
|
|
|
buttonRemoveFile.setIcon(IconType.TRASH);
|
|
|
|
buttonRemoveFile.setTitle("Remove this file");
|
|
|
|
buttonRemoveFile.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
mapForCCUploading.remove(wsContent.getCliendId());
|
|
|
|
table.getRowFormatter().getElement(rowIndexToRem).setAttribute("hidden", "hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
table.setWidget(i, 3, buttonRemoveFile);
|
2021-09-29 16:13:39 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadFileContainer.add(table);
|
|
|
|
}
|
|
|
|
|
2021-10-06 16:01:39 +02:00
|
|
|
showNewFileUpload();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void showNewFileUpload() {
|
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
HTML label = new HTML();
|
|
|
|
label.getElement().getStyle().setMarginTop(10, Unit.PX);
|
2021-09-30 13:06:14 +02:00
|
|
|
label.getElement().getStyle().setMarginBottom(10, Unit.PX);
|
|
|
|
label.setHTML("<b>Add new file/s:</b>");
|
2021-09-27 18:32:19 +02:00
|
|
|
uploadFileContainer.add(label);
|
2021-09-29 16:13:39 +02:00
|
|
|
// mDU = new MultipleDilaogUpload();
|
|
|
|
|
|
|
|
MetadataFieldWrapper uploadField = new MetadataFieldWrapper();
|
|
|
|
uploadField.setFieldName("File");
|
2021-10-05 19:17:05 +02:00
|
|
|
uploadField.setMandatory(false);
|
2021-09-29 16:13:39 +02:00
|
|
|
uploadField.setType(DataTypeWrapper.File);
|
|
|
|
uploadField.setMaxOccurs(1000);
|
|
|
|
|
|
|
|
try {
|
2022-03-03 18:44:21 +01:00
|
|
|
fieldUploadWidget = new MetaDataField(uploadField, uiBus, OPERATION.NEW);
|
2021-09-29 16:13:39 +02:00
|
|
|
uploadFileContainer.add(fieldUploadWidget);
|
2021-09-29 18:27:22 +02:00
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
buttonUpdate.setVisible(true);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
2021-09-28 17:31:16 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
/**
|
|
|
|
* Test if profile data are valid.
|
|
|
|
*
|
|
|
|
* @return the string
|
|
|
|
*/
|
|
|
|
private String checkValidUpload() {
|
2021-09-28 17:31:16 +02:00
|
|
|
|
2021-09-29 18:27:22 +02:00
|
|
|
if (fieldUploadWidget == null)
|
|
|
|
return "No file uploaded";
|
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
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;
|
|
|
|
}
|
2021-09-28 17:31:16 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 16:13:39 +02:00
|
|
|
return null;
|
2021-09-27 18:32:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void showMessage(String txt, LabelType type) {
|
|
|
|
Label l = new Label();
|
|
|
|
l.setType(type);
|
|
|
|
l.setText(txt);
|
|
|
|
uploadFileContainer.add(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|